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 longest integer in digits.
8 AC_DEFUN([BLP_INT_DIGITS],
10 AC_MSG_CHECKING(number of digits in LONG_MIN (incl. sign))
11 AC_CACHE_VAL(blp_int_digits,
12 [AC_TRY_RUN([#include <stdio.h>
19 sprintf(s, "%ld", LONG_MAX);
21 sprintf(s, "%ld", LONG_MIN);
22 if(strlen(s)>len) len=strlen(s);
23 sprintf(s, "%lu", ULONG_MAX);
24 if(strlen(s)>len) len=strlen(s);
28 eval "blp_int_digits=19",
29 eval "blp_int_digits=$?"
30 if test "$blp_int_digits" -lt 11; then
33 eval "blp_int_digits=19")
35 AC_DEFINE_UNQUOTED([INT_DIGITS], $blp_int_digits,
36 [Number of digits in longest `long' value, including sign.
37 This is usually 11, for 32-bit `long's, or 19, for 64-bit
39 AC_MSG_RESULT($blp_int_digits) ])dnl
41 dnl Check for readline and history libraries.
43 dnl Modified for PSPP by Ben Pfaff, based on readline.m4 serial 3 from
44 dnl gnulib, which was written by Simon Josefsson, with help from Bruno
45 dnl Haible and Oskar Liljeblad.
47 AC_DEFUN([PSPP_READLINE],
49 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
50 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
51 AC_REQUIRE([AC_LIB_RPATH])
53 dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
54 dnl INCREADLINE accordingly.
55 AC_LIB_LINKFLAGS_BODY([readline])
56 AC_LIB_LINKFLAGS_BODY([history])
58 dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
59 dnl because if the user has installed libreadline and not disabled its use
60 dnl via --without-libreadline-prefix, he wants to use it. The AC_TRY_LINK
61 dnl will then succeed.
62 am_save_CPPFLAGS="$CPPFLAGS"
63 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE $INCHISTORY])
65 AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
68 dnl On some systems, -lreadline doesn't link without an additional
69 dnl -lncurses or -ltermcap.
70 dnl Try -lncurses before -ltermcap, because libtermcap is unsecure
71 dnl by design and obsolete since 1994. Try -lcurses last, because
72 dnl libcurses is unusable on some old Unices.
73 for extra_lib in "" ncurses termcap curses; do
74 LIBS="$am_save_LIBS $LIBREADLINE $LIBHISTORY"
75 if test -n "$extra_lib"; then
76 LIBS="$LIBS -l$extra_lib"
78 AC_TRY_LINK([#include <stdio.h>
79 #include <readline/readline.h>
80 #include <readline/history.h>],
81 [readline((char*)0); add_history((char*)0);],
82 gl_cv_lib_readline=yes)
83 if test "$gl_cv_lib_readline" = yes; then
84 if test -n "$extra_lib"; then
85 LIBREADLINE="$LIBREADLINE $LIBHISTORY -l$extra_lib"
86 LTLIBREADLINE="$LTLIBREADLINE $LTLIBHISTORY -l$extra_lib"
94 if test "$gl_cv_lib_readline" = yes; then
95 AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline library.])
98 if test "$gl_cv_lib_readline" = yes; then
99 AC_MSG_CHECKING([how to link with libreadline])
100 AC_MSG_RESULT([$LIBREADLINE])
102 dnl If $LIBREADLINE didn't lead to a usable library, we don't
103 dnl need $INCREADLINE either.
104 CPPFLAGS="$am_save_CPPFLAGS"
110 AC_SUBST(LIBREADLINE)
111 AC_SUBST(LTLIBREADLINE)
114 dnl aclocal.m4 ends here