#!/usr/bin/perl
use strict;
use warnings;

use Cwd;
use File::Basename;
use lib ( dirname($0) );
use Qtopia::Paths;
use Qtopia::Vars;
use Qtopia::Opt;
use Qtopia::File;

Qtopia::Paths::get_paths();

# Windows depot builds use the perl scripts directly rather than the compiled code
if ( $isWindows ) {
    check_script($0, "$depotpath/src/build/bin", $ARGV[0]);
}

Qtopia::Opt::read_config_cache();


use constant DEBUG => 0;

my $move;
if ( scalar(@ARGV) >= 2 && $ARGV[0] eq "-C" ) {
    shift(@ARGV);
    $move = fixpath(shift(@ARGV));
}
if ( $move ) {
    chdir $move or die "Can't change to $move";
    print "make[1]: Entering `".fixpath(getcwd())."'\n";
}
my $ret = system(opt("make")." ".join(" ", @ARGV)." MAKE=".fixpath("$QPEDIR/bin/winmake.exe"));
$ret = $ret >> 8;
if ( $move ) {
    print "make[1]: Leaving `".fixpath(getcwd())."'\n";
}
exit $ret;

