Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 1 | dnl configuration script for expat |
| 2 | dnl Process this file with autoconf to produce a configure script. |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 3 | dnl __ __ _ |
| 4 | dnl ___\ \/ /_ __ __ _| |_ |
| 5 | dnl / _ \\ /| '_ \ / _` | __| |
| 6 | dnl | __// \| |_) | (_| | |_ |
| 7 | dnl \___/_/\_\ .__/ \__,_|\__| |
| 8 | dnl |_| XML parser |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 9 | dnl |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 10 | dnl Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net> |
| 11 | dnl Copyright (c) 2000-2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> |
| 12 | dnl Copyright (c) 2001-2003 Greg Stein <gstein@users.sourceforge.net> |
| 13 | dnl Copyright (c) 2006-2012 Karl Waclawek <karl@waclawek.net> |
Elliott Hughes | f898dc2 | 2022-02-23 17:34:51 -0800 | [diff] [blame] | 14 | dnl Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org> |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 15 | dnl Copyright (c) 2017 S. P. Zeidler <spz@netbsd.org> |
| 16 | dnl Copyright (c) 2017 Stephen Groat <stephen@groat.us> |
| 17 | dnl Copyright (c) 2017-2020 Joe Orton <jorton@redhat.com> |
| 18 | dnl Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com> |
| 19 | dnl Copyright (c) 2018 Benjamin Peterson <benjamin@python.org> |
| 20 | dnl Copyright (c) 2018 Marco Maggi <marco.maggi-ipsu@poste.it> |
| 21 | dnl Copyright (c) 2018 KangLin <kl222@126.com> |
| 22 | dnl Copyright (c) 2019 Mohammed Khajapasha <mohammed.khajapasha@intel.com> |
| 23 | dnl Copyright (c) 2019 Kishore Kunche <kishore.kunche@intel.com> |
| 24 | dnl Copyright (c) 2020 Jeffrey Walton <noloader@gmail.com> |
| 25 | dnl Licensed under the MIT license: |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 26 | dnl |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 27 | dnl Permission is hereby granted, free of charge, to any person obtaining |
| 28 | dnl a copy of this software and associated documentation files (the |
| 29 | dnl "Software"), to deal in the Software without restriction, including |
| 30 | dnl without limitation the rights to use, copy, modify, merge, publish, |
| 31 | dnl distribute, sublicense, and/or sell copies of the Software, and to permit |
| 32 | dnl persons to whom the Software is furnished to do so, subject to the |
| 33 | dnl following conditions: |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 34 | dnl |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 35 | dnl The above copyright notice and this permission notice shall be included |
| 36 | dnl in all copies or substantial portions of the Software. |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 37 | dnl |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 38 | dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 39 | dnl EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 40 | dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 41 | dnl NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 42 | dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 43 | dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 44 | dnl USE OR OTHER DEALINGS IN THE SOFTWARE. |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 45 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 46 | dnl Ensure that Expat is configured with autoconf 2.69 or newer. |
Elliott Hughes | f648a29 | 2021-04-01 15:10:13 -0700 | [diff] [blame] | 47 | AC_PREREQ([2.69]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 48 | |
| 49 | dnl Get the version number of Expat, using m4's esyscmd() command to run |
| 50 | dnl the command at m4-generation time. This allows us to create an m4 |
Elliott Hughes | f648a29 | 2021-04-01 15:10:13 -0700 | [diff] [blame] | 51 | dnl symbol holding the correct version number. AC_INIT requires the |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 52 | dnl version number at m4-time, rather than when ./configure is run, so |
| 53 | dnl all this must happen as part of m4, not as part of the shell code |
| 54 | dnl contained in ./configure. |
| 55 | dnl |
| 56 | dnl NOTE: esyscmd() is a GNU M4 extension. Thus, we wrap it in an appropriate |
| 57 | dnl test. I believe this test will work, but I don't have a place with non- |
| 58 | dnl GNU M4 to test it right now. |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 59 | m4_define([expat_version], |
| 60 | m4_ifdef([__gnu__], |
| 61 | [esyscmd(conftools/get-version.sh lib/expat.h)], |
| 62 | [2.2.x])) |
Elliott Hughes | f648a29 | 2021-04-01 15:10:13 -0700 | [diff] [blame] | 63 | AC_INIT([expat], expat_version, [expat-bugs@libexpat.org]) |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 64 | m4_undefine([expat_version]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 65 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 66 | AC_CONFIG_SRCDIR([Makefile.in]) |
| 67 | AC_CONFIG_AUX_DIR([conftools]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 68 | AC_CONFIG_MACRO_DIR([m4]) |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 69 | AC_CANONICAL_HOST |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 70 | AM_INIT_AUTOMAKE |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 71 | |
| 72 | |
| 73 | dnl |
| 74 | dnl Increment LIBREVISION if source code has changed at all |
| 75 | dnl |
| 76 | dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0 |
| 77 | dnl |
| 78 | dnl If the API changes compatibly (i.e. simply adding a new function |
| 79 | dnl without changing or removing earlier interfaces), then increment LIBAGE. |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 80 | dnl |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 81 | dnl If the API changes incompatibly set LIBAGE back to 0 |
| 82 | dnl |
| 83 | |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 84 | LIBCURRENT=9 # sync |
Elliott Hughes | f898dc2 | 2022-02-23 17:34:51 -0800 | [diff] [blame] | 85 | LIBREVISION=6 # with |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 86 | LIBAGE=8 # CMakeLists.txt! |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 87 | |
Elliott Hughes | f648a29 | 2021-04-01 15:10:13 -0700 | [diff] [blame] | 88 | AC_CONFIG_HEADERS([expat_config.h]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 89 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 90 | AM_PROG_AR |
| 91 | AC_PROG_INSTALL |
| 92 | AC_PROG_LN_S |
| 93 | AC_PROG_MAKE_SET |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 94 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 95 | LT_PREREQ([2.4]) |
| 96 | LT_INIT([win32-dll]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 97 | |
| 98 | AC_SUBST(LIBCURRENT) |
| 99 | AC_SUBST(LIBREVISION) |
| 100 | AC_SUBST(LIBAGE) |
| 101 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 102 | AC_LANG([C]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 103 | AC_PROG_CC_C99 |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 104 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 105 | AS_IF([test "$GCC" = yes], |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 106 | [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [AM_CFLAGS]) |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 107 | dnl Be careful about adding the -fexceptions option; some versions of |
| 108 | dnl GCC don't support it and it causes extra warnings that are only |
| 109 | dnl distracting; avoid. |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 110 | AX_APPEND_COMPILE_FLAGS([-fexceptions], [AM_CFLAGS]) |
| 111 | AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -Wmissing-prototypes -Wstrict-prototypes], [AM_CFLAGS]) |
| 112 | AX_APPEND_COMPILE_FLAGS([-pedantic -Wduplicated-cond -Wduplicated-branches -Wlogical-op], [AM_CFLAGS]) |
| 113 | AX_APPEND_COMPILE_FLAGS([-Wrestrict -Wnull-dereference -Wjump-misses-init -Wdouble-promotion], [AM_CFLAGS]) |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 114 | AX_APPEND_COMPILE_FLAGS([-Wshadow -Wformat=2 -Wno-pedantic-ms-format -Wmisleading-indentation], [AM_CFLAGS])]) |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 115 | |
| 116 | AC_LANG_PUSH([C++]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 117 | AC_PROG_CXX |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 118 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 119 | AS_IF([test "$GCC" = yes], |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 120 | [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [AM_CXXFLAGS]) |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 121 | dnl Be careful about adding the -fexceptions option; some versions of |
| 122 | dnl GCC don't support it and it causes extra warnings that are only |
| 123 | dnl distracting; avoid. |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 124 | AX_APPEND_COMPILE_FLAGS([-fexceptions], [AM_CXXFLAGS]) |
| 125 | AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [AM_CXXFLAGS])]) |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 126 | AC_LANG_POP([C++]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 127 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 128 | AS_IF([test "$GCC" = yes], |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 129 | [AX_APPEND_LINK_FLAGS([-fno-strict-aliasing],[AM_LDFLAGS])]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 130 | |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 131 | dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang (issue #312) |
| 132 | AS_CASE(["$LD"],[*clang*], |
| 133 | [AS_CASE(["${host_os}"], |
| 134 | [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])]) |
| 135 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 136 | EXPATCFG_COMPILER_SUPPORTS_VISIBILITY([ |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 137 | AX_APPEND_FLAG([-fvisibility=hidden], [AM_CFLAGS]) |
| 138 | AX_APPEND_FLAG([-DXML_ENABLE_VISIBILITY=1], [AM_CPPFLAGS])]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 139 | |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 140 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 141 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 142 | dnl We define BYTEORDER to 1234 when the platform is little endian; it |
| 143 | dnl defines it to 4321 when the platform is big endian. We also define |
| 144 | dnl WORDS_BIGENDIAN to 1 when the platform is big endian. |
| 145 | dnl |
| 146 | dnl A long time ago (early 2000 years) AC_C_BIGENDIAN was considered |
| 147 | dnl wrong when cross compiling, now (2018, GNU Autoconf 2.69) we assume |
| 148 | dnl it is fine. |
| 149 | AC_C_BIGENDIAN([AC_DEFINE([WORDS_BIGENDIAN], 1) |
| 150 | AS_VAR_SET([BYTEORDER], 4321)], |
| 151 | [AS_VAR_SET([BYTEORDER], 1234)]) |
| 152 | AC_DEFINE_UNQUOTED([BYTEORDER], $BYTEORDER, [1234 = LILENDIAN, 4321 = BIGENDIAN]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 153 | |
| 154 | AC_C_CONST |
| 155 | AC_TYPE_SIZE_T |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 156 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 157 | AC_ARG_WITH([xmlwf], |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 158 | [AS_HELP_STRING([--without-xmlwf], [do not build xmlwf])], |
| 159 | [], |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 160 | [with_xmlwf=yes]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 161 | AM_CONDITIONAL([WITH_XMLWF], [test x${with_xmlwf} = xyes]) |
| 162 | |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 163 | AC_ARG_WITH([examples], |
| 164 | [AS_HELP_STRING([--without-examples], [do not build examples @<:@default=included@:>@])], |
| 165 | [], |
| 166 | [with_examples=yes]) |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 167 | AM_CONDITIONAL([WITH_EXAMPLES], [test x${with_examples} = xyes]) |
| 168 | |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 169 | AC_ARG_WITH([tests], |
| 170 | [AS_HELP_STRING([--without-tests], [do not build tests @<:@default=included@:>@])], |
| 171 | [], |
| 172 | [with_tests=yes]) |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 173 | AM_CONDITIONAL([WITH_TESTS], [test x${with_tests} = xyes]) |
| 174 | |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 175 | |
| 176 | AS_VAR_SET([EXPATCFG_ON_MINGW],[no]) |
| 177 | AS_CASE("${host_os}", |
| 178 | [mingw*], |
| 179 | [AS_VAR_SET([EXPATCFG_ON_MINGW],[yes]) |
| 180 | AC_MSG_NOTICE([detected OS: MinGW])]) |
| 181 | AM_CONDITIONAL([MINGW], [test x${EXPATCFG_ON_MINGW} = xyes]) |
| 182 | |
Elliott Hughes | f648a29 | 2021-04-01 15:10:13 -0700 | [diff] [blame] | 183 | dnl Note: Prefix "_INTERNAL_" here means exclusive use inside of file configure.ac |
Elliott Hughes | aaec48e | 2018-08-16 16:29:01 -0700 | [diff] [blame] | 184 | AM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE >/dev/null]) |
Elliott Hughes | f648a29 | 2021-04-01 15:10:13 -0700 | [diff] [blame] | 185 | AM_CONDITIONAL([_INTERNAL_UNICODE_WCHAR_T], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE_WCHAR_T >/dev/null]) |
| 186 | AM_CONDITIONAL([_INTERNAL_MIN_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_MIN_SIZE >/dev/null]) |
| 187 | AM_CONDITIONAL([_INTERNAL_LARGE_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_LARGE_SIZE >/dev/null]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 188 | |
Elliott Hughes | f898dc2 | 2022-02-23 17:34:51 -0800 | [diff] [blame] | 189 | LT_LIB_M |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 190 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 191 | AC_ARG_WITH([libbsd], |
| 192 | [AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])], |
| 193 | [], |
| 194 | [with_libbsd=no]) |
| 195 | AS_IF([test "x${with_libbsd}" != xno], |
| 196 | [AC_CHECK_LIB([bsd], |
| 197 | [arc4random_buf], |
| 198 | [], |
| 199 | [AS_IF([test "x${with_libbsd}" = xyes], |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 200 | [AC_MSG_ERROR([Enforced use of libbsd cannot be satisfied.])])])]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 201 | AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)]) |
| 202 | AC_LINK_IFELSE([AC_LANG_SOURCE([ |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 203 | #include <stdlib.h> /* for arc4random_buf on BSD, for NULL */ |
| 204 | #if defined(HAVE_LIBBSD) |
| 205 | # include <bsd/stdlib.h> |
| 206 | #endif |
| 207 | int main() { |
| 208 | arc4random_buf(NULL, 0U); |
| 209 | return 0; |
| 210 | } |
| 211 | ])], |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 212 | [AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1], [Define to 1 if you have the `arc4random_buf' function.]) |
| 213 | AC_MSG_RESULT([yes])], |
| 214 | [AC_MSG_RESULT([no]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 215 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 216 | AC_MSG_CHECKING([for arc4random (BSD, macOS or libbsd)]) |
| 217 | AC_LINK_IFELSE([AC_LANG_SOURCE([ |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 218 | #if defined(HAVE_LIBBSD) |
| 219 | # include <bsd/stdlib.h> |
| 220 | #else |
| 221 | # include <stdlib.h> |
| 222 | #endif |
| 223 | int main() { |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 224 | arc4random(); |
| 225 | return 0; |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 226 | } |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 227 | ])], |
| 228 | [AC_DEFINE([HAVE_ARC4RANDOM], [1], [Define to 1 if you have the `arc4random' function.]) |
| 229 | AC_MSG_RESULT([yes])], |
| 230 | [AC_MSG_RESULT([no])])]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 231 | |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 232 | AC_ARG_WITH([getrandom], |
| 233 | [AS_HELP_STRING([--with-getrandom], |
| 234 | [enforce the use of getrandom function in the system @<:@default=check@:>@]) |
| 235 | AS_HELP_STRING([--without-getrandom], |
| 236 | [skip auto detect of getrandom @<:@default=check@:>@])], |
| 237 | [], |
| 238 | [with_getrandom=check]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 239 | |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 240 | AS_IF([test "x$with_getrandom" != xno], |
| 241 | [AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)]) |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 242 | AC_LINK_IFELSE([AC_LANG_SOURCE([ |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 243 | #include <stdlib.h> /* for NULL */ |
| 244 | #include <sys/random.h> |
| 245 | int main() { |
| 246 | return getrandom(NULL, 0U, 0U); |
| 247 | } |
| 248 | ])], |
| 249 | [AC_DEFINE([HAVE_GETRANDOM], [1], [Define to 1 if you have the `getrandom' function.]) |
| 250 | AC_MSG_RESULT([yes])], |
| 251 | [AC_MSG_RESULT([no]) |
| 252 | AS_IF([test "x$with_getrandom" = xyes], |
| 253 | [AC_MSG_ERROR([enforced the use of getrandom --with-getrandom, but not detected])])])]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 254 | |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 255 | AC_ARG_WITH([sys_getrandom], |
| 256 | [AS_HELP_STRING([--with-sys-getrandom], |
| 257 | [enforce the use of syscall SYS_getrandom function in the system @<:@default=check@:>@]) |
| 258 | AS_HELP_STRING([--without-sys-getrandom], |
| 259 | [skip auto detect of syscall SYS_getrandom @<:@default=check@:>@])], |
| 260 | [], |
| 261 | [with_sys_getrandom=check]) |
| 262 | |
| 263 | AS_IF([test "x$with_sys_getrandom" != xno], |
| 264 | [AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)]) |
| 265 | AC_LINK_IFELSE([AC_LANG_SOURCE([ |
| 266 | #include <stdlib.h> /* for NULL */ |
| 267 | #include <unistd.h> /* for syscall */ |
| 268 | #include <sys/syscall.h> /* for SYS_getrandom */ |
| 269 | int main() { |
| 270 | syscall(SYS_getrandom, NULL, 0, 0); |
| 271 | return 0; |
| 272 | } |
| 273 | ])], |
| 274 | [AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1], [Define to 1 if you have `syscall' and `SYS_getrandom'.]) |
| 275 | AC_MSG_RESULT([yes])], |
| 276 | [AC_MSG_RESULT([no]) |
| 277 | AS_IF([test "x$with_sys_getrandom" = xyes], |
| 278 | [AC_MSG_ERROR([enforced the use of syscall SYS_getrandom --with-sys-getrandom, but not detected])])])]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 279 | |
| 280 | dnl Only needed for xmlwf: |
| 281 | AC_CHECK_HEADERS(fcntl.h unistd.h) |
| 282 | AC_TYPE_OFF_T |
| 283 | AC_FUNC_MMAP |
| 284 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 285 | AS_IF([test "$ac_cv_func_mmap_fixed_mapped" = "yes"], |
| 286 | [AS_VAR_SET(FILEMAP,unixfilemap)], |
| 287 | [AS_VAR_SET(FILEMAP,readfilemap)]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 288 | AC_SUBST(FILEMAP) |
| 289 | |
| 290 | |
| 291 | dnl Some basic configuration: |
| 292 | AC_DEFINE([XML_NS], 1, |
| 293 | [Define to make XML Namespaces functionality available.]) |
| 294 | AC_DEFINE([XML_DTD], 1, |
| 295 | [Define to make parameter entity parsing functionality available.]) |
| 296 | AC_DEFINE([XML_DEV_URANDOM], 1, |
| 297 | [Define to include code reading entropy from `/dev/urandom'.]) |
| 298 | |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 299 | AC_ARG_ENABLE([xml-attr-info], |
| 300 | [AS_HELP_STRING([--enable-xml-attr-info], |
| 301 | [Enable retrieving the byte offsets for attribute names and values @<:@default=no@:>@])], |
| 302 | [], |
| 303 | [enable_xml_attr_info=no]) |
| 304 | AS_IF([test "x${enable_xml_attr_info}" = "xyes"], |
| 305 | [AC_DEFINE([XML_ATTR_INFO], 1, |
| 306 | [Define to allow retrieving the byte offsets for attribute names and values.])]) |
| 307 | |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 308 | AC_ARG_ENABLE([xml-context], |
| 309 | AS_HELP_STRING([--enable-xml-context @<:@COUNT@:>@], |
| 310 | [Retain context around the current parse point; |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 311 | default is enabled and a size of 1024 bytes]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 312 | AS_HELP_STRING([--disable-xml-context], |
| 313 | [Do not retain context around the current parse point]), |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 314 | [enable_xml_context=${enableval}]) |
| 315 | AS_IF([test "x${enable_xml_context}" != "xno"], |
| 316 | [AS_IF([test "x${enable_xml_context}" = "xyes" \ |
| 317 | -o "x${enable_xml_context}" = "x"], |
| 318 | [AS_VAR_SET(enable_xml_context,1024)]) |
| 319 | AC_DEFINE_UNQUOTED([XML_CONTEXT_BYTES], [${enable_xml_context}], |
| 320 | [Define to specify how much context to retain around the current parse point.])]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 321 | |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 322 | AC_ARG_WITH([docbook], |
| 323 | [AS_HELP_STRING([--with-docbook], |
| 324 | [enforce XML to man page compilation @<:@default=check@:>@]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 325 | AS_HELP_STRING([--without-docbook], |
Haibo Huang | 40a7191 | 2019-10-11 11:13:39 -0700 | [diff] [blame] | 326 | [skip XML to man page compilation @<:@default=check@:>@])], |
| 327 | [], |
| 328 | [with_docbook=check]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 329 | |
| 330 | AC_ARG_VAR([DOCBOOK_TO_MAN], [docbook2x-man command]) |
| 331 | AS_IF([test "x$with_docbook" != xno], |
Elliott Hughes | aaec48e | 2018-08-16 16:29:01 -0700 | [diff] [blame] | 332 | [AC_CHECK_PROGS([DOCBOOK_TO_MAN], [docbook2x-man db2x_docbook2man docbook2man docbook-to-man])]) |
| 333 | AS_IF([test "x${DOCBOOK_TO_MAN}" = x -a "x$with_docbook" = xyes], |
| 334 | [AC_MSG_ERROR([Required program 'docbook2x-man' not found.])]) |
| 335 | AS_IF([test "x${DOCBOOK_TO_MAN}" != x -a "x$with_docbook" != xno], |
| 336 | [AS_IF([${DOCBOOK_TO_MAN} --help | grep -i -q -F sgmlbase], |
| 337 | [AC_MSG_ERROR([Your local ${DOCBOOK_TO_MAN} was found to work with SGML rather |
| 338 | than XML. Please install docbook2X and use variable DOCBOOK_TO_MAN to point |
| 339 | configure to command docbook2x-man of docbook2X. |
| 340 | Or use DOCBOOK_TO_MAN="xmlto man --skip-validation" if you have xmlto around. |
| 341 | You can also configure using --without-docbook if you can do without a man |
| 342 | page for xmlwf.])])]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 343 | |
Elliott Hughes | aaec48e | 2018-08-16 16:29:01 -0700 | [diff] [blame] | 344 | AM_CONDITIONAL(WITH_DOCBOOK, [test "x${DOCBOOK_TO_MAN}" != x]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 345 | |
Elliott Hughes | f648a29 | 2021-04-01 15:10:13 -0700 | [diff] [blame] | 346 | |
| 347 | dnl Configure CMake file templates |
| 348 | dnl NOTE: The *_TRUE variables read here are Automake conditionals |
| 349 | dnl that are either set to "" when enabled or to "#" when disabled |
| 350 | dnl (because they are used to dynamically comment out certain things) |
| 351 | AS_IF([test "x${enable_xml_attr_info}" = xyes], |
| 352 | [EXPAT_ATTR_INFO=ON], |
| 353 | [EXPAT_ATTR_INFO=OFF]) |
| 354 | EXPAT_DTD=ON |
| 355 | AS_IF([test "x${_INTERNAL_LARGE_SIZE_TRUE}" = x], |
| 356 | [EXPAT_LARGE_SIZE=ON], |
| 357 | [EXPAT_LARGE_SIZE=OFF]) |
| 358 | AS_IF([test "x${_INTERNAL_MIN_SIZE_TRUE}" = x], |
| 359 | [EXPAT_MIN_SIZE=ON], |
| 360 | [EXPAT_MIN_SIZE=OFF]) |
| 361 | EXPAT_NS=ON |
| 362 | AS_IF([test "x${enable_xml_context}" != xno], |
| 363 | [EXPAT_CONTEXT_BYTES=${enable_xml_context}], |
| 364 | [EXPAT_CONTEXT_BYTES=OFF]) |
| 365 | AS_IF([test "x${UNICODE_TRUE}" = x], |
| 366 | [AS_IF( |
| 367 | [test "x${_INTERNAL_UNICODE_WCHAR_T_TRUE}" = x], |
| 368 | [EXPAT_CHAR_TYPE=wchar_t], |
| 369 | [EXPAT_CHAR_TYPE=ushort])], |
| 370 | [EXPAT_CHAR_TYPE=char]) |
| 371 | PACKAGE_INIT="${srcdir}"/cmake/autotools/expat-package-init.cmake |
| 372 | LIBDIR_BASENAME="$(basename "${libdir}")" |
| 373 | SO_MAJOR="$(expr "${LIBCURRENT}" - "${LIBAGE}")" |
| 374 | SO_MINOR="${LIBAGE}" |
| 375 | SO_PATCH="${LIBREVISION}" |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 376 | AC_CHECK_SIZEOF([void *]) # sets ac_cv_sizeof_void_p |
Elliott Hughes | f648a29 | 2021-04-01 15:10:13 -0700 | [diff] [blame] | 377 | AC_SUBST([EXPAT_ATTR_INFO]) |
| 378 | AC_SUBST([EXPAT_DTD]) |
| 379 | AC_SUBST([EXPAT_LARGE_SIZE]) |
| 380 | AC_SUBST([EXPAT_MIN_SIZE]) |
| 381 | AC_SUBST([EXPAT_NS]) |
| 382 | AC_SUBST([EXPAT_CONTEXT_BYTES]) |
| 383 | AC_SUBST([EXPAT_CHAR_TYPE]) |
| 384 | AC_SUBST_FILE([PACKAGE_INIT]) |
| 385 | AC_SUBST([LIBDIR_BASENAME]) |
| 386 | AC_SUBST([SO_MAJOR]) |
| 387 | AC_SUBST([SO_MINOR]) |
| 388 | AC_SUBST([SO_PATCH]) |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 389 | AC_SUBST([ac_cv_sizeof_void_p]) |
Elliott Hughes | f648a29 | 2021-04-01 15:10:13 -0700 | [diff] [blame] | 390 | |
| 391 | |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 392 | dnl write the Automake flags we set |
| 393 | AC_SUBST([AM_CPPFLAGS]) |
| 394 | AC_SUBST([AM_CFLAGS]) |
| 395 | AC_SUBST([AM_CXXFLAGS]) |
| 396 | AC_SUBST([AM_LDFLAGS]) |
| 397 | |
Elliott Hughes | f898dc2 | 2022-02-23 17:34:51 -0800 | [diff] [blame] | 398 | dnl Emulate the use of CMAKE_SHARED_LIBRARY_PREFIX under CMake |
| 399 | AC_MSG_CHECKING([for shared library name prefix]) |
| 400 | AS_CASE("${host_os}", |
| 401 | [cygwin*], [CMAKE_SHARED_LIBRARY_PREFIX=cyg], |
| 402 | [CMAKE_SHARED_LIBRARY_PREFIX=lib]) |
| 403 | AC_MSG_RESULT([${CMAKE_SHARED_LIBRARY_PREFIX}]) |
| 404 | AC_SUBST([CMAKE_SHARED_LIBRARY_PREFIX]) |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 405 | |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 406 | AS_CASE("${host_os}", |
| 407 | [darwin*], [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__macos.cmake.in], |
Elliott Hughes | f898dc2 | 2022-02-23 17:34:51 -0800 | [diff] [blame] | 408 | [mingw*|cygwin*], [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__windows.cmake.in], |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 409 | [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__linux.cmake.in]) |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 410 | AC_CONFIG_FILES([Makefile] |
| 411 | [expat.pc] |
Elliott Hughes | f648a29 | 2021-04-01 15:10:13 -0700 | [diff] [blame] | 412 | [cmake/expat-config.cmake] |
| 413 | [cmake/autotools/expat-config-version.cmake] |
Elliott Hughes | 33bf975 | 2021-08-10 17:33:34 -0700 | [diff] [blame] | 414 | [cmake/autotools/expat-noconfig.cmake:${CMAKE_NOCONFIG_SOURCE}] |
Haibo Huang | fd5e81a | 2019-06-20 12:09:36 -0700 | [diff] [blame] | 415 | [doc/Makefile] |
| 416 | [examples/Makefile] |
| 417 | [lib/Makefile] |
| 418 | [tests/Makefile] |
| 419 | [tests/benchmark/Makefile] |
| 420 | [xmlwf/Makefile]) |
Elliott Hughes | 7247294 | 2018-01-10 08:36:10 -0800 | [diff] [blame] | 421 | AC_CONFIG_FILES([run.sh], [chmod +x run.sh]) |
| 422 | AC_OUTPUT |
Haibo Huang | d1a324a | 2020-10-28 22:19:36 -0700 | [diff] [blame] | 423 | |
| 424 | |
| 425 | AC_MSG_NOTICE([ |
| 426 | |
| 427 | Automake flags (can be overridden by user flags): |
| 428 | [AM_CPPFLAGS]: ${AM_CPPFLAGS} |
| 429 | [AM_CFLAGS]: ${AM_CFLAGS} |
| 430 | [AM_CXXFLAGS]: ${AM_CXXFLAGS} |
| 431 | [AM_LDFLAGS]: ${AM_LDFLAGS} |
| 432 | |
| 433 | User flags (override Automake flags on conflict): |
| 434 | CPPFLAGS: ${CPPFLAGS} |
| 435 | CFLAGS: ${CFLAGS} |
| 436 | CXXFLAGS: ${CXXFLAGS} |
| 437 | LDFLAGS: ${LDFLAGS}]) |