Makefile.am
3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#############################################################################
# Makefile for ctools Python extension module #
# ------------------------------------------------------------------------- #
# Copyright (C) 2011 Jurgen Knodlseder #
# ------------------------------------------------------------------------- #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# ------------------------------------------------------------------------- #
# This Makefile will build the Python interface files (*.py) and the Python #
# wrapper files using SWIG (if available; otherwise we have to make sure #
# the the files exist already). The Python distutils are used to build and #
# install the Python modules (see file setup.py.in). #
# #
# Process this file with automake to produce Makefile.in. #
#############################################################################
if WITH_PYTHON
# Set SWIG interface filename
SWIG_INTERFACE = ctools.i
# Define the targets that should be built before anything else.
# These are honored by 'make all', 'make check' and 'make install'.
if HAVE_SWIG
BUILT_SOURCES = ctools_wrap.cpp ctools.py
endif
# Set files to be removed in clean
if HAVE_SWIG
CLEANFILES = ctools_wrap.cpp ctools.py
endif
all-local: build
# We build the python extension twice since the install step needs the result
# in a specific directory and the test make check has no access to the name
# of this specific directory. So we build one instance for checking, the other
# for installation. If we could get the name built by distutils we could avoid
# this.
#$(PYTHON) setup.py build --build-platlib build
build: ctools_wrap.cpp ctools.py
$(PYTHON) setup.py build
# If 'make check' is invoked we build the extension modules inplace, so that
# putting the 'pyext' directory in the PYTHONPATH allows importing the gammalib
# module. We also catch this special build in the setup script to force static
# linking with libgamma, which will allow a successful 'make check' on systems
# (such as Mac OS X) that have fixed shared library paths.
check-local:
$(PYTHON) setup.py build_ext --inplace
install-exec-local:
$(PYTHON) setup.py install --prefix=$(prefix)
clean-local:
rm -rf build _ctools.so
# Rule for building Python wrappers using SWIG.
if HAVE_SWIG
ctools_wrap.cpp ctools.py: $(SWIG_INTERFACE)
$(SWIG) -c++ -python -Wall -I$(prefix)/share/gammalib/swig -I$(GAMMALIB)/share/gammalib/swig -o ctools_wrap.cpp -outdir . $(srcdir)/$(SWIG_INTERFACE)
endif # HAVE_SWIG
endif # WITH_PYTHON