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 ===========================================================================
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,
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]);
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,
27 AC_MSG_CHECKING([how to link with libcln])
29 AC_CACHE_VAL(ginac_cv_lib_cln_link,
31 case "${ac_cv_header_CLN_cln_h}" in
33 AC_TRY_LINK([#include <CLN/cln.h>],
35 ginac_cv_lib_cln_link="-lcln",
36 ginac_cv_lib_cln_link="fail")
39 AC_TRY_LINK([#include <cln.h>],
41 ginac_cv_lib_cln_link="-lcln",
42 ginac_cv_lib_cln_link="fail")
46 case "${ginac_cv_lib_cln_link}" in
49 LIBS="-lcln ${saved_LIBS}"
50 AC_MSG_RESULT([-lcln])
51 GINAC_CHECK_LIBCLN_SANITY
57 AC_MSG_WARN([linking with libcln failed])
59 dnl should never ever get here:
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
69 AC_DEFUN(GINAC_CHECK_LIBCLN_SANITY,
71 AC_MSG_CHECKING([whether libcln behaves sane])
72 AC_CACHE_VAL(ginac_cv_lib_cln_integrity,
74 case "${ac_cv_header_CLN_cln_h}" in
76 AC_TRY_RUN([#include <CLN/cln.h>
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;
81 ginac_cv_lib_cln_integrity="sane",
82 ginac_cv_lib_cln_integrity="insane",
83 ginac_cv_lib_cln_integrity="guessing sane")
86 AC_TRY_RUN([#include <cln.h>
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;
91 ginac_cv_lib_cln_integrity="sane",
92 ginac_cv_lib_cln_integrity="insane",
93 ginac_cv_lib_cln_integrity="guessing sane")
97 case "${ginac_cv_lib_cln_integrity}" in
98 dnl exit status was 0:
102 dnl exit status was not 0:
105 AC_MSG_WARN([maybe version of libcln is older than 1.0.2?])
107 dnl test-program was not run because we are cross-compiling:
109 AC_MSG_RESULT([hopefully])
111 dnl should never ever get here:
113 AC_MSG_WARN([you found a bug in the configure script!])