2011-04-05 10:16:33 -05:00
|
|
|
:
|
2014-03-04 05:49:46 -06:00
|
|
|
#
|
2017-09-22 08:51:22 -05:00
|
|
|
# This script checks various configure parameters and uses three files:
|
|
|
|
# * autogen.input (ro)
|
|
|
|
# * autogen.lastrun (rw)
|
|
|
|
# * autogen.lastrun.bak (rw)
|
|
|
|
#
|
2017-08-17 09:41:20 -05:00
|
|
|
# If _no_ parameters:
|
2017-09-22 08:51:22 -05:00
|
|
|
# Read args from autogen.input or autogen.lastrun
|
|
|
|
# Else
|
|
|
|
# Backup autogen.lastrun as autogen.lastrun.bak
|
|
|
|
# Write autogen.lastrun with new commandline args
|
2014-03-04 05:49:46 -06:00
|
|
|
#
|
|
|
|
# Run configure with checked args
|
|
|
|
#
|
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;
|
2012-03-29 11:27:08 -05:00
|
|
|
use Cwd ('cwd', 'realpath');
|
2012-12-11 07:49:24 -06:00
|
|
|
use File::Basename;
|
|
|
|
|
|
|
|
my $src_path=dirname(realpath($0));
|
|
|
|
my $build_path=realpath(cwd());
|
|
|
|
# since this looks crazy, if you have a symlink on a path up to and including
|
|
|
|
# the current directory, we need our configure to run in the realpath of that
|
|
|
|
# such that compiled (realpath'd) dependency filenames match the filenames
|
|
|
|
# used in our makefiles - ie. this gets dependencies right via SRC_ROOT
|
|
|
|
chdir ($build_path);
|
|
|
|
# more amazingly, if you don't clobber 'PWD' shells will re-assert their
|
|
|
|
# old path from the environment, not cwd.
|
|
|
|
$ENV{PWD} = $build_path;
|
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");
|
2013-03-28 08:26:25 -05:00
|
|
|
print "Cleaned the build tree\n";
|
2011-04-05 10:16:33 -05:00
|
|
|
}
|
2010-08-24 08:03:44 -05:00
|
|
|
|
2011-07-03 09:05:14 -05:00
|
|
|
my $aclocal;
|
2011-07-03 02:52:21 -05:00
|
|
|
|
2011-05-30 09:23:15 -05:00
|
|
|
# check we have various vital tools
|
|
|
|
sub sanity_checks($)
|
|
|
|
{
|
|
|
|
my $system = shift;
|
|
|
|
my @path = split (':', $ENV{'PATH'});
|
2011-05-31 02:00:39 -05:00
|
|
|
my %required =
|
|
|
|
(
|
|
|
|
'pkg-config' => "pkg-config is required to be installed",
|
|
|
|
'autoconf' => "autoconf is required",
|
2011-07-03 02:52:21 -05:00
|
|
|
$aclocal => "$aclocal is required",
|
2011-05-31 02:00:39 -05:00
|
|
|
);
|
2011-05-30 09:23:15 -05:00
|
|
|
|
|
|
|
for my $elem (@path) {
|
2011-05-31 02:00:39 -05:00
|
|
|
for my $app (keys %required) {
|
2011-05-31 02:32:37 -05:00
|
|
|
if (-f "$elem/$app") {
|
2011-05-31 02:00:39 -05:00
|
|
|
delete $required{$app};
|
|
|
|
}
|
2011-05-30 09:23:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((keys %required) > 0) {
|
2011-05-31 02:00:39 -05:00
|
|
|
print ("Various low-level dependencies are missing, please install them:\n");
|
|
|
|
for my $app (keys %required) {
|
2011-05-31 02:32:37 -05:00
|
|
|
print "\t $app: " . $required{$app} . "\n";
|
2011-05-31 02:00:39 -05:00
|
|
|
}
|
|
|
|
exit (1);
|
2011-05-30 09:23:15 -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>) {
|
2011-05-31 02:00:39 -05:00
|
|
|
chomp();
|
2018-01-18 08:25:58 -06:00
|
|
|
s/^\s+//;
|
2014-05-30 04:18:20 -05:00
|
|
|
s/\s+$//;
|
2011-05-31 02:00:39 -05:00
|
|
|
# migrate from the old system
|
|
|
|
if ( substr($_, 0, 1) eq "'" ) {
|
2014-03-04 05:49:46 -06:00
|
|
|
print STDERR "Migrating options from the old autogen.lastrun format, using:\n";
|
2011-05-31 02:00:39 -05:00
|
|
|
my @opts;
|
|
|
|
@opts = split(/'/);
|
|
|
|
foreach my $opt (@opts) {
|
|
|
|
if ( substr($opt, 0, 1) eq "-" ) {
|
|
|
|
push @lst, $opt;
|
2014-03-04 05:49:46 -06:00
|
|
|
print STDERR " $opt\n";
|
2011-05-31 02:00:39 -05:00
|
|
|
}
|
|
|
|
}
|
2011-08-24 09:49:28 -05:00
|
|
|
} elsif ( substr($_, 0, 1) eq "#" ) {
|
|
|
|
# comment
|
2013-07-19 19:45:36 -05:00
|
|
|
} elsif ( length == 0 ) {
|
|
|
|
# empty line
|
2011-05-31 02:00:39 -05:00
|
|
|
} else {
|
|
|
|
push @lst, $_;
|
2011-04-06 01:48:26 -05:00
|
|
|
}
|
|
|
|
}
|
2011-04-05 10:16:33 -05:00
|
|
|
close ($fh);
|
2011-05-31 02:00:39 -05:00
|
|
|
# print "read args from file '$file': @lst\n";
|
2011-04-05 10:16:33 -05:00
|
|
|
return @lst;
|
2010-12-01 12:03:56 -06:00
|
|
|
}
|
|
|
|
|
2017-05-17 03:24:00 -05:00
|
|
|
sub show_distro_configs($$)
|
2010-12-01 12:03:56 -06:00
|
|
|
{
|
2017-05-17 03:24:00 -05:00
|
|
|
my ($prefix, $path) = @_;
|
2011-04-05 10:16:33 -05:00
|
|
|
my $dirh;
|
2017-05-17 03:24:00 -05:00
|
|
|
opendir ($dirh, "$path");
|
2011-04-08 05:14:52 -05:00
|
|
|
while (($_ = readdir ($dirh))) {
|
2017-05-17 03:24:00 -05:00
|
|
|
if (-d "$path/$_") {
|
|
|
|
show_distro_configs(
|
|
|
|
$prefix eq "" ? "$_/" : "$prefix/$_/", "$path/$_")
|
|
|
|
unless $_ eq '.' || $_ eq '..';
|
|
|
|
next;
|
|
|
|
}
|
2011-05-31 02:00:39 -05:00
|
|
|
/(.*)\.conf$/ || next;
|
2017-05-17 03:24:00 -05:00
|
|
|
print STDERR "\t$prefix$1\n";
|
2011-04-05 10:16:33 -05:00
|
|
|
}
|
|
|
|
closedir ($dirh);
|
|
|
|
}
|
|
|
|
|
2017-05-17 03:24:00 -05:00
|
|
|
sub invalid_distro($$)
|
|
|
|
{
|
|
|
|
my ($config, $distro) = @_;
|
2017-05-17 03:28:07 -05:00
|
|
|
print STDERR "Can't find distro option set: $config\n";
|
2017-05-17 03:24:00 -05:00
|
|
|
print STDERR "Distros with distro option sets are:\n";
|
|
|
|
show_distro_configs("", "$src_path/distro-configs");
|
2017-05-17 03:28:07 -05:00
|
|
|
exit (1);
|
2017-05-17 03:24:00 -05:00
|
|
|
}
|
|
|
|
|
2015-03-08 10:58:35 -05:00
|
|
|
# Avoid confusing "aclocal: error: non-option arguments are not accepted: '.../m4'." error message.
|
|
|
|
die "\$src_path must not contain spaces, but it is '$src_path'." if ($src_path =~ / /);
|
|
|
|
|
2013-10-17 08:01:45 -05:00
|
|
|
# Alloc $ACLOCAL to specify which aclocal to use
|
|
|
|
$aclocal = $ENV{ACLOCAL} ? $ENV{ACLOCAL} : 'aclocal';
|
|
|
|
|
|
|
|
my $system = `uname -s`;
|
|
|
|
chomp $system;
|
|
|
|
|
|
|
|
sanity_checks ($system) unless($system eq 'Darwin');
|
|
|
|
|
2015-12-29 13:32:18 -06:00
|
|
|
# If we are running in a LODE env, make sure we find the right aclocal
|
|
|
|
# by making sure that LODE_HOME/opt/bin is in the PATH
|
|
|
|
if (defined $ENV{LODE_HOME})
|
|
|
|
{
|
|
|
|
my $lode_path = quotemeta "$ENV{LODE_HOME}/opt/bin";
|
|
|
|
if($ENV{PATH} !~ $lode_path)
|
|
|
|
{
|
|
|
|
$ENV{PATH}="$ENV{LODE_HOME}/opt/bin:$ENV{PATH}";
|
|
|
|
print STDERR "add LODE_HOME/opt/bin in PATH\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-17 08:01:45 -05:00
|
|
|
my $aclocal_flags = $ENV{ACLOCAL_FLAGS};
|
|
|
|
|
|
|
|
$aclocal_flags .= " -I $src_path/m4";
|
|
|
|
$aclocal_flags .= " -I $src_path/m4/mac" if ($system eq 'Darwin');
|
|
|
|
$aclocal_flags .= " -I /opt/freeware/share/aclocal" if ($system eq 'AIX');
|
|
|
|
|
|
|
|
$ENV{AUTOMAKE_EXTRA_FLAGS} = '--warnings=no-portability' if (!($system eq 'Darwin'));
|
|
|
|
|
|
|
|
if ($src_path ne $build_path)
|
|
|
|
{
|
|
|
|
system ("ln -sf $src_path/configure.ac configure.ac");
|
|
|
|
system ("ln -sf $src_path/g g");
|
2014-03-23 10:21:51 -05:00
|
|
|
my @modules = <$src_path/*/Makefile>;
|
|
|
|
foreach my $module (@modules)
|
|
|
|
{
|
|
|
|
my $dir = basename (dirname ($module));
|
|
|
|
mkdir ($dir);
|
|
|
|
system ("ln -sf $src_path/$dir/Makefile $dir/Makefile");
|
|
|
|
}
|
|
|
|
my @external_modules = <$src_path/external/*/Makefile>;
|
|
|
|
mkdir ("external");
|
|
|
|
system ("ln -sf $src_path/external/Module_external.mk external/");
|
|
|
|
foreach my $module (@external_modules)
|
|
|
|
{
|
|
|
|
my $dir = basename (dirname ($module));
|
|
|
|
mkdir ("external/$dir");
|
|
|
|
system ("ln -sf $src_path/external/$dir/Makefile external/$dir/Makefile");
|
|
|
|
}
|
2013-10-17 08:01:45 -05:00
|
|
|
}
|
|
|
|
system ("$aclocal $aclocal_flags") && die "Failed to run aclocal";
|
|
|
|
unlink ("configure");
|
|
|
|
system ("autoconf -I ${src_path}") && die "Failed to run autoconf";
|
|
|
|
die "Failed to generate the configure script" if (! -f "configure");
|
|
|
|
|
2017-09-22 08:51:22 -05:00
|
|
|
# Handle help arguments first, so we don't clobber autogen.lastrun
|
2012-03-12 17:27:16 -05:00
|
|
|
for my $arg (@ARGV) {
|
|
|
|
if ($arg =~ /^(--help|-h|-\?)$/) {
|
2016-12-14 01:27:23 -06:00
|
|
|
print STDOUT "autogen.sh - libreoffice configuration helper\n";
|
|
|
|
print STDOUT " --clean forcibly re-generate configuration\n";
|
|
|
|
print STDOUT " --best-effort don't fail on un-known configure with/enable options\n";
|
|
|
|
print STDOUT "\nOther arguments passed directly to configure:\n\n";
|
2012-03-12 17:27:16 -05:00
|
|
|
system ("./configure --help");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-05 10:16:33 -05:00
|
|
|
my @cmdline_args = ();
|
2013-03-28 08:26:25 -05:00
|
|
|
|
|
|
|
my $input = "autogen.input";
|
2017-09-22 08:51:22 -05:00
|
|
|
my $lastrun = "autogen.lastrun";
|
2013-03-28 08:26:25 -05:00
|
|
|
|
2013-04-03 11:01:35 -05:00
|
|
|
if (!@ARGV) {
|
|
|
|
if (-f $input) {
|
2017-09-22 08:51:22 -05:00
|
|
|
if (-f $lastrun) {
|
|
|
|
print STDERR <<WARNING;
|
|
|
|
********************************************************************
|
|
|
|
*
|
|
|
|
* Reading $input and ignoring $lastrun!
|
|
|
|
* Consider removing $lastrun to get rid of this warning.
|
|
|
|
*
|
|
|
|
********************************************************************
|
|
|
|
WARNING
|
|
|
|
}
|
2013-04-03 11:01:35 -05:00
|
|
|
@cmdline_args = read_args ($input);
|
2017-09-22 08:51:22 -05:00
|
|
|
} elsif (-f $lastrun) {
|
|
|
|
print STDERR "Reading $lastrun. Please rename it to $input to avoid this message.\n";
|
|
|
|
@cmdline_args = read_args ($lastrun);
|
2013-04-03 11:01:35 -05:00
|
|
|
}
|
2011-04-05 10:16:33 -05:00
|
|
|
} else {
|
2014-03-04 05:49:46 -06:00
|
|
|
if (-f $input) {
|
|
|
|
print STDERR <<WARNING;
|
|
|
|
********************************************************************
|
|
|
|
*
|
|
|
|
* Using commandline arguments and ignoring $input!
|
|
|
|
*
|
|
|
|
********************************************************************
|
|
|
|
WARNING
|
|
|
|
}
|
2011-04-05 10:16:33 -05:00
|
|
|
@cmdline_args = @ARGV;
|
2010-08-24 08:03:44 -05:00
|
|
|
}
|
|
|
|
|
2012-11-17 04:12:31 -06:00
|
|
|
my @args;
|
2012-12-11 07:49:24 -06:00
|
|
|
my $default_config = "$src_path/distro-configs/default.conf";
|
2014-11-13 10:27:30 -06:00
|
|
|
my $option_checking = 'fatal';
|
|
|
|
|
2012-11-17 04:12:31 -06:00
|
|
|
if (-f $default_config) {
|
2013-03-28 08:26:25 -05:00
|
|
|
print STDERR "Reading default config file: $default_config.\n";
|
2012-11-17 04:12:31 -06:00
|
|
|
push @args, read_args ($default_config);
|
|
|
|
}
|
2011-04-05 10:16:33 -05:00
|
|
|
for my $arg (@cmdline_args) {
|
|
|
|
if ($arg eq '--clean') {
|
2011-05-31 02:00:39 -05:00
|
|
|
clean();
|
2011-04-05 10:16:33 -05:00
|
|
|
} elsif ($arg =~ m/--with-distro=(.*)$/) {
|
2012-12-11 07:49:24 -06:00
|
|
|
my $config = "$src_path/distro-configs/$1.conf";
|
2011-05-31 02:00:39 -05:00
|
|
|
if (! -f $config) {
|
|
|
|
invalid_distro ($config, $1);
|
2012-06-05 04:57:31 -05:00
|
|
|
}
|
2017-05-17 03:28:07 -05:00
|
|
|
push @args, read_args ($config);
|
2014-11-13 10:27:30 -06:00
|
|
|
} elsif ($arg =~ m/--best-effort$/) {
|
|
|
|
$option_checking = 'warn';
|
2012-06-05 04:57:31 -05:00
|
|
|
} else {
|
2011-05-31 02:00:39 -05:00
|
|
|
push @args, $arg;
|
2011-04-05 10:16:33 -05:00
|
|
|
}
|
|
|
|
}
|
2011-07-03 09:05:14 -05:00
|
|
|
|
2011-04-05 10:16:33 -05:00
|
|
|
if (defined $ENV{NOCONFIGURE}) {
|
|
|
|
print "Skipping configure process.";
|
|
|
|
} else {
|
2017-09-22 08:51:22 -05:00
|
|
|
# Save autogen.lastrun only if we did get some arguments on the command-line
|
|
|
|
if (! -f $input && @ARGV) {
|
|
|
|
if (scalar(@cmdline_args) > 0) {
|
|
|
|
# if there's already an autogen.lastrun, make a backup first
|
|
|
|
if (-e $lastrun) {
|
|
|
|
open (my $fh, $lastrun) || warn "Can't open $lastrun.\n";
|
|
|
|
open (BAK, ">$lastrun.bak") || warn "Can't create backup file $lastrun.bak.\n";
|
|
|
|
while (<$fh>) {
|
|
|
|
print BAK;
|
|
|
|
}
|
|
|
|
close (BAK) && close ($fh);
|
|
|
|
}
|
|
|
|
# print "Saving command-line args to $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);
|
|
|
|
}
|
|
|
|
}
|
2012-12-11 07:49:24 -06:00
|
|
|
push @args, "--srcdir=$src_path";
|
2014-11-13 10:27:30 -06:00
|
|
|
push @args, "--enable-option-checking=$option_checking";
|
2012-12-11 07:49:24 -06:00
|
|
|
|
2015-09-22 04:18:57 -05:00
|
|
|
print "Running ./configure with '" . join (" ", @args), "'\n";
|
2011-08-18 00:25:58 -05:00
|
|
|
system ("./configure", @args) && die "Error running configure";
|
2011-04-05 10:16:33 -05:00
|
|
|
}
|
2011-05-29 11:41:15 -05:00
|
|
|
|
|
|
|
# Local Variables:
|
2011-05-31 02:00:39 -05:00
|
|
|
# mode: perl
|
|
|
|
# cperl-indent-level: 4
|
2011-05-29 11:41:15 -05:00
|
|
|
# tab-width: 4
|
|
|
|
# indent-tabs-mode: nil
|
|
|
|
# End:
|
|
|
|
|
2012-01-09 15:29:10 -06:00
|
|
|
# vim:set ft=perl shiftwidth=4 softtabstop=4 expandtab: #
|