configure.ac revision 1.1.1.3
1dnl   configuration script for expat
2dnl   Process this file with autoconf to produce a configure script.
3dnl
4dnl   Copyright 2000 Clark Cooper
5dnl
6dnl   This file is part of EXPAT.
7dnl
8dnl   EXPAT is free software; you can redistribute it and/or modify it
9dnl   under the terms of the License (based on the MIT/X license) contained
10dnl   in the file COPYING that comes with this distribution.
11dnl
12
13dnl Ensure that Expat is configured with autoconf 2.58 or newer
14AC_PREREQ(2.58)
15
16dnl Get the version number of Expat, using m4's esyscmd() command to run
17dnl the command at m4-generation time. This allows us to create an m4
18dnl symbol holding the correct version number. AC_INIT() requires the
19dnl version number at m4-time, rather than when ./configure is run, so
20dnl all this must happen as part of m4, not as part of the shell code
21dnl contained in ./configure.
22dnl
23dnl NOTE: esyscmd() is a GNU M4 extension. Thus, we wrap it in an appropriate
24dnl test. I believe this test will work, but I don't have a place with non-
25dnl GNU M4 to test it right now.
26define([expat_version], ifdef([__gnu__],
27                              [esyscmd(conftools/get-version.sh lib/expat.h)],
28                              [2.2.x]))
29AC_INIT(expat, expat_version, expat-bugs@libexpat.org)
30undefine([expat_version])
31
32AC_CONFIG_SRCDIR(Makefile.in)
33AC_CONFIG_AUX_DIR(conftools)
34AC_CONFIG_MACRO_DIR([m4])
35
36
37dnl
38dnl Increment LIBREVISION if source code has changed at all
39dnl
40dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
41dnl
42dnl If the API changes compatibly (i.e. simply adding a new function
43dnl without changing or removing earlier interfaces), then increment LIBAGE.
44dnl 
45dnl If the API changes incompatibly set LIBAGE back to 0
46dnl
47
48LIBCURRENT=7   # sync
49LIBREVISION=3  # with
50LIBAGE=6       # CMakeLists.txt!
51
52AC_CONFIG_HEADER(expat_config.h)
53
54sinclude(conftools/ac_c_bigendian_cross.m4)
55
56AC_LIBTOOL_WIN32_DLL
57AC_PROG_LIBTOOL
58
59AC_SUBST(LIBCURRENT)
60AC_SUBST(LIBREVISION)
61AC_SUBST(LIBAGE)
62
63dnl Checks for programs.
64AC_PROG_CC
65AC_PROG_CXX
66AC_PROG_INSTALL
67
68if test "$GCC" = yes ; then
69    dnl
70    dnl Be careful about adding the -fexceptions option; some versions of
71    dnl GCC don't support it and it causes extra warnings that are only
72    dnl distracting; avoid.
73    dnl
74    OLDCFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes"
75    CFLAGS="$OLDCFLAGS -fexceptions"
76    AC_MSG_CHECKING(whether $CC accepts -fexceptions)
77    AC_TRY_LINK( , ,
78                   AC_MSG_RESULT(yes),
79                   AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS")
80    if test "x$CXXFLAGS" = x ; then
81    CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'`
82    fi
83
84    CFLAGS="${CFLAGS} -fno-strict-aliasing"
85    CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
86    LDFLAGS="${LDFLAGS} -fno-strict-aliasing"
87fi
88
89dnl Checks for header files.
90AC_HEADER_STDC
91
92dnl Checks for typedefs, structures, and compiler characteristics.
93
94dnl Note: Avoid using AC_C_BIGENDIAN because it does not
95dnl work in a cross compile.
96AC_C_BIGENDIAN_CROSS
97
98AC_C_CONST
99AC_TYPE_SIZE_T
100AC_CHECK_FUNCS(memmove bcopy)
101
102
103AC_ARG_WITH([libbsd], [
104AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])
105], [], [with_libbsd=no])
106AS_IF([test "x${with_libbsd}" != xno], [
107  AC_CHECK_LIB([bsd], [arc4random_buf], [], [
108    AS_IF([test "x${with_libbsd}" = xyes], [
109      AC_MSG_ERROR([Enforced use of libbsd cannot be satisfied.])
110    ])
111  ])
112])
113AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)])
114AC_LINK_IFELSE([AC_LANG_SOURCE([
115  #include <stdlib.h>  /* for arc4random_buf on BSD, for NULL */
116  #if defined(HAVE_LIBBSD)
117  # include <bsd/stdlib.h>
118  #endif
119  int main() {
120    arc4random_buf(NULL, 0U);
121    return 0;
122  }
123])], [
124    AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1],
125        [Define to 1 if you have the `arc4random_buf' function.])
126    AC_MSG_RESULT([yes])
127], [
128    AC_MSG_RESULT([no])
129])
130
131
132AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
133AC_COMPILE_IFELSE([AC_LANG_SOURCE([
134  #include <stdlib.h>  /* for NULL */
135  #include <sys/random.h>
136  int main() {
137    return getrandom(NULL, 0U, 0U);
138  }
139])], [
140    AC_DEFINE([HAVE_GETRANDOM], [1],
141        [Define to 1 if you have the `getrandom' function.])
142    AC_MSG_RESULT([yes])
143], [
144    AC_MSG_RESULT([no])
145
146    AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)])
147    AC_LINK_IFELSE([AC_LANG_SOURCE([
148      #include <stdlib.h>  /* for NULL */
149      #include <unistd.h>  /* for syscall */
150      #include <sys/syscall.h>  /* for SYS_getrandom */
151      int main() {
152        syscall(SYS_getrandom, NULL, 0, 0);
153        return 0;
154      }
155    ])], [
156        AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1],
157            [Define to 1 if you have `syscall' and `SYS_getrandom'.])
158        AC_MSG_RESULT([yes])
159    ], [
160        AC_MSG_RESULT([no])
161    ])
162])
163
164
165dnl Only needed for xmlwf:
166AC_CHECK_HEADERS(fcntl.h unistd.h)
167AC_TYPE_OFF_T
168AC_FUNC_MMAP
169
170if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then
171    FILEMAP=unixfilemap
172else
173    FILEMAP=readfilemap
174fi
175AC_SUBST(FILEMAP)
176
177dnl Needed for the test support code; this was found at
178dnl http://lists.gnu.org/archive/html/bug-autoconf/2002-07/msg00028.html
179
180# AC_CPP_FUNC
181# ------------------ #
182# Checks to see if ANSI C99 CPP variable __func__ works.
183# If not, perhaps __FUNCTION__ works instead. 
184# If not, we'll just define __func__ to "". 
185AC_DEFUN([AC_CPP_FUNC],
186[AC_REQUIRE([AC_PROG_CC_STDC])dnl
187AC_CACHE_CHECK([for an ANSI C99-conforming __func__], ac_cv_cpp_func,
188[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
189[[const char *foo = __func__;]])],
190  [ac_cv_cpp_func=yes], 
191  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
192[[const char *foo = __FUNCTION__;]])],
193  [ac_cv_cpp_func=__FUNCTION__], 
194  [ac_cv_cpp_func=no])])])
195if test $ac_cv_cpp_func = __FUNCTION__; then
196  AC_DEFINE(__func__,__FUNCTION__,
197            [Define to __FUNCTION__ or "" if `__func__' does not conform to 
198ANSI C.])
199elif test $ac_cv_cpp_func = no; then
200  AC_DEFINE(__func__,"",
201            [Define to __FUNCTION__ or "" if `__func__' does not conform to 
202ANSI C.])
203fi
204])# AC_CPP_FUNC
205
206AC_CPP_FUNC
207
208
209dnl Some basic configuration:
210AC_DEFINE([XML_NS], 1,
211          [Define to make XML Namespaces functionality available.])
212AC_DEFINE([XML_DTD], 1,
213          [Define to make parameter entity parsing functionality available.])
214
215AC_ARG_ENABLE([xml-context],
216  AS_HELP_STRING([--enable-xml-context @<:@COUNT@:>@],
217    [Retain context around the current parse point;
218        default is enabled and a size of 1024 bytes])
219AS_HELP_STRING([--disable-xml-context],
220    [Do not retain context around the current parse point]),
221  [enable_xml_context=${enableval}])
222AS_IF([test "x${enable_xml_context}" != "xno"], [
223  AS_IF([test "x${enable_xml_context}" == "xyes" \
224      -o "x${enable_xml_context}" == "x"], [
225    enable_xml_context=1024
226  ])
227  AC_DEFINE_UNQUOTED([XML_CONTEXT_BYTES], [${enable_xml_context}],
228    [Define to specify how much context to retain around the current parse point.])
229])
230
231AC_CONFIG_FILES([Makefile expat.pc])
232AC_CONFIG_FILES([run.sh], [chmod +x run.sh])
233AC_OUTPUT
234
235abs_srcdir="`cd $srcdir && pwd`"
236abs_builddir="`pwd`"
237if test "$abs_srcdir" != "$abs_builddir"; then
238  make mkdir-init
239fi
240