xref: /freebsd/contrib/expat/configure.ac (revision fe9278888fd4414abe2d922e469cf608005f4c65)
1be8aff81SXin LIdnl   configuration script for expat
2be8aff81SXin LIdnl   Process this file with autoconf to produce a configure script.
3cc68614dSXin LIdnl                            __  __            _
4cc68614dSXin LIdnl                         ___\ \/ /_ __   __ _| |_
5cc68614dSXin LIdnl                        / _ \\  /| '_ \ / _` | __|
6cc68614dSXin LIdnl                       |  __//  \| |_) | (_| | |_
7cc68614dSXin LIdnl                        \___/_/\_\ .__/ \__,_|\__|
8cc68614dSXin LIdnl                                 |_| XML parser
9be8aff81SXin LIdnl
10cc68614dSXin LIdnl   Copyright (c) 2000      Clark Cooper <coopercc@users.sourceforge.net>
11cc68614dSXin LIdnl   Copyright (c) 2000-2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
12cc68614dSXin LIdnl   Copyright (c) 2001-2003 Greg Stein <gstein@users.sourceforge.net>
13cc68614dSXin LIdnl   Copyright (c) 2006-2012 Karl Waclawek <karl@waclawek.net>
14*fe927888SPhilip Paepsdnl   Copyright (c) 2016-2025 Sebastian Pipping <sebastian@pipping.org>
15cc68614dSXin LIdnl   Copyright (c) 2017      S. P. Zeidler <spz@netbsd.org>
16cc68614dSXin LIdnl   Copyright (c) 2017      Stephen Groat <stephen@groat.us>
17cc68614dSXin LIdnl   Copyright (c) 2017-2020 Joe Orton <jorton@redhat.com>
18cc68614dSXin LIdnl   Copyright (c) 2018      Yury Gribov <tetra2005@gmail.com>
19cc68614dSXin LIdnl   Copyright (c) 2018      Benjamin Peterson <benjamin@python.org>
20cc68614dSXin LIdnl   Copyright (c) 2018      Marco Maggi <marco.maggi-ipsu@poste.it>
21cc68614dSXin LIdnl   Copyright (c) 2018      KangLin <kl222@126.com>
22cc68614dSXin LIdnl   Copyright (c) 2019      Mohammed Khajapasha <mohammed.khajapasha@intel.com>
23cc68614dSXin LIdnl   Copyright (c) 2019      Kishore Kunche <kishore.kunche@intel.com>
24cc68614dSXin LIdnl   Copyright (c) 2020      Jeffrey Walton <noloader@gmail.com>
25ffd294a1SEnji Cooperdnl   Copyright (c) 2024      Ferenc Géczi <ferenc.gm@gmail.com>
26ffd294a1SEnji Cooperdnl   Copyright (c) 2024      Dag-Erling Smørgrav <des@des.dev>
27cc68614dSXin LIdnl   Licensed under the MIT license:
28be8aff81SXin LIdnl
29cc68614dSXin LIdnl   Permission is  hereby granted,  free of charge,  to any  person obtaining
30cc68614dSXin LIdnl   a  copy  of  this  software   and  associated  documentation  files  (the
31cc68614dSXin LIdnl   "Software"),  to  deal in  the  Software  without restriction,  including
32cc68614dSXin LIdnl   without  limitation the  rights  to use,  copy,  modify, merge,  publish,
33cc68614dSXin LIdnl   distribute, sublicense, and/or sell copies of the Software, and to permit
34cc68614dSXin LIdnl   persons  to whom  the Software  is  furnished to  do so,  subject to  the
35cc68614dSXin LIdnl   following conditions:
36be8aff81SXin LIdnl
37cc68614dSXin LIdnl   The above copyright  notice and this permission notice  shall be included
38cc68614dSXin LIdnl   in all copies or substantial portions of the Software.
39be8aff81SXin LIdnl
40cc68614dSXin LIdnl   THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
41cc68614dSXin LIdnl   EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
42cc68614dSXin LIdnl   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
43cc68614dSXin LIdnl   NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
44cc68614dSXin LIdnl   DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
45cc68614dSXin LIdnl   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
46cc68614dSXin LIdnl   USE OR OTHER DEALINGS IN THE SOFTWARE.
47be8aff81SXin LI
486b2c1e49SXin LIdnl Ensure that Expat is configured with autoconf 2.69 or newer.
49cc68614dSXin LIAC_PREREQ([2.69])
50be8aff81SXin LI
51be8aff81SXin LIdnl Get the version number of Expat, using m4's esyscmd() command to run
52be8aff81SXin LIdnl the command at m4-generation time. This allows us to create an m4
53cc68614dSXin LIdnl symbol holding the correct version number. AC_INIT requires the
54be8aff81SXin LIdnl version number at m4-time, rather than when ./configure is run, so
55be8aff81SXin LIdnl all this must happen as part of m4, not as part of the shell code
56be8aff81SXin LIdnl contained in ./configure.
57be8aff81SXin LIdnl
58be8aff81SXin LIdnl NOTE: esyscmd() is a GNU M4 extension. Thus, we wrap it in an appropriate
59be8aff81SXin LIdnl test. I believe this test will work, but I don't have a place with non-
60be8aff81SXin LIdnl GNU M4 to test it right now.
616b2c1e49SXin LIm4_define([expat_version],
626b2c1e49SXin LI  m4_ifdef([__gnu__],
63be8aff81SXin LI           [esyscmd(conftools/get-version.sh lib/expat.h)],
64be8aff81SXin LI           [2.2.x]))
654543ef51SXin LIAC_INIT([expat], expat_version, [https://github.com/libexpat/libexpat/issues])
666b2c1e49SXin LIm4_undefine([expat_version])
67be8aff81SXin LI
686b2c1e49SXin LIAC_CONFIG_SRCDIR([Makefile.in])
696b2c1e49SXin LIAC_CONFIG_AUX_DIR([conftools])
70be8aff81SXin LIAC_CONFIG_MACRO_DIR([m4])
716b2c1e49SXin LIAC_CANONICAL_HOST
726b2c1e49SXin LIAM_INIT_AUTOMAKE
734543ef51SXin LIAM_MAINTAINER_MODE([enable])  # to allow argument --disable-maintainer-mode
74be8aff81SXin LI
75be8aff81SXin LI
76be8aff81SXin LIdnl
77be8aff81SXin LIdnl Increment LIBREVISION if source code has changed at all
78be8aff81SXin LIdnl
79be8aff81SXin LIdnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
80be8aff81SXin LIdnl
81be8aff81SXin LIdnl If the API changes compatibly (i.e. simply adding a new function
82be8aff81SXin LIdnl without changing or removing earlier interfaces), then increment LIBAGE.
83be8aff81SXin LIdnl
84be8aff81SXin LIdnl If the API changes incompatibly set LIBAGE back to 0
85be8aff81SXin LIdnl
86be8aff81SXin LI
87908f215eSXin LILIBCURRENT=11  # sync
88*fe927888SPhilip PaepsLIBREVISION=2  # with
89908f215eSXin LILIBAGE=10      # CMakeLists.txt!
90be8aff81SXin LI
91cc68614dSXin LIAC_CONFIG_HEADERS([expat_config.h])
92dc58b3fcSXin LIAH_TOP([#ifndef EXPAT_CONFIG_H
93dc58b3fcSXin LI#define EXPAT_CONFIG_H 1])
94dc58b3fcSXin LIAH_BOTTOM([#endif // ndef EXPAT_CONFIG_H])
95be8aff81SXin LI
966b2c1e49SXin LIAM_PROG_AR
976b2c1e49SXin LIAC_PROG_INSTALL
986b2c1e49SXin LIAC_PROG_LN_S
996b2c1e49SXin LIAC_PROG_MAKE_SET
100be8aff81SXin LI
1016b2c1e49SXin LILT_PREREQ([2.4])
1026b2c1e49SXin LILT_INIT([win32-dll])
103be8aff81SXin LI
104be8aff81SXin LIAC_SUBST(LIBCURRENT)
105be8aff81SXin LIAC_SUBST(LIBREVISION)
106be8aff81SXin LIAC_SUBST(LIBAGE)
107be8aff81SXin LI
1086b2c1e49SXin LIAC_LANG([C])
1090a48773fSEric van GyzenAC_PROG_CC_C99
110cc68614dSXin LI
1114543ef51SXin LIAS_IF([test "${ac_cv_prog_cc_c99}" = no],
1124543ef51SXin LI  [AC_MSG_ERROR([Expat requires a C99 compiler.])])
1134543ef51SXin LI
1146b2c1e49SXin LIAS_IF([test "$GCC" = yes],
115cc68614dSXin LI  [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [AM_CFLAGS])
116be8aff81SXin LI   dnl Be careful about adding the -fexceptions option; some versions of
117be8aff81SXin LI   dnl GCC don't support it and it causes extra warnings that are only
118be8aff81SXin LI   dnl distracting; avoid.
119cc68614dSXin LI   AX_APPEND_COMPILE_FLAGS([-fexceptions], [AM_CFLAGS])
120cc68614dSXin LI   AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -Wmissing-prototypes -Wstrict-prototypes], [AM_CFLAGS])
121cc68614dSXin LI   AX_APPEND_COMPILE_FLAGS([-pedantic -Wduplicated-cond -Wduplicated-branches -Wlogical-op], [AM_CFLAGS])
122cc68614dSXin LI   AX_APPEND_COMPILE_FLAGS([-Wrestrict -Wnull-dereference -Wjump-misses-init -Wdouble-promotion], [AM_CFLAGS])
123cc68614dSXin LI   AX_APPEND_COMPILE_FLAGS([-Wshadow -Wformat=2 -Wno-pedantic-ms-format -Wmisleading-indentation], [AM_CFLAGS])])
1240a48773fSEric van Gyzen
1256b2c1e49SXin LIAC_LANG_PUSH([C++])
1266b2c1e49SXin LIAC_PROG_CXX
127cc68614dSXin LI
1286b2c1e49SXin LIAS_IF([test "$GCC" = yes],
129cc68614dSXin LI  [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [AM_CXXFLAGS])
1306b2c1e49SXin LI   dnl Be careful about adding the -fexceptions option; some versions of
1316b2c1e49SXin LI   dnl GCC don't support it and it causes extra warnings that are only
1326b2c1e49SXin LI   dnl distracting; avoid.
133cc68614dSXin LI   AX_APPEND_COMPILE_FLAGS([-fexceptions], [AM_CXXFLAGS])
134cc68614dSXin LI   AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [AM_CXXFLAGS])])
1356b2c1e49SXin LIAC_LANG_POP([C++])
1366b2c1e49SXin LI
1376b2c1e49SXin LIAS_IF([test "$GCC" = yes],
138cc68614dSXin LI  [AX_APPEND_LINK_FLAGS([-fno-strict-aliasing],[AM_LDFLAGS])])
1396b2c1e49SXin LI
1406b2c1e49SXin LIdnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang (issue #312)
1416b2c1e49SXin LIAS_CASE(["$LD"],[*clang*],
1426b2c1e49SXin LI  [AS_CASE(["${host_os}"],
1436b2c1e49SXin LI     [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
1446b2c1e49SXin LI
1456b2c1e49SXin LIEXPATCFG_COMPILER_SUPPORTS_VISIBILITY([
146cc68614dSXin LI  AX_APPEND_FLAG([-fvisibility=hidden],              [AM_CFLAGS])
14771f0c44aSXin LI  AS_IF([test "${enable_shared}" = yes],
14871f0c44aSXin LI        [AX_APPEND_FLAG([-DXML_ENABLE_VISIBILITY=1], [AM_CPPFLAGS])])])
149be8aff81SXin LI
150be8aff81SXin LIdnl Checks for typedefs, structures, and compiler characteristics.
151be8aff81SXin LI
1526b2c1e49SXin LIdnl We define BYTEORDER to 1234 when the platform is little endian; it
1536b2c1e49SXin LIdnl defines it to 4321 when the  platform is big endian.  We also define
1546b2c1e49SXin LIdnl WORDS_BIGENDIAN to 1 when the platform is big endian.
1556b2c1e49SXin LIdnl
1566b2c1e49SXin LIdnl A  long time  ago (early 2000  years) AC_C_BIGENDIAN  was considered
1576b2c1e49SXin LIdnl wrong when cross compiling, now (2018, GNU Autoconf 2.69) we assume
1586b2c1e49SXin LIdnl it is fine.
1596b2c1e49SXin LIAC_C_BIGENDIAN([AC_DEFINE([WORDS_BIGENDIAN], 1)
1606b2c1e49SXin LI                AS_VAR_SET([BYTEORDER], 4321)],
1616b2c1e49SXin LI               [AS_VAR_SET([BYTEORDER], 1234)])
1626b2c1e49SXin LIAC_DEFINE_UNQUOTED([BYTEORDER], $BYTEORDER, [1234 = LILENDIAN, 4321 = BIGENDIAN])
163be8aff81SXin LI
164be8aff81SXin LIAC_C_CONST
165be8aff81SXin LI
1666b2c1e49SXin LIAC_ARG_WITH([xmlwf],
1676b2c1e49SXin LI  [AS_HELP_STRING([--without-xmlwf], [do not build xmlwf])],
1686b2c1e49SXin LI  [],
1696b2c1e49SXin LI  [with_xmlwf=yes])
1700a48773fSEric van GyzenAM_CONDITIONAL([WITH_XMLWF], [test x${with_xmlwf} = xyes])
1710a48773fSEric van Gyzen
1726b2c1e49SXin LIAC_ARG_WITH([examples],
1736b2c1e49SXin LI  [AS_HELP_STRING([--without-examples], [do not build examples @<:@default=included@:>@])],
1746b2c1e49SXin LI  [],
1756b2c1e49SXin LI  [with_examples=yes])
1766b2c1e49SXin LIAM_CONDITIONAL([WITH_EXAMPLES], [test x${with_examples} = xyes])
1776b2c1e49SXin LI
1786b2c1e49SXin LIAC_ARG_WITH([tests],
1796b2c1e49SXin LI  [AS_HELP_STRING([--without-tests], [do not build tests @<:@default=included@:>@])],
1806b2c1e49SXin LI  [],
1816b2c1e49SXin LI  [with_tests=yes])
1826b2c1e49SXin LIAM_CONDITIONAL([WITH_TESTS], [test x${with_tests} = xyes])
1836b2c1e49SXin LI
1844543ef51SXin LIAS_IF([test x${with_tests} = xyes],
1854543ef51SXin LI      [AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])])
1866b2c1e49SXin LI
1876b2c1e49SXin LIAS_VAR_SET([EXPATCFG_ON_MINGW],[no])
1886b2c1e49SXin LIAS_CASE("${host_os}",
1896b2c1e49SXin LI  [mingw*],
1906b2c1e49SXin LI  [AS_VAR_SET([EXPATCFG_ON_MINGW],[yes])
1916b2c1e49SXin LI   AC_MSG_NOTICE([detected OS: MinGW])])
1926b2c1e49SXin LIAM_CONDITIONAL([MINGW], [test x${EXPATCFG_ON_MINGW} = xyes])
1936b2c1e49SXin LI
194cc68614dSXin LIdnl Note: Prefix "_INTERNAL_" here means exclusive use inside of file configure.ac
1950a48773fSEric van GyzenAM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE >/dev/null])
196cc68614dSXin LIAM_CONDITIONAL([_INTERNAL_UNICODE_WCHAR_T], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE_WCHAR_T >/dev/null])
197cc68614dSXin LIAM_CONDITIONAL([_INTERNAL_MIN_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_MIN_SIZE >/dev/null])
198cc68614dSXin LIAM_CONDITIONAL([_INTERNAL_LARGE_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_LARGE_SIZE >/dev/null])
1990a48773fSEric van Gyzen
200cc68614dSXin LILT_LIB_M
2010a48773fSEric van Gyzen
2026b2c1e49SXin LIAC_ARG_WITH([libbsd],
2036b2c1e49SXin LI  [AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])],
2046b2c1e49SXin LI  [],
2056b2c1e49SXin LI  [with_libbsd=no])
2066b2c1e49SXin LIAS_IF([test "x${with_libbsd}" != xno],
2076b2c1e49SXin LI  [AC_CHECK_LIB([bsd],
2086b2c1e49SXin LI     [arc4random_buf],
2096b2c1e49SXin LI     [],
2106b2c1e49SXin LI     [AS_IF([test "x${with_libbsd}" = xyes],
2116b2c1e49SXin LI        [AC_MSG_ERROR([Enforced use of libbsd cannot be satisfied.])])])])
2124543ef51SXin LIAC_MSG_CHECKING([for arc4random_buf (BSD, libbsd or glibc 2.36+)])
2130a48773fSEric van GyzenAC_LINK_IFELSE([AC_LANG_SOURCE([
2140a48773fSEric van Gyzen    #if defined(HAVE_LIBBSD)
2150a48773fSEric van Gyzen    # include <bsd/stdlib.h>
2164543ef51SXin LI    #else
2174543ef51SXin LI    # include <stdlib.h>  /* for arc4random_buf on BSD */
2180a48773fSEric van Gyzen    #endif
219ffd294a1SEnji Cooper    int main(void) {
2204543ef51SXin LI      char dummy[[123]];  // double brackets for m4
2214543ef51SXin LI      arc4random_buf(dummy, 0U);
2220a48773fSEric van Gyzen      return 0;
2230a48773fSEric van Gyzen    }
2246b2c1e49SXin LI  ])],
2256b2c1e49SXin LI  [AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1], [Define to 1 if you have the `arc4random_buf' function.])
2266b2c1e49SXin LI   AC_MSG_RESULT([yes])],
2276b2c1e49SXin LI  [AC_MSG_RESULT([no])
2280a48773fSEric van Gyzen
2294543ef51SXin LI   AC_MSG_CHECKING([for arc4random (BSD, macOS, libbsd or glibc 2.36+)])
2300a48773fSEric van Gyzen   AC_LINK_IFELSE([AC_LANG_SOURCE([
2310a48773fSEric van Gyzen       #if defined(HAVE_LIBBSD)
2320a48773fSEric van Gyzen       # include <bsd/stdlib.h>
2330a48773fSEric van Gyzen       #else
2340a48773fSEric van Gyzen       # include <stdlib.h>
2350a48773fSEric van Gyzen       #endif
236ffd294a1SEnji Cooper       int main(void) {
2370a48773fSEric van Gyzen          arc4random();
2380a48773fSEric van Gyzen          return 0;
2390a48773fSEric van Gyzen       }
2406b2c1e49SXin LI     ])],
2416b2c1e49SXin LI     [AC_DEFINE([HAVE_ARC4RANDOM], [1], [Define to 1 if you have the `arc4random' function.])
2426b2c1e49SXin LI      AC_MSG_RESULT([yes])],
2436b2c1e49SXin LI     [AC_MSG_RESULT([no])])])
2440a48773fSEric van Gyzen
2456b2c1e49SXin LIAC_ARG_WITH([getrandom],
2466b2c1e49SXin LI  [AS_HELP_STRING([--with-getrandom],
2476b2c1e49SXin LI                  [enforce the use of getrandom function in the system @<:@default=check@:>@])
2486b2c1e49SXin LIAS_HELP_STRING([--without-getrandom],
2496b2c1e49SXin LI               [skip auto detect of getrandom @<:@default=check@:>@])],
2506b2c1e49SXin LI  [],
2516b2c1e49SXin LI  [with_getrandom=check])
2520a48773fSEric van Gyzen
2536b2c1e49SXin LIAS_IF([test "x$with_getrandom" != xno],
2546b2c1e49SXin LI  [AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
2550a48773fSEric van Gyzen   AC_LINK_IFELSE([AC_LANG_SOURCE([
2560a48773fSEric van Gyzen       #include <stdlib.h>  /* for NULL */
2570a48773fSEric van Gyzen       #include <sys/random.h>
258ffd294a1SEnji Cooper       int main(void) {
2590a48773fSEric van Gyzen         return getrandom(NULL, 0U, 0U);
2600a48773fSEric van Gyzen       }
2616b2c1e49SXin LI     ])],
2626b2c1e49SXin LI     [AC_DEFINE([HAVE_GETRANDOM], [1], [Define to 1 if you have the `getrandom' function.])
2636b2c1e49SXin LI      AC_MSG_RESULT([yes])],
2646b2c1e49SXin LI     [AC_MSG_RESULT([no])
2656b2c1e49SXin LI      AS_IF([test "x$with_getrandom" = xyes],
2666b2c1e49SXin LI        [AC_MSG_ERROR([enforced the use of getrandom --with-getrandom, but not detected])])])])
2670a48773fSEric van Gyzen
2686b2c1e49SXin LIAC_ARG_WITH([sys_getrandom],
2696b2c1e49SXin LI  [AS_HELP_STRING([--with-sys-getrandom],
2706b2c1e49SXin LI                  [enforce the use of syscall SYS_getrandom function in the system @<:@default=check@:>@])
2716b2c1e49SXin LIAS_HELP_STRING([--without-sys-getrandom],
2726b2c1e49SXin LI               [skip auto detect of syscall SYS_getrandom @<:@default=check@:>@])],
2736b2c1e49SXin LI  [],
2746b2c1e49SXin LI  [with_sys_getrandom=check])
2756b2c1e49SXin LI
2766b2c1e49SXin LIAS_IF([test "x$with_sys_getrandom" != xno],
2776b2c1e49SXin LI  [AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)])
2780a48773fSEric van Gyzen   AC_LINK_IFELSE([AC_LANG_SOURCE([
279ffd294a1SEnji Cooper       #define _GNU_SOURCE
2800a48773fSEric van Gyzen       #include <stdlib.h>  /* for NULL */
2810a48773fSEric van Gyzen       #include <unistd.h>  /* for syscall */
2820a48773fSEric van Gyzen       #include <sys/syscall.h>  /* for SYS_getrandom */
283ffd294a1SEnji Cooper       int main(void) {
2840a48773fSEric van Gyzen         syscall(SYS_getrandom, NULL, 0, 0);
2850a48773fSEric van Gyzen         return 0;
2860a48773fSEric van Gyzen     }
2876b2c1e49SXin LI   ])],
2886b2c1e49SXin LI     [AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1], [Define to 1 if you have `syscall' and `SYS_getrandom'.])
2896b2c1e49SXin LI      AC_MSG_RESULT([yes])],
2906b2c1e49SXin LI     [AC_MSG_RESULT([no])
2916b2c1e49SXin LI      AS_IF([test "x$with_sys_getrandom" = xyes],
2926b2c1e49SXin LI        [AC_MSG_ERROR([enforced the use of syscall SYS_getrandom --with-sys-getrandom, but not detected])])])])
2930a48773fSEric van Gyzen
294be8aff81SXin LIdnl Only needed for xmlwf:
295be8aff81SXin LIAC_CHECK_HEADERS(fcntl.h unistd.h)
296be8aff81SXin LIAC_TYPE_OFF_T
297be8aff81SXin LIAC_FUNC_MMAP
298be8aff81SXin LI
2996b2c1e49SXin LIAS_IF([test "$ac_cv_func_mmap_fixed_mapped" = "yes"],
3006b2c1e49SXin LI  [AS_VAR_SET(FILEMAP,unixfilemap)],
3016b2c1e49SXin LI  [AS_VAR_SET(FILEMAP,readfilemap)])
302be8aff81SXin LIAC_SUBST(FILEMAP)
303be8aff81SXin LI
304be8aff81SXin LI
305be8aff81SXin LIdnl Some basic configuration:
306be8aff81SXin LIAC_DEFINE([XML_NS], 1,
307be8aff81SXin LI          [Define to make XML Namespaces functionality available.])
3084543ef51SXin LIAC_DEFINE([XML_GE], 1,
3094543ef51SXin LI          [Define as 1/0 to enable/disable support for general entities.])
310be8aff81SXin LIAC_DEFINE([XML_DTD], 1,
311be8aff81SXin LI          [Define to make parameter entity parsing functionality available.])
3120a48773fSEric van GyzenAC_DEFINE([XML_DEV_URANDOM], 1,
3130a48773fSEric van Gyzen          [Define to include code reading entropy from `/dev/urandom'.])
3140a48773fSEric van Gyzen
3156b2c1e49SXin LIAC_ARG_ENABLE([xml-attr-info],
3166b2c1e49SXin LI  [AS_HELP_STRING([--enable-xml-attr-info],
3176b2c1e49SXin LI     [Enable retrieving the byte offsets for attribute names and values @<:@default=no@:>@])],
3186b2c1e49SXin LI  [],
3196b2c1e49SXin LI  [enable_xml_attr_info=no])
3206b2c1e49SXin LIAS_IF([test "x${enable_xml_attr_info}" = "xyes"],
3216b2c1e49SXin LI      [AC_DEFINE([XML_ATTR_INFO], 1,
3226b2c1e49SXin LI         [Define to allow retrieving the byte offsets for attribute names and values.])])
3236b2c1e49SXin LI
3240a48773fSEric van GyzenAC_ARG_ENABLE([xml-context],
3250a48773fSEric van Gyzen  AS_HELP_STRING([--enable-xml-context @<:@COUNT@:>@],
3260a48773fSEric van Gyzen    [Retain context around the current parse point;
3270a48773fSEric van Gyzen     default is enabled and a size of 1024 bytes])
3280a48773fSEric van GyzenAS_HELP_STRING([--disable-xml-context],
3290a48773fSEric van Gyzen    [Do not retain context around the current parse point]),
3300a48773fSEric van Gyzen    [enable_xml_context=${enableval}])
3316b2c1e49SXin LIAS_IF([test "x${enable_xml_context}" != "xno"],
3326b2c1e49SXin LI  [AS_IF([test "x${enable_xml_context}" = "xyes" \
3336b2c1e49SXin LI            -o "x${enable_xml_context}" = "x"],
3344543ef51SXin LI     [AS_VAR_SET(enable_xml_context,1024)])],
3354543ef51SXin LI  [AS_VAR_SET(enable_xml_context,0)])
3360a48773fSEric van GyzenAC_DEFINE_UNQUOTED([XML_CONTEXT_BYTES], [${enable_xml_context}],
3374543ef51SXin LI  [Define to specify how much context to retain around the current parse point, 0 to disable.])
3380a48773fSEric van Gyzen
3396b2c1e49SXin LIAC_ARG_WITH([docbook],
3406b2c1e49SXin LI  [AS_HELP_STRING([--with-docbook],
3410a48773fSEric van Gyzen                  [enforce XML to man page compilation @<:@default=check@:>@])
3420a48773fSEric van GyzenAS_HELP_STRING([--without-docbook],
3430a48773fSEric van Gyzen               [skip XML to man page compilation @<:@default=check@:>@])],
3440a48773fSEric van Gyzen  [],
3450a48773fSEric van Gyzen  [with_docbook=check])
3460a48773fSEric van Gyzen
3470a48773fSEric van GyzenAC_ARG_VAR([DOCBOOK_TO_MAN], [docbook2x-man command])
3480a48773fSEric van GyzenAS_IF([test "x$with_docbook" != xno],
3490a48773fSEric van Gyzen  [AC_CHECK_PROGS([DOCBOOK_TO_MAN], [docbook2x-man db2x_docbook2man docbook2man docbook-to-man])])
3500a48773fSEric van GyzenAS_IF([test "x${DOCBOOK_TO_MAN}" = x -a "x$with_docbook" = xyes],
3510a48773fSEric van Gyzen  [AC_MSG_ERROR([Required program 'docbook2x-man' not found.])])
3520a48773fSEric van GyzenAS_IF([test "x${DOCBOOK_TO_MAN}" != x -a "x$with_docbook" != xno],
3530a48773fSEric van Gyzen  [AS_IF([${DOCBOOK_TO_MAN} --help | grep -i -q -F sgmlbase],
3540a48773fSEric van Gyzen    [AC_MSG_ERROR([Your local ${DOCBOOK_TO_MAN} was found to work with SGML rather
3550a48773fSEric van Gyzen  than XML. Please install docbook2X and use variable DOCBOOK_TO_MAN to point
3560a48773fSEric van Gyzen  configure to command docbook2x-man of docbook2X.
3570a48773fSEric van Gyzen  Or use DOCBOOK_TO_MAN="xmlto man --skip-validation" if you have xmlto around.
3580a48773fSEric van Gyzen  You can also configure using --without-docbook if you can do without a man
3590a48773fSEric van Gyzen  page for xmlwf.])])])
3600a48773fSEric van Gyzen
3614543ef51SXin LIdnl This will make sure that a release tarball shipping a pre-rendered xmlwf man page will
362ffd294a1SEnji Cooperdnl get it installed, when no working flavor of docbook2man is available (or wanted).
3634543ef51SXin LIdnl This relies on file xmlwf.1 being at least as recent as its source file xmlwf.xml.
3644543ef51SXin LIAS_IF([test -f "${srcdir}"/doc/xmlwf.1],
365ffd294a1SEnji Cooper  [AM_CONDITIONAL(WITH_MANPAGE, [true])
366ffd294a1SEnji Cooper   AS_IF([test "x$with_docbook" = xno -o "x${DOCBOOK_TO_MAN}" = x],
367ffd294a1SEnji Cooper     [AM_CONDITIONAL(WITH_PREBUILT_MANPAGE, [true])
368ffd294a1SEnji Cooper      AM_CONDITIONAL(WITH_DISTRIBUTABLE_MANPAGE, [false])],
369ffd294a1SEnji Cooper     [AM_CONDITIONAL(WITH_PREBUILT_MANPAGE, [false])
370ffd294a1SEnji Cooper      AM_CONDITIONAL(WITH_DISTRIBUTABLE_MANPAGE, [true])])
371ffd294a1SEnji Cooper   ],
372ffd294a1SEnji Cooper  [AS_IF([test "x$with_docbook" != xno -a "x${DOCBOOK_TO_MAN}" != x],
373ffd294a1SEnji Cooper     [AM_CONDITIONAL(WITH_MANPAGE, [true])
374ffd294a1SEnji Cooper      AM_CONDITIONAL(WITH_DISTRIBUTABLE_MANPAGE, [true])],
375ffd294a1SEnji Cooper     [AM_CONDITIONAL(WITH_MANPAGE, [false])
376ffd294a1SEnji Cooper      AM_CONDITIONAL(WITH_DISTRIBUTABLE_MANPAGE, [false])])
377ffd294a1SEnji Cooper   AM_CONDITIONAL(WITH_PREBUILT_MANPAGE, [false])])
378cc68614dSXin LI
379cc68614dSXin LIdnl Configure CMake file templates
380cc68614dSXin LIdnl NOTE: The *_TRUE variables read here are Automake conditionals
381cc68614dSXin LIdnl       that are either set to "" when enabled or to "#" when disabled
382cc68614dSXin LIdnl       (because they are used to dynamically comment out certain things)
383cc68614dSXin LIAS_IF([test "x${enable_xml_attr_info}" = xyes],
384cc68614dSXin LI  [EXPAT_ATTR_INFO=ON],
385cc68614dSXin LI  [EXPAT_ATTR_INFO=OFF])
386cc68614dSXin LIEXPAT_DTD=ON
387cc68614dSXin LIAS_IF([test "x${_INTERNAL_LARGE_SIZE_TRUE}" = x],
388cc68614dSXin LI  [EXPAT_LARGE_SIZE=ON],
389cc68614dSXin LI  [EXPAT_LARGE_SIZE=OFF])
390cc68614dSXin LIAS_IF([test "x${_INTERNAL_MIN_SIZE_TRUE}" = x],
391cc68614dSXin LI  [EXPAT_MIN_SIZE=ON],
392cc68614dSXin LI  [EXPAT_MIN_SIZE=OFF])
393cc68614dSXin LIEXPAT_NS=ON
394cc68614dSXin LIAS_IF([test "x${enable_xml_context}" != xno],
395cc68614dSXin LI  [EXPAT_CONTEXT_BYTES=${enable_xml_context}],
396cc68614dSXin LI  [EXPAT_CONTEXT_BYTES=OFF])
397cc68614dSXin LIAS_IF([test "x${UNICODE_TRUE}" = x],
398cc68614dSXin LI  [AS_IF(
399cc68614dSXin LI     [test "x${_INTERNAL_UNICODE_WCHAR_T_TRUE}" = x],
400cc68614dSXin LI        [EXPAT_CHAR_TYPE=wchar_t],
401cc68614dSXin LI        [EXPAT_CHAR_TYPE=ushort])],
402cc68614dSXin LI  [EXPAT_CHAR_TYPE=char])
403cc68614dSXin LIPACKAGE_INIT="${srcdir}"/cmake/autotools/expat-package-init.cmake
404cc68614dSXin LILIBDIR_BASENAME="$(basename "${libdir}")"
405cc68614dSXin LISO_MAJOR="$(expr "${LIBCURRENT}" - "${LIBAGE}")"
406cc68614dSXin LISO_MINOR="${LIBAGE}"
407cc68614dSXin LISO_PATCH="${LIBREVISION}"
408cc68614dSXin LIAC_SUBST([EXPAT_ATTR_INFO])
409cc68614dSXin LIAC_SUBST([EXPAT_DTD])
410cc68614dSXin LIAC_SUBST([EXPAT_LARGE_SIZE])
411cc68614dSXin LIAC_SUBST([EXPAT_MIN_SIZE])
412cc68614dSXin LIAC_SUBST([EXPAT_NS])
413cc68614dSXin LIAC_SUBST([EXPAT_CONTEXT_BYTES])
414cc68614dSXin LIAC_SUBST([EXPAT_CHAR_TYPE])
415cc68614dSXin LIAC_SUBST_FILE([PACKAGE_INIT])
416cc68614dSXin LIAC_SUBST([LIBDIR_BASENAME])
417cc68614dSXin LIAC_SUBST([SO_MAJOR])
418cc68614dSXin LIAC_SUBST([SO_MINOR])
419cc68614dSXin LIAC_SUBST([SO_PATCH])
420cc68614dSXin LI
421ffd294a1SEnji Cooperdnl The canonical way of doing this is AC_CHECK_SIZEOF(void *), but
422ffd294a1SEnji Cooperdnl that adds SIZEOF_VOID_P to expat_config.h.in, making it difficult
423ffd294a1SEnji Cooperdnl to have 32-bit and 64-bit versions of libexpat installed on the
424ffd294a1SEnji Cooperdnl same system with a single, shared copy of the header.
425ffd294a1SEnji CooperAC_COMPUTE_INT(SIZEOF_VOID_P, [sizeof(void *)])
426ffd294a1SEnji CooperAC_SUBST([SIZEOF_VOID_P])
427cc68614dSXin LI
428cc68614dSXin LIdnl write the Automake flags we set
429cc68614dSXin LIAC_SUBST([AM_CPPFLAGS])
430cc68614dSXin LIAC_SUBST([AM_CFLAGS])
431cc68614dSXin LIAC_SUBST([AM_CXXFLAGS])
432cc68614dSXin LIAC_SUBST([AM_LDFLAGS])
433cc68614dSXin LI
434ac69e5d4SEric van Gyzendnl Emulate the use of CMAKE_SHARED_LIBRARY_PREFIX under CMake
435ac69e5d4SEric van GyzenAC_MSG_CHECKING([for shared library name prefix])
436ac69e5d4SEric van GyzenAS_CASE("${host_os}",
437ac69e5d4SEric van Gyzen  [cygwin*], [CMAKE_SHARED_LIBRARY_PREFIX=cyg],
438ac69e5d4SEric van Gyzen  [CMAKE_SHARED_LIBRARY_PREFIX=lib])
439ac69e5d4SEric van GyzenAC_MSG_RESULT([${CMAKE_SHARED_LIBRARY_PREFIX}])
440ac69e5d4SEric van GyzenAC_SUBST([CMAKE_SHARED_LIBRARY_PREFIX])
441ac69e5d4SEric van Gyzen
442cc68614dSXin LIAS_CASE("${host_os}",
443cc68614dSXin LI  [darwin*], [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__macos.cmake.in],
444ac69e5d4SEric van Gyzen  [mingw*|cygwin*], [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__windows.cmake.in],
445cc68614dSXin LI  [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__linux.cmake.in])
4466b2c1e49SXin LIAC_CONFIG_FILES([Makefile]
4476b2c1e49SXin LI  [expat.pc]
448cc68614dSXin LI  [cmake/expat-config.cmake]
449cc68614dSXin LI  [cmake/autotools/expat-config-version.cmake]
450cc68614dSXin LI  [cmake/autotools/expat-noconfig.cmake:${CMAKE_NOCONFIG_SOURCE}]
4516b2c1e49SXin LI  [doc/Makefile]
4526b2c1e49SXin LI  [examples/Makefile]
4536b2c1e49SXin LI  [lib/Makefile]
4546b2c1e49SXin LI  [tests/Makefile]
4556b2c1e49SXin LI  [tests/benchmark/Makefile]
4566b2c1e49SXin LI  [xmlwf/Makefile])
4570a48773fSEric van GyzenAC_CONFIG_FILES([run.sh], [chmod +x run.sh])
458be8aff81SXin LIAC_OUTPUT
459cc68614dSXin LI
460cc68614dSXin LI
461cc68614dSXin LIAC_MSG_NOTICE([
462cc68614dSXin LI
463cc68614dSXin LIAutomake flags (can be overridden by user flags):
464cc68614dSXin LI  [AM_CPPFLAGS]: ${AM_CPPFLAGS}
465cc68614dSXin LI    [AM_CFLAGS]: ${AM_CFLAGS}
466cc68614dSXin LI  [AM_CXXFLAGS]: ${AM_CXXFLAGS}
467cc68614dSXin LI   [AM_LDFLAGS]: ${AM_LDFLAGS}
468cc68614dSXin LI
469cc68614dSXin LIUser flags (override Automake flags on conflict):
470cc68614dSXin LI     CPPFLAGS: ${CPPFLAGS}
471cc68614dSXin LI       CFLAGS: ${CFLAGS}
472cc68614dSXin LI     CXXFLAGS: ${CXXFLAGS}
473cc68614dSXin LI      LDFLAGS: ${LDFLAGS}])
474