2011-04-05 10:16:33 -05:00
|
|
|
:
|
|
|
|
eval 'exec perl -S $0 ${1+"$@"}'
|
|
|
|
if 0;
|
2010-08-24 08:03:44 -05:00
|
|
|
|
2011-04-05 10:16:33 -05:00
|
|
|
use strict;
|
2010-08-24 08:03:44 -05:00
|
|
|
|
2011-04-05 10:16:33 -05:00
|
|
|
sub clean()
|
|
|
|
{
|
|
|
|
system ("rm -Rf autom4te.cache");
|
|
|
|
system ("rm -f missing install-sh mkinstalldirs libtool ltmain.sh");
|
|
|
|
print "cleaned the build tree\n";
|
|
|
|
}
|
2010-08-24 08:03:44 -05:00
|
|
|
|
2011-04-05 10:16:33 -05:00
|
|
|
# one argument per line
|
|
|
|
sub read_args($)
|
2010-08-24 08:03:44 -05:00
|
|
|
{
|
2011-04-05 10:16:33 -05:00
|
|
|
my $file = shift;
|
|
|
|
my $fh;
|
|
|
|
my @lst;
|
|
|
|
open ($fh, $file) || die "can't open file: $file";
|
|
|
|
while (<$fh>) {
|
|
|
|
chomp();
|
2011-04-06 01:48:26 -05:00
|
|
|
# migrate from the old system
|
|
|
|
if ( substr($_, 0, 1) eq "'" ) {
|
|
|
|
print "Migrating options from the old autogen.lastrun format, using:\n";
|
|
|
|
my @opts;
|
|
|
|
@opts = split(/'/);
|
|
|
|
foreach my $opt (@opts) {
|
|
|
|
if ( substr($opt, 0, 1) eq "-" ) {
|
|
|
|
push @lst, $opt;
|
|
|
|
print " $opt\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
push @lst, $_;
|
|
|
|
}
|
2011-04-05 10:16:33 -05:00
|
|
|
}
|
|
|
|
close ($fh);
|
|
|
|
# print "read args from file '$file': @lst\n";
|
|
|
|
return @lst;
|
2010-12-01 12:03:56 -06:00
|
|
|
}
|
|
|
|
|
2011-04-05 10:16:33 -05:00
|
|
|
sub invalid_distro($$)
|
2010-12-01 12:03:56 -06:00
|
|
|
{
|
2011-04-05 10:16:33 -05:00
|
|
|
my ($config, $distro) = @_;
|
2011-04-08 05:28:48 -05:00
|
|
|
print STDERR "Can't find distro option set: $config\nThis is not necessarily a problem.\n";
|
|
|
|
print STDERR "Distros with distro option sets are:\n";
|
2011-04-05 10:16:33 -05:00
|
|
|
my $dirh;
|
|
|
|
opendir ($dirh, "distro-configs");
|
2011-04-08 05:14:52 -05:00
|
|
|
while (($_ = readdir ($dirh))) {
|
2011-04-05 10:16:33 -05:00
|
|
|
/(.*)\.conf$/ || next;
|
|
|
|
print STDERR "\t$1\n";
|
|
|
|
}
|
|
|
|
closedir ($dirh);
|
|
|
|
}
|
|
|
|
|
|
|
|
my @cmdline_args = ();
|
2011-04-05 10:16:33 -05:00
|
|
|
if (!@ARGV) {
|
2011-04-05 10:16:33 -05:00
|
|
|
my $lastrun = "autogen.lastrun";
|
|
|
|
@cmdline_args = read_args ($lastrun) if (-f $lastrun);
|
|
|
|
} else {
|
|
|
|
@cmdline_args = @ARGV;
|
2010-08-24 08:03:44 -05:00
|
|
|
}
|
|
|
|
|
2011-04-05 10:16:33 -05:00
|
|
|
my @args;
|
|
|
|
for my $arg (@cmdline_args) {
|
|
|
|
if ($arg eq '--clean') {
|
|
|
|
clean();
|
|
|
|
} elsif ($arg =~ m/--with-distro=(.*)$/) {
|
|
|
|
my $config = "distro-configs/$1.conf";
|
|
|
|
if (! -f $config) {
|
|
|
|
invalid_distro ($config, $1);
|
2011-04-08 05:28:48 -05:00
|
|
|
} else {
|
|
|
|
push @args, read_args ($config);
|
|
|
|
}
|
2011-04-05 10:16:33 -05:00
|
|
|
} else {
|
|
|
|
push @args, $arg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
system ("touch ChangeLog");
|
2010-08-24 08:03:44 -05:00
|
|
|
|
2011-04-05 10:16:33 -05:00
|
|
|
my $system = `uname -s`;
|
2011-04-05 14:21:38 -05:00
|
|
|
chomp $system;
|
2010-08-24 08:03:44 -05:00
|
|
|
|
2011-04-05 10:16:33 -05:00
|
|
|
my $aclocal_flags = $ENV{ACLOCAL_FLAGS};
|
2010-11-27 09:03:38 -06:00
|
|
|
|
2011-04-05 14:21:38 -05:00
|
|
|
$aclocal_flags = "-I ./m4/mac" if (($aclocal_flags eq "") && ($system eq 'Darwin'));
|
|
|
|
|
|
|
|
$ENV{AUTOMAKE_EXTRA_FLAGS} = '--warnings=no-portability' if (!($system eq 'Darwin'));
|
2010-12-01 06:20:29 -06:00
|
|
|
|
2011-04-05 10:16:33 -05:00
|
|
|
system ("aclocal $aclocal_flags") && die "Failed to run aclocal";
|
2011-04-07 07:27:23 -05:00
|
|
|
unlink ("configure");
|
2011-04-05 10:16:33 -05:00
|
|
|
system ("autoconf") && die "Failed to run autoconf";
|
2011-04-07 07:27:23 -05:00
|
|
|
die "failed to generate configure" if (! -x "configure");
|
2011-04-05 10:16:33 -05:00
|
|
|
|
|
|
|
if (defined $ENV{NOCONFIGURE}) {
|
|
|
|
print "Skipping configure process.";
|
|
|
|
} else {
|
2011-05-29 11:39:18 -05:00
|
|
|
# Save autogen.lastrun only if we did get some arguments on the command-line
|
|
|
|
if (@ARGV) {
|
|
|
|
if ($#cmdline_args > 0) {
|
|
|
|
# print "writing args to autogen.lastrun\n";
|
|
|
|
my $fh;
|
|
|
|
open ($fh, ">autogen.lastrun") || die "can't open autogen.lastrun: $!";
|
|
|
|
for my $arg (@cmdline_args) {
|
|
|
|
print $fh "$arg\n";
|
|
|
|
}
|
|
|
|
close ($fh);
|
|
|
|
}
|
2011-04-05 10:16:33 -05:00
|
|
|
}
|
|
|
|
print "running ./configure with '" . join ("' '", @args), "'\n";
|
|
|
|
system ("./configure", @args);
|
|
|
|
}
|