summaryrefslogtreecommitdiff
path: root/source4/build/make/python.mk
diff options
context:
space:
mode:
Diffstat (limited to 'source4/build/make/python.mk')
-rw-r--r--source4/build/make/python.mk66
1 files changed, 66 insertions, 0 deletions
diff --git a/source4/build/make/python.mk b/source4/build/make/python.mk
new file mode 100644
index 0000000000..66e5def8f0
--- /dev/null
+++ b/source4/build/make/python.mk
@@ -0,0 +1,66 @@
+pythonbuilddir = $(builddir)/bin/python
+
+installpython::
+ mkdir -p $(DESTDIR)$(pythondir)
+
+# Install Python
+# Arguments: Module path
+define python_module_template
+
+installpython:: $$(pythonbuilddir)/$(1) ;
+ mkdir -p $$(DESTDIR)$$(pythondir)/$$(dir $(1))
+ cp $$< $$(DESTDIR)$$(pythondir)/$(1)
+
+uninstallpython::
+ rm -f $$(DESTDIR)$$(pythondir)/$(1) ;
+
+pythonmods:: $$(pythonbuilddir)/$(1) ;
+
+endef
+
+define python_py_module_template
+
+$$(pythonbuilddir)/$(1): $(2) ;
+ mkdir -p $$(@D)
+ cp $$< $$@
+
+$(call python_module_template,$(1))
+
+endef
+
+# Python C module
+# Arguments: File name, dependencies, link list
+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:: pythonmods
+
+.SUFFIXES: _wrap.c .i .py
+
+%_wrap.c %.py: %.i
+ [ "$(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)
+
+pydoctor:: pythonmods
+ LD_LIBRARY_PATH=bin/shared PYTHONPATH=$(pythonbuilddir) pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package $(pythonbuilddir)/samba
+
+bin/python/%.py:
+ mkdir -p $(@D)
+ cp $< $@