]> www.ginac.de Git - ginac.git/blob - ginac.m4
dirac_slash should give something with non-zero metric.
[ginac.git] / ginac.m4
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
9
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
12 dnl
13 AC_DEFUN([AM_PATH_GINAC],
14 [dnl 
15 dnl Get the cppflags and libraries from the ginac-config script
16 dnl
17 AC_ARG_WITH(ginac-prefix, AC_HELP_STRING([--with-ginac-prefix=PFX], [Prefix where GiNaC is installed (optional)]),
18             ginac_prefix="$withval", ginac_prefix="")
19 AC_ARG_WITH(ginac-exec-prefix, AC_HELP_STRING([--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, AC_HELP_STRING([--disable-ginactest], [Do not try to compile and run a test GiNaC program]),
22               , enable_ginactest=yes)
23
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
28     fi
29 fi
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
34     fi
35 fi
36
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
41     AC_MSG_RESULT(no)
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])
47 else
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_version=`$GINACLIB_CONFIG $ginac_args --version`
58     ginac_config_major_version=`echo $ginac_config_version | \
59             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
60     ginac_config_minor_version=`echo $ginac_config_version | \
61             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
62     ginac_config_micro_version=`echo $ginac_config_version | \
63             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
64 dnl Check if the installed GiNaC is sufficiently new according to ginac-config.
65     if test \( $ginac_config_major_version -lt $ginac_min_major_version \) -o \
66             \( $ginac_config_major_version -eq $ginac_min_major_version -a $ginac_config_minor_version -lt $ginac_min_minor_version \) -o \
67             \( $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
68         echo -e "\n*** 'ginac-config --version' returned $ginac_config_major_version.$ginac_config_minor_version.$ginac_config_micro_version, but the minimum version"
69         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"
70         echo "*** best to upgrade to the required version."
71         echo "*** If ginac-config was wrong, set the environment variable GINACLIB_CONFIG"
72         echo "*** to point to the correct copy of ginac-config, and remove the file"
73         echo "*** config.cache before re-running configure."
74         ifelse([$3], , :, [$3])
75     else
76 dnl The versions match so far.  Now do a sanity check: Does the result of ginac-config
77 dnl match the version of the headers and the version built into the library, too?
78         no_ginac=""
79         if test "x$enable_ginactest" = "xyes" ; then
80             ac_save_CPPFLAGS="$CPPFLAGS"
81             ac_save_LIBS="$LIBS"
82             CPPFLAGS="$CPPFLAGS $GINACLIB_CPPFLAGS"
83             LIBS="$LIBS $GINACLIB_LIBS"
84             rm -f conf.ginactest
85             AC_TRY_RUN([
86 #include <stdio.h>
87 #include <string.h>
88 #include <ginac/version.h>
89
90 /* we do not #include <stdlib.h> because autoconf in C++ mode inserts a
91    prototype for exit() that conflicts with the one in stdlib.h */
92 extern "C" int system(const char *);
93
94 int main()
95 {
96     int major, minor, micro;
97     char *tmp_version;
98
99     system("touch conf.ginactest");
100
101     if ((GINACLIB_MAJOR_VERSION != $ginac_config_major_version) ||
102         (GINACLIB_MINOR_VERSION != $ginac_config_minor_version) ||
103         (GINACLIB_MICRO_VERSION != $ginac_config_micro_version)) {
104         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);
105         printf("*** corresponds to %d.%d.%d. This mismatch suggests your installation of GiNaC\n", GINACLIB_MAJOR_VERSION, GINACLIB_MINOR_VERSION, GINACLIB_MICRO_VERSION);
106         printf("*** is corrupted or you have specified some wrong -I compiler flags.\n");
107         printf("*** Please inquire and consider reinstalling GiNaC.\n");
108         return 1;
109     }
110     if ((GiNaC::version_major != $ginac_config_major_version) ||
111         (GiNaC::version_minor != $ginac_config_minor_version) ||
112         (GiNaC::version_micro != $ginac_config_micro_version)) {
113         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);
114         printf("*** corresponds to %d.%d.%d. This mismatch suggests your installation of GiNaC\n", GiNaC::version_major, GiNaC::version_minor, GiNaC::version_micro);
115         printf("*** is corrupted or you have specified some wrong -L compiler flags.\n");
116         printf("*** Please inquire and consider reinstalling GiNaC.\n");
117         return 1;
118     }
119     return 0;
120 }
121 ],, no_ginac=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
122             CPPFLAGS="$ac_save_CPPFLAGS"
123             LIBS="$ac_save_LIBS"
124         fi
125         if test "x$no_ginac" = x ; then
126             AC_MSG_RESULT([yes, $ginac_config_version])
127             ifelse([$2], , :, [$2])
128         else
129             AC_MSG_RESULT(no)
130             if test ! -f conf.ginactest ; then
131                 echo "*** Could not run GiNaC test program, checking why..."
132                 CPPFLAGS="$CFLAGS $GINACLIB_CPPFLAGS"
133                 LIBS="$LIBS $GINACLIB_LIBS"
134                 AC_TRY_LINK([
135 #include <stdio.h>
136 #include <ginac/version.h>
137 ],              [ return 0; ],
138                 [ echo "*** The test program compiled, but did not run. This usually means"
139                   echo "*** that the run-time linker is not finding GiNaC or finding the wrong"
140                   echo "*** version of GiNaC. If it is not finding GiNaC, you'll need to set your"
141                   echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
142                   echo "*** to the installed location. Also, make sure you have run ldconfig if that"
143                   echo "*** is required on your system."],
144                 [ echo "*** The test program failed to compile or link. See the file config.log for the"
145                   echo "*** exact error that occured. This usually means GiNaC was incorrectly installed"
146                   echo "*** or that you have moved GiNaC since it was installed. In the latter case, you"
147                   echo "*** may want to edit the ginac-config script: $GINACLIB_CONFIG." ])
148                 CPPFLAGS="$ac_save_CPPFLAGS"
149                 LIBS="$ac_save_LIBS"
150             fi
151             GINACLIB_CPPFLAGS=""
152             GINACLIB_LIBS=""
153             ifelse([$3], , :, [$3])
154         fi
155     fi
156 fi
157 AC_SUBST(GINACLIB_CPPFLAGS)
158 AC_SUBST(GINACLIB_LIBS)
159 rm -f conf.ginactest
160 ])