summaryrefslogtreecommitdiff
path: root/source4/build/smb_build
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-04-27 19:50:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:05:04 -0500
commit620d759f49f4b648d0fa4a84e67f1cecbbdd0f06 (patch)
tree15a768135a197cdd7b3acd369c029ce9248e9012 /source4/build/smb_build
parent710ea949886dd57c66dc6d397e0ea41c89736107 (diff)
downloadsamba-620d759f49f4b648d0fa4a84e67f1cecbbdd0f06.tar.gz
samba-620d759f49f4b648d0fa4a84e67f1cecbbdd0f06.tar.bz2
samba-620d759f49f4b648d0fa4a84e67f1cecbbdd0f06.zip
r15298: Fix the build using a few hacks in the build system.
Recursive dependencies are now forbidden (the build system will bail out if there are any). I've split up auth_sam.c into auth_sam.c and sam.c. Andrew, please rename sam.c / move its contents to whatever/wherever you think suits best. (This used to be commit 6646384aaf3e7fa2aa798c3e564b94b0617ec4d0)
Diffstat (limited to 'source4/build/smb_build')
-rw-r--r--source4/build/smb_build/TODO2
-rw-r--r--source4/build/smb_build/input.pm45
-rw-r--r--source4/build/smb_build/main.pl11
-rw-r--r--source4/build/smb_build/makefile.pm56
-rw-r--r--source4/build/smb_build/output.pm32
5 files changed, 88 insertions, 58 deletions
diff --git a/source4/build/smb_build/TODO b/source4/build/smb_build/TODO
index 3ded826539..c21c3b8082 100644
--- a/source4/build/smb_build/TODO
+++ b/source4/build/smb_build/TODO
@@ -1,4 +1,6 @@
- let the build system implement some make functions($(patsubst),$(wildcard),...) and use our own implementations where `make' does not support them
+- include extra_flags.txt using Makefile construction if
+ supported by current make
- change default subsystem/library build type to STATIC_LIBRARY
- fix order of UNIQUE_DEPENDENCIES
- make --enable-dso the default
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index 09721f3a49..887677243d 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -65,10 +65,7 @@ sub check_module($$$)
$mod->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)";
}
- if (defined($mod->{CHOSEN_BUILD}) and $mod->{CHOSEN_BUILD} ne "DEFAULT")
- {
- $mod->{OUTPUT_TYPE} = $mod->{CHOSEN_BUILD};
- } elsif (not defined($mod->{OUTPUT_TYPE})) {
+ if (not defined($mod->{OUTPUT_TYPE})) {
$mod->{OUTPUT_TYPE} = $default_ot;
}
@@ -76,8 +73,7 @@ sub check_module($$$)
$mod->{INSTALLDIR} = "MODULESDIR/$mod->{SUBSYSTEM}";
push (@{$mod->{PRIVATE_DEPENDENCIES}}, $mod->{SUBSYSTEM}) unless
$INPUT->{$mod->{SUBSYSTEM}}->{TYPE} eq "BINARY";
- } else {
- push (@{$INPUT->{$mod->{SUBSYSTEM}}{PRIVATE_DEPENDENCIES}}, $mod->{NAME});
+ } else {
push (@{$INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS}}, $mod->{INIT_FUNCTION}) if defined($mod->{INIT_FUNCTION});
}
}
@@ -118,17 +114,33 @@ sub check_binary($$)
$bin->{OUTPUT_TYPE} = "BINARY";
}
+
+sub import_integrated($$)
+{
+ my ($lib, $depend) = @_;
+
+ foreach my $mod (values %$depend) {
+ next if(not defined($mod->{SUBSYSTEM}));
+ next if($mod->{SUBSYSTEM} ne $lib->{NAME});
+ next if($mod->{ENABLE} ne "YES");
+
+ push (@{$lib->{FULL_OBJ_LIST}}, "\$($mod->{TYPE}_$mod->{NAME}_OBJ_LIST)");
+ push (@{$lib->{LINK_FLAGS}}, "\$($mod->{TYPE}_$mod->{NAME}_LINK_FLAGS)");
+ push (@{$lib->{PRIVATE_DEPENDENCIES}}, @{$mod->{PUBLIC_DEPENDENCIES}}) if defined($mod->{PUBLIC_DEPENDENCIES});
+ push (@{$lib->{PRIVATE_DEPENDENCIES}}, @{$mod->{PRIVATE_DEPENDENCIES}}) if defined($mod->{PRIVATE_DEPENDENCIES});
+
+ $mod->{ENABLE} = "NO";
+ }
+}
+
sub calc_unique_deps($$$$$$)
{
sub calc_unique_deps($$$$$$);
my ($name, $INPUT, $deps, $udeps, $withlibs, $busy) = @_;
foreach my $n (@$deps) {
- if (grep (/^$n$/, @$busy)) {
- # print "($name) BUSY: $n, list: " . join(',', @$busy) . "\n";
- # die("Recursive dependency for $dep->{NAME}");
- next;
- }
+ die("Dependency unknown: $n") unless (defined($INPUT->{$n}));
+ die("Recursive dependency: $n, list: " . join(',', @$busy)) if (grep (/^$n$/, @$busy));
next if (grep /^$n$/, @$udeps);
my $dep = $INPUT->{$n};
@@ -136,6 +148,7 @@ sub calc_unique_deps($$$$$$)
($withlibs or
($dep->{OUTPUT_TYPE} eq "OBJ_LIST") or
($dep->{OUTPUT_TYPE} eq "MERGEDOBJ") or
+ ($dep->{OUTPUT_TYPE} eq "INTEGRATED") or
($dep->{OUTPUT_TYPE} eq "STATIC_LIBRARY"))) {
push (@$busy, $dep->{NAME});
calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $busy);
@@ -143,9 +156,7 @@ sub calc_unique_deps($$$$$$)
pop (@$busy);
}
- # FIXME: Insert at the right position
- push (@{$udeps}, $dep->{NAME});
-
+ unshift (@{$udeps}, $dep->{NAME});
}
}
@@ -191,6 +202,8 @@ sub check($$$$$)
foreach my $k (keys %$INPUT) {
my $part = $INPUT->{$k};
+ $part->{FULL_OBJ_LIST} = ["\$($part->{TYPE}_$part->{NAME}_OBJ_LIST)"];
+
check_subsystem($INPUT, $part, $subsys_ot) if ($part->{TYPE} eq "SUBSYSTEM");
check_module($INPUT, $part, $module_ot) if ($part->{TYPE} eq "MODULE");
check_library($INPUT, $part, $lib_ot) if ($part->{TYPE} eq "LIBRARY");
@@ -198,6 +211,10 @@ sub check($$$$$)
}
foreach my $part (values %$INPUT) {
+ import_integrated($part, $INPUT);
+ }
+
+ foreach my $part (values %$INPUT) {
$part->{UNIQUE_DEPENDENCIES} = [];
calc_unique_deps($part->{NAME}, $INPUT, $part->{PUBLIC_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES}, 0, []);
calc_unique_deps($part->{NAME}, $INPUT, $part->{PRIVATE_DEPENDENCIES}, $part->{UNIQUE_DEPENDENCIES}, 0, []);
diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl
index 4f6787eaf8..ec4ad0995e 100644
--- a/source4/build/smb_build/main.pl
+++ b/source4/build/smb_build/main.pl
@@ -45,10 +45,8 @@ if (defined($ENV{"MODULE_OUTPUT_TYPE"})) {
$module_output_type = $ENV{MODULE_OUTPUT_TYPE};
} elsif ($config::config{BLDSHARED} eq "true") {
$module_output_type = "SHARED_LIBRARY";
-} elsif ($config::config{BLDMERGED} eq "true") {
- $module_output_type = "MERGEDOBJ";
} else {
- $module_output_type = "OBJ_LIST";
+ $module_output_type = "INTEGRATED";
}
my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
@@ -59,6 +57,13 @@ $config::config{LIBRARY_OUTPUT_TYPE} = $library_output_type;
$config::config{MODULE_OUTPUT_TYPE} = $module_output_type;
my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
+
+foreach my $key (values %$OUTPUT) {
+ next unless defined $key->{OUTPUT_TYPE};
+
+ $mkenv->Integrated($key) if $key->{OUTPUT_TYPE} eq "INTEGRATED";
+}
+
foreach my $key (values %$OUTPUT) {
next unless defined $key->{OUTPUT_TYPE};
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index aa9f93fc2d..83a1f28b0c 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -197,6 +197,14 @@ sub _prepare_list($$$)
$self->output("$ctx->{TYPE}\_$ctx->{NAME}_$var =$tmplist\n");
}
+sub Integrated($$)
+{
+ my ($self,$ctx) = @_;
+
+ $self->_prepare_list($ctx, "OBJ_LIST");
+ $self->_prepare_list($ctx, "LINK_FLAGS");
+}
+
sub SharedLibrary($$)
{
my ($self,$ctx) = @_;
@@ -231,11 +239,11 @@ sub SharedLibrary($$)
}
$self->_prepare_list($ctx, "OBJ_LIST");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
- $self->_prepare_list($ctx, "LINK_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
+ push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
if ($ctx->{TYPE} eq "MODULE" and defined($ctx->{INIT_FUNCTION})) {
my $init_fn = $ctx->{INIT_FUNCTION_TYPE};
@@ -270,12 +278,12 @@ __EOD__
$self->output(<< "__EOD__"
#
-$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) $init_obj
+$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) $init_obj
\@echo Linking \$\@
\@mkdir -p $ctx->{DEBUGDIR}
\@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(LOCAL_LINK_FLAGS) \\
\$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) $soarg \\
- $init_obj \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)$soargdebug
+ $init_obj $soargdebug
__EOD__
);
if (defined($ctx->{ALIASES})) {
@@ -297,12 +305,12 @@ __EOD__
$self->output(<< "__EOD__"
#
-$installdir/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) $init_obj
+$installdir/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) $init_obj
\@echo Linking \$\@
\@mkdir -p $installdir
\@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
\$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) $soarg \\
- $init_obj \$($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST)$singlesoarg
+ $init_obj $singlesoarg
__EOD__
);
@@ -312,17 +320,18 @@ sub MergedObj($$)
{
my ($self,$ctx) = @_;
- return unless $ctx->{TARGET};
-
$self->_prepare_list($ctx, "OBJ_LIST");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
+ return unless $ctx->{TARGET};
+
+ push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
- $self->output("$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n");
+ $self->output("$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)\n");
$self->output("\t\@echo \"Pre-Linking $ctx->{TYPE} $ctx->{NAME}\"\n");
- $self->output("\t@\$(LD) -r \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST) -o $ctx->{TARGET}\n");
+ $self->output("\t@\$(LD) -r \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) -o $ctx->{TARGET}\n");
$self->output("\n");
}
@@ -332,12 +341,13 @@ sub ObjList($$)
return unless $ctx->{TARGET};
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
+ push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
$self->_prepare_list($ctx, "OBJ_LIST");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
$self->output("$ctx->{TARGET}: ");
- $self->output("\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n");
+ $self->output("\$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)\n");
$self->output("\t\@touch $ctx->{TARGET}\n");
}
@@ -348,19 +358,17 @@ sub StaticLibrary($$)
push (@{$self->{static_libs}}, $ctx->{TARGET});
$self->_prepare_list($ctx, "OBJ_LIST");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
- $self->_prepare_list($ctx, "DEPEND_LIST");
- $self->_prepare_list($ctx, "LINK_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
+ push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
$self->output(<< "__EOD__"
#
-$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)
+$ctx->{TARGET}: \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$@
- \@\$(STLD) \$(STLD_FLAGS) \$@ \\
- \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)
+ \@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
__EOD__
);
@@ -391,7 +399,7 @@ sub Binary($$)
$installdir = "bin";
}
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)");
+ push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
unless (defined($ctx->{INSTALLDIR})) {
} elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
@@ -403,17 +411,16 @@ sub Binary($$)
push (@{$self->{binaries}}, "bin/$ctx->{BINARY}");
$self->_prepare_list($ctx, "OBJ_LIST");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
- $self->_prepare_list($ctx, "LINK_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
if ($self->{duplicate_build}) {
$self->output(<< "__EOD__"
#
-bin/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)
+bin/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$\@
\@\$(CC) \$(LDFLAGS) -o \$\@ \$(LOCAL_LINK_FLAGS) \$(INSTALL_LINK_FLAGS) \\
- \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST) \\
\$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
__EOD__
@@ -421,10 +428,9 @@ __EOD__
}
$self->output(<< "__EOD__"
-$installdir/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)
+$installdir/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$\@
\@\$(CC) \$(LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_LIST) \\
\$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
__EOD__
diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm
index de122ee9a0..ba8359a72b 100644
--- a/source4/build/smb_build/output.pm
+++ b/source4/build/smb_build/output.pm
@@ -16,8 +16,10 @@ sub add_dir($$)
$dir =~ s/^\.\///g;
foreach (@$files) {
- $_ = "$dir/$_";
- s/([^\/\.]+)\/\.\.\///g;
+ if (substr($_, 0, 1) ne "\$") {
+ $_ = "$dir/$_";
+ s/([^\/\.]+)\/\.\.\///g;
+ }
push (@ret, $_);
}
@@ -45,8 +47,8 @@ sub generate_shared_library($)
my $link_name;
my $lib_name;
- @{$lib->{DEPEND_LIST}} = ();
- @{$lib->{LINK_LIST}} = ("\$($lib->{TYPE}_$lib->{NAME}\_OBJ_LIST)");
+ $lib->{DEPEND_LIST} = [];
+ $lib->{LINK_FLAGS} = ["\$($lib->{TYPE}_$lib->{NAME}\_OBJ_LIST)"];
$link_name = lc($lib->{NAME});
$lib_name = $link_name;
@@ -77,8 +79,8 @@ sub generate_shared_library($)
}
if (defined($lib->{VERSION})) {
- $lib->{LIBRARY_SONAME} = $lib->{LIBRARY_REALNAME}.".$lib->{SO_VERSION}";
- $lib->{LIBRARY_REALNAME} = $lib->{LIBRARY_REALNAME}.".$lib->{VERSION}";
+ $lib->{LIBRARY_SONAME} = "$lib->{LIBRARY_REALNAME}.$lib->{SO_VERSION}";
+ $lib->{LIBRARY_REALNAME} = "$lib->{LIBRARY_REALNAME}.$lib->{VERSION}";
}
$lib->{TARGET} = "$lib->{DEBUGDIR}/$lib->{LIBRARY_REALNAME}";
@@ -90,14 +92,13 @@ sub generate_static_library($)
my $lib = shift;
my $link_name;
- @{$lib->{DEPEND_LIST}} = ();
+ $lib->{DEPEND_LIST} = [];
$link_name = $lib->{NAME};
$link_name =~ s/^LIB//;
$lib->{LIBRARY_NAME} = "lib".lc($link_name).".a";
- @{$lib->{LINK_LIST}} = ("\$($lib->{TYPE}_$lib->{NAME}\_OBJ_LIST)");
- @{$lib->{LINK_FLAGS}} = ();
+ $lib->{LINK_FLAGS} = ["\$($lib->{TYPE}_$lib->{NAME}\_OBJ_LIST)"];
$lib->{TARGET} = "bin/$lib->{LIBRARY_NAME}";
$lib->{OUTPUT} = "-l".lc($link_name);
@@ -107,9 +108,8 @@ sub generate_binary($)
{
my $bin = shift;
- @{$bin->{DEPEND_LIST}} = ();
- @{$bin->{LINK_LIST}} = ("\$($bin->{TYPE}_$bin->{NAME}\_OBJ_LIST)");
- @{$bin->{LINK_FLAGS}} = ();
+ $bin->{DEPEND_LIST} = [];
+ $bin->{LINK_FLAGS} = ["\$($bin->{TYPE}_$bin->{NAME}\_OBJ_LIST)"];
$bin->{RELEASEDIR} = "bin/install";
$bin->{DEBUGDIR} = "bin/";
@@ -117,17 +117,16 @@ sub generate_binary($)
$bin->{BINARY} = $bin->{NAME};
}
+
sub create_output($$)
{
my ($depend, $config) = @_;
my $part;
foreach $part (values %{$depend}) {
- next if not defined($part->{OUTPUT_TYPE});
+ next unless(defined($part->{OUTPUT_TYPE}));
# Combine object lists
- push(@{$part->{OBJ_LIST}}, add_dir($part->{BASEDIR}, $part->{INIT_OBJ_FILES})) if defined($part->{INIT_OBJ_FILES});
- push(@{$part->{OBJ_LIST}}, add_dir($part->{BASEDIR}, $part->{ADD_OBJ_FILES})) if defined($part->{ADD_OBJ_FILES});
push(@{$part->{OBJ_LIST}}, add_dir($part->{BASEDIR}, $part->{OBJ_FILES})) if defined($part->{OBJ_FILES});
if ((not defined($part->{OBJ_LIST}) or
@@ -161,7 +160,7 @@ sub create_output($$)
my $elem = $depend->{$_};
next if $elem == $part;
- push(@{$part->{LINK_LIST}}, $elem->{OUTPUT}) if defined($elem->{OUTPUT});
+ push(@{$part->{LINK_FLAGS}}, $elem->{OUTPUT}) if defined($elem->{OUTPUT});
push(@{$part->{LINK_FLAGS}}, @{$elem->{LIBS}}) if defined($elem->{LIBS});
push(@{$part->{LINK_FLAGS}},@{$elem->{LDFLAGS}}) if defined($elem->{LDFLAGS});
push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if defined($elem->{TARGET});
@@ -177,6 +176,7 @@ sub create_output($$)
}
}
+
return $depend;
}