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 quality of this machine's sprintf implementation.
43 AC_DEFUN([BLP_IS_SPRINTF_GOOD],
45 AC_MSG_CHECKING(if sprintf returns a char count)
46 AC_CACHE_VAL(blp_is_sprintf_good,
47 [AC_TRY_RUN([#include <stdio.h>
52 exit((int)sprintf(s, "abcdefg")!=7);
55 eval "blp_is_sprintf_good=yes",
56 eval "blp_is_sprintf_good=no",
57 eval "blp_is_sprintf_good=no")
59 if test "$blp_is_sprintf_good" = yes; then
60 AC_DEFINE([HAVE_GOOD_SPRINTF], 1,
61 [Define if sprintf() returns the number of characters written
62 to the destination string, excluding the null terminator.])
69 dnl Check for proper random number generator.
71 AC_DEFUN([BLP_RANDOM],
73 AC_MSG_CHECKING(random number generator)
74 AC_CACHE_VAL(blp_random_good,
75 AC_TRY_COMPILE([#include <stdlib.h>], [int x=RAND_MAX;],
76 blp_random_good=yes, blp_random_good=no))
77 if test "$blp_random_good" = yes; then
78 AC_DEFINE([HAVE_GOOD_RANDOM], 1,
79 [Define if rand() and company work according to ANSI.])
86 dnl Check for readline and history libraries.
88 dnl Modified for PSPP by Ben Pfaff, based on readline.m4 serial 3 from
89 dnl gnulib, which was written by Simon Josefsson, with help from Bruno
90 dnl Haible and Oskar Liljeblad.
92 AC_DEFUN([PSPP_READLINE],
94 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
95 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
96 AC_REQUIRE([AC_LIB_RPATH])
98 dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
99 dnl INCREADLINE accordingly.
100 AC_LIB_LINKFLAGS_BODY([readline])
101 AC_LIB_LINKFLAGS_BODY([history])
103 dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
104 dnl because if the user has installed libreadline and not disabled its use
105 dnl via --without-libreadline-prefix, he wants to use it. The AC_TRY_LINK
106 dnl will then succeed.
107 am_save_CPPFLAGS="$CPPFLAGS"
108 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE $INCHISTORY])
110 AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
111 gl_cv_lib_readline=no
113 dnl On some systems, -lreadline doesn't link without an additional
114 dnl -lncurses or -ltermcap.
115 dnl Try -lncurses before -ltermcap, because libtermcap is unsecure
116 dnl by design and obsolete since 1994. Try -lcurses last, because
117 dnl libcurses is unusable on some old Unices.
118 for extra_lib in "" ncurses termcap curses; do
119 LIBS="$am_save_LIBS $LIBREADLINE $LIBHISTORY"
120 if test -n "$extra_lib"; then
121 LIBS="$LIBS -l$extra_lib"
123 AC_TRY_LINK([#include <stdio.h>
124 #include <readline/readline.h>
125 #include <readline/history.h>],
126 [readline((char*)0); add_history((char*)0);],
127 gl_cv_lib_readline=yes)
128 if test "$gl_cv_lib_readline" = yes; then
129 if test -n "$extra_lib"; then
130 LIBREADLINE="$LIBREADLINE $LIBHISTORY -l$extra_lib"
131 LTLIBREADLINE="$LTLIBREADLINE $LTLIBHISTORY -l$extra_lib"
139 if test "$gl_cv_lib_readline" = yes; then
140 AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline library.])
143 if test "$gl_cv_lib_readline" = yes; then
144 AC_MSG_CHECKING([how to link with libreadline])
145 AC_MSG_RESULT([$LIBREADLINE])
147 dnl If $LIBREADLINE didn't lead to a usable library, we don't
148 dnl need $INCREADLINE either.
149 CPPFLAGS="$am_save_CPPFLAGS"
155 AC_SUBST(LIBREADLINE)
156 AC_SUBST(LTLIBREADLINE)
159 dnl aclocal.m4 ends here