summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-11-21 11:10:45 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:45:50 +0100
commit5256d93a458d0f653afa788bb8f8d894dd1a25b2 (patch)
tree8a618f3a269e57e59af73f77a71c58bbfc380865
parent6b62805ce7db000420752f56b0544d2aecc51833 (diff)
downloadsamba-5256d93a458d0f653afa788bb8f8d894dd1a25b2.tar.gz
samba-5256d93a458d0f653afa788bb8f8d894dd1a25b2.tar.bz2
samba-5256d93a458d0f653afa788bb8f8d894dd1a25b2.zip
r26067: Merge improvements building Python modules.
(This used to be commit 11a2cbbac51781e72ae1288c8e30f175526b01a8)
-rw-r--r--source4/build/smb_build/config_mk.pm9
-rw-r--r--source4/build/smb_build/input.pm49
-rw-r--r--source4/build/smb_build/main.pl4
-rw-r--r--source4/build/smb_build/makefile.pm21
-rw-r--r--source4/build/smb_build/output.pm5
5 files changed, 79 insertions, 9 deletions
diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm
index d0067c858d..4f231c0356 100644
--- a/source4/build/smb_build/config_mk.pm
+++ b/source4/build/smb_build/config_mk.pm
@@ -19,6 +19,14 @@ my $section_types = {
"CPPFLAGS" => "list",
"LDFLAGS" => "list",
},
+ "PYTHON" => {
+ SWIG_FILE => "string",
+ "PRIVATE_DEPENDENCIES" => "list",
+ "PUBLIC_DEPENDENCIES" => "list",
+ "OBJ_FILES" => "list",
+ "ENABLE" => "bool",
+ "LDFLAGS" => "list",
+ },
"SUBSYSTEM" => {
"OBJ_FILES" => "list",
@@ -80,6 +88,7 @@ my $section_types = {
"LIBRARY_REALNAME" => "string",
"INIT_FUNCTION_TYPE" => "string",
+ "OUTPUT_TYPE" => "list",
"OBJ_FILES" => "list",
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index ca61499fd4..2d1aaedb13 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -8,6 +8,7 @@
use smb_build::config;
use strict;
package smb_build::input;
+use File::Basename;
my $srcdir = $config::config{srcdir};
@@ -115,7 +116,9 @@ sub check_library($$$)
return if ($lib->{ENABLE} ne "YES");
- $lib->{OUTPUT_TYPE} = $default_ot;
+ 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";
@@ -131,10 +134,34 @@ sub check_library($$$)
$lib->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)";
}
- $lib->{INSTALLDIR} = "LIBDIR";
+ unless(defined($lib->{INSTALLDIR})) {
+ $lib->{INSTALLDIR} = "LIBDIR";
+ }
add_libreplace($lib);
}
+sub check_python($$)
+{
+ my ($INPUT, $python) = @_;
+
+ $python->{INSTALLDIR} = "PYTHONDIR";
+ push (@{$python->{PUBLIC_DEPENDENCIES}}, "LIBPYTHON");
+ if (defined($python->{SWIG_FILE})) {
+ my $dirname = dirname($python->{SWIG_FILE});
+ my $basename = basename($python->{SWIG_FILE}, ".i");
+
+ $python->{OBJ_FILES} = ["$dirname/$basename\_wrap.o"];
+ $python->{LIBRARY_REALNAME} = "_$basename.\$(SHLIBEXT)";
+ $python->{PYTHON_FILES} = ["$dirname/$basename.py"];
+ } else {
+ my $basename = $python->{NAME};
+ $basename =~ s/^python_//g;
+ $python->{LIBRARY_REALNAME} = "$basename.\$(SHLIBEXT)";
+ }
+
+ check_library($INPUT, $python, ["SHARED_LIBRARY"]);
+}
+
sub check_binary($$)
{
my ($INPUT, $bin) = @_;
@@ -235,10 +262,20 @@ sub check($$$$$)
$part->{LINK_FLAGS} = [];
$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");
- check_binary($INPUT, $part) if ($part->{TYPE} eq "BINARY");
+ if ($part->{TYPE} eq "SUBSYSTEM") {
+ check_subsystem($INPUT, $part, $subsys_ot);
+ } elsif ($part->{TYPE} eq "MODULE") {
+ check_module($INPUT, $part, $module_ot);
+ } elsif ($part->{TYPE} eq "LIBRARY") {
+ check_library($INPUT, $part, $lib_ot);
+ } elsif ($part->{TYPE} eq "BINARY") {
+ check_binary($INPUT, $part);
+ } elsif ($part->{TYPE} eq "PYTHON") {
+ check_python($INPUT, $part);
+ } elsif ($part->{TYPE} eq "EXT_LIB") {
+ } else {
+ die("Unknown type $part->{TYPE}");
+ }
}
foreach my $part (values %$INPUT) {
diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl
index 3ac5c26e1a..de639eb36b 100644
--- a/source4/build/smb_build/main.pl
+++ b/source4/build/smb_build/main.pl
@@ -62,7 +62,8 @@ foreach my $key (values %$OUTPUT) {
$mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
$mkenv->PkgConfig($key, $OUTPUT) if $key->{TYPE} eq "LIBRARY"
and defined($key->{VERSION});
- $mkenv->SharedLibrary($key) if $key->{TYPE} eq "LIBRARY" and
+ $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY" or
+ $key->{TYPE} eq "PYTHON") and
grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
if ($key->{TYPE} eq "LIBRARY" and
${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
@@ -71,6 +72,7 @@ foreach my $key (values %$OUTPUT) {
$mkenv->SharedModule($key) if $key->{TYPE} eq "MODULE" and
grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
$mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
+ $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
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index 08c237c4da..5d942f48eb 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -7,6 +7,7 @@
package smb_build::makefile;
use smb_build::env;
+use File::Basename;
use strict;
use base 'smb_build::env';
@@ -24,6 +25,7 @@ sub new($$$)
$self->{bin_progs} = [];
$self->{torture_progs} = [];
$self->{static_libs} = [];
+ $self->{python_dsos} = [];
$self->{shared_libs} = [];
$self->{installable_shared_libs} = [];
$self->{headers} = [];
@@ -180,6 +182,7 @@ sub _prepare_compiler_linker($)
SHELL=$self->{config}->{SHELL}
PERL=$self->{config}->{PERL}
+PYTHON=$self->{config}->{PYTHON}
CPP=$self->{config}->{CPP}
CPPFLAGS=$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -I\$(srcdir)/lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $self->{config}->{CPPFLAGS}
@@ -393,6 +396,11 @@ sub SharedLibrary($$)
$self->_prepare_list($ctx, "LINK_FLAGS");
# $self->_prepare_list_ex($ctx, "LINK_FLAGS", "-Wl,--whole-archive", "-Wl,--no-whole-archive");
+ if ($ctx->{TYPE} eq "PYTHON") {
+ push (@{$self->{python_dsos}},
+ "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
+ }
+
push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
my $soarg = "";
@@ -519,6 +527,18 @@ __EOD__
}
}
+sub PythonFiles($$)
+{
+ my ($self,$ctx) = @_;
+
+ foreach (@{$ctx->{PYTHON_FILES}}) {
+ my $target = "bin/python/".basename($_);
+ $self->output("$target: $ctx->{BASEDIR}/$_\n" .
+ "\tcp $ctx->{BASEDIR}/$_ \$@\n\n");
+ push (@{$self->{python_dsos}}, $target);
+ }
+}
+
sub Manpage($$)
{
my ($self,$ctx) = @_;
@@ -672,6 +692,7 @@ sub write($$)
$self->output("BINARIES = " . array2oneperline($self->{binaries}) . "\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("INSTALLABLE_SHARED_LIBS = " . array2oneperline($self->{installable_shared_libs}) . "\n");
$self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n");
$self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n");
diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm
index 42e68abec9..17d5755348 100644
--- a/source4/build/smb_build/output.pm
+++ b/source4/build/smb_build/output.pm
@@ -49,9 +49,10 @@ sub generate_shared_library($)
$lib_name = "lib$link_name";
}
- if (defined($lib->{LIBRARY_REALNAME})) {
+ if ($lib->{TYPE} eq "PYTHON") {
+ $lib->{SHAREDDIR} = "bin/python";
+ } elsif (defined($lib->{LIBRARY_REALNAME})) {
$lib->{BASEDIR} =~ s/^\.\///g;
- $lib->{LIBRARY_REALNAME} = "$lib->{LIBRARY_REALNAME}";
$lib->{SHAREDDIR} = $lib->{BASEDIR};
} else {
if ($lib->{TYPE} eq "MODULE") {