1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00

Support building .so versions of the modules.

This commit is contained in:
Jelmer Vernooij 2008-02-26 16:36:24 +01:00
parent b0408abb08
commit 673fb9c185
3 changed files with 50 additions and 34 deletions

View File

@ -1,13 +1,9 @@
pythonbuilddir = $(builddir)/bin/python pythonbuilddir = $(builddir)/bin/python
# Install Python # Install Python
# Arguments: Module path, source location # Arguments: Module path
define python_module_template define python_module_template
$$(pythonbuilddir)/$(1): $(2) ;
mkdir -p $$(@D)
cp $$< $$@
installpython:: $$(pythonbuilddir)/$(1) ; installpython:: $$(pythonbuilddir)/$(1) ;
cp $$< $$(DESTDIR)$$(PYTHONDIR)/$(1) cp $$< $$(DESTDIR)$$(PYTHONDIR)/$(1)
@ -18,6 +14,28 @@ pythonmods:: $$(pythonbuilddir)/$(1) ;
endef endef
define python_py_module_template
$$(pythonbuilddir)/$(1): $(2) ;
mkdir -p $$(@D)
cp $$< $$@
$(call python_module_template,$(1))
endef
# Python C module
# Arguments: Module path, object files
define python_c_module_template
$$(pythonbuilddir)/$(1): $(2) ;
@echo Linking $$@
@mkdir -p $$(@D)
@$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
$(call python_module_template,$(1))
endef
# Swig extensions # Swig extensions
swig:: pythonmods swig:: pythonmods

View File

@ -61,9 +61,6 @@ foreach my $key (values %$OUTPUT) {
${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") { ${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
$shared_libs_used = 1; $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->PythonFiles($key) if defined($key->{PYTHON_FILES});
$mkenv->Header($key) if defined($key->{PUBLIC_HEADERS}); $mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
if ($key->{TYPE} eq "MODULE" and @{$key->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ" and defined($key->{INIT_FUNCTION})) { if ($key->{TYPE} eq "MODULE" and @{$key->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ" and defined($key->{INIT_FUNCTION})) {
@ -84,9 +81,9 @@ foreach my $key (values %$OUTPUT) {
$mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}}); $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
$mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}}); grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
$mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" or $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" and
$key->{TYPE} eq "PYTHON") and grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}}));
grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}}); $mkenv->PythonModule($key) if ($key->{TYPE} eq "PYTHON");
$mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}}); $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
$mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER}) or
defined($key->{PUBLIC_PROTO_HEADER}); defined($key->{PUBLIC_PROTO_HEADER});

View File

@ -113,11 +113,16 @@ sub _prepare_list($$$)
$self->output("$ctx->{NAME}_$var =$tmplist\n"); $self->output("$ctx->{NAME}_$var =$tmplist\n");
} }
sub SharedModulePrimitives($$) sub PythonModule($$)
{ {
my ($self,$ctx) = @_; my ($self,$ctx) = @_;
#FIXME $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");
$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($$) sub SharedModule($$)
@ -127,28 +132,24 @@ sub SharedModule($$)
my $sane_subsystem = lc($ctx->{SUBSYSTEM}); my $sane_subsystem = lc($ctx->{SUBSYSTEM});
$sane_subsystem =~ s/^lib//; $sane_subsystem =~ s/^lib//;
if ($ctx->{TYPE} eq "PYTHON") { $self->output("PLUGINS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
$self->output("\$(call python_module_template," . basename($ctx->{NAME}) . ",$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME})\n"); $self->output("installplugins:: $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
} else { $self->output("\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
$self->output("PLUGINS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n"); $self->output("\t\@mkdir -p \$(DESTDIR)\$(modulesdir)/$sane_subsystem/\n");
$self->output("installplugins:: $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n"); $self->output("\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
$self->output("\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n"); if (defined($ctx->{ALIASES})) {
$self->output("\t\@mkdir -p \$(DESTDIR)\$(modulesdir)/$sane_subsystem/\n"); foreach (@{$ctx->{ALIASES}}) {
$self->output("\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n"); $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
if (defined($ctx->{ALIASES})) {
foreach (@{$ctx->{ALIASES}}) {
$self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
}
} }
}
$self->output("uninstallplugins::\n"); $self->output("uninstallplugins::\n");
$self->output("\t\@echo Uninstalling \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\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"); $self->output("\t\@-rm \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
if (defined($ctx->{ALIASES})) { if (defined($ctx->{ALIASES})) {
foreach (@{$ctx->{ALIASES}}) { foreach (@{$ctx->{ALIASES}}) {
$self->output("\t\@-rm \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n"); $self->output("\t\@-rm \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
}
} }
} }
@ -295,7 +296,7 @@ sub PythonFiles($$)
my ($self,$ctx) = @_; my ($self,$ctx) = @_;
foreach (@{$ctx->{PYTHON_FILES}}) { foreach (@{$ctx->{PYTHON_FILES}}) {
$self->output("\$(call python_module_template," . basename($_) . ",\$(addprefix $ctx->{BASEDIR}/, $_))\n"); $self->output("\$(eval \$(call python_py_module_template," . basename($_) . ",\$(addprefix $ctx->{BASEDIR}/, $_)))\n");
} }
} }