]> www.ginac.de Git - ginac.git/blob - acinclude.m4
- automake 1.4 was complaining about AM_PROG_INSTALL in configure.in
[ginac.git] / acinclude.m4
1 dnl ===========================================================================
2 dnl Additional macros used to configure GiNaC.  We don't start our own 
3 dnl additions' names with AC_ but with GINAC_ in order to steer clear of
4 dnl future trouble.
5 dnl ===========================================================================
6
7 dnl Generally, it is a bad idea to put specialized header files for a library
8 dnl into a generic directory like /usr/local/include/.  Instead, one should put
9 dnl them into a subdirectory.  GiNaC does it, NTL does it.  Unfortunately, CLN
10 dnl doesn't do so but some people choose to do it by hand.  In these cases we
11 dnl need to #include <CLN/cln.h>, otherwise #include <cln.h>.  This macro
12 dnl tries to be clever and find out the correct way by defining the variable
13 dnl HAVE_CLN_CLN_H in config.h:
14 AC_DEFUN(GINAC_CHECK_CLN_H,
15     [AC_PROVIDE([$0])
16     AC_CHECK_HEADERS(CLN/cln.h, ,
17         AC_CHECK_HEADERS(cln.h, ,
18             AC_MSG_ERROR([cannot find header for Bruno Haible's CLN]);
19         )
20     )
21 ])
22
23 dnl This macro is needed because the generic AC_CHECK_LIB doesn't work because
24 dnl C++ is more strongly typed than C.  Therefore we need to work with the 
25 dnl more fundamental AC_TRY_LINK instead.
26 AC_DEFUN(GINAC_CHECK_LIBCLN,
27     [AC_PROVIDE([$0])
28     AC_MSG_CHECKING([how to link with libcln])
29     saved_LIBS="${LIBS}"
30     AC_CACHE_VAL(ginac_cv_lib_cln_link,
31         [LIBS="-lcln"
32         case "${ac_cv_header_CLN_cln_h}" in
33         "yes")
34             AC_TRY_LINK([#include <CLN/cln.h>],
35                 [factorial(1);],
36                 ginac_cv_lib_cln_link="-lcln",
37                 ginac_cv_lib_cln_link="fail")
38             ;;
39         *)
40             AC_TRY_LINK([#include <cln.h>],
41                 [factorial(1);],
42                 ginac_cv_lib_cln_link="-lcln",
43                 ginac_cv_lib_cln_link="fail")
44             ;;
45         esac
46     ])
47     case "${ginac_cv_lib_cln_link}" in
48 dnl linking worked:
49     "-lcln")
50         LIBS="-lcln ${saved_LIBS}"
51         AC_MSG_RESULT([-lcln])
52         GINAC_CHECK_LIBCLN_SANITY
53     ;;
54 dnl linking failed:
55     "fail")
56         LIBS="${saved_LIBS}"
57         AC_MSG_RESULT([])
58         AC_MSG_WARN([linking with libcln failed])
59     ;;
60 dnl should never ever get here:
61     *)
62         LIBS="${saved_LIBS}"
63     ;;
64     esac
65 ])
66
67 dnl Check if the CLN library suits our needs, i.e. if it is new enough, by
68 dnl trying to run into a little bug which was present till version 1.0.1 and
69 dnl then removed.
70 AC_DEFUN(GINAC_CHECK_LIBCLN_SANITY,
71     [AC_PROVIDE([$0])
72     AC_MSG_CHECKING([whether libcln behaves sane])
73     AC_CACHE_VAL(ginac_cv_lib_cln_integrity,
74         [
75         case "${ac_cv_header_CLN_cln_h}" in
76         "yes")
77             AC_TRY_RUN([#include <CLN/cln.h>
78 int main() {
79 cl_RA q(3); q = q/2; cl_RA p(3); p = p/2;
80 if (q+p != 3) return 1; else return 0;
81 }],
82                 ginac_cv_lib_cln_integrity="sane",
83                 ginac_cv_lib_cln_integrity="insane",
84                 ginac_cv_lib_cln_integrity="guessing sane")
85             ;;
86         *)
87             AC_TRY_RUN([#include <cln.h>
88 int main() {
89 cl_RA q(3); q = q/2; cl_RA p(3); p = p/2;
90 if (q+p != 3) return 1; else return 0;
91 }],
92                 ginac_cv_lib_cln_integrity="sane",
93                 ginac_cv_lib_cln_integrity="insane",
94                 ginac_cv_lib_cln_integrity="guessing sane")
95             ;;
96         esac
97     ])
98     case "${ginac_cv_lib_cln_integrity}" in
99 dnl exit status was 0:
100     "sane")
101         AC_MSG_RESULT([yes])
102     ;;
103 dnl exit status was not 0:
104     "insane")
105         AC_MSG_RESULT([no])
106         AC_MSG_WARN([maybe version of libcln is older than 1.0.2?])
107     ;;
108 dnl test-program was not run because we are cross-compiling:
109     "guessing sane")
110         AC_MSG_RESULT([hopefully])
111     ;;
112 dnl should never ever get here:
113     *)
114         AC_MSG_WARN([you found a bug in the configure script!])
115     ;;
116     esac
117 ])