r15036: Add out of tree build support and see how buildfarm will respond to make...
authorAlexander Bokovoy <ab@samba.org>
Tue, 11 Apr 2006 11:37:52 +0000 (11:37 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:04:03 +0000 (14:04 -0500)
(This used to be commit 9329854489e2c231ffb7986d39009e0936873c11)

12 files changed:
source4/build/smb_build/config_mk.pm
source4/build/smb_build/env.pm
source4/build/smb_build/main.pl
source4/build/smb_build/makefile.pm
source4/configure.in
source4/heimdal_build/config.mk
source4/lib/registry/config.mk
source4/main.mk
source4/script/build_idl.sh
source4/script/buildtree.pl [new file with mode: 0644]
source4/script/installheader.pl
source4/script/mkproto.pl

index 587335ac3e91c26a0958459910fd366af79528b4..fa948f4bd9706d51d0d804b577cb5ccdbf12f194 100644 (file)
@@ -109,19 +109,30 @@ use vars qw(@parsed_files);
 #
 # $filename -  the path of the config.mk file
 #              which should be parsed
-sub run_config_mk($$$)
+sub run_config_mk($$$$)
 {
-       sub run_config_mk($$$);
-       my ($input, $srcdir, $filename) = @_;
+       sub run_config_mk($$$$);
+       my ($input, $srcdir, $builddir, $filename) = @_;
        my $result;
        my $linenum = -1;
        my $infragment = 0;
        my $section = "GLOBAL";
        my $makefile = "";
 
-       push (@parsed_files, $srcdir."/".$filename);
+       my $parsing_file = $builddir."/".$filename;
+
+       $ENV{samba_builddir} = $builddir;
+       $ENV{samba_srcdir} = $srcdir;
+       
+       if (!open(CONFIG_MK, $parsing_file)) { 
+               $parsing_file = $srcdir."/".$filename;
+               open(CONFIG_MK, $parsing_file) or 
+                   die("Can't open neither `$builddir."/".$filename' nor `$srcdir/$filename'\n");
+       }
+       
+       push (@parsed_files, $parsing_file);
+       
        
-       open(CONFIG_MK, $srcdir."/".$filename) or die("Can't open `$srcdir/$filename'\n");
        my @lines = <CONFIG_MK>;
        close(CONFIG_MK);
 
@@ -151,7 +162,7 @@ sub run_config_mk($$$)
 
                # include
                if ($line =~ /^include (.*)$/) {
-                       $makefile .= run_config_mk($input, $srcdir, dirname($filename)."/$1");
+                       $makefile .= run_config_mk($input, $srcdir, $builddir, dirname($filename)."/$1");
                        next;
                }
 
index 7ff66274946fca948312501174bffc93880433d6..f6de8ce57f08e1351c96ebd50e8e5a8a586ca9ae 100644 (file)
@@ -8,6 +8,8 @@
 
 package smb_build::env;
 use smb_build::input;
+use File::Path;
+use File::Basename;
 
 use strict;
 
@@ -61,6 +63,7 @@ sub PkgConfig($$$$$$$$)
                $cflags .= " -DHAVE_IMMEDIATE_STRUCTURES=1";
        }
 
+       mkpath(dirname($path),0,0755);
        open(OUT, ">$path") or die("Can't open $path: $!");
 
        print OUT <<"__EOF__";
index 907f513c5c5275ab1d044c22a4a4faf2650a9df9..4f6787eaf8f79eefcd85d81e20d9fb9aae29999d 100644 (file)
@@ -17,8 +17,7 @@ use config;
 use strict;
 
 my $INPUT = {};
-
-my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, "main.mk");
+my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
 
 my $subsystem_output_type;
 
index 197cbc9551fbb6c3f4d0a0c4162284c5e578756a..eab8674ed17fcad759c754962329aee252840342 100644 (file)
@@ -122,7 +122,7 @@ CPP=$self->{config}->{CPP}
 CPPFLAGS=$self->{config}->{CPPFLAGS}
 
 CC=$self->{config}->{CC}
-CFLAGS=-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -D_SAMBA_BUILD_ -DHAVE_CONFIG_H $self->{config}->{CFLAGS} \$(CPPFLAGS)
+CFLAGS=-I\$(builddir)/include -I\$(builddir) -I\$(builddir)/lib -I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -D_SAMBA_BUILD_ -DHAVE_CONFIG_H $self->{config}->{CFLAGS} \$(CPPFLAGS)
 PICFLAG=$self->{config}->{PICFLAG}
 HOSTCC=$self->{config}->{HOSTCC}
 
@@ -368,8 +368,12 @@ sub Header($$)
 {
        my ($self,$ctx) = @_;
 
+       my $dir = $ctx->{BASEDIR};
+
+       $dir =~ s/^\.\///g;
+
        foreach (@{$ctx->{PUBLIC_HEADERS}}) {
-               push (@{$self->{headers}}, "$ctx->{BASEDIR}/$_");
+               push (@{$self->{headers}}, "$dir/$_");
        }
 }
 
@@ -497,7 +501,7 @@ sub ProtoHeader($$)
        $self->output("$dir/$ctx->{PUBLIC_PROTO_HEADER}: $ctx->{MK_FILE} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c)\n");
        $self->output("\t\@echo \"$comment\"\n");
 
-       $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --private=$dir/$ctx->{PRIVATE_PROTO_HEADER} --public=$dir/$ctx->{PUBLIC_PROTO_HEADER} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n\n");
+       $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --private=$dir/$ctx->{PRIVATE_PROTO_HEADER} --public=$dir/$ctx->{PUBLIC_PROTO_HEADER} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n\n");
 }
 
 sub write($$)
@@ -542,7 +546,7 @@ endif
 endif
 ");
        } else {
-               $self->output("include static_deps.mk\n");
+               $self->output("include \$(srcdir)/static_deps.mk\n");
        }
 
        open(MAKEFILE,">$file") || die ("Can't open $file\n");
index 9c52e0bd37199ab29c72bd3327b65c97563c2ad3..1dedd148f5779a2a7a4556be11c81a9ed9e63474 100644 (file)
@@ -113,7 +113,14 @@ $SMB_INFO_LIBRARIES
 CEOF
 
 AC_OUTPUT_COMMANDS(
-[$PERL -I${builddir} -I${srcdir} -I${srcdir}/build ${srcdir}/build/smb_build/main.pl || exit $?],[
+[test "x$ac_abs_srcdir" != "x$ac_abs_builddir" && 
+ (cd $builddir; 
+       test -d heimdal || cp -r $srcdir/heimdal $builddir/
+       test -d heimdal_build || cp -r $srcdir/heimdal_build $builddir/
+       test -d build || samba_builddir="$builddir" samba_srcdir="$srcdir" $PERL $srcdir/script/buildtree.pl
+       test -f $builddir/include/smb.h || cp $srcdir/include/smb.h $builddir/include
+ )
+$PERL -I${builddir} -I${srcdir} -I${srcdir}/build ${srcdir}/build/smb_build/main.pl || exit $?],[
 PERL="$PERL";export PERL;export srcdir; export builddir;
 ])
 AC_OUTPUT
index c66784224ab8dff0d133c6e101f2299d3ebb1051..1fd8d98f29406f34370f147c1c5b302cb60c2af6 100644 (file)
@@ -434,6 +434,7 @@ include perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/krb5_err.et|
 
 .SUFFIXES: .hin 
 .hin.h:
+       @mkdir -p $(dir $@)
        @cp $< $@
 
 $(patsubst heimdal/lib/des/%.h,heimdal/lib/des/hcrypto/%.h,$(wildcard heimdal/lib/des/*.h)): heimdal/lib/des/hcrypto
index 5d535e4c58106f93e7afcaf6ca622135bea1fc11..9cc8c93450fd0f6f181844c01f8a5f1ba015d5da 100644 (file)
@@ -15,11 +15,14 @@ REQUIRED_SUBSYSTEMS = TDR_REGF
 REQUIRED_SUBSYSTEMS = TDR 
 OBJ_FILES = tdr_regf.o
 
-lib/registry/reg_backend_nt4.c: lib/registry/tdr_regf.c
-lib/registry/tdr_regf.c: lib/registry/regf.idl
-       @CPP="$(CPP)" $(PERL) pidl/pidl $(PIDL_ARGS) \
+# Special support for external builddirs
+lib/registry/reg_backend_nt4.c: $(srcdir)/lib/registry/reg_backend_nt4.c
+$(srcdir)/lib/registry/reg_backend_nt4.c: lib/registry/tdr_regf.c
+lib/registry/tdr_regf.h: lib/registry/tdr_regf.c
+lib/registry/tdr_regf.c: $(srcdir)/lib/registry/regf.idl
+       @CPP="$(CPP)" $(PERL) $(srcdir)/pidl/pidl $(PIDL_ARGS) \
                --header --outputdir=lib/registry \
-               --tdr-parser -- lib/registry/regf.idl
+               --tdr-parser -- $^
 
 clean::
        @-rm -f lib/registry/regf.h lib/registry/tdr_regf*
index 18df95487c49594c2445215fcc6bc8568247fc88..85c3ffb82cea4f323fe581d096a304d7cb77924b 100644 (file)
@@ -148,7 +148,7 @@ installmisc: installdirs
        @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(JSDIR) $(DESTDIR)$(SETUPDIR) $(DESTDIR)$(BINDIR)
 
 installpc: installdirs
-       @$(SHELL) $(srcdir)/script/installpc.sh $(srcdir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES)
+       @$(SHELL) $(srcdir)/script/installpc.sh $(builddir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES)
 
 uninstall: uninstallbin uninstallman uninstallmisc uninstalllib uninstallheader \
        uninstallplugins
@@ -204,16 +204,16 @@ $(IDL_HEADER_FILES) $(IDL_NDR_HEADER_FILES) $(IDL_NDR_PARSE_C_FILES) \
        $(IDL_NDR_EJS_H_FILES): idl
 
 idl_full: pidl/lib/Parse/Pidl/IDL.pm
-       @CPP="$(CPP)" PERL="$(PERL)" script/build_idl.sh FULL $(PIDL_ARGS)
+       @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL $(PIDL_ARGS)
 
 idl: pidl/lib/Parse/Pidl/IDL.pm
-       @CPP="$(CPP)" PERL="$(PERL)" script/build_idl.sh PARTIAL $(PIDL_ARGS)
+       @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh PARTIAL $(PIDL_ARGS)
 
 pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp
        -$(YAPP) -s -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp 
 
 smb_interfaces: pidl/smb_interfaces.pm
-       $(PERL) -Ipidl script/build_smb_interfaces.pl \
+       $(PERL) -Ipidl $(srcdir)/script/build_smb_interfaces.pl \
                include/smb_interfaces.h
 
 pidl/smb_interfaces.pm: pidl/smb_interfaces.yp
@@ -270,38 +270,38 @@ realdistclean: distclean removebackup
 test: $(DEFAULT_TEST_TARGET)
 
 test-swrap: all
-       ./script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
+       $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
 
 test-noswrap: all
-       ./script/tests/selftest.sh ${selftest_prefix} all
+       $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all
 
 quicktest: all
-       ./script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
+       $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
 
 valgrindtest: valgrindtest-quick
 
 valgrindtest-quick: all
        SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
        VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
-       ./script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
+       $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
 
 valgrindtest-all: all
        SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
        VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
-       ./script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
+       $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
 
 gdbtest: gdbtest-quick
 
 gdbtest-quick: all
        SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
-       ./script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
+       $(srcdir)/script/tests/selftest.sh ${selftest_prefix} quick SOCKET_WRAPPER
 
 gdbtest-all: all
        SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
-       ./script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
+       $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all SOCKET_WRAPPER
 
 unused_macros:
-       ./script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
+       $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
 
 ###############################################################################
 # File types
@@ -311,15 +311,15 @@ unused_macros:
 
 .c.ho:
        @echo "Compiling $< with host compiler"
-       @$(HOSTCC) `script/cflags.pl $@` $(CFLAGS) -c $< -o $@
+       @$(HOSTCC) `$(srcdir)/script/cflags.pl $@` $(CFLAGS) -c $< -o $@
 
 .c.d:
        @echo "Generating dependencies for $<"
-       @$(CC) -M -MG -MP -MT $(<:.c=.o) `script/cflags.pl $@` $(CFLAGS) $< -o $@
+       @$(CC) -M -MG -MP -MT $(<:.c=.o) `$(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
 
 .c.hd:
        @echo "Generating dependencies for $<"
-       @$(CC) -M -MG -MP -MT $(<:.c=.ho) `script/cflags.pl $@` $(CFLAGS) $< -o $@
+       @$(CC) -M -MG -MP -MT $(<:.c=.ho) `$(srcdir)/script/cflags.pl $@` $(CFLAGS) $< -o $@
 
 include/includes.d: include/includes.h
        @echo "Generating dependencies for $<"
@@ -328,14 +328,14 @@ include/includes.d: include/includes.h
 .c.o:
        @if test -n "$(CC_CHECKER)"; then \
                echo "Checking  $< with '$(CC_CHECKER)'"; \
-               $(CC_CHECKER) `script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@; \
+               $(CC_CHECKER) `$(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@; \
        fi
        @echo "Compiling $<"
-       @$(CC) `script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
+       @$(CC) `$(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
 
 .h.h.gch:
        @echo "Precompiling $<"
-       @$(CC) `script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
+       @$(CC) `$(srcdir)/script/cflags.pl $@` $(CFLAGS) $(PICFLAG) -c $< -o $@
 
 .y.c:
        @echo "Building $< with $(YACC)"
index aaf0ef83839251607fd812d8954175586b9bb445..1b38245e17cc2697b412d1637dd40a95b8f767fb 100755 (executable)
@@ -6,22 +6,22 @@ PIDL_EXTRA_ARGS="$*"
 
 [ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1
 
-PIDL="$PERL ./pidl/pidl --outputdir librpc/gen_ndr --header --ndr-parser --server --client --dcom-proxy --com-header --swig --ejs $PIDL_EXTRA_ARGS"
+PIDL="$PERL $srcdir/pidl/pidl --outputdir librpc/gen_ndr --header --ndr-parser --server --client --dcom-proxy --com-header --swig --ejs $PIDL_EXTRA_ARGS"
 
 if [ x$FULLBUILD = xFULL ]; then
       echo Rebuilding all idl files in librpc/idl
-      $PIDL librpc/idl/*.idl || exit 1
+      $PIDL $srcdir/librpc/idl/*.idl || exit 1
       exit 0
 fi
 
 list=""
 
-for f in librpc/idl/*.idl ; do
+for f in $srcdir/librpc/idl/*.idl ; do
     basename=`basename $f .idl`
     ndr="librpc/gen_ndr/ndr_$basename.c"
     # blergh - most shells don't have the -nt function
     if [ -f $ndr ]; then
-       if [ x`find $f -newer $ndr -print` = x$f ]; then
+       if [ x$srcdir/`find $f -newer $ndr -print` = x$f ]; then
            list="$list $f"
        fi
     else 
diff --git a/source4/script/buildtree.pl b/source4/script/buildtree.pl
new file mode 100644 (file)
index 0000000..41cbb3a
--- /dev/null
@@ -0,0 +1,40 @@
+#! /usr/bin/perl -w
+    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
+        if 0; #$running_under_some_shell
+
+use strict;
+use File::Find ();
+use File::Path qw(mkpath);
+use Cwd 'abs_path';
+
+# Set the variable $File::Find::dont_use_nlink if you're using AFS,
+# since AFS cheats.
+
+# for the convenience of &wanted calls, including -eval statements:
+use vars qw/*name *dir *prune/;
+*name   = *File::Find::name;
+*dir    = *File::Find::dir;
+*prune  = *File::Find::prune;
+my $builddir = abs_path($ENV{samba_builddir});
+my $srcdir = abs_path($ENV{samba_srcdir});
+sub wanted;
+
+
+
+# Traverse desired filesystems
+File::Find::find({wanted => \&wanted, no_chdir => 1}, $srcdir);
+exit;
+
+
+sub wanted {
+    my ($dev,$ino,$mode,$nlink,$uid,$gid,$newdir);
+
+    if ((($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
+       (-d _) && (($newdir = abs_path($_)) !~ /$builddir/)) 
+        { 
+         $newdir =~ s!$srcdir!$builddir!; 
+         mkpath($newdir);
+         print("Creating $newdir\n");
+       }
+}
+
index 808ab8d4335aab0b6951f673618f4bcf7cfc9398..e0597ab3812cb3f4ad1d05c4cdd3fe6f463f575c 100755 (executable)
@@ -2,16 +2,18 @@
 # Copyright (C) 2006 Jelmer Vernooij
 use strict;
 use File::Basename;
+use Cwd 'abs_path';
 
 my $includedir = shift;
-
+my $builddir = abs_path($ENV{samba_builddir});
+my $srcdir = abs_path($ENV{samba_srcdir});
 
 sub read_headermap($)
 {
        my ($fn) = @_;
        my %map = ();
        my $ln = 0;
-       open(MAP, "<headermap.txt");
+       open(MAP, "<$fn");
        while(<MAP>) {
                $ln++;
                s/#.*$//g;
@@ -28,14 +30,19 @@ sub read_headermap($)
        return %map;
 }
 
-my %map = read_headermap("headermap.txt");
+my %map = read_headermap("$srcdir/headermap.txt");
 
 sub findmap($)
 {
        $_ = shift;
        s/^\.\///g;
+       s/$builddir\///g;
+       s/$srcdir\///g;
 
        if (! -f $_ && -f "lib/$_") { $_ = "lib/$_"; }
+       if ($srcdir !~ $builddir) {
+        if (! -f "$srcdir/$_" && -f "$srcdir/lib/$_") { $_ = "lib/$_"; }
+       }
        
        return $map{$_};
 }
@@ -55,7 +62,7 @@ sub install_header($$)
 
        my $lineno = 0;
 
-       open(IN, "<$src");
+       open(IN, "<$src") || open(IN, "<$srcdir/$src");
        open(OUT, ">$dst");
 
        while (<IN>) {
@@ -75,8 +82,8 @@ foreach my $p (@ARGV)
 {
        my $p2 = findmap($p);
        unless ($p2) {
-               warn("Unable to map $p");
-               next;
+           warn("Unable to map $p");
+           next;
        }
        print "Installing $p as $includedir/$p2\n";
 
index 097a5cb18fd0a53053f86ba477d3a73d923099a6..c2dc547c120db0428d19090a30d8fda081b36cb5 100755 (executable)
@@ -9,6 +9,8 @@ use strict;
 # use warnings;
 
 use Getopt::Long;
+use File::Basename;
+use File::Path;
 
 #####################################################################
 # read a file into a string
@@ -21,6 +23,8 @@ my $_public = "";
 my $_private = "";
 my $public_data = \$_public;
 my $private_data = \$_private;
+my $builddir = undef;
+my $srcdir = undef;
 
 sub public($)
 {
@@ -57,7 +61,9 @@ GetOptions(
        },
        'public-define=s' => \$public_define,
        'private-define=s' => \$private_define,
-       'help' => \&usage
+       'help' => \&usage,
+       'builddir=s' => sub { my ($f,$v) = @_; $builddir = $v; },
+       'srcdir=s' => sub { my ($f,$v) = @_; $srcdir = $v; }
 ) or exit(1);
 
 if (not defined($public_define) and defined($public_file)) {
@@ -143,7 +149,9 @@ sub process_file($$$)
 
        $filename =~ s/\.o$/\.c/g;
 
-       open(FH, "< $filename") || die "Failed to open $filename";
+       if (!open(FH, "< $builddir/$filename")) {
+           open(FH, "< $srcdir/$filename") || die "Failed to open $filename";
+       }
 
        $private_file->("\n/* The following definitions come from $filename  */\n\n");
 
@@ -198,6 +206,7 @@ sub process_file($$$)
        close(FH);
 }
 
+
 print_header(\&public, $public_define);
 if ($public_file ne $private_file) {
        print_header(\&private, $private_define);
@@ -232,6 +241,7 @@ my $old_private_data = file_load($private_file);
 
 if (not defined($old_public_data) or ($old_public_data ne $$public_data))
 {
+       mkpath(dirname($public_file), 0, 0755);
        open(PUBLIC, ">$public_file") or die("Can't open `$public_file': $!"); 
        print PUBLIC "$$public_data";
        close(PUBLIC);
@@ -240,6 +250,7 @@ if (not defined($old_public_data) or ($old_public_data ne $$public_data))
 if (($public_file ne $private_file) and (
        not defined($old_private_data) or ($old_private_data ne $$private_data))) {
 
+       mkpath(dirname($private_file), 0, 0755);
        open(PRIVATE, ">$private_file") or die("Can't open `$private_file': $!"); 
        print PRIVATE "$$private_data";
        close(PRIVATE);