Commit d9f17cc9b6334b2f2b23266a593a47d40359a921

Authored by Jürgen Knödlseder
1 parent 17dfa01c

Add dependency tracking for proper rebuilding of the interface.

Showing 1 changed file with 15 additions and 4 deletions
pyext/Makefile.am
@@ -26,21 +26,31 @@ @@ -26,21 +26,31 @@
26 # Process this file with automake to produce Makefile.in. # 26 # Process this file with automake to produce Makefile.in. #
27 ############################################################################# 27 #############################################################################
28 28
  29 +# Works only if Python is available
29 if WITH_PYTHON 30 if WITH_PYTHON
30 31
31 # Set SWIG interface filename 32 # Set SWIG interface filename
32 SWIG_INTERFACE = ctools.i 33 SWIG_INTERFACE = ctools.i
33 34
  35 +# Dependencies. Obtain the list of dependencies by executing ls.
  36 +DEPFILES = $(shell ls *.Pi 2> /dev/null)
  37 +include $(DEPFILES)
  38 +
34 # Define the targets that should be built before anything else. 39 # Define the targets that should be built before anything else.
35 # These are honored by 'make all', 'make check' and 'make install'. 40 # These are honored by 'make all', 'make check' and 'make install'.
36 if HAVE_SWIG 41 if HAVE_SWIG
37 BUILT_SOURCES = ctools_wrap.cpp ctools.py 42 BUILT_SOURCES = ctools_wrap.cpp ctools.py
38 endif 43 endif
39 44
40 -# Set files to be removed in clean 45 +# Set files to be removed in clean. We remove only the SWIG interface files
  46 +# if SWIG is available to rebuild them.
41 if HAVE_SWIG 47 if HAVE_SWIG
42 - CLEANFILES = ctools_wrap.cpp ctools.py 48 + CLEAN_FILES = $(BUILT_SOURCES)
43 endif 49 endif
  50 +CLEANFILES = $(CLEAN_FILES) $(DEPFILES)
  51 +
  52 +# Set SWIG compile command
  53 +SWIGCOMPILE = $(SWIG) -c++ -python -Wall -I$(prefix)/share/gammalib/swig -I$(GAMMALIB)/share/gammalib/swig
44 54
45 all-local: build 55 all-local: build
46 56
@@ -49,7 +59,6 @@ all-local: build @@ -49,7 +59,6 @@ all-local: build
49 # of this specific directory. So we build one instance for checking, the other 59 # of this specific directory. So we build one instance for checking, the other
50 # for installation. If we could get the name built by distutils we could avoid 60 # for installation. If we could get the name built by distutils we could avoid
51 # this. 61 # this.
52 -#$(PYTHON) setup.py build --build-platlib build  
53 build: ctools_wrap.cpp ctools.py 62 build: ctools_wrap.cpp ctools.py
54 $(PYTHON) setup.py build 63 $(PYTHON) setup.py build
55 64
@@ -60,9 +69,11 @@ clean-local: @@ -60,9 +69,11 @@ clean-local:
60 rm -rf build _ctools.so 69 rm -rf build _ctools.so
61 70
62 # Rule for building Python wrappers using SWIG. 71 # Rule for building Python wrappers using SWIG.
  72 +#$(SWIG) -c++ -python -Wall -I$(prefix)/share/gammalib/swig -I$(GAMMALIB)/share/gammalib/swig -o ctools_wrap.cpp -outdir . $(srcdir)/$(SWIG_INTERFACE)
63 if HAVE_SWIG 73 if HAVE_SWIG
64 ctools_wrap.cpp ctools.py: $(SWIG_INTERFACE) 74 ctools_wrap.cpp ctools.py: $(SWIG_INTERFACE)
65 - $(SWIG) -c++ -python -Wall -I$(prefix)/share/gammalib/swig -I$(GAMMALIB)/share/gammalib/swig -o ctools_wrap.cpp -outdir . $(srcdir)/$(SWIG_INTERFACE) 75 + if $(SWIGCOMPILE) -MMD -MF "ctools.Tpi" -o ctools_wrap.cpp $<; \
  76 + then mv -f "ctools.Tpi" "ctools.Pi"; else rm -f "ctools.Tpi"; exit 1; fi
66 endif # HAVE_SWIG 77 endif # HAVE_SWIG
67 78
68 endif # WITH_PYTHON 79 endif # WITH_PYTHON