1 # Configure paths for GiNaC
2 # Christian Bauer 12/1/99
3 # stolen from Sam Lantinga
4 # stolen from Manish Singh
5 # stolen back from Frank Belew
6 # stolen from Manish Singh
7 # Shamelessly stolen from Owen Taylor
9 dnl AM_PATH_GINAC([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
10 dnl Test for GiNaC, and define GINACLIB_CPPFLAGS and GINACLIB_LIBS
12 AC_DEFUN(AM_PATH_GINAC,
14 dnl Get the cppflags and libraries from the ginac-config script
16 AC_ARG_WITH(ginac-prefix,[ --with-ginac-prefix=PFX Prefix where GiNaC is installed (optional)],
17 ginac_prefix="$withval", ginac_prefix="")
18 AC_ARG_WITH(ginac-exec-prefix,[ --with-ginac-exec-prefix=PFX Exec prefix where GiNaC is installed (optional)],
19 ginac_exec_prefix="$withval", ginac_exec_prefix="")
20 AC_ARG_ENABLE(ginactest, [ --disable-ginactest Do not try to compile and run a test GiNaC program],
21 , enable_ginactest=yes)
23 if test x$ginac_exec_prefix != x ; then
24 ginac_args="$ginac_args --exec-prefix=$ginac_exec_prefix"
25 if test x${GINACLIB_CONFIG+set} != xset ; then
26 GINACLIB_CONFIG=$ginac_exec_prefix/bin/ginac-config
29 if test x$ginac_prefix != x ; then
30 ginac_args="$ginac_args --prefix=$ginac_prefix"
31 if test x${GINACLIB_CONFIG+set} != xset ; then
32 GINACLIB_CONFIG=$ginac_prefix/bin/ginac-config
36 AC_PATH_PROG(GINACLIB_CONFIG, ginac-config, no)
37 min_ginac_version=ifelse([$1], ,0.4.0,$1)
38 AC_MSG_CHECKING(for GiNaC - version >= $min_ginac_version)
40 if test "$GINACLIB_CONFIG" = "no" ; then
43 GINACLIB_CPPFLAGS=`$GINACLIB_CONFIG $ginacconf_args --cppflags`
44 GINACLIB_LIBS=`$GINACLIB_CONFIG $ginacconf_args --libs`
46 ginac_major_version=`$GINACLIB_CONFIG $ginac_args --version | \
47 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
48 ginac_minor_version=`$GINACLIB_CONFIG $ginac_args --version | \
49 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
50 ginac_micro_version=`$GINACLIB_CONFIG $ginac_config_args --version | \
51 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
52 if test "x$enable_ginactest" = "xyes" ; then
53 ac_save_CPPFLAGS="$CPPFLAGS"
55 CPPFLAGS="$CPPFLAGS $GINACLIB_CPPFLAGS"
56 LIBS="$LIBS $GINACLIB_LIBS"
58 dnl Now check if the installed GiNaC is sufficiently new. (Also sanity
59 dnl checks the results of ginac-config to some extent
66 #include <ginac/ginac.h>
75 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
76 strcpy (new_str, str);
86 int major, minor, micro;
89 system ("touch conf.ginactest");
91 /* HP/UX 9 (%@#!) writes to sscanf strings */
92 tmp_version = my_strdup("$min_ginac_version");
93 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
94 printf("%s, bad version string\n", "$min_ginac_version");
98 if (($ginac_major_version > major) ||
99 (($ginac_major_version == major) && ($ginac_minor_version > minor)) ||
100 (($ginac_major_version == major) && ($ginac_minor_version == minor) && ($ginac_micro_version >= micro)))
106 printf("\n*** 'ginac-config --version' returned %d.%d.%d, but the minimum version\n", $ginac_major_version, $ginac_minor_version, $ginac_micro_version);
107 printf("*** of GiNaC required is %d.%d.%d. If ginac-config is correct, then it is\n", major, minor, micro);
108 printf("*** best to upgrade to the required version.\n");
109 printf("*** If ginac-config was wrong, set the environment variable GINACLIB_CONFIG\n");
110 printf("*** to point to the correct copy of ginac-config, and remove the file\n");
111 printf("*** config.cache before re-running configure\n");
116 ],, no_ginac=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
117 CPPFLAGS="$ac_save_CPPFLAGS"
121 if test "x$no_ginac" = x ; then
123 ifelse([$2], , :, [$2])
126 if test "$GINACLIB_CONFIG" = "no" ; then
127 echo "*** The ginac-config script installed by GiNaC could not be found"
128 echo "*** If GiNaC was installed in PREFIX, make sure PREFIX/bin is in"
129 echo "*** your path, or set the GINACLIB_CONFIG environment variable to the"
130 echo "*** full path to ginac-config."
132 if test -f conf.ginactest ; then
135 echo "*** Could not run GiNaC test program, checking why..."
136 CPPFLAGS="$CFLAGS $GINACLIB_CPPFLAGS"
137 LIBS="$LIBS $GINACLIB_LIBS"
140 #include <ginac/ginac.h>
142 [ echo "*** The test program compiled, but did not run. This usually means"
143 echo "*** that the run-time linker is not finding GiNaC or finding the wrong"
144 echo "*** version of GiNaC. If it is not finding GiNaC, 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"
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 GiNaC was incorrectly installed"
153 echo "*** or that you have moved GiNaC since it was installed. In the latter case, you"
154 echo "*** may want to edit the ginac-config script: $GINACLIB_CONFIG" ])
155 CPPFLAGS="$ac_save_CPPFLAGS"
161 ifelse([$3], , :, [$3])
163 AC_SUBST(GINACLIB_CPPFLAGS)
164 AC_SUBST(GINACLIB_LIBS)