summaryrefslogtreecommitdiff
path: root/source4/build/smb_build
diff options
context:
space:
mode:
Diffstat (limited to 'source4/build/smb_build')
-rw-r--r--source4/build/smb_build/config_mk.pm38
-rwxr-xr-xsource4/build/smb_build/dot.pl4
-rw-r--r--source4/build/smb_build/header.pm92
-rw-r--r--source4/build/smb_build/input.pm72
-rw-r--r--source4/build/smb_build/main.pl49
-rw-r--r--source4/build/smb_build/makefile.pm214
-rw-r--r--source4/build/smb_build/output.pm63
7 files changed, 122 insertions, 410 deletions
diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm
index d8ec646910..652a52fa60 100644
--- a/source4/build/smb_build/config_mk.pm
+++ b/source4/build/smb_build/config_mk.pm
@@ -20,24 +20,19 @@ my $section_types = {
"LDFLAGS" => "list",
},
"PYTHON" => {
- SWIG_FILE => "string",
+ "LIBRARY_REALNAME" => "string",
"PRIVATE_DEPENDENCIES" => "list",
"PUBLIC_DEPENDENCIES" => "list",
- "OBJ_FILES" => "list",
"ENABLE" => "bool",
"LDFLAGS" => "list",
"CFLAGS" => "list",
},
"SUBSYSTEM" => {
- "OBJ_FILES" => "list",
-
"PRIVATE_DEPENDENCIES" => "list",
"PUBLIC_DEPENDENCIES" => "list",
"ENABLE" => "bool",
- "PRIVATE_PROTO_HEADER" => "string",
-
"CFLAGS" => "list",
"LDFLAGS" => "list",
"STANDARD_VISIBILITY" => "string",
@@ -47,7 +42,6 @@ my $section_types = {
"SUBSYSTEM" => "string",
"INIT_FUNCTION" => "string",
- "OBJ_FILES" => "list",
"PRIVATE_DEPENDENCIES" => "list",
@@ -57,20 +51,15 @@ my $section_types = {
"OUTPUT_TYPE" => "list",
- "PRIVATE_PROTO_HEADER" => "string",
-
"CFLAGS" => "list"
},
"BINARY" => {
- "OBJ_FILES" => "list",
"PRIVATE_DEPENDENCIES" => "list",
"ENABLE" => "bool",
"INSTALLDIR" => "string",
- "PRIVATE_PROTO_HEADER" => "string",
-
"CFLAGS" => "list",
"LDFLAGS" => "list",
"STANDARD_VISIBILITY" => "string",
@@ -78,25 +67,17 @@ my $section_types = {
"USE_HOSTCC" => "bool"
},
"LIBRARY" => {
- "VERSION" => "string",
- "SO_VERSION" => "string",
"LIBRARY_REALNAME" => "string",
- "PC_FILE" => "string",
-
"INIT_FUNCTION_TYPE" => "string",
"INIT_FUNCTION_SENTINEL" => "string",
"OUTPUT_TYPE" => "list",
- "OBJ_FILES" => "list",
-
"PRIVATE_DEPENDENCIES" => "list",
"PUBLIC_DEPENDENCIES" => "list",
"ENABLE" => "bool",
- "PRIVATE_PROTO_HEADER" => "string",
-
"CFLAGS" => "list",
"LDFLAGS" => "list",
"STANDARD_VISIBILITY" => "string"
@@ -107,14 +88,11 @@ use vars qw(@parsed_files);
@parsed_files = ();
-sub _read_config_file
+sub _read_config_file($$$)
{
- use File::Basename;
use Cwd;
- my $srcdir = shift;
- my $builddir = shift;
- my $filename = shift;
+ my ($srcdir, $builddir, $filename) = @_;
my @dirlist;
# We need to change our working directory because config.mk files can
@@ -219,10 +197,13 @@ sub run_config_mk($$$$)
$prev = "";
}
- if ($line =~ /^\[([-a-zA-Z0-9_:]+)\][\t ]*$/)
+ if ($line =~ /^\[([-a-zA-Z0-9_.:]+)\][\t ]*$/)
{
$section = $1;
$infragment = 0;
+
+ $result->{$section}{EXISTS}{KEY} = "EXISTS";
+ $result->{$section}{EXISTS}{VAL} = 1;
next;
}
@@ -233,6 +214,7 @@ sub run_config_mk($$$$)
$subdir =~ s/^\.$//g;
$subdir =~ s/^\.\///g;
$subdir .= "/" if ($subdir ne "");
+ $makefile .= "basedir := $subdir\n";
$makefile .= run_config_mk($input, $srcdir, $builddir, $subdir.$subfile);
next;
}
@@ -251,7 +233,6 @@ sub run_config_mk($$$$)
$infragment = 1;
next;
}
-
# Assignment
if ($line =~ /^([a-zA-Z0-9_]+)[\t ]*=(.*)$/) {
@@ -261,7 +242,7 @@ sub run_config_mk($$$$)
next;
}
- die("$parsing_file:$linenum: Bad line while parsing $parsing_file");
+ die("$parsing_file:$linenum: Bad line");
}
$makefile .= "# }END $parsing_file\n";
@@ -280,6 +261,7 @@ sub run_config_mk($$$$)
$input->{$name}{BASEDIR} = $basedir;
foreach my $key (values %{$result->{$section}}) {
+ next if ($key->{KEY} eq "EXISTS");
$key->{VAL} = smb_build::input::strtrim($key->{VAL});
my $vartype = $sectype->{$key->{KEY}};
if (not defined($vartype)) {
diff --git a/source4/build/smb_build/dot.pl b/source4/build/smb_build/dot.pl
index e50ee50f95..b30c320c6e 100755
--- a/source4/build/smb_build/dot.pl
+++ b/source4/build/smb_build/dot.pl
@@ -26,10 +26,10 @@ sub generate($$$)
foreach my $part (values %{$depend}) {
next if (defined($only) and not contains($only,$part->{NAME}));
foreach my $elem (@{$part->{PUBLIC_DEPENDENCIES}}) {
- $res .= "\t\"$part->{NAME}\" -> \"$elem\"; /* public */\n";
+ $res .= "\t\"$part->{NAME}\" -> \"$elem\" [style=filled]; /* public */\n";
}
foreach my $elem (@{$part->{PRIVATE_DEPENDENCIES}}) {
- $res .= "\t\"$part->{NAME}\" -> \"$elem\"; /* private */\n";
+ $res .= "\t\"$part->{NAME}\" -> \"$elem\" [style=dotted]; /* private */\n";
}
}
diff --git a/source4/build/smb_build/header.pm b/source4/build/smb_build/header.pm
deleted file mode 100644
index c2bdbaf4c8..0000000000
--- a/source4/build/smb_build/header.pm
+++ /dev/null
@@ -1,92 +0,0 @@
-# SMB Build System
-# - create output for build.h
-#
-# Copyright (C) Stefan (metze) Metzmacher 2004
-# Copyright (C) Jelmer Vernooij 2005
-# Released under the GNU GPL
-
-package header;
-use strict;
-
-sub _add_define_section($)
-{
- my $DEFINE = shift;
- my $output = "";
-
- $output .= "
-/* $DEFINE->{COMMENT} */
-#define $DEFINE->{KEY} $DEFINE->{VAL}
-";
-
- return $output;
-}
-
-sub _prepare_build_h($)
-{
- my $depend = shift;
- my @defines = ();
- my $output = "";
-
- foreach my $key (values %$depend) {
- my $DEFINE = ();
- next if ($key->{TYPE} ne "LIBRARY" and
- $key->{TYPE} ne "MODULE" and
- $key->{TYPE} ne "SUBSYSTEM" and
- $key->{TYPE} ne "BINARY");
- next unless defined($key->{INIT_FUNCTIONS});
-
- my $name = $key->{NAME};
- $name =~ s/-/_/g;
- $DEFINE->{COMMENT} = "$key->{TYPE} $key->{NAME} INIT";
- $DEFINE->{KEY} = "STATIC_$name\_MODULES";
- $DEFINE->{VAL} = "\\\n";
- foreach (@{$key->{INIT_FUNCTIONS}}) {
- $DEFINE->{VAL} .= "\t$_, \\\n";
- unless (/{/) {
- my $fn = $key->{INIT_FUNCTION_TYPE};
- my $n = $_;
- if ($fn =~ /\(\*\)/) {
- $fn =~ s/\(\*\)/$n/;
- $output .= "$fn;\n";
- } else {
- $n =~ s/\&//;
- $output .= "$fn $n;\n";
- }
- }
- }
-
- $DEFINE->{VAL} .= "\t$key->{INIT_FUNCTION_SENTINEL} \n";
-
- push(@defines,$DEFINE);
- }
-
- #
- # loop over all BUILD_H define sections
- #
- foreach (@defines) { $output .= _add_define_section($_); }
-
- return $output;
-}
-
-###########################################################
-# This function creates include/build.h from the SMB_BUILD
-# context
-#
-# create_build_h($SMB_BUILD_CTX)
-#
-# $SMB_BUILD_CTX - the global SMB_BUILD context
-#
-# $output - the resulting output buffer
-sub create_smb_build_h($$)
-{
- my ($CTX, $file) = @_;
-
- open(BUILD_H,">$file") || die ("Can't open `$file'\n");
- print BUILD_H "/* autogenerated by build/smb_build/main.pl */\n";
- print BUILD_H _prepare_build_h($CTX);
- close(BUILD_H);
-
- print __FILE__.": creating $file\n";
-}
-
-1;
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index 948f2657b4..a76da496d9 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -84,14 +84,18 @@ sub check_module($$$)
return if ($mod->{ENABLE} ne "YES");
+
if (exists($INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTION_TYPE})) {
$mod->{INIT_FUNCTION_TYPE} = $INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTION_TYPE};
} else {
$mod->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)";
}
+ unless (defined($mod->{INIT_FUNCTION_SENTINEL})) { $mod->{INIT_FUNCTION_SENTINEL} = "NULL"; }
+
if (not defined($mod->{OUTPUT_TYPE})) {
- if ($INPUT->{$mod->{SUBSYSTEM}}->{TYPE} eq "EXT_LIB") {
+ if ((not defined($INPUT->{$mod->{SUBSYSTEM}}->{TYPE})) or
+ $INPUT->{$mod->{SUBSYSTEM}}->{TYPE} eq "EXT_LIB") {
$mod->{OUTPUT_TYPE} = undef;
} else {
$mod->{OUTPUT_TYPE} = $default_ot;
@@ -107,7 +111,7 @@ sub check_module($$$)
}
if (grep(/MERGED_OBJ/, @{$mod->{OUTPUT_TYPE}})) {
push (@{$INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS}}, $mod->{INIT_FUNCTION}) if defined($mod->{INIT_FUNCTION});
- unshift (@{$INPUT->{$mod->{SUBSYSTEM}}{PRIVATE_DEPENDENCIES}}, $mod->{NAME});
+ push (@{$INPUT->{$mod->{SUBSYSTEM}}{PRIVATE_DEPENDENCIES}}, $mod->{NAME});
}
}
@@ -119,16 +123,6 @@ sub check_library($$$)
unless (defined($lib->{OUTPUT_TYPE})) { $lib->{OUTPUT_TYPE} = $default_ot; }
- if (defined($lib->{VERSION}) and not defined($lib->{SO_VERSION})) {
- print "$lib->{NAME}: Please specify SO_VERSION when specifying VERSION\n";
- return;
- }
-
- if (defined($lib->{SO_VERSION}) and not defined($lib->{VERSION})) {
- print "$lib->{NAME}: Please specify VERSION when specifying SO_VERSION\n";
- return;
- }
-
unless (defined($lib->{INIT_FUNCTION_TYPE})) { $lib->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)"; }
unless (defined($lib->{INIT_FUNCTION_SENTINEL})) { $lib->{INIT_FUNCTION_SENTINEL} = "NULL"; }
unless (defined($lib->{INSTALLDIR})) { $lib->{INSTALLDIR} = "LIBDIR"; }
@@ -144,25 +138,12 @@ sub check_python($$$)
$python->{INSTALLDIR} = "PYTHONDIR";
unless (defined($python->{CFLAGS})) { $python->{CFLAGS} = []; }
- if (defined($python->{SWIG_FILE})) {
- my $dirname = dirname($python->{SWIG_FILE});
- my $basename = basename($python->{SWIG_FILE}, ".i");
-
- $dirname .= "/" unless $dirname =~ /\/$/;
- $dirname = "" if $dirname eq "./";
-
- $python->{OBJ_FILES} = ["$dirname$basename\_wrap.o"];
- $python->{LIBRARY_REALNAME} = "_$basename.\$(SHLIBEXT)";
- $python->{PYTHON_FILES} = ["$dirname$basename.py"];
- push (@{$python->{CFLAGS}}, "\$(CFLAG_NO_UNUSED_MACROS)");
- push (@{$python->{CFLAGS}}, "\$(CFLAG_NO_CAST_QUAL)");
- $python->{INIT_FUNCTION} = "{ (char *)\"_$basename\", init_$basename }";
- } else {
- my $basename = $python->{NAME};
- $basename =~ s/^python_//g;
+ my $basename = $python->{NAME};
+ $basename =~ s/^python_//g;
+ unless (defined($python->{LIBRARY_REALNAME})) {
$python->{LIBRARY_REALNAME} = "$basename.\$(SHLIBEXT)";
- $python->{INIT_FUNCTION} = "{ (char *)\"$basename\", init$basename }";
}
+ $python->{INIT_FUNCTION} = "{ (char *)\"$basename\", init$basename }";
push (@{$python->{CFLAGS}}, "\$(EXT_LIB_PYTHON_CFLAGS)");
$python->{SUBSYSTEM} = "LIBPYTHON";
@@ -177,6 +158,8 @@ sub check_binary($$)
return if ($bin->{ENABLE} ne "YES");
($bin->{BINARY} = (lc $bin->{NAME})) if not defined($bin->{BINARY});
+ unless (defined($bin->{INIT_FUNCTION_SENTINEL})) { $bin->{INIT_FUNCTION_SENTINEL} = "NULL"; }
+ unless (defined($bin->{INIT_FUNCTION_TYPE})) { $bin->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)"; }
$bin->{OUTPUT_TYPE} = ["BINARY"];
add_libreplace($bin);
@@ -186,16 +169,13 @@ sub add_implicit($$)
{
my ($INPUT, $n) = @_;
- $INPUT->{$n} = {
- TYPE => "MAKE_RULE",
- NAME => $n,
- TARGET => "",
- OUTPUT_TYPE => undef,
- LIBS => ["\$(".uc($n)."_LIBS)"],
- LDFLAGS => ["\$(".uc($n)."_LDFLAGS)"],
- CFLAGS => ["\$(".uc($n)."_CFLAGS)"],
- CPPFLAGS => ["\$(".uc($n)."_CPPFLAGS)"]
- };
+ $INPUT->{$n}->{TYPE} = "MAKE_RULE";
+ $INPUT->{$n}->{NAME} = $n;
+ $INPUT->{$n}->{OUTPUT_TYPE} = undef;
+ $INPUT->{$n}->{LIBS} = ["\$(".uc($n)."_LIBS)"];
+ $INPUT->{$n}->{LDFLAGS} = ["\$(".uc($n)."_LDFLAGS)"];
+ $INPUT->{$n}->{CFLAGS} = ["\$(".uc($n)."_CFLAGS)"];
+ $INPUT->{$n}->{CPPFLAGS} = ["\$(".uc($n)."_CPPFLAGS)"];
}
sub calc_unique_deps($$$$$$$$)
@@ -204,7 +184,7 @@ sub calc_unique_deps($$$$$$$$)
my ($name, $INPUT, $deps, $udeps, $withlibs, $forward, $pubonly, $busy) = @_;
foreach my $n (@$deps) {
- add_implicit($INPUT, $n) unless (defined($INPUT->{$n}));
+ add_implicit($INPUT, $n) unless (defined($INPUT->{$n}) and defined($INPUT->{$n}->{TYPE}));
my $dep = $INPUT->{$n};
if (grep (/^$n$/, @$busy)) {
next if (@{$dep->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ");
@@ -212,19 +192,19 @@ sub calc_unique_deps($$$$$$$$)
}
next if (grep /^$n$/, @$udeps);
- push (@{$udeps}, $dep->{NAME}) if $forward;
+ push (@{$udeps}, $n) if $forward;
if (defined ($dep->{OUTPUT_TYPE}) &&
($withlibs or
(@{$dep->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ") or
(@{$dep->{OUTPUT_TYPE}}[0] eq "STATIC_LIBRARY"))) {
- push (@$busy, $dep->{NAME});
- calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy);
- calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PRIVATE_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy) unless $pubonly;
+ push (@$busy, $n);
+ calc_unique_deps($n, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy);
+ calc_unique_deps($n, $INPUT, $dep->{PRIVATE_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy) unless $pubonly;
pop (@$busy);
}
- unshift (@{$udeps}, $dep->{NAME}) unless $forward;
+ unshift (@{$udeps}, $n) unless $forward;
}
}
@@ -249,7 +229,7 @@ sub check($$$$$)
foreach my $part (values %$INPUT) {
$part->{LINK_FLAGS} = [];
- $part->{FULL_OBJ_LIST} = ["\$($part->{NAME}_OBJ_LIST)"];
+ $part->{FULL_OBJ_LIST} = ["\$($part->{NAME}_OBJ_FILES)"];
if ($part->{TYPE} eq "SUBSYSTEM") {
check_subsystem($INPUT, $part, $subsys_ot);
diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl
index c3dc46461b..88289af26d 100644
--- a/source4/build/smb_build/main.pl
+++ b/source4/build/smb_build/main.pl
@@ -6,16 +6,27 @@
# Released under the GNU GPL
use smb_build::makefile;
-use smb_build::header;
use smb_build::input;
use smb_build::config_mk;
use smb_build::output;
use smb_build::summary;
use smb_build::config;
+use Getopt::Long;
use strict;
+my $output_file = "data.mk";
+
+my $result = GetOptions (
+ 'output=s' => \$output_file);
+
+if (not $result) {
+ exit(1);
+}
+
+my $input_file = shift @ARGV;
+
my $INPUT = {};
-my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
+my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, $input_file);
my $subsys_output_type = ["MERGED_OBJ"];
@@ -44,45 +55,47 @@ my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
my $shared_libs_used = 0;
foreach my $key (values %$OUTPUT) {
- $mkenv->_prepare_list($key, "OBJ_LIST");
- push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_LIST)");
+ next if ($key->{ENABLE} ne "YES");
+ push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_FILES)");
}
foreach my $key (values %$OUTPUT) {
next unless defined $key->{OUTPUT_TYPE};
+ $mkenv->StaticLibraryPrimitives($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
$mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
- $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
- if (defined($key->{PC_FILE})) {
- $mkenv->output("PC_FILES += $key->{BASEDIR}/$key->{PC_FILE}\n");
- }
$mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
if ($key->{TYPE} eq "LIBRARY" and
${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
$shared_libs_used = 1;
}
- $mkenv->SharedModulePrimitives($key) if ($key->{TYPE} eq "MODULE" or
- $key->{TYPE} eq "PYTHON") and
- grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
- $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
- $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER});
+ if ($key->{TYPE} eq "MODULE" and @{$key->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ" and defined($key->{INIT_FUNCTION})) {
+ $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS += $key->{INIT_FUNCTION},\n");
+ }
$mkenv->CFlags($key);
}
foreach my $key (values %$OUTPUT) {
next unless defined $key->{OUTPUT_TYPE};
+ $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
+}
+
+foreach my $key (values %$OUTPUT) {
+ next unless defined $key->{OUTPUT_TYPE};
+ $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
+
$mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
- $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" or
- $key->{TYPE} eq "PYTHON") and
- grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
+ $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" and
+ grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}}));
+ $mkenv->PythonModule($key) if ($key->{TYPE} eq "PYTHON");
$mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
+ $mkenv->InitFunctions($key) if defined($key->{INIT_FUNCTIONS});
}
-$mkenv->write("data.mk");
-header::create_smb_build_h($OUTPUT, "include/build.h");
+$mkenv->write($output_file);
summary::show($OUTPUT, \%config::config);
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index fb3ac561fa..0269cfe8a3 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -23,12 +23,11 @@ sub new($$$)
$self->{output} = "";
- $self->{mkfile} = $mkfile;
-
$self->output("################################################\n");
$self->output("# Autogenerated by build/smb_build/makefile.pm #\n");
$self->output("################################################\n");
$self->output("\n");
+ $self->output($mkfile);
return $self;
}
@@ -73,17 +72,7 @@ sub _prepare_mk_files($)
push (@tmp, $_);
}
- $self->output("
-ifneq (\$(MAKECMDGOALS),clean)
-ifneq (\$(MAKECMDGOALS),distclean)
-ifneq (\$(MAKECMDGOALS),realdistclean)
-");
$self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n");
- $self->output("
-endif
-endif
-endif
-");
}
sub array2oneperline($)
@@ -113,102 +102,54 @@ sub _prepare_list($$$)
$self->output("$ctx->{NAME}_$var =$tmplist\n");
}
-sub SharedModulePrimitives($$)
+sub PythonModule($$)
{
my ($self,$ctx) = @_;
-
- #FIXME
+
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
+ $self->_prepare_list($ctx, "DEPEND_LIST");
+ $self->_prepare_list($ctx, "LINK_FLAGS");
+
+ $self->output("\$(eval \$(call python_c_module_template,$ctx->{LIBRARY_REALNAME},\$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}\_FULL_OBJ_LIST) \$($ctx->{NAME}_LINK_FLAGS)))\n");
}
sub SharedModule($$)
{
my ($self,$ctx) = @_;
- my $init_obj = "";
-
my $sane_subsystem = lc($ctx->{SUBSYSTEM});
$sane_subsystem =~ s/^lib//;
- if ($ctx->{TYPE} eq "PYTHON") {
- $self->output("PYTHON_DSOS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
- } else {
- $self->output("PLUGINS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
- $self->output("installplugins:: $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
- $self->output("\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
- $self->output("\t\@mkdir -p \$(DESTDIR)\$(modulesdir)/$sane_subsystem/\n");
- $self->output("\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
- if (defined($ctx->{ALIASES})) {
- foreach (@{$ctx->{ALIASES}}) {
- $self->output("\t\@rm -f \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
- $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
- }
- }
-
- $self->output("uninstallplugins::\n");
- $self->output("\t\@echo Uninstalling \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
- $self->output("\t\@-rm \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
-
- if (defined($ctx->{ALIASES})) {
- foreach (@{$ctx->{ALIASES}}) {
- $self->output("\t\@-rm \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
- }
- }
- }
+ $self->output("PLUGINS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
+ $self->output("\$(eval \$(call shared_module_install_template,$sane_subsystem,$ctx->{LIBRARY_REALNAME}))\n");
- $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
$self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
- if (defined($ctx->{INIT_FUNCTION}) and $ctx->{TYPE} ne "PYTHON" and
- $ctx->{INIT_FUNCTION_TYPE} =~ /\(\*\)/) {
- my $init_fn = $ctx->{INIT_FUNCTION_TYPE};
- $init_fn =~ s/\(\*\)/init_module/;
- my $proto_fn = $ctx->{INIT_FUNCTION_TYPE};
- $proto_fn =~ s/\(\*\)/$ctx->{INIT_FUNCTION}/;
-
- $self->output(<< "__EOD__"
-bin/$ctx->{NAME}_init_module.c:
- \@echo Creating \$\@
- \@echo \"#include \\\"includes.h\\\"\" > \$\@
- \@echo \"$proto_fn;\" >> \$\@
- \@echo \"_PUBLIC_ $init_fn\" >> \$\@
- \@echo \"{\" >> \$\@
- \@echo \" return $ctx->{INIT_FUNCTION}();\" >> \$\@
- \@echo \"}\" >> \$\@
- \@echo \"\" >> \$\@
-__EOD__
-);
- $init_obj = "bin/$ctx->{NAME}_init_module.o";
+ if (defined($ctx->{INIT_FUNCTION}) and $ctx->{INIT_FUNCTION_TYPE} =~ /\(\*\)/ and not ($ctx->{INIT_FUNCTION} =~ /\(/)) {
+ $self->output("\$($ctx->{NAME}_OBJ_FILES): CFLAGS+=-D$ctx->{INIT_FUNCTION}=init_module\n");
}
- $self->output(<< "__EOD__"
-#
+ $self->output("\$(eval \$(call shared_module_template,$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}\_FULL_OBJ_LIST) \$($ctx->{NAME}_LINK_FLAGS)))\n");
-$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST) $init_obj
- \@echo Linking \$\@
- \@mkdir -p $ctx->{SHAREDDIR}
- \@\$(MDLD) \$(LDFLAGS) \$(MDLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$($ctx->{NAME}\_FULL_OBJ_LIST) $init_obj \\
- \$($ctx->{NAME}_LINK_FLAGS)
-__EOD__
-);
if (defined($ctx->{ALIASES})) {
- foreach (@{$ctx->{ALIASES}}) {
- $self->output("\t\@rm -f $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
- $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
- }
+ $self->output("\$(eval \$(foreach alias,". join(' ', @{$ctx->{ALIASES}}) . ",\$(call shared_module_alias_template,$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME},$sane_subsystem,\$(alias))))\n");
}
- $self->output("\n");
}
-sub SharedLibraryPrimitives($$)
+sub StaticLibraryPrimitives($$)
{
my ($self,$ctx) = @_;
+
+ $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
+}
- $self->output("$ctx->{NAME}_SOVERSION = $ctx->{SO_VERSION}\n") if (defined($ctx->{SO_VERSION}));
- $self->output("$ctx->{NAME}_VERSION = $ctx->{VERSION}\n") if (defined($ctx->{VERSION}));
+sub SharedLibraryPrimitives($$)
+{
+ my ($self,$ctx) = @_;
if (not grep(/STATIC_LIBRARY/, @{$ctx->{OUTPUT_TYPE}})) {
$self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
@@ -220,58 +161,33 @@ sub SharedLibrary($$)
{
my ($self,$ctx) = @_;
- $self->output("SHARED_LIBS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n") if (defined($ctx->{SO_VERSION}));
+ $self->output("SHARED_LIBS += $ctx->{RESULT_SHARED_LIBRARY}\n");
$self->_prepare_list($ctx, "DEPEND_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
- $self->output(<< "__EOD__"
-$ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
- \@echo Linking \$\@
- \@mkdir -p \$(\@D)
- \@\$(SHLD) \$(LDFLAGS) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$($ctx->{NAME}\_FULL_OBJ_LIST) \\
- \$($ctx->{NAME}_LINK_FLAGS) \\
- \$(if \$(SONAMEFLAG), \$(SONAMEFLAG)$ctx->{LIBRARY_SONAME})
-__EOD__
-);
- if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
- $self->output("\t\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}\n");
- }
- $self->output("ifdef $ctx->{NAME}_SOVERSION\n");
- $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}\n");
- $self->output("endif\n");
+ $self->output("\$(eval \$(call shared_library_template,$ctx->{RESULT_SHARED_LIBRARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}\_FULL_OBJ_LIST) \$($ctx->{NAME}_LINK_FLAGS),$ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME},$ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}))\n");
}
sub MergedObj($$)
{
my ($self, $ctx) = @_;
- return unless defined($ctx->{OUTPUT});
-
- $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
- $self->output(<< "__EOD__"
-#
-$ctx->{RESULT_MERGED_OBJ}: \$($ctx->{NAME}_OBJ_LIST)
- \@echo Partially linking \$@
- \@mkdir -p \$(\@D)
- \$(PARTLINK) -o \$@ \$($ctx->{NAME}_OBJ_LIST)
+ $self->output("\$(call partial_link_template, $ctx->{OUTPUT}, \$($ctx->{NAME}_OBJ_FILES))\n");
+}
-__EOD__
-);
+sub InitFunctions($$)
+{
+ my ($self, $ctx) = @_;
+ $self->output("\$($ctx->{NAME}_OBJ_FILES): CFLAGS+=-DSTATIC_$ctx->{NAME}_MODULES=\"\$($ctx->{NAME}_INIT_FUNCTIONS)$ctx->{INIT_FUNCTION_SENTINEL}\"\n");
}
sub StaticLibrary($$)
{
my ($self,$ctx) = @_;
- return unless (defined($ctx->{OBJ_FILES}));
-
- $self->output("STATIC_LIBS += $ctx->{TARGET_STATIC_LIBRARY}\n") if ($ctx->{TYPE} eq "LIBRARY");
-
+ $self->output("STATIC_LIBS += $ctx->{RESULT_STATIC_LIBRARY}\n") if ($ctx->{TYPE} eq "LIBRARY");
$self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
- $self->_prepare_list($ctx, "FULL_OBJ_LIST");
-
$self->output("$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)\n");
}
@@ -280,74 +196,31 @@ sub Binary($$)
my ($self,$ctx) = @_;
unless (defined($ctx->{INSTALLDIR})) {
+ $self->output("BINARIES += $ctx->{TARGET_BINARY}\n");
} elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
- $self->output("SBIN_PROGS += bin/$ctx->{BINARY}\n");
+ $self->output("SBIN_PROGS += $ctx->{RESULT_BINARY}\n");
} elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
- $self->output("BIN_PROGS += bin/$ctx->{BINARY}\n");
+ $self->output("BIN_PROGS += $ctx->{RESULT_BINARY}\n");
}
- $self->output("binaries:: $ctx->{TARGET_BINARY}\n");
-
$self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
-$self->output(<< "__EOD__"
-$ctx->{RESULT_BINARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
- \@echo Linking \$\@
-__EOD__
- );
-
if (defined($ctx->{USE_HOSTCC}) && $ctx->{USE_HOSTCC} eq "YES") {
- $self->output(<< "__EOD__"
- \@\$(HOSTLD) \$(HOSTLD_FLAGS) -L\${builddir}/bin/static -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$\($ctx->{NAME}_LINK_FLAGS)
-__EOD__
- );
+$self->output("\$(call host_binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}_LINK_FLAGS))\n");
} else {
- $self->output(<< "__EOD__"
- \@\$(BNLD) \$(BNLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$\($ctx->{NAME}_LINK_FLAGS)
-
-__EOD__
- );
- }
-}
-
-sub PythonFiles($$)
-{
- my ($self,$ctx) = @_;
-
- foreach (@{$ctx->{PYTHON_FILES}}) {
- my $target = "bin/python/".basename($_);
- my $source = output::add_dir_str($ctx->{BASEDIR}, $_);
- $self->output("$target: $source\n\n");
- $self->output("PYTHON_PYS += $target\n");
+$self->output("\$(call binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}_LINK_FLAGS))\n");
}
}
-sub ProtoHeader($$)
-{
- my ($self,$ctx) = @_;
-
- my $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER});
- $self->output("PROTO_HEADERS += $priv\n");
-
- $self->output("$priv: $ctx->{MK_FILE} \$($ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");
- $self->output("\t\@echo \"Creating \$@\"\n");
- $self->output("\t\@mkdir -p \$(\@D)\n");
- $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --public=/dev/null --private=\$@ \$($ctx->{NAME}_OBJ_LIST)\n\n");
-}
-
sub write($$)
{
my ($self, $file) = @_;
- $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
-
$self->_prepare_mk_files();
- $self->output($self->{mkfile});
+ $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
open(MAKEFILE,">$file") || die ("Can't open $file\n");
print MAKEFILE $self->{output};
@@ -374,7 +247,6 @@ sub CFlags($$)
my $src_ne_build = ($srcdir ne $builddir) ? 1 : 0;
- return unless defined ($key->{OBJ_LIST});
return unless defined ($key->{FINAL_CFLAGS});
return unless (@{$key->{FINAL_CFLAGS}} > 0);
@@ -388,19 +260,19 @@ sub CFlags($$)
my @cflags = ();
foreach my $flag (@sorted_cflags) {
if($src_ne_build) {
- if($flag =~ m#^-I([^/].*$)#) {
- my $dir = $1;
- $dir =~ s#^\$\((?:src|build)dir\)/?##;
+ if($flag =~ m#^-I([^/].*$)#) {
+ my $dir = $1;
+ $dir =~ s#^\$\((?:src|build)dir\)/?##;
push(@cflags, "-I$builddir/$dir", "-I$srcdir/$dir");
- next;
- }
+ next;
+ }
}
push(@cflags, $flag);
}
my $cflags = join(' ', @cflags);
- $self->output("\$(patsubst %.ho,%.d,\$($key->{NAME}_OBJ_LIST:.o=.d)) \$($key->{NAME}_OBJ_LIST): CFLAGS+= $cflags\n");
+ $self->output("\$(patsubst %.ho,%.d,\$($key->{NAME}_OBJ_FILES:.o=.d)) \$($key->{NAME}_OBJ_FILES): CFLAGS+= $cflags\n");
}
1;
diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm
index 4ae4a62cf4..f9f12c3a73 100644
--- a/source4/build/smb_build/output.pm
+++ b/source4/build/smb_build/output.pm
@@ -7,39 +7,6 @@
package output;
use strict;
-use smb_build::config;
-
-sub add_dir_str($$)
-{
- my ($dir,$file) = @_;
- my $dirsep = "/";
-
- $dir =~ s/^\.$//g;
- $dir =~ s/^\.\///g;
-
- $dirsep = "" if ($dir eq "");
-
- my $ret = $file;
- if (substr($ret, 0, 1) ne "\$") {
- $ret = "$dir$dirsep$file";
- $ret =~ s/([^\/\.]+)\/\.\.\///g;
- $ret =~ s/([^\/\.]+)\/\.\.\///g;
- }
-
- return $ret;
-}
-
-sub add_dir_array($$)
-{
- my ($dir,$files) = @_;
- my @ret = ();
-
- foreach (@{$files}) {
- push (@ret, add_dir_str($dir, $_));
- }
-
- return @ret;
-}
sub generate_shared_library($)
{
@@ -80,10 +47,8 @@ sub generate_shared_library($)
$lib->{LIBRARY_DEBUGNAME} = $lib->{LIBRARY_REALNAME};
- if (defined($lib->{VERSION}) and $config::config{SONAMEFLAG} ne "#") {
- $lib->{LIBRARY_SONAME} = "$lib->{LIBRARY_REALNAME}.\$($lib->{NAME}_SOVERSION)";
- $lib->{LIBRARY_REALNAME} = "$lib->{LIBRARY_REALNAME}.\$($lib->{NAME}_VERSION)";
- }
+ $lib->{LIBRARY_SONAME} = "\$(if \$($lib->{NAME}_SOVERSION),$lib->{LIBRARY_REALNAME}.\$($lib->{NAME}_SOVERSION),$lib->{LIBRARY_REALNAME})";
+ $lib->{LIBRARY_REALNAME} = "\$(if \$($lib->{NAME}_VERSION),$lib->{LIBRARY_REALNAME}.\$($lib->{NAME}_VERSION),$lib->{LIBRARY_REALNAME})";
$lib->{RESULT_SHARED_LIBRARY} = "$lib->{SHAREDDIR}/$lib->{LIBRARY_REALNAME}";
$lib->{OUTPUT_SHARED_LIBRARY} = "-l$link_name";
@@ -97,11 +62,9 @@ sub generate_merged_obj($)
my $link_name = $lib->{NAME};
$link_name =~ s/^LIB//;
- if (defined($lib->{OBJ_FILES})) {
- $lib->{MERGED_OBJNAME} = lc($link_name).".o";
- $lib->{RESULT_MERGED_OBJ} = $lib->{OUTPUT_MERGED_OBJ} = "bin/mergedobj/$lib->{MERGED_OBJNAME}";
- $lib->{TARGET_MERGED_OBJ} = $lib->{RESULT_MERGED_OBJ};
- }
+ $lib->{MERGED_OBJNAME} = lc($link_name).".o";
+ $lib->{RESULT_MERGED_OBJ} = $lib->{OUTPUT_MERGED_OBJ} = "bin/mergedobj/$lib->{MERGED_OBJNAME}";
+ $lib->{TARGET_MERGED_OBJ} = $lib->{RESULT_MERGED_OBJ};
}
sub generate_static_library($)
@@ -116,12 +79,10 @@ sub generate_static_library($)
$lib->{LIBRARY_NAME} = "lib".lc($link_name).".a";
- if (defined($lib->{OBJ_FILES})) {
- $lib->{RESULT_STATIC_LIBRARY} = "bin/static/$lib->{LIBRARY_NAME}";
- $lib->{TARGET_STATIC_LIBRARY} = $lib->{RESULT_STATIC_LIBRARY};
- $lib->{STATICDIR} = 'bin/static';
- $lib->{OUTPUT_STATIC_LIBRARY} = "-l".lc($link_name);
- }
+ $lib->{RESULT_STATIC_LIBRARY} = "bin/static/$lib->{LIBRARY_NAME}";
+ $lib->{TARGET_STATIC_LIBRARY} = $lib->{RESULT_STATIC_LIBRARY};
+ $lib->{STATICDIR} = 'bin/static';
+ $lib->{OUTPUT_STATIC_LIBRARY} = "-l".lc($link_name);
}
sub generate_binary($)
@@ -160,10 +121,6 @@ sub create_output($$)
foreach $part (values %{$depend}) {
next unless(defined($part->{OUTPUT_TYPE}));
- # Combine object lists
- my @list = add_dir_array($part->{BASEDIR}, $part->{OBJ_FILES});
- push(@{$part->{OBJ_LIST}}, @list) if defined($part->{OBJ_FILES});
-
generate_binary($part) if grep(/BINARY/, @{$part->{OUTPUT_TYPE}});
generate_shared_library($part) if grep(/SHARED_LIBRARY/, @{$part->{OUTPUT_TYPE}});
generate_static_library($part) if grep(/STATIC_LIBRARY/, @{$part->{OUTPUT_TYPE}});
@@ -197,7 +154,7 @@ sub create_output($$)
push (@{$part->{FULL_OBJ_LIST}}, $elem->{TARGET});
} else {
push(@{$part->{LINK_FLAGS}}, "\$($elem->{NAME}_OUTPUT)") if defined($elem->{OUTPUT});
- push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if defined($elem->{TARGET});
+ push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if (defined($elem->{TARGET}));
}
}
}