dvander@558: #!/usr/bin/perl ds@704: # vim: set ts=2 sw=2 tw=99 noet: dvander@558: dvander@558: use strict; dvander@558: use Cwd; dvander@558: use File::Basename; ds@704: use File::Path; dvander@558: dvander@558: my ($myself, $path) = fileparse($0); dvander@558: chdir($path); dvander@558: dvander@558: require 'helpers.pm'; dvander@558: ds@704: #Go back above build dir ds@704: chdir(Build::PathFormat('../../..')); ds@704: ds@704: #Get the source path. ds@704: our ($root) = getcwd(); ds@704: ds@704: my $reconf = 0; dvander@558: ds@704: #Create output folder if it doesn't exist. ds@704: if (!(-d 'OUTPUT')) { ds@704: $reconf = 1; ds@704: } else { ds@704: if (-f 'OUTPUT/sentinel') { ds@704: my @s = stat('OUTPUT/sentinel'); ds@704: my $mtime = $s[9]; ds@704: my @files = ('build/pushbuild.txt', 'build/AMBuildScript', 'build/product.version'); ds@704: my ($i); ds@704: for ($i = 0; $i <= $#files; $i++) { ds@704: if (IsNewer($files[$i], $mtime)) { ds@704: $reconf = 1; ds@704: last; ds@704: } ds@704: } ds@704: } else { ds@704: $reconf = 1; ds@704: } ds@704: } ds@704: ds@704: if ($reconf) { ds@704: rmtree('OUTPUT'); ds@704: mkdir('OUTPUT') or die("Failed to create output folder: $!\n"); ds@704: chdir('OUTPUT'); ds@704: my ($result); ds@704: print "Attempting to reconfigure...\n"; ds@704: if ($^O eq "linux") { ds@704: $result = `CC=gcc-4.1 CXX=gcc-4.1 python3.1 ../build/configure.py --enable-optimize`; ds@704: } elsif ($^O eq "darwin") { ds@704: $result = `CC=gcc-4.2 CXX=gcc-4.2 python3.1 ../build/configure.py --enable-optimize`; ds@704: } else { ds@704: $result = `C:\\Python31\\Python.exe ..\\build\\configure.py --enable-optimize`; ds@704: } ds@704: print "$result\n"; ds@704: if ($? != 0) { ds@704: die('Could not configure!'); ds@704: } ds@704: open(FILE, '>sentinel'); ds@704: print FILE "this is nothing.\n"; ds@704: close(FILE); ds@704: } ds@704: ds@704: sub IsNewer dvander@558: { ds@704: my ($file, $time) = (@_); ds@704: ds@704: my @s = stat($file); ds@704: my $mtime = $s[9]; ds@704: return $mtime > $time; dvander@558: } dvander@558: ds@704: exit(0); ds@704: ds@704: