Makefile.am
12.6 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#############################################################################
# Makefile for gammalib Python extension module #
# ------------------------------------------------------------------------- #
# Copyright (C) 2011-2020 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 wrapper directory depending on the whether the wrappers were actually
# shipped with the distribution of whether the wrappers have to be build
# using swig
if BUILD_WRAPPERS
wrapperdir = $(top_builddir)/pyext
else
wrapperdir = $(srcdir)
endif
# Set instrument specific SWIG targets
if WITH_INST_MWL
MWL_SWIG_TARGETS = $(wrapperdir)/gammalib/mwl_wrap.cpp \
$(wrapperdir)/gammalib/mwl.py
MWL_TESTS = $(top_srcdir)/inst/mwl/test/test_MWL.py
endif
if WITH_INST_CTA
CTA_SWIG_TARGETS = $(wrapperdir)/gammalib/cta_wrap.cpp \
$(wrapperdir)/gammalib/cta.py
CTA_TESTS = $(top_srcdir)/inst/cta/test/test_CTA.py
endif
if WITH_INST_LAT
LAT_SWIG_TARGETS = $(wrapperdir)/gammalib/lat_wrap.cpp \
$(wrapperdir)/gammalib/lat.py
LAT_TESTS = $(top_srcdir)/inst/lat/test/test_LAT.py
endif
if WITH_INST_COM
COM_SWIG_TARGETS = $(wrapperdir)/gammalib/com_wrap.cpp \
$(wrapperdir)/gammalib/com.py
COM_TESTS = $(top_srcdir)/inst/com/test/test_COM.py
endif
if WITH_INST_SPI
SPI_SWIG_TARGETS = $(wrapperdir)/gammalib/spi_wrap.cpp \
$(wrapperdir)/gammalib/spi.py
SPI_TESTS = $(top_srcdir)/inst/spi/test/test_SPI.py
endif
# Insert new target here
INST_SWIG_TARGETS = $(MWL_SWIG_TARGETS) \
$(SPI_SWIG_TARGETS) \
$(CTA_SWIG_TARGETS) \
$(LAT_SWIG_TARGETS) \
$(COM_SWIG_TARGETS)
# Set SWIG targets
PYTHON_WRAPPERS = $(wrapperdir)/gammalib/app_wrap.cpp \
$(wrapperdir)/gammalib/app.py \
$(wrapperdir)/gammalib/base_wrap.cpp \
$(wrapperdir)/gammalib/base.py \
$(wrapperdir)/gammalib/fits_wrap.cpp \
$(wrapperdir)/gammalib/fits.py \
$(wrapperdir)/gammalib/linalg_wrap.cpp \
$(wrapperdir)/gammalib/linalg.py \
$(wrapperdir)/gammalib/model_wrap.cpp \
$(wrapperdir)/gammalib/model.py \
$(wrapperdir)/gammalib/numerics_wrap.cpp \
$(wrapperdir)/gammalib/numerics.py \
$(wrapperdir)/gammalib/obs_wrap.cpp \
$(wrapperdir)/gammalib/obs.py \
$(wrapperdir)/gammalib/opt_wrap.cpp \
$(wrapperdir)/gammalib/opt.py \
$(wrapperdir)/gammalib/sky_wrap.cpp \
$(wrapperdir)/gammalib/sky.py \
$(wrapperdir)/gammalib/support_wrap.cpp \
$(wrapperdir)/gammalib/support.py \
$(wrapperdir)/gammalib/test_wrap.cpp \
$(wrapperdir)/gammalib/test.py \
$(wrapperdir)/gammalib/xml_wrap.cpp \
$(wrapperdir)/gammalib/xml.py \
$(wrapperdir)/gammalib/xspec_wrap.cpp \
$(wrapperdir)/gammalib/xspec.py \
$(wrapperdir)/gammalib/vo_wrap.cpp \
$(wrapperdir)/gammalib/vo.py \
$(INST_SWIG_TARGETS)
# Test scripts to be distributed in $(pyexecdir)/gammalib/tests
testscripts = gammalib/tests/__init__.py \
$(top_srcdir)/test/test_python.py \
$(top_srcdir)/test/test_support.py \
$(top_srcdir)/test/test_GApplication.py \
$(top_srcdir)/test/test_GFits.py \
$(top_srcdir)/test/test_GLinalg.py \
$(top_srcdir)/test/test_GModel.py \
$(top_srcdir)/test/test_GNumerics.py \
$(top_srcdir)/test/test_GObservation.py \
$(top_srcdir)/test/test_GOptimizer.py \
$(top_srcdir)/test/test_GSky.py \
$(top_srcdir)/test/test_GSupport.py \
$(top_srcdir)/test/test_GTest.py \
$(top_srcdir)/test/test_GVO.py \
$(top_srcdir)/test/test_GXml.py \
$(top_srcdir)/test/test_GXspec.py \
$(MWL_TESTS) $(CTA_TESTS) $(LAT_TESTS) $(COM_TESTS) $(SPI_TESTS)
# Test data to be distributed in $(pyexecdir)/gammalib/tests/data
testdata = $(top_srcdir)/test/data/initial_coords.txt \
$(top_srcdir)/test/data/fk5_to_galactic.txt \
$(top_srcdir)/test/data/file.fits.gz \
$(top_srcdir)/test/data/test_GApplication.par \
$(top_srcdir)/test/data/model_point_plaw.xml \
$(top_srcdir)/test/data/test_cube.fits \
$(top_srcdir)/test/data/filefunction.txt \
$(top_srcdir)/test/data/model_temporal_lightcurve.fits \
$(top_srcdir)/test/data/model_temporal_phasecurve.fits
# Test data to be distributed in $(pyexecdir)/gammalib/tests/data/caldb/data/cta/prod2
testcaldbidx = $(top_srcdir)/test/data/caldb/data/cta/prod2/caldb.indx
# Test data to be distributed in $(pyexecdir)/gammalib/tests/data/caldb/data/cta/prod2/bcf/North_0.5h
testcaldbbcf = $(top_srcdir)/test/data/caldb/data/cta/prod2/bcf/North_0.5h/irf_file.fits.gz
# Distribute scripts
testscriptsdir = $(pyexecdir)/gammalib/tests
testscripts_DATA = $(testscripts)
testdatadir = $(pyexecdir)/gammalib/tests/data
testdata_DATA = $(testdata)
testcaldbidxdir = $(pyexecdir)/gammalib/tests/data/caldb/data/cta/prod2
testcaldbidx_DATA = $(testcaldbidx)
testcaldbbcfdir = $(pyexecdir)/gammalib/tests/data/caldb/data/cta/prod2/bcf/North_0.5h
testcaldbbcf_DATA = $(testcaldbbcf)
# If building of Python wrappers was requested then add them to the build
# source
if BUILD_WRAPPERS
# Set SWIG compile command
SWIGCOMPILE = $(SWIG) -c++ -python -Wall
# 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 = $(PYTHON_WRAPPERS)
# Add the wrappers to the files that will be deleted in a 'make clean'
CLEAN_FILES = $(BUILT_SOURCES)
# Rule to build SWIG wrappers
swig: $(BUILT_SOURCES)
# General rule for core modules
%_wrap.cpp %.py: %.i
if $(SWIGCOMPILE) -MMD -MF "$*.Tpi" -I$(top_srcdir)/pyext -o $@ -outdir gammalib $<; \
then mv -f "$*.Tpi" "$*.Pi"; else rm -f "$*.Tpi"; exit 1; fi
# Rule for MWL module
if WITH_INST_MWL
$(wrapperdir)/gammalib/mwl.py: $(wrapperdir)/gammalib/mwl_wrap.cpp
$(wrapperdir)/gammalib/mwl_wrap.cpp: $(top_srcdir)/inst/mwl/pyext/mwl.i
if $(SWIGCOMPILE) -MMD -MF "gammalib/mwl.Tpi" -I$(top_srcdir)/pyext -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
$(wrapperdir)/gammalib/cta.py: $(wrapperdir)/gammalib/cta_wrap.cpp
$(wrapperdir)/gammalib/cta_wrap.cpp: $(top_srcdir)/inst/cta/pyext/cta.i
if $(SWIGCOMPILE) -MMD -MF "gammalib/cta.Tpi" -I$(top_srcdir)/pyext -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
$(wrapperdir)/gammalib/lat.py: $(wrapperdir)/gammalib/lat_wrap.cpp
$(wrapperdir)/gammalib/lat_wrap.cpp: $(top_srcdir)/inst/lat/pyext/lat.i
if $(SWIGCOMPILE) -MMD -MF "gammalib/lat.Tpi" -I$(top_srcdir)/pyext -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
$(wrapperdir)/gammalib/com.py: $(wrapperdir)/gammalib/com_wrap.cpp
$(wrapperdir)/gammalib/com_wrap.cpp: $(top_srcdir)/inst/com/pyext/com.i
if $(SWIGCOMPILE) -MMD -MF "gammalib/com.Tpi" -I$(top_srcdir)/pyext -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
# Rule for SPI module
if WITH_INST_SPI
$(wrapperdir)/gammalib/spi.py: $(wrapperdir)/gammalib/spi_wrap.cpp
$(wrapperdir)/gammalib/spi_wrap.cpp: $(top_srcdir)/inst/spi/pyext/spi.i
if $(SWIGCOMPILE) -MMD -MF "gammalib/spi.Tpi" -I$(top_srcdir)/pyext -o gammalib/spi_wrap.cpp -outdir gammalib $<; \
then mv -f "gammalib/spi.Tpi" "gammalib/spi.Pi"; else rm -f "gammalib/spi.Tpi"; exit 1; fi
endif
# Insert new rule here
# ... otherwise, if building of Python wrappers has not been required then
# they are located in the source directory and we don't have to build them
# using swig
else
CLEAN_FILES =
BUILT_SOURCES =
endif # BUILD_WRAPPERS
# Extra files to be distributed in the tar file
EXTRA_DIST = gammalib/tests $(PYTHON_WRAPPERS)
dist-hook:
cp -r $(srcdir)/*.i $(distdir)
cp -r $(srcdir)/gammalib/*.i $(distdir)/gammalib
# Dependencies. Obtain the list of dependencies by executing ls.
DEPFILES = $(shell ls gammalib/*.Pi 2> /dev/null)
include $(DEPFILES)
# 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 "Build post process Python module "$$f; \
libgamma=`otool -L $$f | grep -o libgamma.*.dylib`; \
install_name_tool -change $(libdir)/$$libgamma @rpath/$$libgamma $$f; \
install_name_tool -add_rpath $(abs_top_builddir)/src/.libs $$f; \
done
endif
# Do nothing for 'make check'
#check-local:
# Install the gammalib Python module
install-exec-local:
if IS_ELCAPITAN
-for f in build/gammalib/_*.so; do \
echo "Install pre process Python module "$$f; \
install_name_tool -rpath $(abs_top_builddir)/src/.libs $(libdir) $$f; \
done
endif
$(PYTHON) setup.py install --prefix=$(DESTDIR)$(prefix)
# Uninstall the gammalib Python module
uninstall-local:
rm -rf $(DESTDIR)$(pyexecdir)/gammalib/*.py
rm -rf $(DESTDIR)$(pyexecdir)/gammalib/*.pyc
rm -rf $(DESTDIR)$(pyexecdir)/gammalib/*.so
rm -rf $(DESTDIR)$(pyexecdir)/gammalib/__pycache__
rm -rf $(DESTDIR)$(pyexecdir)/gammalib/tests/*.pyc
rm -rf $(DESTDIR)$(pyexecdir)/gammalib/tests/__pycache__
rm -rf $(DESTDIR)$(pyexecdir)/gammalib-@VERSION@*.egg-info
rm -rf $(DESTDIR)$(datarootdir)/gammalib
# Set files to be removed in 'make clean'
CLEANFILES = $(CLEAN_FILES) $(DEPFILES)
# Files to be removed in build directory. Only remove wrapper files if the
# have been built or if the were copied in the build directory
clean-local:
rm -rf build
if BUILD_WRAPPERS
rm -rf $(top_builddir)/pyext/gammalib/[a-z]*.py
rm -rf $(top_builddir)/pyext/gammalib/*_wrap.cpp
else
if test "x$(top_builddir)" != "x$(top_srcdir)"; then \
rm -rf $(top_builddir)/pyext/gammalib/[a-z]*.py; \
rm -rf $(top_builddir)/pyext/gammalib/*_wrap.cpp; \
fi
endif
rm -rf $(top_builddir)/pyext/gammalib/*.pyc
rm -rf $(top_builddir)/pyext/gammalib/_*.so
rm -rf $(top_builddir)/pyext/gammalib/__pycache__
endif # WITH_PYTHON