Remove BLP_RANDOM. Its results were unused. Remove
[pspp-builds.git] / acinclude.m4
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.
5
6 dnl Check longest integer in digits.
7
8 AC_DEFUN([BLP_INT_DIGITS],
9 [
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>
13                           #include <limits.h>
14                           int
15                           main()
16                           {
17                             int len;
18                             char s[80];
19                             sprintf(s, "%ld", LONG_MAX);
20                             len = strlen(s);
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);
25                             exit(len);
26                           }
27                          ],
28                          eval "blp_int_digits=19",
29                          eval "blp_int_digits=$?"
30                          if test "$blp_int_digits" -lt 11; then
31                            blp_int_digits=11
32                          fi,
33                          eval "blp_int_digits=19")
34              ])
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
38          `long's.])
39 AC_MSG_RESULT($blp_int_digits) ])dnl
40
41 dnl Check for readline and history libraries.
42
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.
46
47 AC_DEFUN([PSPP_READLINE],
48 [
49   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
50   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
51   AC_REQUIRE([AC_LIB_RPATH])
52
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])
57
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])
64
65   AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
66     gl_cv_lib_readline=no
67     am_save_LIBS="$LIBS"
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"
77       fi
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"
87         fi
88         break
89       fi
90     done
91     LIBS="$am_save_LIBS"
92   ])
93
94   if test "$gl_cv_lib_readline" = yes; then
95     AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline library.])
96   fi
97
98   if test "$gl_cv_lib_readline" = yes; then
99     AC_MSG_CHECKING([how to link with libreadline])
100     AC_MSG_RESULT([$LIBREADLINE])
101   else
102     dnl If $LIBREADLINE didn't lead to a usable library, we don't
103     dnl need $INCREADLINE either.
104     CPPFLAGS="$am_save_CPPFLAGS"
105     LIBREADLINE=
106     LTLIBREADLINE=
107     LIBHISTORY=
108     LTLIBHISTORY=
109   fi
110   AC_SUBST(LIBREADLINE)
111   AC_SUBST(LTLIBREADLINE)
112 ])
113
114 dnl aclocal.m4 ends here