Import upstream sources.
[cparse] / configure.ac
CommitLineData
3cd4b0f8
MW
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
21AC_INIT(cparse, 0.0.20040813, richard+cparse@sfere.greenend.org.uk)
22AM_INIT_AUTOMAKE(cparse, 0.0.20040813)
23AC_CONFIG_SRCDIR([cparse.h])
24AM_CONFIG_HEADER([config.h])
25
26# Checks for programs.
27AC_PROG_CC
28AC_SET_MAKE
29
30AC_PROG_YACC
31AM_PROG_LEX
32
33# libtool config
34AC_DISABLE_STATIC
35
36AC_PROG_LIBTOOL
37
38missing_libraries=""
39missing_headers=""
40missing_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.
46AC_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.
53if 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])
58fi
59
60if test ! -z "$missing_libraries"; then
61 AC_MSG_ERROR([missing libraries:$missing_libraries])
62fi
63
64# Checks for header files.
65RJK_FIND_GC_H
66AC_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
70AC_CHECK_HEADERS([getopt.h unistd.h],[:],[
71 missing_headers="$missing_headers $ac_header"
72])
73
74if test ! -z "$missing_headers"; then
75 AC_MSG_ERROR([missing headers:$missing_headers])
76fi
77
78# Checks for typedefs, structures, and compiler characteristics.
79AC_C_CONST
80AC_TYPE_SIZE_T
81AC_C_INLINE
82AC_CHECK_TYPES([_Bool])
83
84if 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
93fi
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.
98CC="${CC} -D_GNU_SOURCE"
99
100AH_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
119AC_CONFIG_FILES([Makefile
120 tests/Makefile])
121AC_OUTPUT