Merge branch 'tizen_base' into tizen
[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 AM_INIT_AUTOMAKE
35 AC_CONFIG_MACRO_DIR([m4])
36
37
38 dnl
39 dnl Increment LIBREVISION if source code has changed at all
40 dnl
41 dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
42 dnl
43 dnl If the API changes compatibly (i.e. simply adding a new function
44 dnl without changing or removing earlier interfaces), then increment LIBAGE.
45 dnl 
46 dnl If the API changes incompatibly set LIBAGE back to 0
47 dnl
48
49 LIBCURRENT=7   # sync
50 LIBREVISION=7  # with
51 LIBAGE=6       # CMakeLists.txt!
52
53 CPPFLAGS="${CPPFLAGS} -DHAVE_EXPAT_CONFIG_H"
54 AC_CONFIG_HEADER(expat_config.h)
55
56 sinclude(conftools/ac_c_bigendian_cross.m4)
57
58 AC_LIBTOOL_WIN32_DLL
59 AC_PROG_LIBTOOL
60
61 AC_SUBST(LIBCURRENT)
62 AC_SUBST(LIBREVISION)
63 AC_SUBST(LIBAGE)
64
65 dnl Checks for programs.
66 AC_PROG_CC_C99
67 AC_PROG_CXX
68 AC_PROG_INSTALL
69
70 if 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"
89 fi
90
91 dnl Checks for header files.
92 AC_HEADER_STDC
93
94 dnl Checks for typedefs, structures, and compiler characteristics.
95
96 dnl Note: Avoid using AC_C_BIGENDIAN because it does not
97 dnl work in a cross compile.
98 AC_C_BIGENDIAN_CROSS
99
100 AC_C_CONST
101 AC_TYPE_SIZE_T
102 AC_CHECK_FUNCS(memmove bcopy)
103
104
105 AC_ARG_WITH([xmlwf], [
106 AS_HELP_STRING([--without-xmlwf], [do not build xmlwf])], [], [with_xmlwf=yes])
107 AM_CONDITIONAL([WITH_XMLWF], [test x${with_xmlwf} = xyes])
108
109 AM_CONDITIONAL([MINGW], [echo -- "${host}" | fgrep -q mingw])
110 AM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | fgrep -q XML_UNICODE])
111
112
113 AC_ARG_WITH([libbsd], [
114 AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])
115 ], [], [with_libbsd=no])
116 AS_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 ])
123 AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)])
124 AC_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
161 AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
162 AC_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
194 dnl Only needed for xmlwf:
195 AC_CHECK_HEADERS(fcntl.h unistd.h)
196 AC_TYPE_OFF_T
197 AC_FUNC_MMAP
198
199 if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then
200     FILEMAP=unixfilemap
201 else
202     FILEMAP=readfilemap
203 fi
204 AC_SUBST(FILEMAP)
205
206
207 dnl Some basic configuration:
208 AC_DEFINE([XML_NS], 1,
209           [Define to make XML Namespaces functionality available.])
210 AC_DEFINE([XML_DTD], 1,
211           [Define to make parameter entity parsing functionality available.])
212 AC_DEFINE([XML_DEV_URANDOM], 1,
213           [Define to include code reading entropy from `/dev/urandom'.])
214
215 AC_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])
219 AS_HELP_STRING([--disable-xml-context],
220     [Do not retain context around the current parse point]),
221   [enable_xml_context=${enableval}])
222 AS_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
231 AC_ARG_WITH([docbook], [AS_HELP_STRING([--with-docbook],
232     [enforce XML to man page compilation @<:@default=check@:>@])
233 AS_HELP_STRING([--without-docbook],
234     [skip XML to man page compilation @<:@default=check@:>@])],
235   [],
236   [with_docbook=check])
237
238 AC_ARG_VAR([DOCBOOK_TO_MAN], [docbook2x-man command])
239 AS_IF([test "x$with_docbook" != xno],
240   [AC_CHECK_PROGS([DOCBOOK_TO_MAN], [docbook2x-man docbook2man docbook-to-man],
241   [if test "x$with_docbook" != xcheck; then 
242     AC_MSG_ERROR([Required program 'docbook2x-man' not found.])])])
243
244 AM_CONDITIONAL(WITH_DOCBOOK, [test x${DOCBOOK_TO_MAN} != x])
245
246 AC_CONFIG_FILES([Makefile expat.pc])
247 AC_CONFIG_FILES([
248   doc/Makefile
249   examples/Makefile
250   lib/Makefile
251   tests/Makefile
252   tests/benchmark/Makefile
253   xmlwf/Makefile
254 ])
255 AC_CONFIG_FILES([run.sh], [chmod +x run.sh])
256 AC_OUTPUT