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([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([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([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
124 echo "**** The following problems have been detected by configure."
125 echo "**** Please check the messages below before running \"make\"."
126 echo "**** (see the section 'Common Problems' in the INSTALL file)"
127 echo "$ginac_error_txt"
128 if test "x${ginac_warning_txt}" != "x"; then
129 echo "${ginac_warning_txt}"
131 if test "x$cache_file" != "x/dev/null"; then
132 echo "deleting cache ${cache_file}"
137 if test "x${ginac_warning}" = "xyes"; then
138 echo "=== The following minor problems have been detected by configure."
139 echo "=== Please check the messages below before running \"make\"."
140 echo "=== (see the section 'Common Problems' in the INSTALL file)"
141 echo "$ginac_warning_txt"
143 echo "Configuration of GiNaC $VERSION done. Now type \"make\"."
146 AC_DEFUN([GINAC_HAVE_RUSAGE],
147 [AC_CACHE_CHECK([whether struct rusage is declared in <sys/resource.h>],
149 [AC_TRY_COMPILE([#include <sys/times.h>
150 #include <sys/resource.h>],
151 [struct rusage resUsage;
152 getrusage(RUSAGE_SELF, &resUsage);
154 [ac_cv_have_rusage=yes],
155 [ac_cv_have_rusage=no])
158 if test "$ac_cv_have_rusage" = yes; then
160 AC_DEFINE(HAVE_RUSAGE,,[define if struct rusage declared in <sys/resource.h>])
162 AC_SUBST(CONFIG_RUSAGE)
165 dnl Usage: GINAC_EXCOMPILER
166 dnl - Checks if dlopen is available
167 dnl - Allows user to disable GiNaC::compile_ex (e.g. for security reasons)
168 dnl Defines HAVE_LIBDL preprocessor macro, sets DL_LIBS and CONFIG_EXCOMPILER
170 AC_DEFUN([GINAC_EXCOMPILER], [
171 CONFIG_EXCOMPILER=yes
174 AC_ARG_ENABLE([excompiler],
175 [AS_HELP_STRING([--enable-excompiler], [Enable GiNaC::compile_ex (default: yes)])],
176 [if test "$enableval" = "no"; then
177 CONFIG_EXCOMPILER="no"
179 [CONFIG_EXCOMPILER="yes"])
183 CONFIG_EXCOMPILER="notsupported"
189 if test "$CONFIG_EXCOMPILER" = "yes"; then
190 AC_CHECK_LIB(dl, dlopen, [
192 AC_DEFINE(HAVE_LIBDL, 1, [set to 1 if you have a working libdl installed.])],
194 [AC_MSG_WARN([libdl not found. GiNaC::compile_ex will be disabled.])
195 CONFIG_EXCOMPILER="no"])
196 elif test "$CONFIG_EXCOMPILER" = "no"; then
197 AC_MSG_RESULT([INFO: GiNaC::compile_ex disabled at user request.])
199 AC_MSG_RESULT([INFO: GiNaC::compile_ex is not supported on $host_os.])
202 AC_SUBST(CONFIG_EXCOMPILER)])