Commit c8e6bee845b22b644ccbe6f52c8488ef889f31f0

Authored by knodlseder
1 parent 3caf2946

use pkgconfig if available; this improves finding of packed cfitsio

Showing 1 changed file with 38 additions and 16 deletions
configure.ac
@@ -72,6 +72,9 @@ AC_PROG_CXX @@ -72,6 +72,9 @@ AC_PROG_CXX
72 AC_PROG_INSTALL 72 AC_PROG_INSTALL
73 AC_PROG_LIBTOOL 73 AC_PROG_LIBTOOL
74 74
  75 +# Is pkgconfig available? This sets PKG_CONFIG to the binary location
  76 +PKG_PROG_PKG_CONFIG
  77 +
75 78
76 dnl ======================= 79 dnl =======================
77 dnl Checks for header files 80 dnl Checks for header files
@@ -328,24 +331,43 @@ AC_ARG_WITH([cfitsio], @@ -328,24 +331,43 @@ AC_ARG_WITH([cfitsio],
328 # If we want to use cfitsio, then search the library now 331 # If we want to use cfitsio, then search the library now
329 if test "x$with_cfitsio" = "xyes"; then 332 if test "x$with_cfitsio" = "xyes"; then
330 333
331 - # Set host specific cfitsio dependencies  
332 - cfitsio_deps=  
333 - case $host in  
334 - *-*-solaris*) cfitsio_deps="-lm -lsocket" ;;  
335 - *) cfitsio_deps="-lm" ;;  
336 - esac 334 + # Use pkgconfig if available
  335 + if test "x$PKG_CONFIG" != "x"; then
  336 + PKG_CHECK_MODULES([cfitsio], [cfitsio],
  337 + [has_cfitsio="yes"],
  338 + [AC_MSG_WARN([cfitsio pkgconfig information not found])])
  339 + if test "x$has_cfitsio" = "xyes"; then
  340 + CFLAGS="$CFLAGS $cfitsio_CFLAGS"
  341 + CPPFLAGS="$CPPFLAGS $cfitsio_CFLAGS"
  342 + LDFLAGS="$LDFLAGS $cfitsio_LIBS"
  343 + CFITSIO="cfitsio"
  344 + fi
  345 + fi
  346 +
  347 + # If we still don't have cfitsio, then search the library and headers in
  348 + # standard paths
  349 + if test "x$has_cfitsio" = "xno"; then
  350 +
  351 + # Set host specific cfitsio dependencies
  352 + cfitsio_deps=
  353 + case $host in
  354 + *-*-solaris*) cfitsio_deps="-lm -lsocket" ;;
  355 + *) cfitsio_deps="-lm" ;;
  356 + esac
337 357
338 - # Check for cfitsio library and headers  
339 - # cfitsio/fitsio.h is for Scientific Linux  
340 - # libcfitsio0/fitsio.h is for OpenSuse  
341 - AC_FIND_LIB_HEADER([cfitsio], [ffpss], [fitsio.h cfitsio/fitsio.h libcfitsio0/fitsio.h],  
342 - [has_cfitsio="yes"], [], [${cfitsio_deps}])  
343 -  
344 - # Add cfitsio dependencies  
345 - if test "x$has_cfitsio" = "xyes"; then  
346 - LIBS="${LIBS} ${cfitsio_deps}" 358 + # Check for cfitsio library and headers
  359 + AC_FIND_LIB_HEADER([cfitsio], [ffpss], [fitsio.h],
  360 + [has_cfitsio="yes"], [], [${cfitsio_deps}])
  361 + #AC_FIND_LIB_HEADER([cfitsio], [ffpss], [fitsio.h cfitsio/fitsio.h libcfitsio0/fitsio.h],
  362 + # [has_cfitsio="yes"], [], [${cfitsio_deps}])
  363 +
  364 + # Add cfitsio dependencies
  365 + if test "x$has_cfitsio" = "xyes"; then
  366 + LIBS="${LIBS} ${cfitsio_deps}"
  367 + fi
  368 +
347 fi 369 fi
348 - 370 +
349 fi 371 fi
350 if test "x$has_cfitsio" = "xyes"; then 372 if test "x$has_cfitsio" = "xyes"; then
351 AC_DEFINE([HAVE_LIBCFITSIO], [1], [Define if cfitsio library is available]) 373 AC_DEFINE([HAVE_LIBCFITSIO], [1], [Define if cfitsio library is available])