Imported Upstream version 2.2.3
[platform/upstream/expat.git] / configure.ac
1 dnl   configuration script for expat
2 dnl   Process this file with autoconf to produce a configure script.
3 dnl
4 dnl   Copyright 2000 Clark Cooper
5 dnl
6 dnl   This file is part of EXPAT.
7 dnl
8 dnl   EXPAT is free software; you can redistribute it and/or modify it
9 dnl   under the terms of the License (based on the MIT/X license) contained
10 dnl   in the file COPYING that comes with this distribution.
11 dnl
12
13 dnl Ensure that Expat is configured with autoconf 2.58 or newer
14 AC_PREREQ(2.58)
15
16 dnl Get the version number of Expat, using m4's esyscmd() command to run
17 dnl the command at m4-generation time. This allows us to create an m4
18 dnl symbol holding the correct version number. AC_INIT() requires the
19 dnl version number at m4-time, rather than when ./configure is run, so
20 dnl all this must happen as part of m4, not as part of the shell code
21 dnl contained in ./configure.
22 dnl
23 dnl NOTE: esyscmd() is a GNU M4 extension. Thus, we wrap it in an appropriate
24 dnl test. I believe this test will work, but I don't have a place with non-
25 dnl GNU M4 to test it right now.
26 define([expat_version], ifdef([__gnu__],
27                               [esyscmd(conftools/get-version.sh lib/expat.h)],
28                               [2.2.x]))
29 AC_INIT(expat, expat_version, expat-bugs@libexpat.org)
30 undefine([expat_version])
31
32 AC_CONFIG_SRCDIR(Makefile.in)
33 AC_CONFIG_AUX_DIR(conftools)
34 AC_CONFIG_MACRO_DIR([m4])
35
36
37 dnl
38 dnl Increment LIBREVISION if source code has changed at all
39 dnl
40 dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
41 dnl
42 dnl If the API changes compatibly (i.e. simply adding a new function
43 dnl without changing or removing earlier interfaces), then increment LIBAGE.
44 dnl 
45 dnl If the API changes incompatibly set LIBAGE back to 0
46 dnl
47
48 LIBCURRENT=7   # sync
49 LIBREVISION=5  # with
50 LIBAGE=6       # CMakeLists.txt!
51
52 AC_CONFIG_HEADER(expat_config.h)
53
54 sinclude(conftools/ac_c_bigendian_cross.m4)
55
56 AC_LIBTOOL_WIN32_DLL
57 AC_PROG_LIBTOOL
58
59 AC_SUBST(LIBCURRENT)
60 AC_SUBST(LIBREVISION)
61 AC_SUBST(LIBAGE)
62
63 dnl Checks for programs.
64 AC_PROG_CC_C99
65 AC_PROG_CXX
66 AC_PROG_INSTALL
67
68 if 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"
87 fi
88
89 dnl Checks for header files.
90 AC_HEADER_STDC
91
92 dnl Checks for typedefs, structures, and compiler characteristics.
93
94 dnl Note: Avoid using AC_C_BIGENDIAN because it does not
95 dnl work in a cross compile.
96 AC_C_BIGENDIAN_CROSS
97
98 AC_C_CONST
99 AC_TYPE_SIZE_T
100 AC_CHECK_FUNCS(memmove bcopy)
101
102
103 AC_ARG_WITH([libbsd], [
104 AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])
105 ], [], [with_libbsd=no])
106 AS_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 ])
113 AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)])
114 AC_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     AC_MSG_CHECKING([for arc4random (BSD, macOS or libbsd)])
131     AC_LINK_IFELSE([AC_LANG_SOURCE([
132       #if defined(HAVE_LIBBSD)
133       # include <bsd/stdlib.h>
134       #else
135       # include <stdlib.h>
136       #endif
137       int main() {
138           arc4random();
139           return 0;
140       }
141     ])], [
142         AC_DEFINE([HAVE_ARC4RANDOM], [1],
143             [Define to 1 if you have the `arc4random' function.])
144         AC_MSG_RESULT([yes])
145     ], [
146         AC_MSG_RESULT([no])
147     ])
148 ])
149
150
151 AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
152 AC_LINK_IFELSE([AC_LANG_SOURCE([
153   #include <stdlib.h>  /* for NULL */
154   #include <sys/random.h>
155   int main() {
156     return getrandom(NULL, 0U, 0U);
157   }
158 ])], [
159     AC_DEFINE([HAVE_GETRANDOM], [1],
160         [Define to 1 if you have the `getrandom' function.])
161     AC_MSG_RESULT([yes])
162 ], [
163     AC_MSG_RESULT([no])
164
165     AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)])
166     AC_LINK_IFELSE([AC_LANG_SOURCE([
167       #include <stdlib.h>  /* for NULL */
168       #include <unistd.h>  /* for syscall */
169       #include <sys/syscall.h>  /* for SYS_getrandom */
170       int main() {
171         syscall(SYS_getrandom, NULL, 0, 0);
172         return 0;
173       }
174     ])], [
175         AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1],
176             [Define to 1 if you have `syscall' and `SYS_getrandom'.])
177         AC_MSG_RESULT([yes])
178     ], [
179         AC_MSG_RESULT([no])
180     ])
181 ])
182
183
184 dnl Only needed for xmlwf:
185 AC_CHECK_HEADERS(fcntl.h unistd.h)
186 AC_TYPE_OFF_T
187 AC_FUNC_MMAP
188
189 if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then
190     FILEMAP=unixfilemap
191 else
192     FILEMAP=readfilemap
193 fi
194 AC_SUBST(FILEMAP)
195
196
197 dnl Some basic configuration:
198 AC_DEFINE([XML_NS], 1,
199           [Define to make XML Namespaces functionality available.])
200 AC_DEFINE([XML_DTD], 1,
201           [Define to make parameter entity parsing functionality available.])
202 AC_DEFINE([XML_DEV_URANDOM], 1,
203           [Define to include code reading entropy from `/dev/urandom'.])
204
205 AC_ARG_ENABLE([xml-context],
206   AS_HELP_STRING([--enable-xml-context @<:@COUNT@:>@],
207     [Retain context around the current parse point;
208         default is enabled and a size of 1024 bytes])
209 AS_HELP_STRING([--disable-xml-context],
210     [Do not retain context around the current parse point]),
211   [enable_xml_context=${enableval}])
212 AS_IF([test "x${enable_xml_context}" != "xno"], [
213   AS_IF([test "x${enable_xml_context}" = "xyes" \
214       -o "x${enable_xml_context}" = "x"], [
215     enable_xml_context=1024
216   ])
217   AC_DEFINE_UNQUOTED([XML_CONTEXT_BYTES], [${enable_xml_context}],
218     [Define to specify how much context to retain around the current parse point.])
219 ])
220
221 AC_CONFIG_FILES([Makefile expat.pc])
222 AC_CONFIG_FILES([run.sh], [chmod +x run.sh])
223 AC_OUTPUT
224
225 abs_srcdir="`cd $srcdir && pwd`"
226 abs_builddir="`pwd`"
227 if test "$abs_srcdir" != "$abs_builddir"; then
228   make mkdir-init
229 fi