• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)
34AM_INIT_AUTOMAKE
35AC_CONFIG_MACRO_DIR([m4])
36
37
38dnl
39dnl Increment LIBREVISION if source code has changed at all
40dnl
41dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
42dnl
43dnl If the API changes compatibly (i.e. simply adding a new function
44dnl without changing or removing earlier interfaces), then increment LIBAGE.
45dnl
46dnl If the API changes incompatibly set LIBAGE back to 0
47dnl
48
49LIBCURRENT=7   # sync
50LIBREVISION=8  # with
51LIBAGE=6       # CMakeLists.txt!
52
53CPPFLAGS="${CPPFLAGS} -DHAVE_EXPAT_CONFIG_H"
54AC_CONFIG_HEADER(expat_config.h)
55
56sinclude(conftools/ac_c_bigendian_cross.m4)
57
58AC_LIBTOOL_WIN32_DLL
59AC_PROG_LIBTOOL
60
61AC_SUBST(LIBCURRENT)
62AC_SUBST(LIBREVISION)
63AC_SUBST(LIBAGE)
64
65dnl Checks for programs.
66AC_PROG_CC_C99
67AC_PROG_CXX
68AC_PROG_INSTALL
69
70if test "$GCC" = yes ; then
71    dnl
72    dnl Be careful about adding the -fexceptions option; some versions of
73    dnl GCC don't support it and it causes extra warnings that are only
74    dnl distracting; avoid.
75    dnl
76    OLDCFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes"
77    CFLAGS="$OLDCFLAGS -fexceptions"
78    AC_MSG_CHECKING(whether $CC accepts -fexceptions)
79    AC_TRY_LINK( , ,
80                   AC_MSG_RESULT(yes),
81                   AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS")
82    if test "x$CXXFLAGS" = x ; then
83    CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'`
84    fi
85
86    CFLAGS="${CFLAGS} -fno-strict-aliasing"
87    CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
88    LDFLAGS="${LDFLAGS} -fno-strict-aliasing"
89fi
90
91dnl Checks for header files.
92AC_HEADER_STDC
93
94dnl Checks for typedefs, structures, and compiler characteristics.
95
96dnl Note: Avoid using AC_C_BIGENDIAN because it does not
97dnl work in a cross compile.
98AC_C_BIGENDIAN_CROSS
99
100AC_C_CONST
101AC_TYPE_SIZE_T
102AC_CHECK_FUNCS(memmove bcopy)
103
104
105AC_ARG_WITH([xmlwf], [
106AS_HELP_STRING([--without-xmlwf], [do not build xmlwf])], [], [with_xmlwf=yes])
107AM_CONDITIONAL([WITH_XMLWF], [test x${with_xmlwf} = xyes])
108
109AM_CONDITIONAL([MINGW], [echo -- "${host}" | ${FGREP} mingw >/dev/null])
110AM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE >/dev/null])
111
112
113AC_ARG_WITH([libbsd], [
114AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])
115], [], [with_libbsd=no])
116AS_IF([test "x${with_libbsd}" != xno], [
117  AC_CHECK_LIB([bsd], [arc4random_buf], [], [
118    AS_IF([test "x${with_libbsd}" = xyes], [
119      AC_MSG_ERROR([Enforced use of libbsd cannot be satisfied.])
120    ])
121  ])
122])
123AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)])
124AC_LINK_IFELSE([AC_LANG_SOURCE([
125  #include <stdlib.h>  /* for arc4random_buf on BSD, for NULL */
126  #if defined(HAVE_LIBBSD)
127  # include <bsd/stdlib.h>
128  #endif
129  int main() {
130    arc4random_buf(NULL, 0U);
131    return 0;
132  }
133])], [
134    AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1],
135        [Define to 1 if you have the `arc4random_buf' function.])
136    AC_MSG_RESULT([yes])
137], [
138    AC_MSG_RESULT([no])
139
140    AC_MSG_CHECKING([for arc4random (BSD, macOS or libbsd)])
141    AC_LINK_IFELSE([AC_LANG_SOURCE([
142      #if defined(HAVE_LIBBSD)
143      # include <bsd/stdlib.h>
144      #else
145      # include <stdlib.h>
146      #endif
147      int main() {
148          arc4random();
149          return 0;
150      }
151    ])], [
152        AC_DEFINE([HAVE_ARC4RANDOM], [1],
153            [Define to 1 if you have the `arc4random' function.])
154        AC_MSG_RESULT([yes])
155    ], [
156        AC_MSG_RESULT([no])
157    ])
158])
159
160
161AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
162AC_LINK_IFELSE([AC_LANG_SOURCE([
163  #include <stdlib.h>  /* for NULL */
164  #include <sys/random.h>
165  int main() {
166    return getrandom(NULL, 0U, 0U);
167  }
168])], [
169    AC_DEFINE([HAVE_GETRANDOM], [1],
170        [Define to 1 if you have the `getrandom' function.])
171    AC_MSG_RESULT([yes])
172], [
173    AC_MSG_RESULT([no])
174
175    AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)])
176    AC_LINK_IFELSE([AC_LANG_SOURCE([
177      #include <stdlib.h>  /* for NULL */
178      #include <unistd.h>  /* for syscall */
179      #include <sys/syscall.h>  /* for SYS_getrandom */
180      int main() {
181        syscall(SYS_getrandom, NULL, 0, 0);
182        return 0;
183      }
184    ])], [
185        AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1],
186            [Define to 1 if you have `syscall' and `SYS_getrandom'.])
187        AC_MSG_RESULT([yes])
188    ], [
189        AC_MSG_RESULT([no])
190    ])
191])
192
193
194dnl Only needed for xmlwf:
195AC_CHECK_HEADERS(fcntl.h unistd.h)
196AC_TYPE_OFF_T
197AC_FUNC_MMAP
198
199if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then
200    FILEMAP=unixfilemap
201else
202    FILEMAP=readfilemap
203fi
204AC_SUBST(FILEMAP)
205
206
207dnl Some basic configuration:
208AC_DEFINE([XML_NS], 1,
209          [Define to make XML Namespaces functionality available.])
210AC_DEFINE([XML_DTD], 1,
211          [Define to make parameter entity parsing functionality available.])
212AC_DEFINE([XML_DEV_URANDOM], 1,
213          [Define to include code reading entropy from `/dev/urandom'.])
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_ARG_WITH([docbook], [AS_HELP_STRING([--with-docbook],
232    [enforce XML to man page compilation @<:@default=check@:>@])
233AS_HELP_STRING([--without-docbook],
234    [skip XML to man page compilation @<:@default=check@:>@])],
235  [],
236  [with_docbook=check])
237
238AC_ARG_VAR([DOCBOOK_TO_MAN], [docbook2x-man command])
239AS_IF([test "x$with_docbook" != xno],
240  [AC_CHECK_PROGS([DOCBOOK_TO_MAN], [docbook2x-man db2x_docbook2man docbook2man docbook-to-man])])
241AS_IF([test "x${DOCBOOK_TO_MAN}" = x -a "x$with_docbook" = xyes],
242  [AC_MSG_ERROR([Required program 'docbook2x-man' not found.])])
243AS_IF([test "x${DOCBOOK_TO_MAN}" != x -a "x$with_docbook" != xno],
244  [AS_IF([${DOCBOOK_TO_MAN} --help | grep -i -q -F sgmlbase],
245    [AC_MSG_ERROR([Your local ${DOCBOOK_TO_MAN} was found to work with SGML rather
246  than XML. Please install docbook2X and use variable DOCBOOK_TO_MAN to point
247  configure to command docbook2x-man of docbook2X.
248  Or use DOCBOOK_TO_MAN="xmlto man --skip-validation" if you have xmlto around.
249  You can also configure using --without-docbook if you can do without a man
250  page for xmlwf.])])])
251
252AM_CONDITIONAL(WITH_DOCBOOK, [test "x${DOCBOOK_TO_MAN}" != x])
253
254AC_CONFIG_FILES([Makefile expat.pc])
255AC_CONFIG_FILES([
256  doc/Makefile
257  examples/Makefile
258  lib/Makefile
259  tests/Makefile
260  tests/benchmark/Makefile
261  xmlwf/Makefile
262])
263AC_CONFIG_FILES([run.sh], [chmod +x run.sh])
264AC_OUTPUT
265