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 for my $arg (@cmdline_args) {
108 if ($arg eq '--clean') {
110 } elsif ($arg =~ m/--with-distro=(.*)$/) {
111 my $config = "distro-configs
/$1.conf
";
113 invalid_distro ($config, $1);
115 push @args, read_args ($config);
121 for my $arg (@args) {
122 if ($arg =~ /^([A-Z]+)=(.*)/) {
127 # Alloc $ACLOCAL to specify which aclocal to use
128 $aclocal = $ENV{ACLOCAL} ? $ENV{ACLOCAL} : 'aclocal';
130 my $system = `uname -s`;
133 sanity_checks ($system) unless($system eq 'Darwin');
135 # since this looks crazy, if you have a symlink on a path up to and including
136 # the current directory, we need our configure to run in the realpath of that
137 # such that compiled (realpath'd) dependency filenames match the filenames
138 # used in our makefiles - ie. this gets dependencies right via SRC_ROOT
139 my $cwd_str = realpath(cwd());
141 # more amazingly, if you don't clobber 'PWD' shells will re-assert their
142 # old path from the environment, not cwd.
143 $ENV{PWD} = $cwd_str;
145 my $aclocal_flags = $ENV{ACLOCAL_FLAGS};
147 $aclocal_flags .= " -I .
/m4";
148 $aclocal_flags .= " -I .
/m
4/mac
" if ($system eq 'Darwin');
150 $ENV{AUTOMAKE_EXTRA_FLAGS} = '--warnings=no-portability' if (!($system eq 'Darwin'));
152 system ("$aclocal $aclocal_flags") && die "Failed to run aclocal
";
153 unlink ("configure
");
154 system ("autoconf
") && die "Failed to run autoconf
";
155 die "failed to generate configure
" if (! -x "configure
");
157 if (defined $ENV{NOCONFIGURE}) {
158 print "Skipping configure process.
";
160 # Save autogen.lastrun only if we did get some arguments on the command-line
162 if (scalar(@cmdline_args) > 0) {
163 # if there's already an autogen.lastrun, make a backup first
164 if (-e "autogen.lastrun
") {
165 open (my $fh, "autogen.lastrun
") || warn "can
't open autogen.lastrun. \n";
166 open (BAK, ">autogen.lastrun.bak") || warn "can't create backup
file.
\n";
170 close (BAK) && close ($fh);
172 # print "writing args to autogen.lastrun
\n";
174 open ($fh, ">autogen.lastrun
") || die "can
't open autogen.lastrun: $!";
175 for my $arg (@cmdline_args) {
181 elsif ( ! -e "autogen.lastrun")
183 open (my $fh, ">autogen.lastrun") || die "can't create autogen.lastrun
";
186 print "running .
/configure with
'" . join ("' '", @args), "'\n";
187 system (".
/configure
", @args) && die "Error running configure
";
192 # cperl-indent-level: 4
194 # indent-tabs-mode: nil
197 # vim:set ft=perl shiftwidth=4 softtabstop=4 expandtab: #