summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
Diffstat (limited to 'source4/build')
-rw-r--r--source4/build/smb_build/config_mk.pm2
-rw-r--r--source4/build/smb_build/header.pm86
-rw-r--r--source4/build/smb_build/input.pm1
-rw-r--r--source4/build/smb_build/main.pl18
-rw-r--r--source4/build/smb_build/makefile.pm133
5 files changed, 59 insertions, 181 deletions
diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm
index 4d8db8a04e..70520554ab 100644
--- a/source4/build/smb_build/config_mk.pm
+++ b/source4/build/smb_build/config_mk.pm
@@ -245,6 +245,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;
}
@@ -263,7 +264,6 @@ sub run_config_mk($$$$)
$infragment = 1;
next;
}
-
# Assignment
if ($line =~ /^([a-zA-Z0-9_]+)[\t ]*=(.*)$/) {
diff --git a/source4/build/smb_build/header.pm b/source4/build/smb_build/header.pm
deleted file mode 100644
index 93240f1d17..0000000000
--- a/source4/build/smb_build/header.pm
+++ /dev/null
@@ -1,86 +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};
- $fn =~ s/\(\*\)/$_/;
- $output .= "$fn;\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 da90e9db48..9aef1c1002 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -265,7 +265,6 @@ sub check($$$$$)
foreach my $part (values %$INPUT) {
$part->{LINK_FLAGS} = [];
- $part->{FULL_OBJ_LIST} = ["\$($part->{NAME}_OBJ_LIST)"];
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 3ed0327d6d..c6031e23e6 100644
--- a/source4/build/smb_build/main.pl
+++ b/source4/build/smb_build/main.pl
@@ -6,7 +6,6 @@
# 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;
@@ -53,10 +52,10 @@ foreach my $key (values %$OUTPUT) {
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})) {
- push(@{$mkenv->{pc_files}}, "$key->{BASEDIR}/$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}});
@@ -70,23 +69,30 @@ foreach my $key (values %$OUTPUT) {
$mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
$mkenv->Manpage($key) if defined($key->{MANPAGE});
$mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
- $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or
- defined($key->{PUBLIC_PROTO_HEADER});
}
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->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
+ $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or
+ defined($key->{PUBLIC_PROTO_HEADER});
+ $mkenv->InitFunctions($key) if defined($key->{INIT_FUNCTIONS});
}
$mkenv->write("data.mk");
-header::create_smb_build_h($OUTPUT, "include/build.h");
cflags::create_cflags($OUTPUT, $config::config{srcdir},
$config::config{builddir}, "extra_cflags.txt");
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index d11e761ce1..5fd9f359ee 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -21,17 +21,6 @@ sub new($$$)
bless($self, $myname);
- $self->{manpages} = [];
- $self->{sbin_progs} = [];
- $self->{bin_progs} = [];
- $self->{static_libs} = [];
- $self->{python_dsos} = [];
- $self->{python_pys} = [];
- $self->{shared_libs} = [];
- $self->{headers} = [];
- $self->{plugins} = [];
- $self->{pc_files} = [];
- $self->{proto_headers} = [];
$self->{output} = "";
$self->{mkfile} = $mkfile;
@@ -123,23 +112,19 @@ sub SharedModule($$)
{
my ($self,$ctx) = @_;
- my $init_obj = "";
-
my $sane_subsystem = lc($ctx->{SUBSYSTEM});
$sane_subsystem =~ s/^lib//;
if ($ctx->{TYPE} eq "PYTHON") {
- push (@{$self->{python_dsos}},
- "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
+ $self->output("PYTHON_DSOS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
} else {
- push (@{$self->{plugins}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
+ $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");
}
}
@@ -161,41 +146,22 @@ sub SharedModule($$)
$self->_prepare_list($ctx, "LINK_FLAGS");
if (defined($ctx->{INIT_FUNCTION}) and $ctx->{TYPE} ne "PYTHON") {
- 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";
+ $self->output("\$($ctx->{NAME}_OBJ_LIST): CFLAGS+=-D$ctx->{INIT_FUNCTION}=init_module\n");
}
$self->output(<< "__EOD__"
-#
-$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST) $init_obj
+$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_OBJ_LIST)
\@echo Linking \$\@
- \@mkdir -p $ctx->{SHAREDDIR}
+ \@mkdir -p \$(\@D)
\@\$(MDLD) \$(MDLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$($ctx->{NAME}\_FULL_OBJ_LIST) $init_obj \\
+ \$($ctx->{NAME}\_OBJ_LIST) \\
\$($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");
}
}
@@ -219,36 +185,28 @@ sub SharedLibrary($$)
{
my ($self,$ctx) = @_;
- push (@{$self->{shared_libs}}, $ctx->{RESULT_SHARED_LIBRARY}) if (defined($ctx->{SO_VERSION}));
+ $self->output("SHARED_LIBS += $ctx->{RESULT_SHARED_LIBRARY}\n") if (defined($ctx->{SO_VERSION}));
$self->_prepare_list($ctx, "DEPEND_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
- my $soarg = "";
- my $lns = "";
- if ($self->{config}->{SONAMEFLAG} ne "#" and defined($ctx->{LIBRARY_SONAME})) {
- $soarg = "$self->{config}->{SONAMEFLAG}$ctx->{LIBRARY_SONAME}";
- if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
- $lns .= "\n\t\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
- }
- }
-
- if (defined($ctx->{LIBRARY_SONAME})) {
- $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}";
- }
-
$self->output(<< "__EOD__"
-#
+
$ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$\@
\@mkdir -p $ctx->{SHAREDDIR}
\@\$(SHLD) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$($ctx->{NAME}\_FULL_OBJ_LIST) \\
+ \$($ctx->{NAME}\_OBJ_LIST) \\
\$($ctx->{NAME}_LINK_FLAGS) \\
- $soarg$lns
+ \$(if \$(SONAMEFLAG), \$(SONAMEFLAG)$ctx->{LIBRARY_SONAME})
__EOD__
);
- $self->output("\n");
+ 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");
}
sub MergedObj($$)
@@ -269,7 +227,7 @@ __EOD__
);
}
-sub StaticLibrary($$)
+sub StaticLibraryPrimitives($$)
{
my ($self,$ctx) = @_;
@@ -279,7 +237,17 @@ sub StaticLibrary($$)
$self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
$self->_prepare_list($ctx, "FULL_OBJ_LIST");
+}
+sub InitFunctions($$)
+{
+ my ($self, $ctx) = @_;
+ $self->output("\$($ctx->{NAME}_OBJ_LIST): CFLAGS+=-DSTATIC_$ctx->{NAME}_MODULES=\"\$($ctx->{NAME}_INIT_FUNCTIONS)$ctx->{INIT_FUNCTION_SENTINEL}\"\n");
+}
+
+sub StaticLibrary($$)
+{
+ my ($self,$ctx) = @_;
$self->output(<< "__EOD__"
#
$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)
@@ -288,30 +256,37 @@ $ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)
\@mkdir -p $ctx->{STATICDIR}
\@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{NAME}_FULL_OBJ_LIST)
-__EOD__
-);
+ return unless (defined($ctx->{OBJ_FILES}));
+
+ $self->output("STATIC_LIBS += $ctx->{TARGET_STATIC_LIBRARY}\n") if ($ctx->{TYPE} eq "LIBRARY");
+ $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
+ $self->output("$ctx->{TARGET_STATIC_LIBRARY}: \$($ctx->{NAME}_OBJ_LIST)\n");
}
sub Header($$)
{
my ($self,$ctx) = @_;
+ return if ($#{$ctx->{PUBLIC_HEADERS}} == -1);
+
+ $self->output("PUBLIC_HEADERS +=");
+
foreach (@{$ctx->{PUBLIC_HEADERS}}) {
- push (@{$self->{headers}}, output::add_dir_str($ctx->{BASEDIR}, $_));
+ $self->output(" " . output::add_dir_str($ctx->{BASEDIR}, $_));
}
+
+ $self->output("\n");
}
sub Binary($$)
{
my ($self,$ctx) = @_;
- my $extradir = "";
-
unless (defined($ctx->{INSTALLDIR})) {
} elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
- push (@{$self->{sbin_progs}}, $ctx->{RESULT_BINARY});
+ $self->output("SBIN_PROGS += $ctx->{RESULT_BINARY}\n");
} elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
- push (@{$self->{bin_progs}}, $ctx->{RESULT_BINARY});
+ $self->output("BIN_PROGS += $ctx->{RESULT_BINARY}\n");
}
$self->output("binaries:: $ctx->{TARGET_BINARY}\n");
@@ -349,10 +324,8 @@ sub PythonFiles($$)
foreach (@{$ctx->{PYTHON_FILES}}) {
my $target = "bin/python/".basename($_);
my $source = output::add_dir_str($ctx->{BASEDIR}, $_);
- $self->output("$target: $source\n" .
- "\tmkdir -p \$(builddir)/bin/python\n" .
- "\tcp $source \$@\n\n");
- push (@{$self->{python_pys}}, $target);
+ $self->output("$target: $source\n\n");
+ $self->output("PYTHON_PYS += $target\n");
}
}
@@ -360,8 +333,7 @@ sub Manpage($$)
{
my ($self,$ctx) = @_;
- my $path = output::add_dir_str($ctx->{BASEDIR}, $ctx->{MANPAGE});
- push (@{$self->{manpages}}, $path);
+ $self->output("MANPAGES += " . output::add_dir_str($ctx->{BASEDIR}, $ctx->{MANPAGE}) . "\n");
}
sub ProtoHeader($$)
@@ -382,7 +354,7 @@ sub ProtoHeader($$)
$comment .= " and ";
$target.= " ";
}
- push (@{$self->{proto_headers}}, $priv);
+ $self->output("PROTO_HEADERS += $priv\n");
} else {
$ctx->{PRIVATE_PROTO_HEADER} = $ctx->{PUBLIC_PROTO_HEADER};
$priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER});
@@ -392,7 +364,7 @@ sub ProtoHeader($$)
$pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER});
$comment .= $pub;
$target .= $pub;
- push (@{$self->{proto_headers}}, $pub);
+ $self->output("PROTO_HEADERS += $pub\n");
} else {
$ctx->{PUBLIC_PROTO_HEADER} = $ctx->{PRIVATE_PROTO_HEADER};
$pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER});
@@ -407,19 +379,6 @@ sub write($$)
{
my ($self, $file) = @_;
- $self->output("MANPAGES = " . array2oneperline($self->{manpages})."\n");
- $self->output("BIN_PROGS = " . array2oneperline($self->{bin_progs}) . "\n");
- $self->output("SBIN_PROGS = " . array2oneperline($self->{sbin_progs}) . "\n");
- $self->output("STATIC_LIBS = " . array2oneperline($self->{static_libs}) . "\n");
- $self->output("SHARED_LIBS = " . array2oneperline($self->{shared_libs}) . "\n");
- $self->output("PYTHON_DSOS = " . array2oneperline($self->{python_dsos}) . "\n");
- $self->output("PYTHON_PYS = " . array2oneperline($self->{python_pys}) . "\n");
- $self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n");
- $self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n");
- $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
- $self->output("PROTO_HEADERS = " . array2oneperline($self->{proto_headers}) . "\n");
- $self->output("PLUGINS = " . array2oneperline($self->{plugins}) . "\n");
-
$self->_prepare_mk_files();
$self->output($self->{mkfile});