From 39a4656a9324422481517a6c7b38fd4dbdb3a81b Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Wed, 6 Jul 2016 23:58:16 +0200 Subject: [PATCH] Make 'make distcheck' work --- .gitignore | 12 ++++++++---- configure.ac | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------- pyext/Makefile.am | 15 +++++++++------ pyext/setup.py.in | 13 ++++++++++--- test/Makefile.am | 14 +++++++++++++- 5 files changed, 108 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index 55997f7..5b2968d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,10 @@ inst/cta/test/*.fits inst/cta/test/*.fits.gz inst/cta/test/dev/*.fits inst/spi/test/data/*.xml +inst/com/test/*.trs +inst/cta/test/*.trs +inst/lat/test/*.trs +inst/mwl/test/*.trs # Generated files pyext/gammalib/*.py @@ -94,10 +98,10 @@ test/test_GVector test/test_GXml test/test_GXspec test/test_GVO -test/test_LAT -test/test_MWL -test/test_CTA -test/test_COM +inst/lat/test/test_LAT +inst/mwl/test/test_MWL +inst/cta/test/test_CTA +inst/com/test/test_COM test/region.reg test/.samp test/test_python.sh diff --git a/configure.ac b/configure.ac index b45451e..8d2627f 100644 --- a/configure.ac +++ b/configure.ac @@ -809,14 +809,17 @@ AC_SUBST(OPENMP_LIB_LDFLAGS) # Python binding requires Python and either the files gammalib_wrap.cpp and # # gammalib.py or swig to create these files. The following conditionals # # are set: # -# WITH_PYTHON - Python bindings will be built # -# HAVE_SWIG - swig is available # +# WITH_PYTHON - Python bindings will be built # +# HAVE_SWIG - swig is available # +# HAVE_WRAPPERS - wrappers are available # ############################################################################# # Initialise flags enable_python="no" has_python="no" has_python_h="no" has_swig="no" +has_wrappers="no" +build_wrappers="no" # Python binding enabled? AC_ARG_ENABLE([python-binding], @@ -931,40 +934,58 @@ else # Do we have Python wrappers has_wrappers="yes" - AC_CHECK_FILES([pyext/gammalib/app_wrap.cpp pyext/gammalib/app.py - pyext/gammalib/base_wrap.cpp pyext/gammalib/base.py - pyext/gammalib/fits_wrap.cpp pyext/gammalib/fits.py - pyext/gammalib/linalg_wrap.cpp pyext/gammalib/linalg.py - pyext/gammalib/model_wrap.cpp pyext/gammalib/model.py - pyext/gammalib/numerics_wrap.cpp pyext/gammalib/numerics.py - pyext/gammalib/obs_wrap.cpp pyext/gammalib/obs.py - pyext/gammalib/opt_wrap.cpp pyext/gammalib/opt.py - pyext/gammalib/sky_wrap.cpp pyext/gammalib/sky.py - pyext/gammalib/support_wrap.cpp pyext/gammalib/support.py - pyext/gammalib/test_wrap.cpp pyext/gammalib/test.py - pyext/gammalib/xml_wrap.cpp pyext/gammalib/xml.py - pyext/gammalib/xspec_wrap.cpp pyext/gammalib/xspec.py - pyext/gammalib/vo_wrap.cpp pyext/gammalib/vo.py],, + AC_CHECK_FILES([$srcdir/pyext/gammalib/app_wrap.cpp + $srcdir/pyext/gammalib/app.py + $srcdir/pyext/gammalib/base_wrap.cpp + $srcdir/pyext/gammalib/base.py + $srcdir/pyext/gammalib/fits_wrap.cpp + $srcdir/pyext/gammalib/fits.py + $srcdir/pyext/gammalib/linalg_wrap.cpp + $srcdir/pyext/gammalib/linalg.py + $srcdir/pyext/gammalib/model_wrap.cpp + $srcdir/pyext/gammalib/model.py + $srcdir/pyext/gammalib/numerics_wrap.cpp + $srcdir/pyext/gammalib/numerics.py + $srcdir/pyext/gammalib/obs_wrap.cpp + $srcdir/pyext/gammalib/obs.py + $srcdir/pyext/gammalib/opt_wrap.cpp + $srcdir/pyext/gammalib/opt.py + $srcdir/pyext/gammalib/sky_wrap.cpp + $srcdir/pyext/gammalib/sky.py + $srcdir/pyext/gammalib/support_wrap.cpp + $srcdir/pyext/gammalib/support.py + $srcdir/pyext/gammalib/test_wrap.cpp + $srcdir/pyext/gammalib/test.py + $srcdir/pyext/gammalib/xml_wrap.cpp + $srcdir/pyext/gammalib/xml.py + $srcdir/pyext/gammalib/xspec_wrap.cpp + $srcdir/pyext/gammalib/xspec.py + $srcdir/pyext/gammalib/vo_wrap.cpp + $srcdir/pyext/gammalib/vo.py],, [has_wrappers="no"]) -if test "x$with_mwl" = "xyes"; then - AC_CHECK_FILES([pyext/gammalib/mwl_wrap.cpp pyext/gammalib/mwl.py],, - [has_wrappers="no"]) -fi -if test "x$with_lat" = "xyes"; then - AC_CHECK_FILES([pyext/gammalib/lat_wrap.cpp pyext/gammalib/lat.py],, - [has_wrappers="no"]) -fi -if test "x$with_cta" = "xyes"; then - AC_CHECK_FILES([pyext/gammalib/cta_wrap.cpp pyext/gammalib/cta.py],, - [has_wrappers="no"]) -fi -if test "x$with_com" = "xyes"; then - AC_CHECK_FILES([pyext/gammalib/com_wrap.cpp pyext/gammalib/com.py],, - [has_wrappers="no"]) -fi -if test "x$has_wrappers" = "xno"; then - AC_MSG_WARN([Python wrapper(s) missing. Requires swig for wrapper generation.]) -fi + if test "x$with_mwl" = "xyes"; then + AC_CHECK_FILES([$srcdir/pyext/gammalib/mwl_wrap.cpp + $srcdir/pyext/gammalib/mwl.py],, + [has_wrappers="no"]) + fi + if test "x$with_lat" = "xyes"; then + AC_CHECK_FILES([$srcdir/pyext/gammalib/lat_wrap.cpp + $srcdir/pyext/gammalib/lat.py],, + [has_wrappers="no"]) + fi + if test "x$with_cta" = "xyes"; then + AC_CHECK_FILES([$srcdir/pyext/gammalib/cta_wrap.cpp + $srcdir/pyext/gammalib/cta.py],, + [has_wrappers="no"]) + fi + if test "x$with_com" = "xyes"; then + AC_CHECK_FILES([$srcdir/pyext/gammalib/com_wrap.cpp + $srcdir/pyext/gammalib/com.py],, + [has_wrappers="no"]) + fi + if test "x$has_wrappers" = "xno"; then + AC_MSG_WARN([Python wrapper(s) missing. Requires swig for wrapper generation.]) + fi # Do we have wrappers or can we created wrappers? can_wrappers="no" @@ -972,16 +993,22 @@ fi can_wrappers="yes" fi + # Don't we have wrappers but we have swig + if [test "x$has_wrappers" = "xno" -a "x$has_swig" = "xyes"]; then + build_wrappers="yes" + fi + # Signal if Python is enabled if [test "x$ac_enable_python_binding" = "xyes" -a "x$has_python" = "xyes" -a "x$has_python_h" = "xyes" -a "x$can_wrappers" = "xyes"]; then enable_python="yes" AC_DEFINE([HAVE_PYTHON], [1], [Define if Python bindings are built]) fi - fi -AM_CONDITIONAL(HAVE_SWIG, test "x$has_swig" = "xyes") AM_CONDITIONAL(WITH_PYTHON, test "x$enable_python" = "xyes") +AM_CONDITIONAL(HAVE_SWIG, test "x$has_swig" = "xyes") +AM_CONDITIONAL(HAVE_WRAPPERS, test "x$has_wrappers" = "xyes") +AM_CONDITIONAL(BUILD_WRAPPERS, test "x$build_wrappers" = "xyes") # Set Python environment if test "x$enable_python" = "xyes"; then @@ -1403,15 +1430,19 @@ if test "x$with_inst" = "xyes"; then fi if test "x$with_mwl" = "xyes"; then AC_CONFIG_FILES([inst/mwl/Makefile]) + AC_CONFIG_FILES([inst/mwl/test/Makefile]) fi if test "x$with_cta" = "xyes"; then AC_CONFIG_FILES([inst/cta/Makefile]) + AC_CONFIG_FILES([inst/cta/test/Makefile]) fi if test "x$with_lat" = "xyes"; then AC_CONFIG_FILES([inst/lat/Makefile]) + AC_CONFIG_FILES([inst/lat/test/Makefile]) fi if test "x$with_com" = "xyes"; then AC_CONFIG_FILES([inst/com/Makefile]) + AC_CONFIG_FILES([inst/com/test/Makefile]) fi AC_OUTPUT diff --git a/pyext/Makefile.am b/pyext/Makefile.am index d6795cd..ca8c161 100755 --- a/pyext/Makefile.am +++ b/pyext/Makefile.am @@ -241,13 +241,15 @@ endif # Install the gammalib Python module install-exec-local: - $(PYTHON) setup.py install --prefix=$(prefix) + $(PYTHON) setup.py install --prefix=$(DESTDIR)$(prefix) # Uninstall the gammalib Python module uninstall-local: - rm -rf $(pyexecdir)/gammalib - rm -rf $(pyexecdir)/gammalib-@VERSION@* - rm -rf $(datarootdir)/gammalib + rm -rf $(DESTDIR)$(pyexecdir)/gammalib/*.py + rm -rf $(DESTDIR)$(pyexecdir)/gammalib/*.pyc + rm -rf $(DESTDIR)$(pyexecdir)/gammalib/*.so + 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) @@ -255,8 +257,9 @@ CLEANFILES = $(CLEAN_FILES) $(DEPFILES) # Files to be removed in build directory clean-local: rm -rf build - rm -rf $(builddir)/gammalib/__init__.py? - rm -rf $(builddir)/gammalib/_*.so + rm -rf $(builddir)/gammalib/*.py rm -rf $(builddir)/gammalib/*.pyc + rm -rf $(builddir)/gammalib/*_wrap.cpp + rm -rf $(builddir)/gammalib/_*.so endif # WITH_PYTHON diff --git a/pyext/setup.py.in b/pyext/setup.py.in index 3f0621c..1b61b8b 100644 --- a/pyext/setup.py.in +++ b/pyext/setup.py.in @@ -43,6 +43,13 @@ if is_build: else: print('Python extension module installation:') +# Set prefix +prefix = '@prefix@' +if (len(sys.argv) >= 3): + if (sys.argv[2].find('--prefix') != -1): + start = sys.argv[2].find('=') + 1 + prefix = sys.argv[2][start:] + # Darwin MacPorts kluge: Remove -L/opt/local/lib path from LDSHARED as this # overrides the GammaLib settings. Otherwise, MacPorts libraries would be # used instead of the libraries selected by GammaLib @@ -73,8 +80,8 @@ runtime_library_dirs = ['../src/.libs'] libraries = ['gamma'] # Add install directory to runtime library path -if os.path.exists('@prefix@/lib'): - runtime_library_dirs.append('@prefix@/lib') +if os.path.exists(prefix+'/lib'): + runtime_library_dirs.append(prefix+'/lib') # Add cfitsio library only if available if '@WITH_CFITSIO_TRUE@' != '#': @@ -196,7 +203,7 @@ for module in inst_modules: py_modules.append(pkg_name+'.'+module) # Set data files to install. -data_files=[('@prefix@/share/gammalib/swig', install_files)] +data_files=[(prefix+'/share/gammalib/swig', install_files)] # Setup setup(name='@PACKAGE_NAME@', diff --git a/test/Makefile.am b/test/Makefile.am index b6e74a9..35eb9b3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -19,6 +19,9 @@ # # ############################################################################# +# Set sub directories +SUBDIRS = reports + # Optional instrument specific tests if WITH_INST_MWL INST_MWL = $(top_builddir)/inst/mwl/test/test_MWL @@ -190,7 +193,6 @@ test_GObservation_CPPFLAGS = @CPPFLAGS@ test_GObservation_LDADD = $(top_builddir)/src/libgamma.la # Add Valgrind rule -# valgrind: @if type valgrind >/dev/null 2>&1; then \ cd .. ; \ @@ -207,3 +209,13 @@ valgrind: else \ echo "valgrind not found in PATH."; \ fi + +# Files to be removed in build directory +clean-local: + rm -rf $(builddir)/*.fits + rm -rf $(builddir)/*.log + rm -rf $(builddir)/*.html + rm -rf $(builddir)/*.xml + rm -rf $(builddir)/*.reg + rm -rf $(builddir)/*.dat + rm -rf $(builddir)/reports/*.xml -- libgit2 0.21.4