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_STD_CXX_HEADERS
8 dnl Check for standard C++ headers, bail out if something is missing.
9 AC_DEFUN([GINAC_STD_CXX_HEADERS], [
10 AC_CACHE_CHECK([for standard C++ header files], [ginac_cv_std_cxx_headers], [
11 ginac_cv_std_cxx_headers="no"
13 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
27 ]])], [ginac_cv_std_cxx_headers="yes"])
29 if test "${ginac_cv_std_cxx_headers}" != "yes"; then
30 AC_MSG_ERROR([Standard ISO C++ 98 headers are missing])
34 dnl Usage: GINAC_LIBREADLINE
36 dnl Check if GNU readline library and headers are avialable.
37 dnl Defines GINSH_LIBS variable, and HAVE_LIBREADLINE,
38 dnl HAVE_READLINE_READLINE_H, HAVE_READLINE_HISTORY_H preprocessor macros.
40 dnl Note: this macro rejects readline versions <= 4.2 and non-GNU
43 AC_DEFUN([GINAC_READLINE],[
44 AC_REQUIRE([GINAC_TERMCAP])
46 AC_CHECK_HEADERS(readline/readline.h readline/history.h)
47 if test "x${ac_cv_header_readline_readline_h}" != "xyes" -o "x${ac_cv_header_readline_history_h}" != "xyes"; then
48 GINAC_WARNING([ginsh will not compile, because readline headers could not be found.])
50 AC_CACHE_CHECK([for version of libreadline], [ginac_cv_rl_supported], [
51 ginac_cv_rl_supported="no"
52 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
54 #include <readline/readline.h>
55 #if !defined(RL_VERSION_MAJOR) || !defined(RL_VERSION_MINOR)
56 #error "Ancient/unsupported version of readline"
58 [ginac_cv_rl_supported="yes"])])
59 if test "x${ginac_cv_rl_supported}" != "xyes"; then
60 GINAC_WARNING([ginsh will not compile, because of an unsupported version of readline (<= 4.2 or non-GNU).])
63 LIBS="$LIBTERMCAP $LIBS"
64 AC_CHECK_LIB(readline, readline)
65 if test "x${ac_cv_lib_readline_readline}" != "xyes"; then
66 GINAC_WARNING([ginsh will not compile, because libreadline could not be found.])
72 AC_SUBST(GINSH_LIBS)])
74 dnl Usage: GINAC_TERMCAP
75 dnl libreadline is based on the termcap functions.
76 dnl Some systems have tgetent(), tgetnum(), tgetstr(), tgetflag(), tputs(),
77 dnl tgoto() in libc, some have it in libtermcap, some have it in libncurses.
78 dnl When both libtermcap and libncurses exist, we prefer the latter, because
79 dnl libtermcap is being phased out.
80 AC_DEFUN([GINAC_TERMCAP],
84 ;; dnl no termcap libraries are necessary (need hacked libreadline)
86 AC_CHECK_FUNCS(tgetent)
87 if test "x$ac_cv_func_tgetent" = "xyes"; then
90 AC_CHECK_LIB(ncurses, tgetent, LIBTERMCAP="-lncurses")
91 if test -z "$LIBTERMCAP"; then
92 AC_CHECK_LIB(termcap, tgetent, LIBTERMCAP="-ltermcap")
100 dnl Usage: GINAC_ERROR(message)
101 dnl This macro displays the warning "message" and sets the flag ginac_error
103 AC_DEFUN([GINAC_ERROR],[
104 ginac_error_txt="$ginac_error_txt
109 dnl Usage: GINAC_WARNING(message)
110 dnl This macro displays the warning "message" and sets the flag ginac_warning
112 AC_DEFUN([GINAC_WARNING],[
113 ginac_warning_txt="$ginac_warning_txt
118 dnl Usage: GINAC_CHECK_ERRORS
119 dnl (must be put at end of configure.in, because it exits on error)
120 dnl This macro displays a warning message if GINAC_ERROR or GINAC_WARNING
121 dnl has occured previously.
122 AC_DEFUN([GINAC_CHECK_ERRORS],[
123 if test "x${ginac_error}" = "xyes"; then
125 echo "**** The following problems have been detected by configure."
126 echo "**** Please check the messages below before running \"make\"."
127 echo "**** (see the section 'Common Problems' in the INSTALL file)"
128 echo "$ginac_error_txt"
129 if test "x${ginac_warning_txt}" != "x"; then
130 echo "${ginac_warning_txt}"
132 if test "x$cache_file" != "x/dev/null"; then
133 echo "deleting cache ${cache_file}"
138 if test "x${ginac_warning}" = "xyes"; then
140 echo "=== The following minor problems have been detected by configure."
141 echo "=== Please check the messages below before running \"make\"."
142 echo "=== (see the section 'Common Problems' in the INSTALL file)"
143 echo "$ginac_warning_txt"
145 echo "Configuration of GiNaC $VERSION done. Now type \"make\"."
148 AC_DEFUN([GINAC_HAVE_RUSAGE],
149 [AC_CACHE_CHECK([whether struct rusage is declared in <sys/resource.h>],
151 [AC_TRY_COMPILE([#include <sys/times.h>
152 #include <sys/resource.h>],
153 [struct rusage resUsage;
154 getrusage(RUSAGE_SELF, &resUsage);
156 [ac_cv_have_rusage=yes],
157 [ac_cv_have_rusage=no])
160 if test "$ac_cv_have_rusage" = yes; then
162 AC_DEFINE(HAVE_RUSAGE,,[define if struct rusage declared in <sys/resource.h>])
164 AC_SUBST(CONFIG_RUSAGE)
167 dnl Usage: GINAC_EXCOMPILER
168 dnl - Checks if dlopen is available
169 dnl - Allows user to disable GiNaC::compile_ex (e.g. for security reasons)
170 dnl Defines HAVE_LIBDL preprocessor macro, sets DL_LIBS and CONFIG_EXCOMPILER
172 AC_DEFUN([GINAC_EXCOMPILER], [
173 CONFIG_EXCOMPILER=yes
176 AC_ARG_ENABLE([excompiler],
177 [AS_HELP_STRING([--enable-excompiler], [Enable GiNaC::compile_ex (default: yes)])],
178 [if test "$enableval" = "no"; then
179 CONFIG_EXCOMPILER="no"
181 [CONFIG_EXCOMPILER="yes"])
185 CONFIG_EXCOMPILER="notsupported"
191 if test "$CONFIG_EXCOMPILER" = "yes"; then
192 AC_CHECK_HEADER([dlfcn.h], [CONFIG_EXCOMPILER="yes"], [CONFIG_EXCOMPILER="no"])
193 elif test "$CONFIG_EXCOMPILER" = "no"; then
194 AC_MSG_NOTICE([GiNaC::compile_ex disabled at user request.])
196 AC_MSG_NOTICE([GiNaC::compile_ex is not supported on $host_os.])
199 if test "$CONFIG_EXCOMPILER" = "yes"; then
200 dnl Some systems (GNU/Linux, Solaris) have dlopen in -ldl, some
201 dnl others (OpenBSD) -- in libc
202 found_dlopen_lib="no"
204 AC_CHECK_LIB(dl, dlopen, [found_dlopen_lib="yes"])
205 if test "$found_dlopen_lib" = "no"; then
207 AC_CHECK_FUNC(dlopen, [found_dlopen_lib="yes"])
209 if test "$found_dlopen_lib" = "no"; then
210 CONFIG_EXCOMPILER="no"
211 AC_MSG_WARN([Could not found working dlopen(). GiNaC::compile_ex will be disabled.])
213 AC_DEFINE(HAVE_LIBDL, 1, [set to 1 if dlopen() works.])
217 AC_SUBST(CONFIG_EXCOMPILER)])