Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into nosmbpython
[ab/samba.git/.git] / source4 / build / make / python.mk
1 pythonbuilddir = $(builddir)/bin/python
2
3 installpython::
4         mkdir -p $(DESTDIR)$(pythondir)
5
6 # Install Python
7 # Arguments: Module path
8 define python_module_template
9
10 installpython:: $$(pythonbuilddir)/$(1) ;
11         mkdir -p $$(DESTDIR)$$(pythondir)/$$(dir $(1))
12         cp $$< $$(DESTDIR)$$(pythondir)/$(1)
13
14 uninstallpython:: 
15         rm -f $$(DESTDIR)$$(pythondir)/$(1) ;
16
17 pythonmods:: $$(pythonbuilddir)/$(1) ;
18
19 endef
20
21 define python_py_module_template
22
23 $$(pythonbuilddir)/$(1): $(2) ;
24         mkdir -p $$(@D)
25         cp $$< $$@
26
27 $(call python_module_template,$(1))
28
29 endef
30
31 # Python C module
32 # Arguments: File name, dependencies, link list
33 define python_c_module_template
34
35 $$(pythonbuilddir)/$(1): $(2) ; 
36         @echo Linking $$@
37         @mkdir -p $$(@D)
38         @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
39
40 $(call python_module_template,$(1))
41 endef
42
43 # Swig extensions
44 swig:: pythonmods
45
46 .SUFFIXES: _wrap.c .i .py
47
48 %_wrap.c %.py: %.i
49         [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -I$(srcdir)/scripting/swig -python -keyword $<
50
51 realdistclean::
52         @echo "Removing SWIG output files"
53         # FIXME: Remove _wrap.c files
54
55 pythonmods::
56
57 clean::
58         @echo "Removing python modules"
59         @rm -rf $(pythonbuilddir)
60
61 pydoctor:: pythonmods
62         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
63
64 bin/python/%.py: 
65         mkdir -p $(@D)
66         cp $< $@