use make macro for python.
authorJelmer Vernooij <jelmer@samba.org>
Tue, 26 Feb 2008 15:02:51 +0000 (16:02 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 26 Feb 2008 15:02:51 +0000 (16:02 +0100)
(This used to be commit b0408abb08648c0155d8f5da5fb299b1acbc09b6)

source4/Makefile
source4/build/make/python.mk [new file with mode: 0644]
source4/build/smb_build/makefile.pm
source4/scripting/python/config.mk

index 9d4a91d9bec300b2920961b2b733dfdda3225a75..6083ee35b5f8ed415ac557a211a31b3f1f6ca736 100644 (file)
@@ -39,6 +39,7 @@ ALL_PREDEP = proto
 endif
 
 include build/make/rules.mk
+include build/make/python.mk
 include data.mk
 include extra_cflags.txt
 
diff --git a/source4/build/make/python.mk b/source4/build/make/python.mk
new file mode 100644 (file)
index 0000000..6f54cd6
--- /dev/null
@@ -0,0 +1,37 @@
+pythonbuilddir = $(builddir)/bin/python
+
+# Install Python
+# Arguments: Module path, source location
+define python_module_template
+
+$$(pythonbuilddir)/$(1): $(2) ;
+       mkdir -p $$(@D)
+       cp $$< $$@
+
+installpython:: $$(pythonbuilddir)/$(1) ;
+       cp $$< $$(DESTDIR)$$(PYTHONDIR)/$(1)
+
+uninstallpython:: 
+       rm -f $$(DESTDIR)$$(PYTHONDIR)/$(1) ;
+
+pythonmods:: $$(pythonbuilddir)/$(1) ;
+
+endef
+
+# Swig extensions
+swig:: pythonmods
+
+.SUFFIXES: _wrap.c .i
+
+.i_wrap.c:
+       [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -I$(srcdir)/scripting/swig -python -keyword $<
+
+realdistclean::
+       @echo "Removing SWIG output files"
+       # FIXME: Remove _wrap.c files
+
+pythonmods::
+
+clean::
+       @echo "Removing python modules"
+       @rm -rf $(pythonbuilddir)
index 04bef1e1603db135e923bc91ebb8d186650d5abe..df34f070c7273f25d5a17cc4d3325fb4da9c4aef 100644 (file)
@@ -128,7 +128,7 @@ sub SharedModule($$)
        $sane_subsystem =~ s/^lib//;
        
        if ($ctx->{TYPE} eq "PYTHON") {
-               $self->output("PYTHON_DSOS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
+               $self->output("\$(call python_module_template," . basename($ctx->{NAME}) . ",$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");
@@ -295,9 +295,7 @@ sub PythonFiles($$)
        my ($self,$ctx) = @_;
 
        foreach (@{$ctx->{PYTHON_FILES}}) {
-               my $target = "bin/python/".basename($_);
-               $self->output("$target: \$(addprefix $ctx->{BASEDIR}/, $_)\n\n");
-               $self->output("PYTHON_PYS += $target\n");
+               $self->output("\$(call python_module_template," . basename($_) . ",\$(addprefix $ctx->{BASEDIR}/, $_))\n");
        }
 }
 
index 16cd301aad42f0044f3198d08aded8d7b96d452e..cafbea6b6ed0946e7990f2f4bff992dbdc3768f3 100644 (file)
@@ -15,36 +15,9 @@ OBJ_FILES = uuidmodule.o
 PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS
 SWIG_FILE = misc.i
 
-# Swig extensions
-swig:: pythonmods
-
-.SUFFIXES: _wrap.c .i
-
-.i_wrap.c:
-       [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -I$(srcdir)/scripting/swig -python -keyword $<
-
-realdistclean::
-       @echo "Removing SWIG output files"
-       @-rm -f bin/python/*
-       # FIXME: Remove _wrap.c files
-
-pythonmods:: $(PYTHON_DSOS) $(PYTHON_PYS)
-
 PYDOCTOR_MODULES=bin/python/ldb.py bin/python/auth.py bin/python/credentials.py bin/python/registry.py bin/python/tdb.py bin/python/security.py bin/python/events.py bin/python/net.py
 
 pydoctor:: pythonmods
        LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=Samba --make-html --docformat=restructuredtext --add-package scripting/python/samba/ $(addprefix --add-module , $(PYDOCTOR_MODULES))
 
-bin/python/%.py: 
-       mkdir -p $(@D)
-       cp $< $@
-
-installpython:: pythonmods
-       @$(SHELL) $(srcdir)/script/installpython.sh \
-               $(INSTALLPERMS) \
-               $(DESTDIR)$(PYTHONDIR) \
-               scripting/python bin/python
 
-clean::
-       @echo "Removing python modules"
-       @rm -f bin/python/*