Update build system to Autoconf 2.58, Automake 1.7, gettext 0.12.1.
[pspp-builds.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl Initialize.
4 AC_PREREQ(2.58)
5 AC_INIT(pspp, 0.3.1)
6 AC_CONFIG_HEADERS([config.h])
7 AM_INIT_AUTOMAKE
8
9 dnl Checks for programs.
10 AC_GNU_SOURCE
11 AC_PROG_CC
12
13 dnl Internationalization macros.
14 AM_GNU_GETTEXT
15 AM_GNU_GETTEXT_VERSION  dnl Prevents autoreconf complaint.
16
17 dnl Checks for libraries.
18 AC_CHECK_LIB(m, sin)
19 AC_CHECK_LIB(gmp, mpf_get_str, [LIBS="-lgmp $LIBS"],
20              [AC_CHECK_LIB(gmp, __gmpf_get_str, [LIBS="-lgmp $LIBS"])])
21   
22 AC_CHECK_LIB(ncurses, tgetent, LIBS="-lncurses $LIBS" termcap=yes,
23   AC_CHECK_LIB(termcap, tgetent, LIBS="-ltermcap $LIBS" termcap=yes,
24                termcap=no))
25 if test "$termcap" = yes; then
26   AC_CHECK_HEADERS(termcap.h)
27   AC_DEFINE(HAVE_LIBTERMCAP, 1, 
28         [Define if you have the termcap library (-ltermcap).])
29 fi
30
31 AC_CHECK_LIB(readline, readline)
32 if test "$ac_cv_lib_readline_readline" = yes; then
33   AC_CHECK_HEADERS(readline/readline.h)
34   AC_CHECK_LIB(readline, add_history, history=yes,
35     AC_CHECK_LIB(history, add_history, LIBS="-lhistory" history=yes,
36                  history=no))
37   if test "$history" = yes; then
38     AC_CHECK_HEADERS(readline/history.h)
39     AC_DEFINE(HAVE_LIBHISTORY, 1,
40         [Define if you have the history library (-lhistory).])
41   fi
42 fi
43
44 dnl Checks for header files.
45 AC_CHECK_HEADERS([limits.h memory.h sys/stat.h sys/time.h sys/types.h \
46                   fpu_control.h sys/mman.h sys/wait.h ieeefp.h fenv.h])
47 AC_HEADER_STAT
48 AC_HEADER_STDC
49 AC_HEADER_TIME
50
51 AC_C_CONST
52 AC_C_INLINE
53 AC_TYPE_SIZE_T
54 AC_STRUCT_TM
55
56 AC_CHECK_SIZEOF(short, 2)
57 AC_CHECK_SIZEOF(int, 4)
58 AC_CHECK_SIZEOF(long, 4)
59 AC_CHECK_SIZEOF(long long, 0)
60 AC_CHECK_SIZEOF(float, 0)
61 AC_CHECK_SIZEOF(double, 8)
62 AC_CHECK_SIZEOF(long double, 0)
63
64 AC_DEFINE(FPREP_IEEE754, 1,
65         [Define for machines that have IEEE 754 floating point arithmetic,
66          the most common format today.])
67
68 AC_C_BIGENDIAN
69
70 BLP_IS_SPRINTF_GOOD
71 BLP_INT_DIGITS
72 BLP_RANDOM
73
74 AC_FUNC_ALLOCA
75 AC_FUNC_MEMCMP
76 AC_FUNC_VPRINTF
77 AC_REPLACE_FUNCS([memmove memset stpcpy strpbrk strerror strtol strtoul \
78                   memchr getline getdelim strcasecmp strncasecmp memmem \
79                   strtok_r])
80 AC_CHECK_FUNCS([gethostname strstr strtod __setfpucw isinf isnan finite \
81                 getpid feholdexcept])
82
83 AC_PROG_LN_S
84
85 dnl This must be after other tests so warnings don't provoke errors above.
86 if test "$ac_cv_c_compiler_gnu" = yes; then
87         CFLAGS="-g -Wall -W -Wno-uninitialized -Wwrite-strings \
88 -Wstrict-prototypes -Wpointer-arith -Wno-sign-compare"
89         if test "$CC_OPTIONS" != ""; then
90                 CFLAGS="$CFLAGS $CC_OPTIONS"
91         fi
92 fi
93 AC_SUBST(CFLAGS)
94
95 AH_BOTTOM([#include <pref.h>])
96
97 AC_CONFIG_FILES([Makefile po/Makefile.in m4/Makefile intl/Makefile
98                  lib/Makefile lib/julcal/Makefile lib/misc/Makefile 
99                  lib/dcdflib/Makefile doc/Makefile src/Makefile 
100                  config/Makefile tests/Makefile])
101 AC_CONFIG_COMMANDS([pref.h],[
102            # Copy pref.h from pref.h.orig if prudent
103            if test ! -f pref.h; then
104              echo "creating pref.h"
105              cp $ac_given_srcdir/pref.h.orig pref.h
106            elif test "`ls -t pref.h.orig pref.h 2>/dev/null | sed 1q`" = pref.h.orig; then
107              echo "replacing pref.h with newer pref.h.orig"
108              cp $ac_given_srcdir/pref.h.orig pref.h
109            else
110              echo "pref.h exists"
111            fi
112            if test -f pref.h; then touch pref.h; fi
113           ])
114 AC_OUTPUT
115
116 dnl configure.in ends here