3 # This script checks various configure parameters and uses three files:
5 # * autogen.lastrun (rw)
6 # * autogen.lastrun.bak (rw)
9 # Read args from autogen.input or autogen.lastrun
11 # Backup autogen.lastrun as autogen.lastrun.bak
12 # Write autogen.lastrun with new commandline args
14 # Run configure with checked args
16 eval 'exec perl -S $0 ${1+"$@"}'
20 use Cwd
('cwd', 'realpath');
23 my
$src_path=dirname(realpath
($0));
24 my
$build_path=realpath
(cwd
());
25 # since this looks crazy, if you have a symlink on a path up to and including
26 # the current directory, we need our configure to run in the realpath of that
27 # such that compiled (realpath'd) dependency filenames match the filenames
28 # used in our makefiles - ie. this gets dependencies right via SRC_ROOT
30 # more amazingly, if you don't clobber 'PWD' shells will re-assert their
31 # old path from the environment, not cwd.
32 $ENV{PWD
} = $build_path;
36 system
("rm -Rf autom4te.cache");
37 system
("rm -f missing install-sh mkinstalldirs libtool ltmain.sh");
38 print
"Cleaned the build tree\n";
43 # check we have various vital tools
47 my @path
= split (':', $ENV{'PATH'});
50 'pkg-config' => "pkg-config is required to be installed",
51 'autoconf' => "autoconf is required",
52 $aclocal => "$aclocal is required",
55 for my
$elem (@path
) {
56 for my
$app (keys
%required
) {
57 if (-f "$elem/$app") {
58 delete
$required{$app};
62 if ((keys
%required
) > 0) {
63 print
("Various low-level dependencies are missing, please install them:\n");
64 for my
$app (keys
%required
) {
65 print
"\t $app: " .
$required{$app} .
"\n";
71 # one argument per line
77 open
($fh, $file) || die
"can't open file: $file";
81 # migrate from the old system
82 if ( substr
($_, 0, 1) eq
"'" ) {
83 print STDERR
"Migrating options from the old autogen.lastrun format, using:\n";
86 foreach my $opt (@opts) {
87 if ( substr($opt, 0, 1) eq "-" ) {
89 print STDERR " $opt\n";
92 } elsif ( substr($_, 0, 1) eq "#" ) {
94 } elsif ( length == 0 ) {
101 # print "read args from file '$file': @lst\n";
105 sub invalid_distro($$)
107 my ($config, $distro) = @_;
108 print STDERR "Can't
find distro option
set: $config\nThis is not necessarily a problem.
\n";
109 print STDERR "Distros with distro option sets are
:\n";
111 opendir ($dirh, "$src_path/distro-configs
");
112 while (($_ = readdir ($dirh))) {
113 /(.*)\.conf$/ || next;
114 print STDERR "\t$1\n";
119 # Avoid confusing "aclocal
: error
: non-option arguments are not accepted
: '.../m4'.
" error message.
120 die "\
$src_path must not contain spaces
, but it is
'$src_path'.
" if ($src_path =~ / /);
122 # Alloc $ACLOCAL to specify which aclocal to use
123 $aclocal = $ENV{ACLOCAL} ? $ENV{ACLOCAL} : 'aclocal';
125 my $system = `uname -s`;
128 sanity_checks ($system) unless($system eq 'Darwin');
130 # If we are running in a LODE env, make sure we find the right aclocal
131 # by making sure that LODE_HOME/opt/bin is in the PATH
132 if (defined $ENV{LODE_HOME})
134 my $lode_path = quotemeta "$ENV{LODE_HOME
}/opt
/bin
";
135 if($ENV{PATH} !~ $lode_path)
137 $ENV{PATH}="$ENV{LODE_HOME
}/opt
/bin
:$ENV{PATH
}";
138 print STDERR "add LODE_HOME
/opt
/bin
in PATH
\n";
142 my $aclocal_flags = $ENV{ACLOCAL_FLAGS};
144 $aclocal_flags .= " -I $src_path/m4";
145 $aclocal_flags .= " -I $src_path/m
4/mac
" if ($system eq 'Darwin');
146 $aclocal_flags .= " -I /opt
/freeware
/share
/aclocal
" if ($system eq 'AIX');
148 $ENV{AUTOMAKE_EXTRA_FLAGS} = '--warnings=no-portability' if (!($system eq 'Darwin'));
150 if ($src_path ne $build_path)
152 system ("ln -sf $src_path/configure.ac configure.ac
");
153 system ("ln -sf $src_path/g g
");
154 my @modules = <$src_path/*/Makefile>;
155 foreach my $module (@modules)
157 my $dir = basename (dirname ($module));
159 system ("ln -sf $src_path/$dir/Makefile
$dir/Makefile
");
161 my @external_modules = <$src_path/external/*/Makefile>;
163 system ("ln -sf $src_path/external
/Module_external.mk external
/");
164 foreach my $module (@external_modules)
166 my $dir = basename (dirname ($module));
167 mkdir ("external
/$dir");
168 system ("ln -sf $src_path/external
/$dir/Makefile external
/$dir/Makefile
");
171 system ("$aclocal $aclocal_flags") && die "Failed to run aclocal
";
172 unlink ("configure
");
173 system ("autoconf
-I ${src_path}") && die "Failed to run autoconf
";
174 die "Failed to generate the configure
script" if (! -f "configure
");
176 # Handle help arguments first, so we don't clobber autogen.lastrun
177 for my $arg (@ARGV) {
178 if ($arg =~ /^(--help|-h|-\?)$/) {
179 print STDERR "autogen.sh
- libreoffice configuration helper
\n";
180 print STDERR " --clean forcibly re-generate configuration
\n";
181 print STDERR " --best-effort don
't fail on un-known configure with/enable options\n";
182 print STDERR "\nOther arguments passed directly to configure:\n\n";
183 system ("./configure --help");
188 my @cmdline_args = ();
190 my $input = "autogen.input";
191 my $lastrun = "autogen.lastrun";
196 print STDERR <<WARNING;
197 ********************************************************************
199 * Reading $input and ignoring $lastrun!
200 * Consider removing $lastrun to get rid of this warning.
202 ********************************************************************
205 @cmdline_args = read_args ($input);
206 } elsif (-f $lastrun) {
207 print STDERR "Reading $lastrun. Please rename it to $input to avoid this message.\n";
208 @cmdline_args = read_args ($lastrun);
212 print STDERR <<WARNING;
213 ********************************************************************
215 * Using commandline arguments and ignoring $input!
217 ********************************************************************
220 @cmdline_args = @ARGV;
224 my $default_config = "$src_path/distro-configs/default.conf";
225 my $option_checking = 'fatal
';
227 if (-f $default_config) {
228 print STDERR "Reading default config file: $default_config.\n";
229 push @args, read_args ($default_config);
231 for my $arg (@cmdline_args) {
232 if ($arg eq '--clean') {
234 } elsif ($arg =~ m/--with-distro=(.*)$/) {
235 my $config = "$src_path/distro-configs/$1.conf";
237 invalid_distro ($config, $1);
239 push @args, read_args ($config);
241 } elsif ($arg =~ m/--best-effort$/) {
242 $option_checking = 'warn
';
247 for my $arg (@args) {
248 if ($arg =~ /^([A-Z]+)=(.*)/) {
253 if (defined $ENV{NOCONFIGURE}) {
254 print "Skipping configure process.";
256 # Save autogen.lastrun only if we did get some arguments on the command-line
257 if (! -f $input && @ARGV) {
258 if (scalar(@cmdline_args) > 0) {
259 # if there's already an autogen.lastrun
, make a backup first
261 open
(my
$fh, $lastrun) || warn
"Can't open $lastrun.\n";
262 open
(BAK
, ">$lastrun.bak") || warn
"Can't create backup file $lastrun.bak.\n";
266 close
(BAK
) && close
($fh);
268 # print "Saving command-line args to $lastrun\n";
270 open
($fh, ">autogen.lastrun") || die
"Can't open autogen.lastrun: $!";
271 for my
$arg (@cmdline_args
) {
277 push @args
, "--srcdir=$src_path";
278 push @args
, "--enable-option-checking=$option_checking";
280 print
"Running ./configure with '" .
join (" ", @args
), "'\n";
281 system
("./configure", @args
) && die
"Error running configure";
286 # cperl-indent-level: 4
288 # indent-tabs-mode: nil
291 # vim:set ft=perl shiftwidth=4 softtabstop=4 expandtab: #