1 # Configure paths for GiNaC
2 # Richard Kreckel 12/12/2000
3 # borrowed from Christian Bauer
4 # stolen from Sam Lantinga
5 # stolen from Manish Singh
6 # stolen back from Frank Belew
7 # stolen from Manish Singh
8 # Shamelessly stolen from Owen Taylor
10 dnl AM_PATH_GINAC([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
11 dnl Test for GiNaC, and define GINACLIB_CPPFLAGS and GINACLIB_LIBS
13 AC_DEFUN(AM_PATH_GINAC,
15 dnl Get the cppflags and libraries from the ginac-config script
17 AC_ARG_WITH(ginac-prefix,[ --with-ginac-prefix=PFX Prefix where GiNaC is installed (optional)],
18 ginac_prefix="$withval", ginac_prefix="")
19 AC_ARG_WITH(ginac-exec-prefix,[ --with-ginac-exec-prefix=PFX Exec prefix where GiNaC is installed (optional)],
20 ginac_exec_prefix="$withval", ginac_exec_prefix="")
21 AC_ARG_ENABLE(ginactest, [ --disable-ginactest Do not try to compile and run a test GiNaC program],
22 , enable_ginactest=yes)
24 if test x$ginac_exec_prefix != x ; then
25 ginac_args="$ginac_args --exec-prefix=$ginac_exec_prefix"
26 if test x${GINACLIB_CONFIG+set} != xset ; then
27 GINACLIB_CONFIG=$ginac_exec_prefix/bin/ginac-config
30 if test x$ginac_prefix != x ; then
31 ginac_args="$ginac_args --prefix=$ginac_prefix"
32 if test x${GINACLIB_CONFIG+set} != xset ; then
33 GINACLIB_CONFIG=$ginac_prefix/bin/ginac-config
37 AC_PATH_PROG(GINACLIB_CONFIG, ginac-config, no)
38 ginac_min_version=ifelse([$1], ,0.7.0,$1)
39 AC_MSG_CHECKING(for GiNaC - version >= $ginac_min_version)
40 if test "$GINACLIB_CONFIG" = "no" ; then
42 echo "*** The ginac-config script installed by GiNaC could not be found"
43 echo "*** If GiNaC was installed in PREFIX, make sure PREFIX/bin is in"
44 echo "*** your path, or set the GINACLIB_CONFIG environment variable to the"
45 echo "*** full path to ginac-config."
46 ifelse([$3], , :, [$3])
48 dnl Parse required version and the result of ginac-config.
49 ginac_min_major_version=`echo $ginac_min_version | \
50 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
51 ginac_min_minor_version=`echo $ginac_min_version | \
52 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
53 ginac_min_micro_version=`echo $ginac_min_version | \
54 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
55 GINACLIB_CPPFLAGS=`$GINACLIB_CONFIG $ginac_args --cppflags`
56 GINACLIB_LIBS=`$GINACLIB_CONFIG $ginac_args --libs`
57 ginac_config_major_version=`$GINACLIB_CONFIG $ginac_args --version | \
58 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
59 ginac_config_minor_version=`$GINACLIB_CONFIG $ginac_args --version | \
60 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
61 ginac_config_micro_version=`$GINACLIB_CONFIG $ginac_args --version | \
62 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
63 dnl Check if the installed GiNaC is sufficiently new according to ginac-config.
64 if test \( $ginac_config_major_version -lt $ginac_min_major_version \) -o \
65 \( $ginac_config_major_version -eq $ginac_min_major_version -a $ginac_config_minor_version -lt $ginac_min_minor_version \) -o \
66 \( $ginac_config_major_version -eq $ginac_min_major_version -a $ginac_config_minor_version -eq $ginac_min_minor_version -a $ginac_config_micro_version -lt $ginac_min_micro_version \); then
67 echo -e "\n*** 'ginac-config --version' returned $ginac_config_major_version.$ginac_config_minor_version.$ginac_config_micro_version, but the minimum version"
68 echo "*** of GiNaC required is $ginac_min_major_version.$ginac_min_minor_version.$ginac_min_micro_version. If ginac-config is correct, then it is"
69 echo "*** best to upgrade to the required version."
70 echo "*** If ginac-config was wrong, set the environment variable GINACLIB_CONFIG"
71 echo "*** to point to the correct copy of ginac-config, and remove the file"
72 echo "*** config.cache before re-running configure."
73 ifelse([$3], , :, [$3])
75 dnl The versions match so far. Now do a sanity check: Does the result of ginac-config
76 dnl match the version of the headers and the version built into the library, too?
78 if test "x$enable_ginactest" = "xyes" ; then
79 ac_save_CPPFLAGS="$CPPFLAGS"
81 CPPFLAGS="$CPPFLAGS $GINACLIB_CPPFLAGS"
82 LIBS="$LIBS $GINACLIB_LIBS"
87 #include <ginac/version.h>
89 /* we do not #include <stdlib.h> because autoconf in C++ mode inserts a
90 prototype for exit() that conflicts with the one in stdlib.h */
91 extern "C" int system(const char *);
95 int major, minor, micro;
98 system("touch conf.ginactest");
100 if ((GINACLIB_MAJOR_VERSION != $ginac_config_major_version) ||
101 (GINACLIB_MINOR_VERSION != $ginac_config_minor_version) ||
102 (GINACLIB_MICRO_VERSION != $ginac_config_micro_version)) {
103 printf("\n*** 'ginac-config --version' returned %d.%d.%d, but the header file I found\n", $ginac_config_major_version, $ginac_config_minor_version, $ginac_config_micro_version);
104 printf("*** corresponds to %d.%d.%d. This mismatch suggests your installation of GiNaC\n", GINACLIB_MAJOR_VERSION, GINACLIB_MINOR_VERSION, GINACLIB_MICRO_VERSION);
105 printf("*** is corrupted or you have specified some wrong -I compiler flags.\n");
106 printf("*** Please inquire and consider reinstalling GiNaC.\n");
109 if ((GiNaC::version_major != $ginac_config_major_version) ||
110 (GiNaC::version_minor != $ginac_config_minor_version) ||
111 (GiNaC::version_micro != $ginac_config_micro_version)) {
112 printf("\n*** 'ginac-config --version' returned %d.%d.%d, but the library I found\n", $ginac_config_major_version, $ginac_config_minor_version, $ginac_config_micro_version);
113 printf("*** corresponds to %d.%d.%d. This mismatch suggests your installation of GiNaC\n", GiNaC::version_major, GiNaC::version_minor, GiNaC::version_micro);
114 printf("*** is corrupted or you have specified some wrong -L compiler flags.\n");
115 printf("*** Please inquire and consider reinstalling GiNaC.\n");
120 ],, no_ginac=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
121 CPPFLAGS="$ac_save_CPPFLAGS"
124 if test "x$no_ginac" = x ; then
125 AC_MSG_RESULT([yes, `$GINACLIB_CONFIG $ginac_args --version`])
126 ifelse([$2], , :, [$2])
129 if test ! -f conf.ginactest ; then
130 echo "*** Could not run GiNaC test program, checking why..."
131 CPPFLAGS="$CFLAGS $GINACLIB_CPPFLAGS"
132 LIBS="$LIBS $GINACLIB_LIBS"
135 #include <ginac/version.h>
137 [ echo "*** The test program compiled, but did not run. This usually means"
138 echo "*** that the run-time linker is not finding GiNaC or finding the wrong"
139 echo "*** version of GiNaC. If it is not finding GiNaC, you'll need to set your"
140 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
141 echo "*** to the installed location. Also, make sure you have run ldconfig if that"
142 echo "*** is required on your system."],
143 [ echo "*** The test program failed to compile or link. See the file config.log for the"
144 echo "*** exact error that occured. This usually means GiNaC was incorrectly installed"
145 echo "*** or that you have moved GiNaC since it was installed. In the latter case, you"
146 echo "*** may want to edit the ginac-config script: $GINACLIB_CONFIG." ])
147 CPPFLAGS="$ac_save_CPPFLAGS"
152 ifelse([$3], , :, [$3])
156 AC_SUBST(GINACLIB_CPPFLAGS)
157 AC_SUBST(GINACLIB_LIBS)