]> www.ginac.de Git - ginac.git/blob - acinclude.m4
- collect() does nothing
[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([for doublefactorial in -lcln])
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/cl_integer.h>],
35                 [doublefactorial(2);],
36                 ginac_cv_lib_cln_link="-lcln",
37                 ginac_cv_lib_cln_link="fail")
38             ;;
39         *)
40             AC_TRY_LINK([#include <cl_integer.h>],
41                 [doublefactorial(2);],
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="${ginac_cv_lib_cln_link} ${saved_LIBS}"
51         AC_MSG_RESULT("yes")
52     ;;
53 dnl linking failed:
54     "fail")
55         LIBS="${saved_LIBS}"
56         AC_MSG_RESULT([no])
57         GINAC_ERROR([I could not successfully link a test-program against libcln and run it.
58    You either need to set \$LDFLAGS or install/update the CLN library.])
59     ;;
60     esac
61 ])
62
63 dnl Usage: GINAC_TERMCAP
64 dnl libreadline is based on the termcap functions.
65 dnl Some systems have tgetent(), tgetnum(), tgetstr(), tgetflag(), tputs(),
66 dnl tgoto() in libc, some have it in libtermcap, some have it in libncurses.
67 dnl When both libtermcap and libncurses exist, we prefer the latter, because
68 dnl libtermcap is being phased out.
69 AC_DEFUN(GINAC_TERMCAP,
70 [LIBTERMCAP=
71 AC_CHECK_FUNCS(tgetent)
72 if test "x$ac_cv_func_tgetent" = "xyes"; then
73     :
74 else
75     AC_CHECK_LIB(ncurses, tgetent, LIBTERMCAP="-lncurses")
76     if test -z "$LIBTERMCAP"; then
77         AC_CHECK_LIB(termcap, tgetent, LIBTERMCAP="-ltermcap")
78     fi
79 fi
80 AC_SUBST(LIBTERMCAP)
81 ])
82
83 dnl Usage: GINAC_ERROR(message)
84 dnl This macro displays the warning "message" and sets the flag ginac_error
85 dnl to yes.
86 AC_DEFUN(GINAC_ERROR,[
87 ginac_error_txt="$ginac_error_txt
88 ** $1
89 "
90 ginac_error=yes])
91
92 dnl Usage: GINAC_WARNING(message)
93 dnl This macro displays the warning "message" and sets the flag ginac_warning
94 dnl to yes.
95 AC_DEFUN(GINAC_WARNING,[
96 ginac_warning_txt="$ginac_warning_txt
97 == $1
98 "
99 ginac_warning=yes])
100
101 dnl Usage: GINAC_CHECK_ERRORS
102 dnl (preferably to be put at end of configure.in)
103 dnl This macro displays a warning message if GINAC_ERROR or GINAC_WARNING 
104 dnl has occured previously.
105 AC_DEFUN(GINAC_CHECK_ERRORS,[
106 if test "x${ginac_error}" = "xyes"; then
107     echo "**** The following problems have been detected by configure."
108     echo "**** Please check the messages below before running \"make\"."
109     echo "**** (see the section 'Common Problems' in the INSTALL file)"
110     echo "$ginac_error_txt"
111     if test "x${ginac_warning_txt}" != "x"; then
112         echo "${ginac_warning_txt}"
113     fi
114     echo "deleting cache ${cache_file}"
115     rm -f $cache_file
116     else 
117         if test x$ginac_warning = xyes; then
118             echo "=== The following minor problems have been detected by configure."
119             echo "=== Please check the messages below before running \"make\"."
120             echo "=== (see the section 'Common Problems' in the INSTALL file)"
121             echo "$ginac_warning_txt"
122         fi
123     echo "Configuration of GiNaC $VERSION done. Now type \"make\"."
124 fi])