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