summaryrefslogtreecommitdiff
path: root/autogen.sh
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-12-11 07:49:24 -0600
committerNorbert Thiebaud <nthiebaud@gmail.com>2012-12-11 14:26:30 +0000
commitae4e327739112ba326a2945fc0d5550739f3083d (patch)
treed8430835484c045cd334fc596dcc627cf98aa430 /autogen.sh
parent8532cbd3e685d7a1e4e26bf7c2b7bf0b1c38c5be (diff)
Prepare for read-only source build
This patch allows to do mkdir <build_dir> cd <build_dir> <src_root>/autogen.sh make Only the remaining dmake modules are poluting the <src_root>... which will get eventually convererd to gmake... Change-Id: Iefd64732fa12e096d554cff4eee6b777deb92338 Reviewed-on: https://gerrit.libreoffice.org/1273 Reviewed-by: Luboš Luňák <l.lunak@suse.cz> Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com> Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'autogen.sh')
-rwxr-xr-xautogen.sh41
1 files changed, 25 insertions, 16 deletions
diff --git a/autogen.sh b/autogen.sh
index 04d87c0ea903..fa77b739a8f7 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -4,6 +4,18 @@
use strict;
use Cwd ('cwd', 'realpath');
+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;
sub clean()
{
@@ -79,7 +91,7 @@ sub invalid_distro($$)
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";
my $dirh;
- opendir ($dirh, "distro-configs");
+ opendir ($dirh, "$src_path/distro-configs");
while (($_ = readdir ($dirh))) {
/(.*)\.conf$/ || next;
print STDERR "\t$1\n";
@@ -104,7 +116,7 @@ if (!@ARGV) {
}
my @args;
-my $default_config = "distro-configs/default.conf";
+my $default_config = "$src_path/distro-configs/default.conf";
if (-f $default_config) {
print STDERR "Reading default config file: $default_config\n";
push @args, read_args ($default_config);
@@ -113,7 +125,7 @@ for my $arg (@cmdline_args) {
if ($arg eq '--clean') {
clean();
} elsif ($arg =~ m/--with-distro=(.*)$/) {
- my $config = "distro-configs/$1.conf";
+ my $config = "$src_path/distro-configs/$1.conf";
if (! -f $config) {
invalid_distro ($config, $1);
} else {
@@ -137,26 +149,21 @@ chomp $system;
sanity_checks ($system) unless($system eq 'Darwin');
-# 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
-my $cwd_str = realpath(cwd());
-chdir ($cwd_str);
-# more amazingly, if you don't clobber 'PWD' shells will re-assert their
-# old path from the environment, not cwd.
-$ENV{PWD} = $cwd_str;
-
my $aclocal_flags = $ENV{ACLOCAL_FLAGS};
-$aclocal_flags .= " -I ./m4";
-$aclocal_flags .= " -I ./m4/mac" if ($system eq 'Darwin');
+$aclocal_flags .= " -I $src_path/m4";
+$aclocal_flags .= " -I $src_path/m4/mac" if ($system eq 'Darwin');
$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");
+}
system ("$aclocal $aclocal_flags") && die "Failed to run aclocal";
unlink ("configure");
-system ("autoconf") && die "Failed to run autoconf";
+system ("autoconf -I ${src_path}") && die "Failed to run autoconf";
die "failed to generate configure" if (! -f "configure");
if (defined $ENV{NOCONFIGURE}) {
@@ -188,6 +195,8 @@ if (defined $ENV{NOCONFIGURE}) {
open (my $fh, ">autogen.lastrun") || die "can't create autogen.lastrun";
close ($fh);
}
+ push @args, "--srcdir=$src_path";
+
print "running ./configure with '" . join ("' '", @args), "'\n";
system ("./configure", @args) && die "Error running configure";
}