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
5 dnl ===========================================================================
7 dnl Usage: GINAC_LIBREADLINE
9 dnl Check if GNU readline library and headers are avialable.
10 dnl Defines GINSH_LIBS variable, and HAVE_LIBREADLINE,
11 dnl HAVE_READLINE_READLINE_H, HAVE_READLINE_HISTORY_H preprocessor macros.
13 dnl Note: this macro rejects readline versions <= 4.2 and non-GNU
16 AC_DEFUN([GINAC_READLINE],[
17 AC_REQUIRE([GINAC_TERMCAP])
19 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
20 if test "x${ac_cv_header_readline_readline_h}" != "xyes" -o "x${ac_cv_header_readline_history_h}" != "xyes"; then
21 GINAC_WARNING([readline headers could not be found.])
23 AC_CACHE_CHECK([for version of libreadline], [ginac_cv_rl_supported], [
24 ginac_cv_rl_supported="no"
25 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
27 #include <readline/readline.h>
28 #if !defined(RL_VERSION_MAJOR) || !defined(RL_VERSION_MINOR)
29 #error "Ancient/unsupported version of readline"
31 [ginac_cv_rl_supported="yes"])])
32 if test "x${ginac_cv_rl_supported}" != "xyes"; then
33 GINAC_WARNING([Unsupported version of readline (<= 4.2 or non-GNU).])
36 LIBS="$LIBTERMCAP $LIBS"
37 AC_CHECK_LIB(readline, readline)
38 if test "x${ac_cv_lib_readline_readline}" != "xyes"; then
39 GINAC_WARNING([libreadline could not be found.])
45 AC_SUBST(GINSH_LIBS)])
47 dnl Usage: GINAC_TERMCAP
48 dnl libreadline is based on the termcap functions.
49 dnl Some systems have tgetent(), tgetnum(), tgetstr(), tgetflag(), tputs(),
50 dnl tgoto() in libc, some have it in libtermcap, some have it in libncurses.
51 dnl When both libtermcap and libncurses exist, we prefer the latter, because
52 dnl libtermcap is being phased out.
53 AC_DEFUN([GINAC_TERMCAP],
57 ;; dnl no termcap libraries are necessary (need hacked libreadline)
59 AC_CHECK_FUNCS(tgetent)
60 if test "x$ac_cv_func_tgetent" = "xyes"; then
63 AC_CHECK_LIB(ncurses, tgetent, LIBTERMCAP="-lncurses")
64 if test -z "$LIBTERMCAP"; then
65 AC_CHECK_LIB(termcap, tgetent, LIBTERMCAP="-ltermcap")
73 dnl Usage: GINAC_ERROR(message)
74 dnl This macro displays the warning "message" and sets the flag ginac_error
76 AC_DEFUN([GINAC_ERROR],[
77 ginac_error_txt="$ginac_error_txt
82 dnl Usage: GINAC_WARNING(message)
83 dnl This macro displays the warning "message" and sets the flag ginac_warning
85 AC_DEFUN([GINAC_WARNING],[
86 ginac_warning_txt="$ginac_warning_txt
91 dnl Usage: GINAC_CHECK_ERRORS
92 dnl (must be put at end of configure.in, because it exits on error)
93 dnl This macro displays a warning message if GINAC_ERROR or GINAC_WARNING
94 dnl has occured previously.
95 AC_DEFUN([GINAC_CHECK_ERRORS],[
96 if test "x${ginac_error}" = "xyes"; then
97 echo "**** The following problems have been detected by configure."
98 echo "**** Please check the messages below before running \"make\"."
99 echo "**** (see the section 'Common Problems' in the INSTALL file)"
100 echo "$ginac_error_txt"
101 if test "x${ginac_warning_txt}" != "x"; then
102 echo "${ginac_warning_txt}"
104 if test "x$cache_file" != "x/dev/null"; then
105 echo "deleting cache ${cache_file}"
110 if test "x${ginac_warning}" = "xyes"; then
111 echo "=== The following minor problems have been detected by configure."
112 echo "=== Please check the messages below before running \"make\"."
113 echo "=== (see the section 'Common Problems' in the INSTALL file)"
114 echo "$ginac_warning_txt"
116 echo "Configuration of GiNaC $VERSION done. Now type \"make\"."
119 AC_DEFUN([GINAC_HAVE_RUSAGE],
120 [AC_CACHE_CHECK([whether struct rusage is declared in <sys/resource.h>],
122 [AC_TRY_COMPILE([#include <sys/times.h>
123 #include <sys/resource.h>],
124 [struct rusage resUsage;
125 getrusage(RUSAGE_SELF, &resUsage);
127 [ac_cv_have_rusage=yes],
128 [ac_cv_have_rusage=no])
131 if test "$ac_cv_have_rusage" = yes; then
133 AC_DEFINE(HAVE_RUSAGE,,[define if struct rusage declared in <sys/resource.h>])
135 AC_SUBST(CONFIG_RUSAGE)