2 eval 'exec perl -S $0 ${1+"$@"}'
6 use Cwd
('cwd', 'realpath');
10 system
("rm -Rf autom4te.cache");
11 system
("rm -f missing install-sh mkinstalldirs libtool ltmain.sh");
12 print
"cleaned the build tree\n";
17 # check we have various vital tools
21 my @path
= split (':', $ENV{'PATH'});
24 'pkg-config' => "pkg-config is required to be installed",
25 'autoconf' => "autoconf is required",
26 $aclocal => "$aclocal is required",
29 for my
$elem (@path
) {
30 for my
$app (keys
%required
) {
31 if (-f "$elem/$app") {
32 delete
$required{$app};
36 if ((keys
%required
) > 0) {
37 print
("Various low-level dependencies are missing, please install them:\n");
38 for my
$app (keys
%required
) {
39 print
"\t $app: " .
$required{$app} .
"\n";
45 # one argument per line
51 open
($fh, $file) || die
"can't open file: $file";
54 # migrate from the old system
55 if ( substr
($_, 0, 1) eq
"'" ) {
56 print
"Migrating options from the old autogen.lastrun format, using:\n";
59 foreach my $opt (@opts) {
60 if ( substr($opt, 0, 1) eq "-" ) {
65 } elsif ( substr($_, 0, 1) eq "#" ) {
72 # print "read args from file '$file': @lst\n";
76 sub invalid_distro($$)
78 my ($config, $distro) = @_;
79 print STDERR "Can't
find distro option
set: $config\nThis is not necessarily a problem.
\n";
80 print STDERR "Distros with distro option sets are
:\n";
82 opendir ($dirh, "distro-configs
");
83 while (($_ = readdir ($dirh))) {
84 /(.*)\.conf$/ || next;
85 print STDERR "\t$1\n";
90 # Handle help arguments first, so we don't clobber autogen.lastrun
92 if ($arg =~ /^(--help|-h|-\?)$/) {
93 system (".
/configure
--help");
98 my @cmdline_args = ();
100 my $lastrun = "autogen.lastrun
";
101 @cmdline_args = read_args ($lastrun) if (-f $lastrun);
103 @cmdline_args = @ARGV;
107 my $default_config = "distro-configs
/default.conf
";
108 if (-f $default_config) {
109 print STDERR "Reading default config
file: $default_config\n";
110 push @args, read_args ($default_config);
112 for my $arg (@cmdline_args) {
113 if ($arg eq '--clean') {
115 } elsif ($arg =~ m/--with-distro=(.*)$/) {
116 my $config = "distro-configs
/$1.conf
";
118 invalid_distro ($config, $1);
120 push @args, read_args ($config);
126 for my $arg (@args) {
127 if ($arg =~ /^([A-Z]+)=(.*)/) {
132 # Alloc $ACLOCAL to specify which aclocal to use
133 $aclocal = $ENV{ACLOCAL} ? $ENV{ACLOCAL} : 'aclocal';
135 my $system = `uname -s`;
138 sanity_checks ($system) unless($system eq 'Darwin');
140 # since this looks crazy, if you have a symlink on a path up to and including
141 # the current directory, we need our configure to run in the realpath of that
142 # such that compiled (realpath'd) dependency filenames match the filenames
143 # used in our makefiles - ie. this gets dependencies right via SRC_ROOT
144 my $cwd_str = realpath(cwd());
146 # more amazingly, if you don't clobber 'PWD' shells will re-assert their
147 # old path from the environment, not cwd.
148 $ENV{PWD} = $cwd_str;
150 my $aclocal_flags = $ENV{ACLOCAL_FLAGS};
152 $aclocal_flags .= " -I .
/m4";
153 $aclocal_flags .= " -I .
/m
4/mac
" if ($system eq 'Darwin');
155 $ENV{AUTOMAKE_EXTRA_FLAGS} = '--warnings=no-portability' if (!($system eq 'Darwin'));
157 system ("$aclocal $aclocal_flags") && die "Failed to run aclocal
";
158 unlink ("configure
");
159 system ("autoconf
") && die "Failed to run autoconf
";
160 die "failed to generate configure
" if (! -f "configure
");
162 if (defined $ENV{NOCONFIGURE}) {
163 print "Skipping configure process.
";
165 # Save autogen.lastrun only if we did get some arguments on the command-line
167 if (scalar(@cmdline_args) > 0) {
168 # if there's already an autogen.lastrun, make a backup first
169 if (-e "autogen.lastrun
") {
170 open (my $fh, "autogen.lastrun
") || warn "can
't open autogen.lastrun. \n";
171 open (BAK, ">autogen.lastrun.bak") || warn "can't create backup
file.
\n";
175 close (BAK) && close ($fh);
177 # print "writing args to autogen.lastrun
\n";
179 open ($fh, ">autogen.lastrun
") || die "can
't open autogen.lastrun: $!";
180 for my $arg (@cmdline_args) {
186 elsif ( ! -e "autogen.lastrun")
188 open (my $fh, ">autogen.lastrun") || die "can't create autogen.lastrun
";
191 print "running .
/configure with
'" . join ("' '", @args), "'\n";
192 system (".
/configure
", @args) && die "Error running configure
";
197 # cperl-indent-level: 4
199 # indent-tabs-mode: nil
202 # vim:set ft=perl shiftwidth=4 softtabstop=4 expandtab: #