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.
6 dnl Check that a new enough version of Perl is available.
9 AC_PATH_PROG([PERL], perl, no)
11 if test "$PERL" = no; then
12 AC_MSG_ERROR([perl is not found])
14 $PERL -e 'require 5.005_03;' || {
15 AC_MSG_ERROR([Perl 5.005_03 or better is required])
19 dnl Check that libplot is available.
20 AC_DEFUN([PSPP_LIBPLOT],
22 AC_ARG_WITH(libplot, [ --without-libplot don't compile in support of charts (using libplot)])
24 if test x"$with_libplot" != x"no" ; then
25 AC_CHECK_LIB(plot, pl_newpl_r,,
26 AC_MSG_ERROR([You must install libplot development libraries (or use --without-libplot)])
31 dnl Check that off_t is defined as an integer type.
32 dnl Solaris sometimes declares it as a struct, if it
33 dnl thinks that the compiler does not support `long long'.
34 AC_DEFUN([PSPP_OFF_T],
36 AC_COMPILE_IFELSE([#include <sys/types.h>
43 }], [], [AC_MSG_ERROR(
44 [Your system's definition of off_t is broken. You are probably
45 using Solaris. You can probably fix the problem with
46 `--disable-largefile' or `CFLAGS=-ansi'.])])
49 dnl Check whether a warning flag is accepted.
50 dnl If so, add it to CFLAGS.
51 dnl Example: PSPP_ENABLE_WARNING(-Wdeclaration-after-statement)
52 AC_DEFUN([PSPP_ENABLE_WARNING],
54 m4_define([pspp_cv_name], [pspp_cv_[]m4_translit([$1], [-], [_])])dnl
55 AC_CACHE_CHECK([whether $CC accepts $1], [pspp_cv_name],
56 [pspp_save_CFLAGS="$CFLAGS"
58 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [pspp_cv_name[]=yes], [pspp_cv_name[]=no])
59 CFLAGS="$pspp_save_CFLAGS"])
60 if test $pspp_cv_name = yes; then
65 dnl Check for readline and history libraries.
67 dnl Modified for PSPP by Ben Pfaff, based on readline.m4 serial 3 from
68 dnl gnulib, which was written by Simon Josefsson, with help from Bruno
69 dnl Haible and Oskar Liljeblad.
71 AC_DEFUN([PSPP_READLINE],
73 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
74 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
75 AC_REQUIRE([AC_LIB_RPATH])
77 dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
78 dnl INCREADLINE accordingly.
79 AC_LIB_LINKFLAGS_BODY([readline])
80 AC_LIB_LINKFLAGS_BODY([history])
82 dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
83 dnl because if the user has installed libreadline and not disabled its use
84 dnl via --without-libreadline-prefix, he wants to use it. The AC_TRY_LINK
85 dnl will then succeed.
86 am_save_CPPFLAGS="$CPPFLAGS"
87 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE $INCHISTORY])
89 AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
92 dnl On some systems, -lreadline doesn't link without an additional
93 dnl -lncurses or -ltermcap.
94 dnl Try -lncurses before -ltermcap, because libtermcap is unsecure
95 dnl by design and obsolete since 1994. Try -lcurses last, because
96 dnl libcurses is unusable on some old Unices.
97 for extra_lib in "" ncurses termcap curses; do
98 LIBS="$am_save_LIBS $LIBREADLINE $LIBHISTORY"
99 if test -n "$extra_lib"; then
100 LIBS="$LIBS -l$extra_lib"
102 AC_TRY_LINK([#include <stdio.h>
103 #include <readline/readline.h>
104 #include <readline/history.h>],
105 [readline((char*)0); add_history((char*)0);],
106 gl_cv_lib_readline=yes)
107 if test "$gl_cv_lib_readline" = yes; then
108 if test -n "$extra_lib"; then
109 LIBREADLINE="$LIBREADLINE $LIBHISTORY -l$extra_lib"
110 LTLIBREADLINE="$LTLIBREADLINE $LTLIBHISTORY -l$extra_lib"
118 if test "$gl_cv_lib_readline" = yes; then
119 AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline library.])
122 if test "$gl_cv_lib_readline" = yes; then
123 AC_MSG_CHECKING([how to link with libreadline])
124 AC_MSG_RESULT([$LIBREADLINE])
126 dnl If $LIBREADLINE didn't lead to a usable library, we don't
127 dnl need $INCREADLINE either.
128 CPPFLAGS="$am_save_CPPFLAGS"
134 AC_SUBST(LIBREADLINE)
135 AC_SUBST(LTLIBREADLINE)
138 dnl aclocal.m4 ends here