Makefile.am
6.31 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#############################################################################
# Makefile for gammalib Python extension module #
# ------------------------------------------------------------------------- #
# Copyright (C) 2011-2012 Juergen Knoedlseder #
# ------------------------------------------------------------------------- #
# #
# 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. #
#############################################################################
# Works only if Python is available
if WITH_PYTHON
# Set instrument specific SWIG targets
if WITH_INST_MWL
MWL_SWIG_TARGETS = gammalib/mwl_wrap.cpp gammalib/mwl.py
endif
if WITH_INST_CTA
CTA_SWIG_TARGETS = gammalib/cta_wrap.cpp gammalib/cta.py
endif
if WITH_INST_LAT
LAT_SWIG_TARGETS = gammalib/lat_wrap.cpp gammalib/lat.py
endif
if WITH_INST_COM
COM_SWIG_TARGETS = gammalib/com_wrap.cpp gammalib/com.py
endif
INST_SWIG_TARGETS = $(MWL_SWIG_TARGETS) \
$(CTA_SWIG_TARGETS) \
$(LAT_SWIG_TARGETS) \
$(COM_SWIG_TARGETS)
# Sources that are required for the build. All targets in the list will be built
# before anything. These are honored by 'make all', 'make check' and 'make install'.
# We use this here to make sure that all these targets are build by swig before we
# start compiling the Python modules.
BUILT_SOURCES = gammalib/app_wrap.cpp gammalib/app.py \
gammalib/base_wrap.cpp gammalib/base.py \
gammalib/fits_wrap.cpp gammalib/fits.py \
gammalib/linalg_wrap.cpp gammalib/linalg.py \
gammalib/model_wrap.cpp gammalib/model.py \
gammalib/numerics_wrap.cpp gammalib/numerics.py \
gammalib/obs_wrap.cpp gammalib/obs.py \
gammalib/opt_wrap.cpp gammalib/opt.py \
gammalib/sky_wrap.cpp gammalib/sky.py \
gammalib/support_wrap.cpp gammalib/support.py \
gammalib/xml_wrap.cpp gammalib/xml.py \
gammalib/xspec_wrap.cpp gammalib/xspec.py \
gammalib/test_wrap.cpp gammalib/test.py \
$(INST_SWIG_TARGETS)
# Dependencies. Obtain the list of dependencies by executing ls.
DEPFILES = $(shell ls gammalib/*.Pi 2> /dev/null)
include $(DEPFILES)
# Set files to be removed in clean. We remove only the SWIG interface files if SWIG
# is available to rebuild them.
if HAVE_SWIG
CLEAN_FILES = $(BUILT_SOURCES)
endif
CLEANFILES = $(CLEAN_FILES) $(DEPFILES)
# Set SWIG compile command
SWIGCOMPILE = $(SWIG) -c++ -python -Wall
# Things we want to do when 'make' is invoked.
all-local: build
# Build the gammalib extension module
build: $(BUILT_SOURCES)
@PYTHON_BUILD_PREFIX@ $(PYTHON) setup.py build_ext
# Do nothing for 'make check'
#check-local:
# Install the gammalib extension module
install-exec-local:
$(PYTHON) setup.py install --prefix=$(prefix)
# Remove build directory and test libraries
clean-local:
rm -rf build
rm -rf gammalib/__init__.py? gammalib/_*.so gammalib/*.pyc
# Rules for building Python wrappers using SWIG. The rules are only active if
# SWIG is avialable. The is a general rule for core modules and specific rules
# for each instrument module.
if HAVE_SWIG
# Rule to build SWIG wrappers
swig: $(BUILT_SOURCES)
# General rule for core modules
%_wrap.cpp %.py: %.i
if $(SWIGCOMPILE) -MMD -MF "$*.Tpi" -o $@ -outdir gammalib $<; \
then mv -f "$*.Tpi" "$*.Pi"; else rm -f "$*.Tpi"; exit 1; fi
# Rule for MWL module
if WITH_INST_MWL
gammalib/mwl.py: gammalib/mwl_wrap.cpp
gammalib/mwl_wrap.cpp: $(top_srcdir)/inst/mwl/pyext/mwl.i
if $(SWIGCOMPILE) -MMD -MF "gammalib/mwl.Tpi" -o gammalib/mwl_wrap.cpp -outdir gammalib $<; \
then mv -f "gammalib/mwl.Tpi" "gammalib/mwl.Pi"; else rm -f "gammalib/mwl.Tpi"; exit 1; fi
endif
# Rule for CTA module
if WITH_INST_CTA
gammalib/cta.py: gammalib/cta_wrap.cpp
gammalib/cta_wrap.cpp: $(top_srcdir)/inst/cta/pyext/cta.i
if $(SWIGCOMPILE) -MMD -MF "gammalib/cta.Tpi" -o gammalib/cta_wrap.cpp -outdir gammalib $<; \
then mv -f "gammalib/cta.Tpi" "gammalib/cta.Pi"; else rm -f "gammalib/cta.Tpi"; exit 1; fi
endif
# Rule for LAT module
if WITH_INST_LAT
gammalib/lat.py: gammalib/lat_wrap.cpp
gammalib/lat_wrap.cpp: $(top_srcdir)/inst/lat/pyext/lat.i
if $(SWIGCOMPILE) -MMD -MF "gammalib/lat.Tpi" -o gammalib/lat_wrap.cpp -outdir gammalib $<; \
then mv -f "gammalib/lat.Tpi" "gammalib/lat.Pi"; else rm -f "gammalib/lat.Tpi"; exit 1; fi
endif
# Rule for COM module
if WITH_INST_COM
gammalib/com.py: gammalib/com_wrap.cpp
gammalib/com_wrap.cpp: $(top_srcdir)/inst/com/pyext/com.i
if $(SWIGCOMPILE) -MMD -MF "gammalib/com.Tpi" -o gammalib/com_wrap.cpp -outdir gammalib $<; \
then mv -f "gammalib/com.Tpi" "gammalib/com.Pi"; else rm -f "gammalib/com.Tpi"; exit 1; fi
endif
endif # HAVE_SWIG
endif # WITH_PYTHON