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