chiark / gitweb /
Import upstream sources.
[cparse] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 #
3 # Copyright (C) 2004 Richard Kettlewell
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 # USA
19 #
20
21 AC_INIT(cparse, 0.0.20040813, richard+cparse@sfere.greenend.org.uk)
22 AM_INIT_AUTOMAKE(cparse, 0.0.20040813)
23 AC_CONFIG_SRCDIR([cparse.h])
24 AM_CONFIG_HEADER([config.h])
25
26 # Checks for programs.
27 AC_PROG_CC
28 AC_SET_MAKE
29
30 AC_PROG_YACC
31 AM_PROG_LEX
32
33 # libtool config
34 AC_DISABLE_STATIC
35
36 AC_PROG_LIBTOOL
37
38 missing_libraries=""
39 missing_headers=""
40 missing_functions=""
41
42 # Turn of libgc so that you can use valgrind.  (Hopefuly someone will add libgc
43 # support to valgrind at some point.)  Since nothing ever calls free() this is
44 # rather wasteful of memory - it's not intended to allow people to use the code
45 # in production without a garbage collector.
46 AC_ARG_WITH([gc],[use the garbage collector],[
47   WANT_GC="$withval"
48 ],[WANT_GC=yes])
49
50 # Checks for libraries.
51 # We save up a list of missing libraries that we can't do without
52 # and report them all at once.
53 if test $WANT_GC = yes; then
54   AC_CHECK_LIB(gc, GC_malloc,
55               [AC_SUBST(LIBGC,[-lgc])],
56               [missing_libraries="$missing_libraries libgc"])
57   AC_DEFINE([USE_GC],[1],[define to use a garbage collector])
58 fi
59
60 if test ! -z "$missing_libraries"; then
61   AC_MSG_ERROR([missing libraries:$missing_libraries])
62 fi
63
64 # Checks for header files.
65 RJK_FIND_GC_H
66 AC_CHECK_HEADERS([inttypes.h])
67 # Compilation will fail if any of these headers are missing, so we
68 # check for them here and fail early.
69 # We don't bother checking very standard stuff
70 AC_CHECK_HEADERS([getopt.h unistd.h],[:],[
71   missing_headers="$missing_headers $ac_header"
72 ])
73
74 if test ! -z "$missing_headers"; then
75   AC_MSG_ERROR([missing headers:$missing_headers])
76 fi
77
78 # Checks for typedefs, structures, and compiler characteristics.
79 AC_C_CONST
80 AC_TYPE_SIZE_T
81 AC_C_INLINE
82 AC_CHECK_TYPES([_Bool])
83
84 if test "x$GCC" = xyes; then
85   # a reasonable default set of warnings
86   CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
87         -Wwrite-strings -Wmissing-prototypes \
88         -Wshadow \
89         -Wmissing-declarations -Wnested-externs -Werror"
90
91   AC_DEFINE([__NO_STRING_INLINES],[1],[define to suppress gcc optimizations we can't cope with])
92
93 fi
94
95 # Flex includes <stdio.h> and other headers before we get a chance to
96 # include <config.h>, so we have to hack definitions that affect the
97 # meanings of those header files onto the command line.
98 CC="${CC} -D_GNU_SOURCE"
99
100 AH_BOTTOM([#ifdef __GNUC__
101 # define attribute(x) __attribute__(x)
102 #else
103 # define attribute(x)
104 #endif
105
106 /* older GNU C versions define LONG_LONG_MAX instead of LLONG_MAX */
107 #include <limits.h>
108
109 #if !defined LLONG_MAX && defined LONG_LONG_MAX
110 # define LLONG_MAX LONG_LONG_MAX
111 # define ULLONG_MAX ULONG_LONG_MAX
112 #endif
113
114 /* not everyone defines SIZE_MAX, fortunately we can compute it portably */
115 #if !defined SIZE_MAX
116 # define SIZE_MAX ((size_t)~(size_t)0)
117 #endif])
118
119 AC_CONFIG_FILES([Makefile
120                  tests/Makefile])
121 AC_OUTPUT