Commit 6089c3c439fae2218f3b736b5a1c9409d51551c3

Authored by knodlseder
1 parent 76f6e80f

search standard paths first

Showing 1 changed file with 102 additions and 113 deletions
configure.ac
... ... @@ -114,22 +114,35 @@ else
114 114 fi
115 115  
116 116  
117   -dnl ========================================================================
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.
120   -dnl The following conditionals are set:
121   -dnl HAVE_PYTHON - Python >= 2.2 and headers are available
122   -dnl has_python - Python >= 2.2 and headers are available
123   -dnl HAVE_SWIG - swig is available
124   -dnl ENABLE_PYTHON_BINDING - Python binding is requested
125   -dnl WITH_PYTHON_BINDING - Either has swig or python wraper files
126   -dnl ========================================================================
127   -
128   -# Checks for Python (HAVE_PYTHON)
  117 +dnl =========================================================================
  118 +dnl Checks if Python bindings are to be build. Python binding requires Python
  119 +dnl and either the files gammalib_wrap.cpp and gammalib.py or swig to create
  120 +dnl these files. The following conditionals are set:
  121 +dnl WITH_PYTHON - Python bindings will be built
  122 +dnl HAVE_SWIG - swig is available
  123 +dnl =========================================================================
  124 +
  125 +# Initialise flags
  126 +enable_python="no"
129 127 has_python="no"
  128 +has_swig="no"
  129 +has_wrappers="no"
  130 +
  131 +# Python binding enabled?
  132 +AC_ARG_ENABLE([python-binding],
  133 + AS_HELP_STRING([--enable-python-binding],
  134 + [build python binding [default=yes]]),
  135 + [ac_enable_python_binding="$enableval"],
  136 + [ac_enable_python_binding="yes"])
  137 +if test "x$ac_enable_python_binding" = "xno"; then
  138 + AC_MSG_NOTICE([Python binding for gammalib will not be built])
  139 + AC_MSG_NOTICE([Enable Python binding module building with --enable-python-binding])
  140 +fi
  141 +
  142 +# Do we have Python and Python.h?
130 143 AM_PATH_PYTHON([2.2],
131 144 [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])])
  145 + [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 146 if test "x$has_python" = "xyes"; then
134 147  
135 148 # Determine include path for python
... ... @@ -150,65 +163,57 @@ if test "x$has_python" = "xyes"; then
150 163 AC_MSG_WARN([No Python header file "$PY_INCLUDE/Python.h" found. Please install appropriate Python development package.])
151 164 fi
152 165 fi
153   -AM_CONDITIONAL(HAVE_PYTHON, test "x$has_python" = "xyes")
154 166  
155   -# Checks for SWIG (HAVE_SWIG)
  167 +# Do we have swig?
156 168 AC_PATH_PROG([SWIG], [swig])
157   -AM_CONDITIONAL(HAVE_SWIG, test "$SWIG")
158   -
159   -# Python binding enabled?
160   -AC_ARG_ENABLE([python-binding],
161   - AS_HELP_STRING([--enable-python-binding],
162   - [build python binding [default=yes]]),
163   - [ac_enable_python_binding="$enableval"],
164   - [ac_enable_python_binding="yes"])
165   -AM_CONDITIONAL(ENABLE_PYTHON_BINDING, test "x$ac_enable_python_binding" = "xyes")
166   -
167   -# Checks for ctatools_wrap.cpp and ctatools.py
168   -AC_CHECK_FILES([pyext/ctatools_wrap.cpp pyext/ctatools.py],,)
169   -has_python_wrap="no"
170   -if test "x$ac_cv_file_pyext_ctatools_wrap_cpp" = "xyes"; then
171   - if test "x$ac_cv_file_pyext_ctatools_py" = "xyes"; then
172   - has_python_wrap="yes"
  169 +if test "$SWIG"; then
  170 + has_swig="yes"
  171 +fi
  172 +AM_CONDITIONAL(HAVE_SWIG, test "x$has_swig" = "xyes")
  173 +
  174 +# Do we have wrappers (gammalib_wrap.cpp and gammalib.py)?
  175 +AC_CHECK_FILES([pyext/gammalib_wrap.cpp pyext/gammalib.py],,)
  176 +if test "x$ac_cv_file_pyext_gammalib_wrap_cpp" = "xyes"; then
  177 + if test "x$ac_cv_file_pyext_gammalib_py" = "xyes"; then
  178 + has_wrappers="yes"
173 179 fi
174 180 fi
175   -AM_CONDITIONAL(WITH_PYTHON_BINDING, test "x$has_python_wrap" = "xyes" -o "$SWIG")
176 181  
177   -# Inform about missing components and set host dependent variables
178   -if test "x$ac_enable_python_binding" = "xyes"; then
179   - if test "x$has_python" = "xyes"; then
180   - if test "x$has_python_wrap" != "xyes"; then
181   - if test ! "$SWIG"; then
182   - AC_MSG_WARN([Neither pyext/ctatools_wrap.cpp and pyext/ctatools.py nor swig has not been found])
183   - AC_MSG_WARN([Python binding for ctatools cannot be built])
184   - AC_MSG_WARN([Either use a ctatools distribution with ctatools_wrap.cpp and ctatools.py shipped or install swig on your system])
185   - AC_MSG_WARN([swig can be obtained from http://www.swig.org/])
186   - fi
187   - fi
188   -
189   - # Set host specific build prefix (needed for Solaris pycc bug)
190   - PYTHON_BUILD_PREFIX=
191   - case $host in
192   - sparc*-sun-solaris*) PYTHON_BUILD_PREFIX="CC=CC" ;;
193   - *) PYTHON_BUILD_PREFIX="" ;;
194   - esac
195   - AC_SUBST(PYTHON_BUILD_PREFIX)
196   -
197   - # Set host specific extra libraries. Add all host specific libraries here that
198   - # need to be linked in the python module
199   - PYTHON_EXTRA_LIBS=
200   - case $host in
201   - sparc*-sun-solaris*) PYTHON_EXTRA_LIBS="Cstd" ;;
202   - *) PYTHON_EXTRA_LIBS="" ;;
203   - esac
204   - AC_SUBST(PYTHON_EXTRA_LIBS)
205   -
206   - else
207   - AC_MSG_WARN([Python binding for ctatools cannot be built as Python seems not to be installed on your system])
  182 +# Signal if Python is enabled
  183 +if test "x$ac_enable_python_binding" = "xyes" -a "x$has_python" = "xyes"; then
  184 + if test "x$has_swig" = "xyes" -o "x$has_wrappers" = "xyes"; then
  185 + enable_python="yes"
208 186 fi
  187 +fi
  188 +AM_CONDITIONAL(WITH_PYTHON, test "x$enable_python" = "xyes")
  189 +
  190 +# Set Python environment
  191 +if test "x$enable_python" = "xyes"; then
  192 +
  193 + # Set host specific build prefix (needed for Solaris pycc bug)
  194 + PYTHON_BUILD_PREFIX=
  195 + case $host in
  196 + sparc*-sun-solaris*) PYTHON_BUILD_PREFIX="CC=CC" ;;
  197 + *) PYTHON_BUILD_PREFIX="" ;;
  198 + esac
  199 + AC_SUBST(PYTHON_BUILD_PREFIX)
  200 +
  201 + # Set host specific extra libraries. Add all host specific libraries here that
  202 + # need to be linked in the python module
  203 + PYTHON_EXTRA_LIBS=
  204 + case $host in
  205 + sparc*-sun-solaris*) PYTHON_EXTRA_LIBS="Cstd" ;;
  206 + *) PYTHON_EXTRA_LIBS="" ;;
  207 + esac
  208 + AC_SUBST(PYTHON_EXTRA_LIBS)
  209 +
209 210 else
210   - AC_MSG_NOTICE([Python binding for ctatools will not be built])
211   - AC_MSG_NOTICE([Enable Python binding module building with --enable-python-binding])
  211 + if test "x$has_python_wrap" = "xno" -a "x$has_swig" = "xno"; then
  212 + AC_MSG_WARN([Neither pyext/ctatools_wrap.cpp and pyext/ctatools.py nor swig has not been found])
  213 + AC_MSG_WARN([Python binding for ctatools cannot be built])
  214 + AC_MSG_WARN([Either use a ctatools distribution with ctatools_wrap.cpp and ctatools.py shipped or install swig on your system])
  215 + AC_MSG_WARN([swig can be obtained from http://www.swig.org/])
  216 + fi
212 217 fi
213 218  
214 219  
... ... @@ -219,51 +224,38 @@ dnl ===========================
219 224 # Initialise GammaLib availability
220 225 has_gammalib="no"
221 226  
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
  227 +# First check for GammaLib in the standard path using the AC_LINK_IFELSE macro.
  228 +# This allows also search in paths that are eventually specified by LDFAGS.
  229 +AC_LANG(C++)
  230 +SAVED_LDFLAGS=$LDFLAGS
  231 +LDFLAGS="$LDFLAGS -lgamma"
  232 +AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <GammaLib.hpp>],
  233 + [GSkyDir dir])],
  234 + [has_gammalib="yes"
  235 + AC_MSG_NOTICE([GammaLib found in standard path])],
  236 + [AC_MSG_WARN([GammaLib not found in any standard path])])
  237 +LDFLAGS=$SAVED_LDFLAGS
  238 +
  239 +# If GammaLib has not been found in any standard path then search now in a
  240 +# number of predefined locations.
  241 +if test "x$has_gammalib" = "xno"; then
  242 + for i in "$ctatools_prefix" /opt/local /usr/local /usr ; do
  243 + if test -f $i/lib64/libgamma.so -o -f $i/lib64/libgamma.so -a -d $i/include/gammalib; then
  244 + LIBDIR_GAMMALIB=$i/lib64
  245 + INCDIR_GAMMALIB=$i/include/gammalib
  246 + break
  247 + fi
  248 + if test -f $i/lib/libgamma.so -o -f $i/lib/libgamma.dylib -a -d $i/include/gammalib; then
  249 + LIBDIR_GAMMALIB=$i/lib
  250 + INCDIR_GAMMALIB=$i/include/gammalib
  251 + break
  252 + fi
  253 + done
  254 + if test -n "$LIBDIR_GAMMALIB" -a -n "$INCDIR_GAMMALIB"; then
  255 + has_gammalib="yes"
  256 + LDFLAGS="$LDFLAGS -L$LIBDIR_GAMMALIB"
  257 + CPPFLAGS="$CPPFLAGS -I$INCDIR_GAMMALIB"
  258 + AC_MSG_NOTICE([GammaLib found in ${LIBDIR_GAMMALIB} and ${INCDIR_GAMMALIB}.])
267 259 fi
268 260 fi
269 261  
... ... @@ -276,9 +268,6 @@ if test &quot;x$has_gammalib&quot; = &quot;xyes&quot;; then
276 268 AC_SUBST(LIBDIR_GAMMALIB)
277 269 AC_SUBST(INCDIR_GAMMALIB)
278 270 fi
279   -#echo $LDFLAGS
280   -#echo $CPPFLAGS
281   -#echo $LIBS
282 271  
283 272  
284 273 dnl ==================
... ...