Commit 3efc918ba71db746c0e4ed4ade7c506166486127

Authored by knodlseder
1 parent 1162207c

don't use pkg-config anymore and handle CPPFLAGS/LDFLAGS

Showing 1 changed file with 92 additions and 18 deletions
configure.ac
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 # 17 #
18 # Process this file with autoconf to produce a configure script 18 # Process this file with autoconf to produce a configure script
19 19
20 -AC_INIT([ctatools], [0.2.2], [knodlseder@cesr.fr], [ctatools], [http://cta.irap.omp.eu/ctatools]) 20 +AC_INIT([ctatools], [0.2.3], [knodlseder@cesr.fr], [ctatools])
21 AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp]) 21 AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp])
22 AC_CONFIG_MACRO_DIR([m4]) 22 AC_CONFIG_MACRO_DIR([m4])
23 AC_CONFIG_HEADERS([config.h]) 23 AC_CONFIG_HEADERS([config.h])
@@ -39,8 +39,8 @@ AC_DEFINE_UNQUOTED([PACKAGE_PREFIX], "${ctatools_prefix}", [Location where libra @@ -39,8 +39,8 @@ AC_DEFINE_UNQUOTED([PACKAGE_PREFIX], "${ctatools_prefix}", [Location where libra
39 dnl ============================================== 39 dnl ==============================================
40 dnl Add pkgconfig information of install directory 40 dnl Add pkgconfig information of install directory
41 dnl ============================================== 41 dnl ==============================================
42 -PKG_CONFIG_PATH="${ctatools_prefix}/lib/pkgconfig:/opt/local/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"  
43 -export PKG_CONFIG_PATH 42 +# PKG_CONFIG_PATH="${ctatools_prefix}/lib/pkgconfig:/opt/local/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
  43 +# export PKG_CONFIG_PATH
44 44
45 45
46 dnl =========================== 46 dnl ===========================
@@ -118,17 +118,39 @@ dnl ======================================================================== @@ -118,17 +118,39 @@ dnl ========================================================================
118 dnl Checks for python binding. Python binding requires Python and either the 118 dnl Checks for python binding. Python binding requires Python and either the
119 dnl files gammalib_wrap.cpp and gammalib.py or SWIG to create these files. 119 dnl files gammalib_wrap.cpp and gammalib.py or SWIG to create these files.
120 dnl The following conditionals are set: 120 dnl The following conditionals are set:
121 -dnl HAVE_PYTHON - Python >= 2.2 is available 121 +dnl HAVE_PYTHON - Python >= 2.2 and headers are available
  122 +dnl has_python - Python >= 2.2 and headers are available
122 dnl HAVE_SWIG - swig is available 123 dnl HAVE_SWIG - swig is available
123 dnl ENABLE_PYTHON_BINDING - Python binding is requested 124 dnl ENABLE_PYTHON_BINDING - Python binding is requested
124 dnl WITH_PYTHON_BINDING - Either has swig or python wraper files 125 dnl WITH_PYTHON_BINDING - Either has swig or python wraper files
125 dnl ======================================================================== 126 dnl ========================================================================
126 127
127 # Checks for Python (HAVE_PYTHON) 128 # Checks for Python (HAVE_PYTHON)
  129 +has_python="no"
128 AM_PATH_PYTHON([2.2], 130 AM_PATH_PYTHON([2.2],
129 - [],  
130 - [AC_MSG_WARN([Python not found. Python is required to build python binding. Python can be obtained from http://www.python.org])])  
131 -AM_CONDITIONAL(HAVE_PYTHON, test "$PYTHON") 131 + [has_python="yes"],
  132 + [AC_MSG_WARN([Python >=2.2 not found. Python >=2.2 is required to build python binding. Python can be obtained from http://www.python.org])])
  133 +if test "x$has_python" = "xyes"; then
  134 +
  135 + # Determine include path for python
  136 + AC_PATH_PROG(PY_INCLUDE, python)
  137 + PY_INCLUDE=`echo $PY_INCLUDE | sed -e "s/bin/include/"`
  138 + PY_INCLUDE="$PY_INCLUDE$PYTHON_VERSION"
  139 +
  140 + # Check if we have Python.h
  141 + AC_CHECK_HEADERS($PY_INCLUDE/Python.h, [has_python="yes"], [has_python="no"])
  142 +
  143 + # Mac OS X kluge: if test before was unsuccessful then check for headers in /usr/include
  144 + if test "x$has_python" = "xno"; then
  145 + AC_CHECK_HEADERS("/usr/include/python$PYTHON_VERSION/Python.h", [has_python="yes"], [has_python="no"])
  146 + fi
  147 +
  148 + # Signal any problem
  149 + if test "x$has_python" = "xno"; then
  150 + AC_MSG_WARN([No Python header file "$PY_INCLUDE/Python.h" found. Please install appropriate Python development package.])
  151 + fi
  152 +fi
  153 +AM_CONDITIONAL(HAVE_PYTHON, test "x$has_python" = "xyes")
132 154
133 # Checks for SWIG (HAVE_SWIG) 155 # Checks for SWIG (HAVE_SWIG)
134 AC_PATH_PROG([SWIG], [swig]) 156 AC_PATH_PROG([SWIG], [swig])
@@ -154,7 +176,7 @@ AM_CONDITIONAL(WITH_PYTHON_BINDING, test "x$has_python_wrap" = "xyes" -o "$SWIG" @@ -154,7 +176,7 @@ AM_CONDITIONAL(WITH_PYTHON_BINDING, test "x$has_python_wrap" = "xyes" -o "$SWIG"
154 176
155 # Inform about missing components and set host dependent variables 177 # Inform about missing components and set host dependent variables
156 if test "x$ac_enable_python_binding" = "xyes"; then 178 if test "x$ac_enable_python_binding" = "xyes"; then
157 - if test "$PYTHON"; then 179 + if test "x$has_python" = "xyes"; then
158 if test "x$has_python_wrap" != "xyes"; then 180 if test "x$has_python_wrap" != "xyes"; then
159 if test ! "$SWIG"; then 181 if test ! "$SWIG"; then
160 AC_MSG_WARN([Neither pyext/ctatools_wrap.cpp and pyext/ctatools.py nor swig has not been found]) 182 AC_MSG_WARN([Neither pyext/ctatools_wrap.cpp and pyext/ctatools.py nor swig has not been found])
@@ -193,18 +215,70 @@ fi @@ -193,18 +215,70 @@ fi
193 dnl =========================== 215 dnl ===========================
194 dnl Checks for GammaLib library 216 dnl Checks for GammaLib library
195 dnl =========================== 217 dnl ===========================
  218 +
  219 +# Initialise GammaLib availability
196 has_gammalib="no" 220 has_gammalib="no"
197 -PKG_CHECK_MODULES([GammaLib], [gammalib >= 0.4.7],  
198 - [has_gammalib="yes"],  
199 - [AC_MSG_ERROR([GammaLib library not found])  
200 - AC_MSG_ERROR([Make sure that at least version 0.4.7 of GammaLib in installed])  
201 - AC_MSG_ERROR([If GammaLib is not installed in the default location, please adjust the PKG_CONFIG_PATH environment variable])]) 221 +
  222 +#PKG_CHECK_MODULES([GammaLib], [gammalib >= 0.4.7],
  223 +# [has_gammalib="yes"],
  224 +# [AC_MSG_ERROR([GammaLib library not found])
  225 +# AC_MSG_ERROR([Make sure that at least version 0.4.7 of GammaLib in installed])
  226 +# AC_MSG_ERROR([If GammaLib is not installed in the default location, please adjust the PKG_CONFIG_PATH environment variable])])
  227 +#if test "x$has_gammalib" = "xyes"; then
  228 +# AC_DEFINE([HAVE_LIBGAMMA], [1], [Define if gammalib is available])
  229 +# CFLAGS="$CFLAGS $GammaLib_CFLAGS"
  230 +# CPPFLAGS="$CPPFLAGS $GammaLib_CFLAGS"
  231 +# LDFLAGS="$LDFLAGS $GammaLib_LIBS"
  232 +#fi
  233 +
  234 +# Search for GammaLib in a some standard directories
  235 +for i in "$ctatools_prefix" /opt/local /usr/local /usr ; do
  236 + if test -f $i/lib/libgamma.so -o -f $i/lib/libgamma.dylib -a -d $i/include/gammalib; then
  237 + LIBDIR_GAMMALIB=$i/lib
  238 + INCDIR_GAMMALIB=$i/include/gammalib
  239 + break
  240 + fi
  241 + if test -f $i/lib64/libgamma.so -o -f $i/lib64/libgamma.so -a -d $i/include/gammalib; then
  242 + LIBDIR_GAMMALIB=$i/lib64
  243 + INCDIR_GAMMALIB=$i/include/gammalib
  244 + break
  245 + fi
  246 +done
  247 +if test -n "$LIBDIR_GAMMALIB" -a -n "$INCDIR_GAMMALIB"; then
  248 + has_gammalib="yes"
  249 + LDFLAGS="$LDFLAGS -L$LIBDIR_GAMMALIB"
  250 + CPPFLAGS="$CPPFLAGS -I$INCDIR_GAMMALIB"
  251 + AC_MSG_NOTICE([GammaLib found in ${LIBDIR_GAMMALIB} and ${INCDIR_GAMMALIB}.])
  252 +else
  253 +
  254 + # If GammaLib has not yet been found then search now using the AC_LINK_IFELSE
  255 + # macro. This allows also search in paths that are eventually specified in
  256 + # LDFLAGS
  257 + if test "x$has_gammalib" != "xyes"; then
  258 + AC_LANG(C++)
  259 + SAVED_LDFLAGS=$LDFLAGS
  260 + LDFLAGS="$LDFLAGS -lgamma"
  261 + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GammaLib.hpp>],
  262 + [GSkyDir dir])],
  263 + [has_gammalib="yes"
  264 + AC_MSG_NOTICE([GammaLib found.])],
  265 + [AC_MSG_WARN([GammaLib is not installed.])])
  266 + LDFLAGS=$SAVED_LDFLAGS
  267 + fi
  268 +fi
  269 +
  270 +# Set GammaLib information
202 if test "x$has_gammalib" = "xyes"; then 271 if test "x$has_gammalib" = "xyes"; then
  272 + LIBS_GAMMALIB="-lgamma"
  273 + LIBS="${LIBS} ${LIBS_GAMMALIB}"
203 AC_DEFINE([HAVE_LIBGAMMA], [1], [Define if gammalib is available]) 274 AC_DEFINE([HAVE_LIBGAMMA], [1], [Define if gammalib is available])
204 - CFLAGS="$CFLAGS $GammaLib_CFLAGS"  
205 - CPPFLAGS="$CPPFLAGS $GammaLib_CFLAGS"  
206 - LDFLAGS="$LDFLAGS $GammaLib_LIBS" 275 + AC_SUBST(LIBS_GAMMALIB)
  276 + AC_SUBST(LIBDIR_GAMMALIB)
  277 + AC_SUBST(INCDIR_GAMMALIB)
207 fi 278 fi
  279 +#echo $LDFLAGS
  280 +#echo $CPPFLAGS
  281 +#echo $LIBS
208 282
209 283
210 dnl ================== 284 dnl ==================
@@ -253,7 +327,7 @@ echo @@ -253,7 +327,7 @@ echo
253 echo " ctatools configuration summary" 327 echo " ctatools configuration summary"
254 echo " ==============================" 328 echo " =============================="
255 if test "x$has_gammalib" = "xyes"; then 329 if test "x$has_gammalib" = "xyes"; then
256 - echo " * GammaLib support (yes)" 330 + echo " * GammaLib support (yes) ${LIBDIR_GAMMALIB} ${INCDIR_GAMMALIB}"
257 else 331 else
258 echo " - GammaLib support (no) no gammalib library found" 332 echo " - GammaLib support (no) no gammalib library found"
259 fi 333 fi
@@ -263,7 +337,7 @@ else @@ -263,7 +337,7 @@ else
263 echo " * swig (yes)" 337 echo " * swig (yes)"
264 fi 338 fi
265 if test "x$ac_enable_python_binding" = "xyes"; then 339 if test "x$ac_enable_python_binding" = "xyes"; then
266 - if test "$PYTHON"; then 340 + if test "x$has_python" = "xyes"; then
267 if test "x$has_python_wrap" = "xyes"; then 341 if test "x$has_python_wrap" = "xyes"; then
268 if test ! "$SWIG"; then 342 if test ! "$SWIG"; then
269 echo " * Python binding (yes)" 343 echo " * Python binding (yes)"