Commit 2eba19a0d9e04e708dd8a06052605d05d80cc1f2
1 parent
f49abdad
update with latest GammaLib improvements
Showing
3 changed files
with
228 additions
and
68 deletions
configure.ac
| 1 | -dnl ============================================================= | ||
| 2 | -dnl Process this file with autoconf to produce a configure script | ||
| 3 | -dnl ============================================================= | ||
| 4 | -AC_INIT([ctatools], [0.1.0], [knodlseder@cesr.fr]) | 1 | +# Configuration for ctatools - a set of tools for science analysis of CTA data |
| 2 | +# | ||
| 3 | +# Copyright (C) 2011 | ||
| 4 | +# | ||
| 5 | +# Process this file with autoconf to produce a configure script | ||
| 6 | + | ||
| 7 | +AC_INIT([ctatools], [0.1.0], [knodlseder@cesr.fr], [ctatools], []) | ||
| 5 | AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp]) | 8 | AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp]) |
| 6 | AC_CONFIG_MACRO_DIR([m4]) | 9 | AC_CONFIG_MACRO_DIR([m4]) |
| 7 | AC_CONFIG_HEADERS([config.h]) | 10 | AC_CONFIG_HEADERS([config.h]) |
| 8 | AM_INIT_AUTOMAKE | 11 | AM_INIT_AUTOMAKE |
| 9 | 12 | ||
| 10 | -# Set prefix | 13 | + |
| 14 | +dnl ========== | ||
| 15 | +dnl Set prefix | ||
| 16 | +dnl ========== | ||
| 11 | AC_PREFIX_DEFAULT([/usr/local/gamma]) | 17 | AC_PREFIX_DEFAULT([/usr/local/gamma]) |
| 12 | -AC_DEFINE([PREFIX], [$prefix], 'Installation prefix') | 18 | +if test "x$prefix" = xNONE; then |
| 19 | + AC_DEFINE_UNQUOTED([PACKAGE_PREFIX], ["/usr/local/gamma"], | ||
| 20 | + [Location where library is installed]) | ||
| 21 | +else | ||
| 22 | + AC_DEFINE_UNQUOTED([PACKAGE_PREFIX], "${prefix}", | ||
| 23 | + [Location where library is installed]) | ||
| 24 | +fi | ||
| 13 | 25 | ||
| 14 | -# Checks for programs. | ||
| 15 | -AC_PROG_CXX | ||
| 16 | -AC_PROG_INSTALL | ||
| 17 | -AC_PROG_LIBTOOL | ||
| 18 | 26 | ||
| 19 | -# Checks for header files. | 27 | +dnl =========================== |
| 28 | +dnl things required by automake | ||
| 29 | +dnl =========================== | ||
| 30 | +dnl AC_ARG_PROGRAM | ||
| 31 | +AC_PROG_MAKE_SET | ||
| 32 | + | ||
| 33 | + | ||
| 34 | +dnl ========================= | ||
| 35 | +dnl Check for system services | ||
| 36 | +dnl ========================= | ||
| 37 | +AC_CANONICAL_HOST | ||
| 20 | 38 | ||
| 21 | -# Checks for typedefs, structures, and compiler characteristics. | ||
| 22 | 39 | ||
| 23 | -# Checks for library functions. | 40 | +dnl ======================= |
| 41 | +dnl Checks for header files | ||
| 42 | +dnl ======================= | ||
| 43 | +AC_STDC_HEADERS | ||
| 44 | + | ||
| 45 | + | ||
| 46 | +dnl ============================================================= | ||
| 47 | +dnl Checks for typedefs, structures, and compiler characteristics | ||
| 48 | +dnl ============================================================= | ||
| 49 | +AC_TYPE_SIZE_T | ||
| 50 | +AC_C_CONST | ||
| 51 | +AC_C_INLINE | ||
| 52 | + | ||
| 53 | + | ||
| 54 | +dnl =================== | ||
| 55 | +dnl Checks for programs | ||
| 56 | +dnl =================== | ||
| 57 | +AC_PROG_CXX | ||
| 58 | +AC_PROG_INSTALL | ||
| 59 | +AC_PROG_LIBTOOL | ||
| 24 | 60 | ||
| 25 | 61 | ||
| 26 | dnl ================================= | 62 | dnl ================================= |
| @@ -76,57 +112,100 @@ CPPFLAGS="$CPPFLAGS $GammaLib_CFLAGS" | @@ -76,57 +112,100 @@ CPPFLAGS="$CPPFLAGS $GammaLib_CFLAGS" | ||
| 76 | LDFLAGS="$LDFLAGS $GammaLib_LIBS" | 112 | LDFLAGS="$LDFLAGS $GammaLib_LIBS" |
| 77 | 113 | ||
| 78 | # Check for GammaLib library and determine path to library | 114 | # Check for GammaLib library and determine path to library |
| 79 | -AC_ARG_WITH([gammalib-lib-dir], | ||
| 80 | - AC_HELP_STRING([--with-gammalib-lib-dir], | ||
| 81 | - [GammaLib library directory [[/usr/(local/(gamma/))lib(64)]]]), | ||
| 82 | - [gammalib_lib_dir=$withval]) | ||
| 83 | -if test "x$gammalib_lib_dir" != "x"; then | ||
| 84 | - test -f $gammalib_lib_dir/libgamma.a -o -f $gammalib_lib_dir/libgamma.so -o -f $gammalib_lib_dir/libgamma.dylib && LIBDIR_GAMMALIB=$gammalib_lib_dir | ||
| 85 | -else | ||
| 86 | - for i in /usr/local/gamma/lib /usr/local/gamma/lib64 /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64 ; do | ||
| 87 | - test -f $i/libgamma.a -o -f $i/libgamma.so -o -f $i/libgamma.dylib && LIBDIR_GAMMALIB=$i | ||
| 88 | - done | ||
| 89 | -fi | ||
| 90 | -if test -z "$LIBDIR_GAMMALIB"; then | ||
| 91 | - if test "x$gammalib_lib_dir" != "x"; then | ||
| 92 | - AC_MSG_ERROR(Cannot find GammaLib library under $gammalib_lib_dir) | ||
| 93 | - else | ||
| 94 | - AC_MSG_ERROR(Cannot find GammaLib library. Use --with-gammalib-lib-dir= to specify non-default path.) | ||
| 95 | - fi | ||
| 96 | -fi | ||
| 97 | -AC_SUBST(LIBDIR_GAMMALIB) | 115 | +#AC_ARG_WITH([gammalib-lib-dir], |
| 116 | +# AC_HELP_STRING([--with-gammalib-lib-dir], | ||
| 117 | +# [GammaLib library directory [[/usr/(local/(gamma/))lib(64)]]]), | ||
| 118 | +# [gammalib_lib_dir=$withval]) | ||
| 119 | +#if test "x$gammalib_lib_dir" != "x"; then | ||
| 120 | +# test -f $gammalib_lib_dir/libgamma.a -o -f $gammalib_lib_dir/libgamma.so -o -f $gammalib_lib_dir/libgamma.dylib && LIBDIR_GAMMALIB=$gammalib_lib_dir | ||
| 121 | +#else | ||
| 122 | +# for i in /usr/local/gamma/lib /usr/local/gamma/lib64 /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64 ; do | ||
| 123 | +# test -f $i/libgamma.a -o -f $i/libgamma.so -o -f $i/libgamma.dylib && LIBDIR_GAMMALIB=$i | ||
| 124 | +# done | ||
| 125 | +#fi | ||
| 126 | +#if test -z "$LIBDIR_GAMMALIB"; then | ||
| 127 | +# if test "x$gammalib_lib_dir" != "x"; then | ||
| 128 | +# AC_MSG_ERROR(Cannot find GammaLib library under $gammalib_lib_dir) | ||
| 129 | +# else | ||
| 130 | +# AC_MSG_ERROR(Cannot find GammaLib library. Use --with-gammalib-lib-dir= to specify non-default path.) | ||
| 131 | +# fi | ||
| 132 | +#fi | ||
| 133 | +#AC_SUBST(LIBDIR_GAMMALIB) | ||
| 98 | 134 | ||
| 99 | 135 | ||
| 100 | -dnl ========================= | ||
| 101 | -dnl Check for Python bindings | ||
| 102 | -dnl ========================= | 136 | +dnl ======================================================================== |
| 137 | +dnl Checks for python binding. Python binding requires Python and either the | ||
| 138 | +dnl files gammalib_wrap.cpp and gammalib.py or SWIG to create these files. | ||
| 139 | +dnl The following conditionals are set: | ||
| 140 | +dnl HAVE_PYTHON - Python >= 2.2 is available | ||
| 141 | +dnl HAVE_SWIG - swig is available | ||
| 142 | +dnl ENABLE_PYTHON_BINDING - Python binding is requested | ||
| 143 | +dnl WITH_PYTHON_BINDING - Either has swig or python wraper files | ||
| 144 | +dnl ======================================================================== | ||
| 145 | +# Checks for Python (HAVE_PYTHON) | ||
| 146 | +AM_PATH_PYTHON([2.2], | ||
| 147 | + [], | ||
| 148 | + [AC_MSG_WARN([Python not found. Python is required to build python binding. Python can be obtained from http://www.python.org])]) | ||
| 149 | +AM_CONDITIONAL(HAVE_PYTHON, test "$PYTHON") | ||
| 103 | 150 | ||
| 104 | -# Checks for SWIG | 151 | +# Checks for SWIG (HAVE_SWIG) |
| 105 | AC_PATH_PROG([SWIG], [swig]) | 152 | AC_PATH_PROG([SWIG], [swig]) |
| 106 | AM_CONDITIONAL(HAVE_SWIG, test "$SWIG") | 153 | AM_CONDITIONAL(HAVE_SWIG, test "$SWIG") |
| 107 | 154 | ||
| 108 | -# Checks for Python | ||
| 109 | -AM_PATH_PYTHON([2.2], | ||
| 110 | - [], | ||
| 111 | - [AC_MSG_WARN([Python not found. Python is required to build python binding. Python can be obtained from http://www.python.org])]) | ||
| 112 | -AM_CONDITIONAL(HAVE_PYTHON, test "$PYTHON") | ||
| 113 | - | 155 | +# Python binding enabled? |
| 114 | AC_ARG_ENABLE([python-binding], | 156 | AC_ARG_ENABLE([python-binding], |
| 115 | - AS_HELP_STRING([--enable-python-binding], | ||
| 116 | - [build python binding (default=yes)]), | ||
| 117 | - [ac_enable_python_binding=no], | ||
| 118 | - [ac_enable_python_binding=yes]) | ||
| 119 | -if test "x$ac_enable_python_binding" = "xyes" | ||
| 120 | -then | ||
| 121 | - if test ! "$SWIG" -a ! "$PYTHON" | ||
| 122 | - then | ||
| 123 | - AC_MSG_WARN([Python binding for ctatools cannot be built. Ensure that SWIG and Python packages are available.]) | 157 | + AS_HELP_STRING([--enable-python-binding], |
| 158 | + [build python binding (default=yes)]), | ||
| 159 | + [ac_enable_python_binding="$enableval"], | ||
| 160 | + [ac_enable_python_binding="yes"]) | ||
| 161 | +AM_CONDITIONAL(ENABLE_PYTHON_BINDING, test "x$ac_enable_python_binding" = "xyes") | ||
| 162 | + | ||
| 163 | +# Checks for ctatools_wrap.cpp and ctatools.py | ||
| 164 | +AC_CHECK_FILES([pyext/ctatools_wrap.cpp pyext/ctatools.py],,) | ||
| 165 | +has_python_wrap="no" | ||
| 166 | +if test "x$ac_cv_file_pyext_ctatools_wrap_cpp" = "xyes"; then | ||
| 167 | + if test "x$ac_cv_file_pyext_ctatools_py" = "xyes"; then | ||
| 168 | + has_python_wrap="yes" | ||
| 169 | + fi | ||
| 170 | +fi | ||
| 171 | +AM_CONDITIONAL(WITH_PYTHON_BINDING, test "x$has_python_wrap" = "xyes" -o "$SWIG") | ||
| 172 | + | ||
| 173 | +# Inform about missing components and set host dependent variables | ||
| 174 | +if test "x$ac_enable_python_binding" = "xyes"; then | ||
| 175 | + if test "$PYTHON"; then | ||
| 176 | + if test "x$has_python_wrap" != "xyes"; then | ||
| 177 | + if test ! "$SWIG"; then | ||
| 178 | + AC_MSG_WARN([Neither pyext/ctatools_wrap.cpp and pyext/ctatools.py nor swig has not been found]) | ||
| 179 | + AC_MSG_WARN([Python binding for ctatools cannot be built]) | ||
| 180 | + AC_MSG_WARN([Either use a ctatools distribution with ctatools_wrap.cpp and ctatools.py shipped or install swig on your system]) | ||
| 181 | + AC_MSG_WARN([swig can be obtained from http://www.swig.org/]) | ||
| 182 | + fi | ||
| 124 | fi | 183 | fi |
| 184 | + | ||
| 185 | + # Set host specific build prefix (needed for Solaris pycc bug) | ||
| 186 | + PYTHON_BUILD_PREFIX= | ||
| 187 | + case $host in | ||
| 188 | + sparc*-sun-solaris*) PYTHON_BUILD_PREFIX="CC=CC" ;; | ||
| 189 | + *) PYTHON_BUILD_PREFIX="" ;; | ||
| 190 | + esac | ||
| 191 | + AC_SUBST(PYTHON_BUILD_PREFIX) | ||
| 192 | + | ||
| 193 | + # Set host specific extra libraries. Add all host specific libraries here that | ||
| 194 | + # need to be linked in the python module | ||
| 195 | + PYTHON_EXTRA_LIBS= | ||
| 196 | + case $host in | ||
| 197 | + sparc*-sun-solaris*) PYTHON_EXTRA_LIBS="Cstd" ;; | ||
| 198 | + *) PYTHON_EXTRA_LIBS="" ;; | ||
| 199 | + esac | ||
| 200 | + AC_SUBST(PYTHON_EXTRA_LIBS) | ||
| 201 | + | ||
| 202 | + else | ||
| 203 | + AC_MSG_WARN([Python binding for ctatools cannot be built as Python seems not to be installed on your system]) | ||
| 204 | + fi | ||
| 125 | else | 205 | else |
| 126 | - AC_MSG_NOTICE([Python binding for ctatools will not be built.]) | ||
| 127 | - AC_MSG_NOTICE([Enable Python binding module building with --enable-python-binding]) | 206 | + AC_MSG_NOTICE([Python binding for ctatools will not be built]) |
| 207 | + AC_MSG_NOTICE([Enable Python binding module building with --enable-python-binding]) | ||
| 128 | fi | 208 | fi |
| 129 | -AM_CONDITIONAL(ENABLE_PYTHON_BINDING, test "x$ac_enable_python_binding" = "xyes") | ||
| 130 | 209 | ||
| 131 | 210 | ||
| 132 | dnl ================== | 211 | dnl ================== |
| @@ -164,3 +243,40 @@ AC_CONFIG_FILES([Makefile | @@ -164,3 +243,40 @@ AC_CONFIG_FILES([Makefile | ||
| 164 | pyext/Makefile | 243 | pyext/Makefile |
| 165 | pyext/setup.py]) | 244 | pyext/setup.py]) |
| 166 | AC_OUTPUT | 245 | AC_OUTPUT |
| 246 | + | ||
| 247 | + | ||
| 248 | +dnl =========================== | ||
| 249 | +dnl Print configuration summary | ||
| 250 | +dnl =========================== | ||
| 251 | +echo | ||
| 252 | +echo " ctatools configuration summary" | ||
| 253 | +echo " ==============================" | ||
| 254 | +if test ! "$SWIG"; then | ||
| 255 | + echo " - swig (no)" | ||
| 256 | +else | ||
| 257 | + echo " * swig (yes)" | ||
| 258 | +fi | ||
| 259 | +if test "x$ac_enable_python_binding" = "xyes"; then | ||
| 260 | + if test "$PYTHON"; then | ||
| 261 | + if test "x$has_python_wrap" = "xyes"; then | ||
| 262 | + if test ! "$SWIG"; then | ||
| 263 | + echo " * Python binding (yes)" | ||
| 264 | + else | ||
| 265 | + echo " * Python binding (yes) use swig for updates" | ||
| 266 | + fi | ||
| 267 | + else | ||
| 268 | + if test ! "$SWIG"; then | ||
| 269 | + echo " - Python binding (no) swig not installed" | ||
| 270 | + else | ||
| 271 | + echo " * Python binding (yes) use swig for building" | ||
| 272 | + fi | ||
| 273 | + fi | ||
| 274 | + else | ||
| 275 | + echo " - Python binding (no) python not installed" | ||
| 276 | + fi | ||
| 277 | +else | ||
| 278 | + echo " - Python binding (no)" | ||
| 279 | +fi | ||
| 280 | +echo | ||
| 281 | +echo "Now type 'make'" | ||
| 282 | +echo |
pyext/Makefile.am
| 1 | ## Process this file with automake to produce Makefile.in | 1 | ## Process this file with automake to produce Makefile.in |
| 2 | +# | ||
| 3 | +# The actual implemented logic is to use swig if swig is | ||
| 4 | +# available on the system | ||
| 2 | 5 | ||
| 3 | -if HAVE_SWIG | ||
| 4 | -if HAVE_PYTHON | ||
| 5 | if ENABLE_PYTHON_BINDING | 6 | if ENABLE_PYTHON_BINDING |
| 7 | +if HAVE_PYTHON | ||
| 8 | +if WITH_PYTHON_BINDING | ||
| 6 | 9 | ||
| 10 | +# Set SWIG interface filename | ||
| 7 | SWIG_INTERFACE = ctatools.i | 11 | SWIG_INTERFACE = ctatools.i |
| 8 | -BUILT_SOURCES = ctatools_wrap.cpp ctatools.py | ||
| 9 | -CLEANFILES = ctatools_wrap.cpp ctatools.py | 12 | + |
| 13 | +# Define the targets that should be built before anything else. | ||
| 14 | +# These are honored by 'make all', 'make check' and 'make install'. | ||
| 15 | +if HAVE_SWIG | ||
| 16 | + BUILT_SOURCES = ctatools_wrap.cpp ctatools.py | ||
| 17 | +endif | ||
| 18 | + | ||
| 19 | +# Set files to be removed in clean | ||
| 20 | +if HAVE_SWIG | ||
| 21 | + CLEANFILES = ctatools_wrap.cpp ctatools.py | ||
| 22 | +endif | ||
| 10 | 23 | ||
| 11 | all-local: ctatools_wrap.cpp ctatools.py | 24 | all-local: ctatools_wrap.cpp ctatools.py |
| 12 | - $(PYTHON) setup.py build | 25 | + $(PYTHON_BUILD_PREFIX) $(PYTHON) setup.py build |
| 13 | 26 | ||
| 14 | install-exec-local: | 27 | install-exec-local: |
| 15 | $(PYTHON) setup.py install --prefix=$(prefix) | 28 | $(PYTHON) setup.py install --prefix=$(prefix) |
| @@ -17,13 +30,11 @@ install-exec-local: | @@ -17,13 +30,11 @@ install-exec-local: | ||
| 17 | clean-local: | 30 | clean-local: |
| 18 | rm -rf build | 31 | rm -rf build |
| 19 | 32 | ||
| 33 | +if HAVE_SWIG | ||
| 20 | ctatools_wrap.cpp ctatools.py: $(SWIG_INTERFACE) | 34 | ctatools_wrap.cpp ctatools.py: $(SWIG_INTERFACE) |
| 21 | $(SWIG) -c++ -python -Wall -includeall -I$(prefix)/share/gammalib/swig -o ctatools_wrap.cpp -outdir . $(srcdir)/$(SWIG_INTERFACE) | 35 | $(SWIG) -c++ -python -Wall -includeall -I$(prefix)/share/gammalib/swig -o ctatools_wrap.cpp -outdir . $(srcdir)/$(SWIG_INTERFACE) |
| 22 | - @if test "x`uname`" = "xCygwin"; then \ | ||
| 23 | - echo "WARNING: working around bug in SWIG on Windows/Cygwin platforms ONLY"; \ | ||
| 24 | - sed -i.bak -f $(srcdir)/fix_wrapper.sed ctatools_wrap.cpp; \ | ||
| 25 | - fi | 36 | +endif # HAVE_SWIG |
| 26 | 37 | ||
| 27 | -endif # ENABLE_PYTHON_BINDING | 38 | +endif # WITH_PYTHON_BINDING |
| 28 | endif # HAVE_PYTHON | 39 | endif # HAVE_PYTHON |
| 29 | -endif # HAVE_SWIG | 40 | +endif # ENABLE_PYTHON_BINDING |
pyext/setup.py.in
| 1 | from distutils.core import setup, Extension | 1 | from distutils.core import setup, Extension |
| 2 | +import glob | ||
| 3 | +import os | ||
| 4 | + | ||
| 5 | +# Set default include directories and data files | ||
| 6 | +include_dirs = ['@prefix@/include/gammalib'] | ||
| 7 | +data_files = glob.glob('@top_srcdir@/pyext/*.i') | ||
| 8 | +library_dirs = ['../src/.libs','@prefix@/lib'] | ||
| 9 | +libraries = ['ctatools','gamma','cfitsio'] | ||
| 10 | + | ||
| 11 | +# Add application include files | ||
| 12 | +dirs = glob.glob('../src/ct*') | ||
| 13 | +for dir in dirs: | ||
| 14 | + if len(dir) > 0: | ||
| 15 | + path = os.path.abspath(dir) | ||
| 16 | + include_dirs.append(path) | ||
| 17 | + | ||
| 18 | +# Add extra libraries | ||
| 19 | +extra_libs = ('@PYTHON_EXTRA_LIBS@').split(',') | ||
| 20 | +for extra_lib in extra_libs: | ||
| 21 | + if len(extra_lib) > 0: | ||
| 22 | + libraries.append(extra_lib) | ||
| 23 | + | ||
| 24 | +# Get extra library paths | ||
| 25 | +extra_lib_paths = ('@LDFLAGS@').split(' ') | ||
| 26 | +for extra_lib_path in extra_lib_paths: | ||
| 27 | + dir = extra_lib_path.lstrip('-L') | ||
| 28 | + if len(dir) > 0: | ||
| 29 | + library_dirs.append(extra_lib_path.lstrip('-L')) | ||
| 30 | +print include_dirs | ||
| 31 | +print libraries | ||
| 32 | +print library_dirs | ||
| 33 | + | ||
| 34 | +# Setup | ||
| 2 | setup(name='@PACKAGE_NAME@', | 35 | setup(name='@PACKAGE_NAME@', |
| 3 | version='@PACKAGE_VERSION@', | 36 | version='@PACKAGE_VERSION@', |
| 4 | description='ctatools Python binding', | 37 | description='ctatools Python binding', |
| @@ -7,8 +40,8 @@ setup(name='@PACKAGE_NAME@', | @@ -7,8 +40,8 @@ setup(name='@PACKAGE_NAME@', | ||
| 7 | url='http://gammalib.sourceforge.net/', | 40 | url='http://gammalib.sourceforge.net/', |
| 8 | py_modules=['ctatools'], | 41 | py_modules=['ctatools'], |
| 9 | ext_modules=[Extension('_ctatools', ['ctatools_wrap.cpp'], | 42 | ext_modules=[Extension('_ctatools', ['ctatools_wrap.cpp'], |
| 10 | - include_dirs=['@prefix@/include/gammalib', '@top_srcdir@/src/ctselect', '@top_srcdir@/src/ctbin', '@top_srcdir@/src/ctlike', '@top_srcdir@/src/ctobssim'], | ||
| 11 | - library_dirs=['../src/.libs','@prefix@/lib'], | ||
| 12 | - libraries=['ctatools','gamma','cfitsio'], | 43 | + include_dirs=include_dirs, |
| 44 | + library_dirs=library_dirs, | ||
| 45 | + libraries=libraries, | ||
| 13 | runtime_library_dirs=['@prefix@/lib'])], | 46 | runtime_library_dirs=['@prefix@/lib'])], |
| 14 | ) | 47 | ) |