]> www.ginac.de Git - ginac.git/blob - ginac.m4
- configure, configure.in: Bumped version up to 0.6.2.
[ginac.git] / ginac.m4
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
8
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
11 dnl
12 AC_DEFUN(AM_PATH_GINAC,
13 [dnl 
14 dnl Get the cppflags and libraries from the ginac-config script
15 dnl
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)
22
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
27      fi
28   fi
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
33      fi
34   fi
35
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)
39   no_ginac=""
40   if test "$GINACLIB_CONFIG" = "no" ; then
41     no_ginac=yes
42   else
43     GINACLIB_CPPFLAGS=`$GINACLIB_CONFIG $ginacconf_args --cppflags`
44     GINACLIB_LIBS=`$GINACLIB_CONFIG $ginacconf_args --libs`
45
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"
54       ac_save_LIBS="$LIBS"
55       CPPFLAGS="$CPPFLAGS $GINACLIB_CPPFLAGS"
56       LIBS="$LIBS $GINACLIB_LIBS"
57 dnl
58 dnl Now check if the installed GiNaC is sufficiently new. (Also sanity
59 dnl checks the results of ginac-config to some extent
60 dnl
61       rm -f conf.ginactest
62       AC_TRY_RUN([
63 #include <stdio.h>
64 #include <stdlib.h>
65 #include <string.h>
66 #include <ginac/ginac.h>
67
68 char*
69 my_strdup (char *str)
70 {
71   char *new_str;
72   
73   if (str)
74     {
75       new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
76       strcpy (new_str, str);
77     }
78   else
79     new_str = NULL;
80   
81   return new_str;
82 }
83
84 int main ()
85 {
86   int major, minor, micro;
87   char *tmp_version;
88
89   system ("touch conf.ginactest");
90
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, &micro) != 3) {
94      printf("%s, bad version string\n", "$min_ginac_version");
95      exit(1);
96    }
97
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)))
101     {
102       return 0;
103     }
104   else
105     {
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");
112       return 1;
113     }
114 }
115
116 ],, no_ginac=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
117        CPPFLAGS="$ac_save_CPPFLAGS"
118        LIBS="$ac_save_LIBS"
119      fi
120   fi
121   if test "x$no_ginac" = x ; then
122      AC_MSG_RESULT(yes)
123      ifelse([$2], , :, [$2])     
124   else
125      AC_MSG_RESULT(no)
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."
131      else
132        if test -f conf.ginactest ; then
133         :
134        else
135           echo "*** Could not run GiNaC test program, checking why..."
136           CPPFLAGS="$CFLAGS $GINACLIB_CPPFLAGS"
137           LIBS="$LIBS $GINACLIB_LIBS"
138           AC_TRY_LINK([
139 #include <stdio.h>
140 #include <ginac/ginac.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 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"
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 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"
156           LIBS="$ac_save_LIBS"
157        fi
158      fi
159      GINACLIB_CPPFLAGS=""
160      GINACLIB_LIBS=""
161      ifelse([$3], , :, [$3])
162   fi
163   AC_SUBST(GINACLIB_CPPFLAGS)
164   AC_SUBST(GINACLIB_LIBS)
165   rm -f conf.ginactest
166 ])