Makefile.am
8.89 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#############################################################################
# Makefile for gammalib Python extension module #
# ------------------------------------------------------------------------- #
# Copyright (C) 2011-2015 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
MWL_TESTS = ../inst/mwl/test/test_MWL.py
endif
if WITH_INST_CTA
CTA_SWIG_TARGETS = gammalib/cta_wrap.cpp gammalib/cta.py
CTA_TESTS = ../inst/cta/test/test_CTA.py
endif
if WITH_INST_LAT
LAT_SWIG_TARGETS = gammalib/lat_wrap.cpp gammalib/lat.py
LAT_TESTS = ../inst/lat/test/test_LAT.py
endif
if WITH_INST_COM
COM_SWIG_TARGETS = gammalib/com_wrap.cpp gammalib/com.py
COM_TESTS = ../inst/com/test/test_COM.py
endif
INST_SWIG_TARGETS = $(MWL_SWIG_TARGETS) \
$(CTA_SWIG_TARGETS) \
$(LAT_SWIG_TARGETS) \
$(COM_SWIG_TARGETS)
# Test scripts to be distributed in $(pyexecdir)/gammalib/tests
testscripts = gammalib/tests/__init__.py \
../test/test_python.py \
../test/test_GApplication.py \
../test/test_GFits.py \
../test/test_GLinalg.py \
../test/test_GModel.py \
../test/test_GNumerics.py \
../test/test_GObservation.py \
../test/test_GOptimizer.py \
../test/test_GSky.py \
../test/test_GSupport.py \
../test/test_GTest.py \
../test/test_GVO.py \
../test/test_GXml.py \
../test/test_GXspec.py \
$(MWL_TESTS) $(CTA_TESTS) $(LAT_TESTS) $(COM_TESTS)
testdata = ../test/data/initial_coords.txt \
../test/data/fk5_to_galactic.txt
# Distribute scripts
EXTRA_DIST = $(testscripts) $(testdata)
testscriptsdir = $(pyexecdir)/gammalib/tests
testscripts_DATA = $(testscripts)
testdatadir = $(pyexecdir)/gammalib/tests/data
testdata_DATA = $(testdata)
# Distribute test data
if WITH_INST_CTA
testdatacta = ../inst/cta/test/data/irf_1dc.xml \
../inst/cta/test/data/irf_unbinned.xml \
../inst/cta/test/data/crab_events.fits.gz \
../inst/cta/test/data/crab_cntmap.fits.gz
testdatactadir = $(pyexecdir)/gammalib/tests/cta/data
testdatacta_DATA = $(testdatacta)
testcaldbcta = ../inst/cta/test/caldb/cta_dummy_irf.dat \
../inst/cta/test/caldb/prod1_gauss.fits \
../inst/cta/test/caldb/prod1_king.fits
testcaldbctadir = $(pyexecdir)/gammalib/tests/cta/caldb
testcaldbcta_DATA = $(testcaldbcta)
testdc1cta = ../inst/cta/test/caldb/dc1/arf.fits \
../inst/cta/test/caldb/dc1/psf.fits \
../inst/cta/test/caldb/dc1/psf_magic.fits \
../inst/cta/test/caldb/dc1/rmf.fits
testdc1ctadir = $(pyexecdir)/gammalib/tests/cta/caldb/dc1
testdc1cta_DATA = $(testdc1cta)
endif
# 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/test_wrap.cpp gammalib/test.py \
gammalib/xml_wrap.cpp gammalib/xml.py \
gammalib/xspec_wrap.cpp gammalib/xspec.py \
gammalib/vo_wrap.cpp gammalib/vo.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
if IS_ELCAPITAN
-for f in build/gammalib/_*.so; do \
echo "Post process module "$$f; \
install_name_tool -change $(libdir)/libgamma.1.dylib @rpath/libgamma.1.dylib $$f; \
install_name_tool -add_rpath $(libdir) $$f; \
install_name_tool -add_rpath $(abs_top_srcdir)/src/.libs $$f; \
done
endif
# 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