1 dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
8 dnl Instead of giving an error about each prerequisite as we encounter it,
9 dnl group them all together at the end of the run, to be user-friendly.
10 AC_DEFUN([PSPP_REQUIRED_PREREQ], [pspp_required_prereqs="$pspp_required_prereqs
12 AC_DEFUN([PSPP_OPTIONAL_PREREQ], [pspp_optional_prereqs="$pspp_optional_prereqs
14 AC_DEFUN([PSPP_CHECK_PREREQS],
16 if test "$pspp_optional_prereqs" != ""; then
17 AC_MSG_WARN([The following optional prerequisites are not installed.
18 You may wish to install them to obtain additional functionality:$pspp_optional_prereqs])
20 if test "$pspp_required_prereqs" != ""; then
21 AC_MSG_ERROR([The following required prerequisites are not installed.
22 You must install them before PSPP can be built:$pspp_required_prereqs])
27 dnl Check that a new enough version of Perl is available.
30 AC_PATH_PROG([PERL], perl, no)
32 if test "$PERL" != no && $PERL -e 'require 5.005_03;'; then :; else
33 PSPP_REQUIRED_PREREQ([Perl 5.005_03 (or later)])
37 dnl Check that libplot is available.
38 AC_DEFUN([PSPP_LIBPLOT],
40 AC_ARG_WITH(libplot, [ --without-libplot don't compile in support of charts (using libplot)])
42 if test x"$with_libplot" != x"no" ; then
43 AC_CHECK_LIB(plot, pl_newpl_r,,
44 [PSPP_REQUIRED_PREREQ([libplot (or use --without-libplot)])])
48 dnl Check that off_t is defined as an integer type.
49 dnl Solaris sometimes declares it as a struct, if it
50 dnl thinks that the compiler does not support `long long'.
51 AC_DEFUN([PSPP_OFF_T],
53 AC_COMPILE_IFELSE([#include <sys/types.h>
60 }], [], [AC_MSG_ERROR(
61 [Your system's definition of off_t is broken. You are probably
62 using Solaris. You can probably fix the problem with
63 `--disable-largefile' or `CFLAGS=-ansi'.])])
66 dnl Check whether a warning flag is accepted.
67 dnl If so, add it to CFLAGS.
68 dnl Example: PSPP_ENABLE_WARNING(-Wdeclaration-after-statement)
69 AC_DEFUN([PSPP_ENABLE_WARNING],
71 m4_define([pspp_cv_name], [pspp_cv_[]m4_translit([$1], [-], [_])])dnl
72 AC_CACHE_CHECK([whether $CC accepts $1], [pspp_cv_name],
73 [pspp_save_CFLAGS="$CFLAGS"
75 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [pspp_cv_name[]=yes], [pspp_cv_name[]=no])
76 CFLAGS="$pspp_save_CFLAGS"])
77 if test $pspp_cv_name = yes; then
82 dnl Check for readline and history libraries.
84 dnl Modified for PSPP by Ben Pfaff, based on readline.m4 serial 3 from
85 dnl gnulib, which was written by Simon Josefsson, with help from Bruno
86 dnl Haible and Oskar Liljeblad.
88 AC_DEFUN([PSPP_READLINE],
90 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
91 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
92 AC_REQUIRE([AC_LIB_RPATH])
94 dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
95 dnl INCREADLINE accordingly.
96 AC_LIB_LINKFLAGS_BODY([readline])
97 AC_LIB_LINKFLAGS_BODY([history])
99 dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
100 dnl because if the user has installed libreadline and not disabled its use
101 dnl via --without-libreadline-prefix, he wants to use it. The AC_TRY_LINK
102 dnl will then succeed.
103 am_save_CPPFLAGS="$CPPFLAGS"
104 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE $INCHISTORY])
106 AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
107 gl_cv_lib_readline=no
109 dnl On some systems, -lreadline doesn't link without an additional
110 dnl -lncurses or -ltermcap.
111 dnl Try -lncurses before -ltermcap, because libtermcap is unsecure
112 dnl by design and obsolete since 1994. Try -lcurses last, because
113 dnl libcurses is unusable on some old Unices.
114 for extra_lib in "" ncurses termcap curses; do
115 LIBS="$am_save_LIBS $LIBREADLINE $LIBHISTORY"
116 if test -n "$extra_lib"; then
117 LIBS="$LIBS -l$extra_lib"
119 AC_TRY_LINK([#include <stdio.h>
120 #include <readline/readline.h>
121 #include <readline/history.h>],
122 [readline((char*)0); add_history((char*)0);],
123 gl_cv_lib_readline=yes)
124 if test "$gl_cv_lib_readline" = yes; then
125 if test -n "$extra_lib"; then
126 LIBREADLINE="$LIBREADLINE $LIBHISTORY -l$extra_lib"
127 LTLIBREADLINE="$LTLIBREADLINE $LTLIBHISTORY -l$extra_lib"
135 if test "$gl_cv_lib_readline" = yes; then
136 AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline library.])
137 AC_MSG_CHECKING([how to link with libreadline])
138 AC_MSG_RESULT([$LIBREADLINE])
140 dnl If $LIBREADLINE didn't lead to a usable library, we don't
141 dnl need $INCREADLINE either.
142 CPPFLAGS="$am_save_CPPFLAGS"
147 PSPP_OPTIONAL_PREREQ([libreadline (which may itself require libncurses or libtermcap)])
149 AC_SUBST(LIBREADLINE)
150 AC_SUBST(LTLIBREADLINE)
153 dnl aclocal.m4 ends here