jpayne@68: # Configure path for the GNU Scientific Library jpayne@68: # Christopher R. Gabriel , April 2000 jpayne@68: jpayne@68: jpayne@68: AC_DEFUN([AX_PATH_GSL], jpayne@68: [ jpayne@68: AC_ARG_WITH(gsl-prefix,[ --with-gsl-prefix=PFX Prefix where GSL is installed (optional)], jpayne@68: gsl_prefix="$withval", gsl_prefix="") jpayne@68: AC_ARG_WITH(gsl-exec-prefix,[ --with-gsl-exec-prefix=PFX Exec prefix where GSL is installed (optional)], jpayne@68: gsl_exec_prefix="$withval", gsl_exec_prefix="") jpayne@68: AC_ARG_ENABLE(gsltest, [ --disable-gsltest Do not try to compile and run a test GSL program], jpayne@68: , enable_gsltest=yes) jpayne@68: jpayne@68: if test "x${GSL_CONFIG+set}" != xset ; then jpayne@68: if test "x$gsl_prefix" != x ; then jpayne@68: GSL_CONFIG="$gsl_prefix/bin/gsl-config" jpayne@68: fi jpayne@68: if test "x$gsl_exec_prefix" != x ; then jpayne@68: GSL_CONFIG="$gsl_exec_prefix/bin/gsl-config" jpayne@68: fi jpayne@68: fi jpayne@68: jpayne@68: AC_PATH_PROG(GSL_CONFIG, gsl-config, no) jpayne@68: min_gsl_version=ifelse([$1], ,0.2.5,$1) jpayne@68: AC_MSG_CHECKING(for GSL - version >= $min_gsl_version) jpayne@68: no_gsl="" jpayne@68: if test "$GSL_CONFIG" = "no" ; then jpayne@68: no_gsl=yes jpayne@68: else jpayne@68: GSL_CFLAGS=`$GSL_CONFIG --cflags` jpayne@68: GSL_LIBS=`$GSL_CONFIG --libs` jpayne@68: jpayne@68: gsl_major_version=`$GSL_CONFIG --version | \ jpayne@68: sed 's/^\([[0-9]]*\).*/\1/'` jpayne@68: if test "x${gsl_major_version}" = "x" ; then jpayne@68: gsl_major_version=0 jpayne@68: fi jpayne@68: jpayne@68: gsl_minor_version=`$GSL_CONFIG --version | \ jpayne@68: sed 's/^\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\).*/\2/'` jpayne@68: if test "x${gsl_minor_version}" = "x" ; then jpayne@68: gsl_minor_version=0 jpayne@68: fi jpayne@68: jpayne@68: gsl_micro_version=`$GSL_CONFIG --version | \ jpayne@68: sed 's/^\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\).*/\3/'` jpayne@68: if test "x${gsl_micro_version}" = "x" ; then jpayne@68: gsl_micro_version=0 jpayne@68: fi jpayne@68: jpayne@68: if test "x$enable_gsltest" = "xyes" ; then jpayne@68: ac_save_CFLAGS="$CFLAGS" jpayne@68: ac_save_LIBS="$LIBS" jpayne@68: CFLAGS="$CFLAGS $GSL_CFLAGS" jpayne@68: LIBS="$LIBS $GSL_LIBS" jpayne@68: jpayne@68: rm -f conf.gsltest jpayne@68: AC_TRY_RUN([ jpayne@68: #include jpayne@68: #include jpayne@68: #include jpayne@68: jpayne@68: char* my_strdup (const char *str); jpayne@68: jpayne@68: char* jpayne@68: my_strdup (const char *str) jpayne@68: { jpayne@68: char *new_str; jpayne@68: jpayne@68: if (str) jpayne@68: { jpayne@68: new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); jpayne@68: strcpy (new_str, str); jpayne@68: } jpayne@68: else jpayne@68: new_str = NULL; jpayne@68: jpayne@68: return new_str; jpayne@68: } jpayne@68: jpayne@68: int main (void) jpayne@68: { jpayne@68: int major = 0, minor = 0, micro = 0; jpayne@68: int n; jpayne@68: char *tmp_version; jpayne@68: jpayne@68: system ("touch conf.gsltest"); jpayne@68: jpayne@68: /* HP/UX 9 (%@#!) writes to sscanf strings */ jpayne@68: tmp_version = my_strdup("$min_gsl_version"); jpayne@68: jpayne@68: n = sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) ; jpayne@68: jpayne@68: if (n != 2 && n != 3) { jpayne@68: printf("%s, bad version string\n", "$min_gsl_version"); jpayne@68: exit(1); jpayne@68: } jpayne@68: jpayne@68: if (($gsl_major_version > major) || jpayne@68: (($gsl_major_version == major) && ($gsl_minor_version > minor)) || jpayne@68: (($gsl_major_version == major) && ($gsl_minor_version == minor) && ($gsl_micro_version >= micro))) jpayne@68: { jpayne@68: exit(0); jpayne@68: } jpayne@68: else jpayne@68: { jpayne@68: exit(1); jpayne@68: } jpayne@68: } jpayne@68: jpayne@68: ],, no_gsl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) jpayne@68: CFLAGS="$ac_save_CFLAGS" jpayne@68: LIBS="$ac_save_LIBS" jpayne@68: fi jpayne@68: fi jpayne@68: if test "x$no_gsl" = x ; then jpayne@68: AC_MSG_RESULT(yes) jpayne@68: ifelse([$2], , :, [$2]) jpayne@68: else jpayne@68: AC_MSG_RESULT(no) jpayne@68: if test "$GSL_CONFIG" = "no" ; then jpayne@68: echo "*** The gsl-config script installed by GSL could not be found" jpayne@68: echo "*** If GSL was installed in PREFIX, make sure PREFIX/bin is in" jpayne@68: echo "*** your path, or set the GSL_CONFIG environment variable to the" jpayne@68: echo "*** full path to gsl-config." jpayne@68: else jpayne@68: if test -f conf.gsltest ; then jpayne@68: : jpayne@68: else jpayne@68: echo "*** Could not run GSL test program, checking why..." jpayne@68: CFLAGS="$CFLAGS $GSL_CFLAGS" jpayne@68: LIBS="$LIBS $GSL_LIBS" jpayne@68: AC_TRY_LINK([ jpayne@68: #include jpayne@68: ], [ return 0; ], jpayne@68: [ echo "*** The test program compiled, but did not run. This usually means" jpayne@68: echo "*** that the run-time linker is not finding GSL or finding the wrong" jpayne@68: echo "*** version of GSL. If it is not finding GSL, you'll need to set your" jpayne@68: echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" jpayne@68: echo "*** to the installed location Also, make sure you have run ldconfig if that" jpayne@68: echo "*** is required on your system" jpayne@68: echo "***" jpayne@68: echo "*** If you have an old version installed, it is best to remove it, although" jpayne@68: echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], jpayne@68: [ echo "*** The test program failed to compile or link. See the file config.log for the" jpayne@68: echo "*** exact error that occured. This usually means GSL was incorrectly installed" jpayne@68: echo "*** or that you have moved GSL since it was installed. In the latter case, you" jpayne@68: echo "*** may want to edit the gsl-config script: $GSL_CONFIG" ]) jpayne@68: CFLAGS="$ac_save_CFLAGS" jpayne@68: LIBS="$ac_save_LIBS" jpayne@68: fi jpayne@68: fi jpayne@68: # GSL_CFLAGS="" jpayne@68: # GSL_LIBS="" jpayne@68: ifelse([$3], , :, [$3]) jpayne@68: fi jpayne@68: AC_SUBST(GSL_CFLAGS) jpayne@68: AC_SUBST(GSL_LIBS) jpayne@68: rm -f conf.gsltest jpayne@68: ]) jpayne@68: jpayne@68: AU_ALIAS([AM_PATH_GSL], [AX_PATH_GSL])