jpayne@68
|
1 # Configure path for the GNU Scientific Library
|
jpayne@68
|
2 # Christopher R. Gabriel <cgabriel@linux.it>, April 2000
|
jpayne@68
|
3
|
jpayne@68
|
4
|
jpayne@68
|
5 AC_DEFUN([AX_PATH_GSL],
|
jpayne@68
|
6 [
|
jpayne@68
|
7 AC_ARG_WITH(gsl-prefix,[ --with-gsl-prefix=PFX Prefix where GSL is installed (optional)],
|
jpayne@68
|
8 gsl_prefix="$withval", gsl_prefix="")
|
jpayne@68
|
9 AC_ARG_WITH(gsl-exec-prefix,[ --with-gsl-exec-prefix=PFX Exec prefix where GSL is installed (optional)],
|
jpayne@68
|
10 gsl_exec_prefix="$withval", gsl_exec_prefix="")
|
jpayne@68
|
11 AC_ARG_ENABLE(gsltest, [ --disable-gsltest Do not try to compile and run a test GSL program],
|
jpayne@68
|
12 , enable_gsltest=yes)
|
jpayne@68
|
13
|
jpayne@68
|
14 if test "x${GSL_CONFIG+set}" != xset ; then
|
jpayne@68
|
15 if test "x$gsl_prefix" != x ; then
|
jpayne@68
|
16 GSL_CONFIG="$gsl_prefix/bin/gsl-config"
|
jpayne@68
|
17 fi
|
jpayne@68
|
18 if test "x$gsl_exec_prefix" != x ; then
|
jpayne@68
|
19 GSL_CONFIG="$gsl_exec_prefix/bin/gsl-config"
|
jpayne@68
|
20 fi
|
jpayne@68
|
21 fi
|
jpayne@68
|
22
|
jpayne@68
|
23 AC_PATH_PROG(GSL_CONFIG, gsl-config, no)
|
jpayne@68
|
24 min_gsl_version=ifelse([$1], ,0.2.5,$1)
|
jpayne@68
|
25 AC_MSG_CHECKING(for GSL - version >= $min_gsl_version)
|
jpayne@68
|
26 no_gsl=""
|
jpayne@68
|
27 if test "$GSL_CONFIG" = "no" ; then
|
jpayne@68
|
28 no_gsl=yes
|
jpayne@68
|
29 else
|
jpayne@68
|
30 GSL_CFLAGS=`$GSL_CONFIG --cflags`
|
jpayne@68
|
31 GSL_LIBS=`$GSL_CONFIG --libs`
|
jpayne@68
|
32
|
jpayne@68
|
33 gsl_major_version=`$GSL_CONFIG --version | \
|
jpayne@68
|
34 sed 's/^\([[0-9]]*\).*/\1/'`
|
jpayne@68
|
35 if test "x${gsl_major_version}" = "x" ; then
|
jpayne@68
|
36 gsl_major_version=0
|
jpayne@68
|
37 fi
|
jpayne@68
|
38
|
jpayne@68
|
39 gsl_minor_version=`$GSL_CONFIG --version | \
|
jpayne@68
|
40 sed 's/^\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\).*/\2/'`
|
jpayne@68
|
41 if test "x${gsl_minor_version}" = "x" ; then
|
jpayne@68
|
42 gsl_minor_version=0
|
jpayne@68
|
43 fi
|
jpayne@68
|
44
|
jpayne@68
|
45 gsl_micro_version=`$GSL_CONFIG --version | \
|
jpayne@68
|
46 sed 's/^\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\).*/\3/'`
|
jpayne@68
|
47 if test "x${gsl_micro_version}" = "x" ; then
|
jpayne@68
|
48 gsl_micro_version=0
|
jpayne@68
|
49 fi
|
jpayne@68
|
50
|
jpayne@68
|
51 if test "x$enable_gsltest" = "xyes" ; then
|
jpayne@68
|
52 ac_save_CFLAGS="$CFLAGS"
|
jpayne@68
|
53 ac_save_LIBS="$LIBS"
|
jpayne@68
|
54 CFLAGS="$CFLAGS $GSL_CFLAGS"
|
jpayne@68
|
55 LIBS="$LIBS $GSL_LIBS"
|
jpayne@68
|
56
|
jpayne@68
|
57 rm -f conf.gsltest
|
jpayne@68
|
58 AC_TRY_RUN([
|
jpayne@68
|
59 #include <stdio.h>
|
jpayne@68
|
60 #include <stdlib.h>
|
jpayne@68
|
61 #include <string.h>
|
jpayne@68
|
62
|
jpayne@68
|
63 char* my_strdup (const char *str);
|
jpayne@68
|
64
|
jpayne@68
|
65 char*
|
jpayne@68
|
66 my_strdup (const char *str)
|
jpayne@68
|
67 {
|
jpayne@68
|
68 char *new_str;
|
jpayne@68
|
69
|
jpayne@68
|
70 if (str)
|
jpayne@68
|
71 {
|
jpayne@68
|
72 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
|
jpayne@68
|
73 strcpy (new_str, str);
|
jpayne@68
|
74 }
|
jpayne@68
|
75 else
|
jpayne@68
|
76 new_str = NULL;
|
jpayne@68
|
77
|
jpayne@68
|
78 return new_str;
|
jpayne@68
|
79 }
|
jpayne@68
|
80
|
jpayne@68
|
81 int main (void)
|
jpayne@68
|
82 {
|
jpayne@68
|
83 int major = 0, minor = 0, micro = 0;
|
jpayne@68
|
84 int n;
|
jpayne@68
|
85 char *tmp_version;
|
jpayne@68
|
86
|
jpayne@68
|
87 system ("touch conf.gsltest");
|
jpayne@68
|
88
|
jpayne@68
|
89 /* HP/UX 9 (%@#!) writes to sscanf strings */
|
jpayne@68
|
90 tmp_version = my_strdup("$min_gsl_version");
|
jpayne@68
|
91
|
jpayne@68
|
92 n = sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) ;
|
jpayne@68
|
93
|
jpayne@68
|
94 if (n != 2 && n != 3) {
|
jpayne@68
|
95 printf("%s, bad version string\n", "$min_gsl_version");
|
jpayne@68
|
96 exit(1);
|
jpayne@68
|
97 }
|
jpayne@68
|
98
|
jpayne@68
|
99 if (($gsl_major_version > major) ||
|
jpayne@68
|
100 (($gsl_major_version == major) && ($gsl_minor_version > minor)) ||
|
jpayne@68
|
101 (($gsl_major_version == major) && ($gsl_minor_version == minor) && ($gsl_micro_version >= micro)))
|
jpayne@68
|
102 {
|
jpayne@68
|
103 exit(0);
|
jpayne@68
|
104 }
|
jpayne@68
|
105 else
|
jpayne@68
|
106 {
|
jpayne@68
|
107 exit(1);
|
jpayne@68
|
108 }
|
jpayne@68
|
109 }
|
jpayne@68
|
110
|
jpayne@68
|
111 ],, no_gsl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
jpayne@68
|
112 CFLAGS="$ac_save_CFLAGS"
|
jpayne@68
|
113 LIBS="$ac_save_LIBS"
|
jpayne@68
|
114 fi
|
jpayne@68
|
115 fi
|
jpayne@68
|
116 if test "x$no_gsl" = x ; then
|
jpayne@68
|
117 AC_MSG_RESULT(yes)
|
jpayne@68
|
118 ifelse([$2], , :, [$2])
|
jpayne@68
|
119 else
|
jpayne@68
|
120 AC_MSG_RESULT(no)
|
jpayne@68
|
121 if test "$GSL_CONFIG" = "no" ; then
|
jpayne@68
|
122 echo "*** The gsl-config script installed by GSL could not be found"
|
jpayne@68
|
123 echo "*** If GSL was installed in PREFIX, make sure PREFIX/bin is in"
|
jpayne@68
|
124 echo "*** your path, or set the GSL_CONFIG environment variable to the"
|
jpayne@68
|
125 echo "*** full path to gsl-config."
|
jpayne@68
|
126 else
|
jpayne@68
|
127 if test -f conf.gsltest ; then
|
jpayne@68
|
128 :
|
jpayne@68
|
129 else
|
jpayne@68
|
130 echo "*** Could not run GSL test program, checking why..."
|
jpayne@68
|
131 CFLAGS="$CFLAGS $GSL_CFLAGS"
|
jpayne@68
|
132 LIBS="$LIBS $GSL_LIBS"
|
jpayne@68
|
133 AC_TRY_LINK([
|
jpayne@68
|
134 #include <stdio.h>
|
jpayne@68
|
135 ], [ return 0; ],
|
jpayne@68
|
136 [ echo "*** The test program compiled, but did not run. This usually means"
|
jpayne@68
|
137 echo "*** that the run-time linker is not finding GSL or finding the wrong"
|
jpayne@68
|
138 echo "*** version of GSL. If it is not finding GSL, you'll need to set your"
|
jpayne@68
|
139 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
jpayne@68
|
140 echo "*** to the installed location Also, make sure you have run ldconfig if that"
|
jpayne@68
|
141 echo "*** is required on your system"
|
jpayne@68
|
142 echo "***"
|
jpayne@68
|
143 echo "*** If you have an old version installed, it is best to remove it, although"
|
jpayne@68
|
144 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
|
jpayne@68
|
145 [ echo "*** The test program failed to compile or link. See the file config.log for the"
|
jpayne@68
|
146 echo "*** exact error that occured. This usually means GSL was incorrectly installed"
|
jpayne@68
|
147 echo "*** or that you have moved GSL since it was installed. In the latter case, you"
|
jpayne@68
|
148 echo "*** may want to edit the gsl-config script: $GSL_CONFIG" ])
|
jpayne@68
|
149 CFLAGS="$ac_save_CFLAGS"
|
jpayne@68
|
150 LIBS="$ac_save_LIBS"
|
jpayne@68
|
151 fi
|
jpayne@68
|
152 fi
|
jpayne@68
|
153 # GSL_CFLAGS=""
|
jpayne@68
|
154 # GSL_LIBS=""
|
jpayne@68
|
155 ifelse([$3], , :, [$3])
|
jpayne@68
|
156 fi
|
jpayne@68
|
157 AC_SUBST(GSL_CFLAGS)
|
jpayne@68
|
158 AC_SUBST(GSL_LIBS)
|
jpayne@68
|
159 rm -f conf.gsltest
|
jpayne@68
|
160 ])
|
jpayne@68
|
161
|
jpayne@68
|
162 AU_ALIAS([AM_PATH_GSL], [AX_PATH_GSL])
|