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 whether a warning flag is accepted.
7 dnl If so, add it to CFLAGS.
8 dnl Example: PSPP_ENABLE_WARNING(-Wdeclaration-after-statement)
9 AC_DEFUN([PSPP_ENABLE_WARNING],
11 m4_define([pspp_cv_name], [pspp_cv_[]m4_translit([$1], [-], [_])])dnl
12 AC_CACHE_CHECK([whether $CC accepts $1], [pspp_cv_name],
13 [pspp_save_CFLAGS="$CFLAGS"
15 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [pspp_cv_name[]=yes], [pspp_cv_name[]=no])
16 CFLAGS="$pspp_save_CFLAGS"])
17 if test $pspp_cv_name = yes; then
22 dnl Check for readline and history libraries.
24 dnl Modified for PSPP by Ben Pfaff, based on readline.m4 serial 3 from
25 dnl gnulib, which was written by Simon Josefsson, with help from Bruno
26 dnl Haible and Oskar Liljeblad.
28 AC_DEFUN([PSPP_READLINE],
30 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
31 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
32 AC_REQUIRE([AC_LIB_RPATH])
34 dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
35 dnl INCREADLINE accordingly.
36 AC_LIB_LINKFLAGS_BODY([readline])
37 AC_LIB_LINKFLAGS_BODY([history])
39 dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
40 dnl because if the user has installed libreadline and not disabled its use
41 dnl via --without-libreadline-prefix, he wants to use it. The AC_TRY_LINK
42 dnl will then succeed.
43 am_save_CPPFLAGS="$CPPFLAGS"
44 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE $INCHISTORY])
46 AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
49 dnl On some systems, -lreadline doesn't link without an additional
50 dnl -lncurses or -ltermcap.
51 dnl Try -lncurses before -ltermcap, because libtermcap is unsecure
52 dnl by design and obsolete since 1994. Try -lcurses last, because
53 dnl libcurses is unusable on some old Unices.
54 for extra_lib in "" ncurses termcap curses; do
55 LIBS="$am_save_LIBS $LIBREADLINE $LIBHISTORY"
56 if test -n "$extra_lib"; then
57 LIBS="$LIBS -l$extra_lib"
59 AC_TRY_LINK([#include <stdio.h>
60 #include <readline/readline.h>
61 #include <readline/history.h>],
62 [readline((char*)0); add_history((char*)0);],
63 gl_cv_lib_readline=yes)
64 if test "$gl_cv_lib_readline" = yes; then
65 if test -n "$extra_lib"; then
66 LIBREADLINE="$LIBREADLINE $LIBHISTORY -l$extra_lib"
67 LTLIBREADLINE="$LTLIBREADLINE $LTLIBHISTORY -l$extra_lib"
75 if test "$gl_cv_lib_readline" = yes; then
76 AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline library.])
79 if test "$gl_cv_lib_readline" = yes; then
80 AC_MSG_CHECKING([how to link with libreadline])
81 AC_MSG_RESULT([$LIBREADLINE])
83 dnl If $LIBREADLINE didn't lead to a usable library, we don't
84 dnl need $INCREADLINE either.
85 CPPFLAGS="$am_save_CPPFLAGS"
92 AC_SUBST(LTLIBREADLINE)
95 dnl aclocal.m4 ends here