Fixed the calculation of percentiles and added --syntax and --algorithm options
[pspp-builds.git] / acinclude.m4
1 dnl Check longest integer in digits.
2
3 AC_DEFUN([BLP_INT_DIGITS],
4 [
5 AC_MSG_CHECKING(number of digits in LONG_MIN (incl. sign))
6 AC_CACHE_VAL(blp_int_digits,
7              [AC_TRY_RUN([#include <stdio.h>
8                           #include <limits.h>
9                           int
10                           main()
11                           {
12                             int len;
13                             char s[80];
14                             sprintf(s, "%ld", LONG_MAX);
15                             len = strlen(s);
16                             sprintf(s, "%ld", LONG_MIN);
17                             if(strlen(s)>len) len=strlen(s);
18                             sprintf(s, "%lu", ULONG_MAX);
19                             if(strlen(s)>len) len=strlen(s);
20                             exit(len);
21                           }
22                          ],
23                          eval "blp_int_digits=19",
24                          eval "blp_int_digits=$?"
25                          if test "$blp_int_digits" -lt 11; then
26                            blp_int_digits=11
27                          fi,
28                          eval "blp_int_digits=19")
29              ])
30 AC_DEFINE_UNQUOTED([INT_DIGITS], $blp_int_digits,
31         [Number of digits in longest `long' value, including sign.
32          This is usually 11, for 32-bit `long's, or 19, for 64-bit
33          `long's.])
34 AC_MSG_RESULT($blp_int_digits) ])dnl
35
36 dnl Check quality of this machine's sprintf implementation.
37
38 AC_DEFUN([BLP_IS_SPRINTF_GOOD],
39 [
40 AC_MSG_CHECKING(if sprintf returns a char count)
41 AC_CACHE_VAL(blp_is_sprintf_good,
42              [AC_TRY_RUN([#include <stdio.h>
43                           int 
44                           main()
45                           {
46                             char s[8];
47                             exit((int)sprintf(s, "abcdefg")!=7);
48                           }
49                          ], 
50                          eval "blp_is_sprintf_good=yes",
51                          eval "blp_is_sprintf_good=no",
52                          eval "blp_is_sprintf_good=no")
53              ])
54 if test "$blp_is_sprintf_good" = yes; then
55   AC_DEFINE([HAVE_GOOD_SPRINTF], 1, 
56         [Define if sprintf() returns the number of characters written
57          to the destination string, excluding the null terminator.])
58   AC_MSG_RESULT(yes)
59 else
60   AC_MSG_RESULT(no)
61 fi
62 ])dnl
63
64 dnl Check for proper random number generator.
65
66 AC_DEFUN([BLP_RANDOM],
67 [
68 AC_MSG_CHECKING(random number generator)
69 AC_CACHE_VAL(blp_random_good, 
70   AC_TRY_COMPILE([#include <stdlib.h>], [int x=RAND_MAX;], 
71     blp_random_good=yes, blp_random_good=no))
72 if test "$blp_random_good" = yes; then
73   AC_DEFINE([HAVE_GOOD_RANDOM], 1, 
74         [Define if rand() and company work according to ANSI.])
75   AC_MSG_RESULT(good)
76 else
77   AC_MSG_RESULT(bad)
78 fi
79 ])dnl
80
81 dnl aclocal.m4 ends here