From 9cf41988ff6cf0647ec4850f25415ba66845fd70 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Tue, 11 Apr 2006 11:37:52 +0000 Subject: r15036: Add out of tree build support and see how buildfarm will respond to make constructs (This used to be commit 9329854489e2c231ffb7986d39009e0936873c11) --- source4/build/smb_build/config_mk.pm | 23 +++++++++++++++++------ source4/build/smb_build/env.pm | 3 +++ source4/build/smb_build/main.pl | 3 +-- source4/build/smb_build/makefile.pm | 12 ++++++++---- 4 files changed, 29 insertions(+), 12 deletions(-) (limited to 'source4/build/smb_build') diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm index 587335ac3e..fa948f4bd9 100644 --- a/source4/build/smb_build/config_mk.pm +++ b/source4/build/smb_build/config_mk.pm @@ -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 = ; 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; } diff --git a/source4/build/smb_build/env.pm b/source4/build/smb_build/env.pm index 7ff6627494..f6de8ce57f 100644 --- a/source4/build/smb_build/env.pm +++ b/source4/build/smb_build/env.pm @@ -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__"; diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl index 907f513c5c..4f6787eaf8 100644 --- a/source4/build/smb_build/main.pl +++ b/source4/build/smb_build/main.pl @@ -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; diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm index 197cbc9551..eab8674ed1 100644 --- a/source4/build/smb_build/makefile.pm +++ b/source4/build/smb_build/makefile.pm @@ -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"); -- cgit