summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/build/smb_build/config_mk.pm23
-rw-r--r--source4/build/smb_build/env.pm3
-rw-r--r--source4/build/smb_build/main.pl3
-rw-r--r--source4/build/smb_build/makefile.pm12
-rw-r--r--source4/configure.in9
-rw-r--r--source4/heimdal_build/config.mk1
-rw-r--r--source4/lib/registry/config.mk11
-rw-r--r--source4/main.mk36
-rwxr-xr-xsource4/script/build_idl.sh8
-rw-r--r--source4/script/buildtree.pl40
-rwxr-xr-xsource4/script/installheader.pl19
-rwxr-xr-xsource4/script/mkproto.pl15
12 files changed, 133 insertions, 47 deletions
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 = <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;
}
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");
diff --git a/source4/configure.in b/source4/configure.in
index 9c52e0bd37..1dedd148f5 100644
--- a/source4/configure.in
+++ b/source4/configure.in
@@ -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
diff --git a/source4/heimdal_build/config.mk b/source4/heimdal_build/config.mk
index c66784224a..1fd8d98f29 100644
--- a/source4/heimdal_build/config.mk
+++ b/source4/heimdal_build/config.mk
@@ -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
diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk
index 5d535e4c58..9cc8c93450 100644
--- a/source4/lib/registry/config.mk
+++ b/source4/lib/registry/config.mk
@@ -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*
diff --git a/source4/main.mk b/source4/main.mk
index 18df95487c..85c3ffb82c 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -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)"
diff --git a/source4/script/build_idl.sh b/source4/script/build_idl.sh
index aaf0ef8383..1b38245e17 100755
--- a/source4/script/build_idl.sh
+++ b/source4/script/build_idl.sh
@@ -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
index 0000000000..41cbb3ad76
--- /dev/null
+++ b/source4/script/buildtree.pl
@@ -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");
+ }
+}
+
diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl
index 808ab8d433..e0597ab381 100755
--- a/source4/script/installheader.pl
+++ b/source4/script/installheader.pl
@@ -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";
diff --git a/source4/script/mkproto.pl b/source4/script/mkproto.pl
index 097a5cb18f..c2dc547c12 100755
--- a/source4/script/mkproto.pl
+++ b/source4/script/mkproto.pl
@@ -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);