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.69 or newer. 14AC_PREREQ([2.69]) 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. 26m4_define([expat_version], 27 m4_ifdef([__gnu__], 28 [esyscmd(conftools/get-version.sh lib/expat.h)], 29 [2.2.x])) 30AC_INIT([expat], expat_version, [expat-bugs@libexpat.org]) 31m4_undefine([expat_version]) 32 33AC_CONFIG_SRCDIR([Makefile.in]) 34AC_CONFIG_AUX_DIR([conftools]) 35AC_CONFIG_MACRO_DIR([m4]) 36AC_CANONICAL_HOST 37AM_INIT_AUTOMAKE 38 39 40dnl 41dnl Increment LIBREVISION if source code has changed at all 42dnl 43dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0 44dnl 45dnl If the API changes compatibly (i.e. simply adding a new function 46dnl without changing or removing earlier interfaces), then increment LIBAGE. 47dnl 48dnl If the API changes incompatibly set LIBAGE back to 0 49dnl 50 51LIBCURRENT=8 # sync 52LIBREVISION=0 # with 53LIBAGE=7 # CMakeLists.txt! 54 55AX_APPEND_FLAG([-DHAVE_EXPAT_CONFIG_H], [AM_CPPFLAGS]) 56AC_CONFIG_HEADERS([expat_config.h]) 57 58AM_PROG_AR 59AC_PROG_INSTALL 60AC_PROG_LN_S 61AC_PROG_MAKE_SET 62 63LT_PREREQ([2.4]) 64LT_INIT([win32-dll]) 65 66AC_SUBST(LIBCURRENT) 67AC_SUBST(LIBREVISION) 68AC_SUBST(LIBAGE) 69 70AC_LANG([C]) 71AC_PROG_CC_C99 72 73AS_IF([test "$GCC" = yes], 74 [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [AM_CFLAGS]) 75 dnl Be careful about adding the -fexceptions option; some versions of 76 dnl GCC don't support it and it causes extra warnings that are only 77 dnl distracting; avoid. 78 AX_APPEND_COMPILE_FLAGS([-fexceptions], [AM_CFLAGS]) 79 AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -Wmissing-prototypes -Wstrict-prototypes], [AM_CFLAGS]) 80 AX_APPEND_COMPILE_FLAGS([-pedantic -Wduplicated-cond -Wduplicated-branches -Wlogical-op], [AM_CFLAGS]) 81 AX_APPEND_COMPILE_FLAGS([-Wrestrict -Wnull-dereference -Wjump-misses-init -Wdouble-promotion], [AM_CFLAGS]) 82 AX_APPEND_COMPILE_FLAGS([-Wshadow -Wformat=2 -Wmisleading-indentation], [AM_CFLAGS])]) 83 84AC_LANG_PUSH([C++]) 85AC_PROG_CXX 86 87AS_IF([test "$GCC" = yes], 88 [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [AM_CXXFLAGS]) 89 dnl Be careful about adding the -fexceptions option; some versions of 90 dnl GCC don't support it and it causes extra warnings that are only 91 dnl distracting; avoid. 92 AX_APPEND_COMPILE_FLAGS([-fexceptions], [AM_CXXFLAGS]) 93 AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [AM_CXXFLAGS])]) 94AC_LANG_POP([C++]) 95 96AS_IF([test "$GCC" = yes], 97 [AX_APPEND_LINK_FLAGS([-fno-strict-aliasing],[AM_LDFLAGS])]) 98 99dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang (issue #312) 100AS_CASE(["$LD"],[*clang*], 101 [AS_CASE(["${host_os}"], 102 [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])]) 103 104EXPATCFG_COMPILER_SUPPORTS_VISIBILITY([ 105 AX_APPEND_FLAG([-fvisibility=hidden], [AM_CFLAGS]) 106 AX_APPEND_FLAG([-DXML_ENABLE_VISIBILITY=1], [AM_CPPFLAGS])]) 107 108dnl Checks for typedefs, structures, and compiler characteristics. 109 110dnl We define BYTEORDER to 1234 when the platform is little endian; it 111dnl defines it to 4321 when the platform is big endian. We also define 112dnl WORDS_BIGENDIAN to 1 when the platform is big endian. 113dnl 114dnl A long time ago (early 2000 years) AC_C_BIGENDIAN was considered 115dnl wrong when cross compiling, now (2018, GNU Autoconf 2.69) we assume 116dnl it is fine. 117AC_C_BIGENDIAN([AC_DEFINE([WORDS_BIGENDIAN], 1) 118 AS_VAR_SET([BYTEORDER], 4321)], 119 [AS_VAR_SET([BYTEORDER], 1234)]) 120AC_DEFINE_UNQUOTED([BYTEORDER], $BYTEORDER, [1234 = LILENDIAN, 4321 = BIGENDIAN]) 121 122AC_C_CONST 123AC_TYPE_SIZE_T 124 125AC_ARG_WITH([xmlwf], 126 [AS_HELP_STRING([--without-xmlwf], [do not build xmlwf])], 127 [], 128 [with_xmlwf=yes]) 129AM_CONDITIONAL([WITH_XMLWF], [test x${with_xmlwf} = xyes]) 130 131AC_ARG_WITH([examples], 132 [AS_HELP_STRING([--without-examples], [do not build examples @<:@default=included@:>@])], 133 [], 134 [with_examples=yes]) 135AM_CONDITIONAL([WITH_EXAMPLES], [test x${with_examples} = xyes]) 136 137AC_ARG_WITH([tests], 138 [AS_HELP_STRING([--without-tests], [do not build tests @<:@default=included@:>@])], 139 [], 140 [with_tests=yes]) 141AM_CONDITIONAL([WITH_TESTS], [test x${with_tests} = xyes]) 142 143 144AS_VAR_SET([EXPATCFG_ON_MINGW],[no]) 145AS_CASE("${host_os}", 146 [mingw*], 147 [AS_VAR_SET([EXPATCFG_ON_MINGW],[yes]) 148 AC_MSG_NOTICE([detected OS: MinGW])]) 149AM_CONDITIONAL([MINGW], [test x${EXPATCFG_ON_MINGW} = xyes]) 150 151dnl Note: Prefix "_INTERNAL_" here means exclusive use inside of file configure.ac 152AM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE >/dev/null]) 153AM_CONDITIONAL([_INTERNAL_UNICODE_WCHAR_T], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE_WCHAR_T >/dev/null]) 154AM_CONDITIONAL([_INTERNAL_MIN_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_MIN_SIZE >/dev/null]) 155AM_CONDITIONAL([_INTERNAL_LARGE_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_LARGE_SIZE >/dev/null]) 156 157 158AC_ARG_WITH([libbsd], 159 [AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])], 160 [], 161 [with_libbsd=no]) 162AS_IF([test "x${with_libbsd}" != xno], 163 [AC_CHECK_LIB([bsd], 164 [arc4random_buf], 165 [], 166 [AS_IF([test "x${with_libbsd}" = xyes], 167 [AC_MSG_ERROR([Enforced use of libbsd cannot be satisfied.])])])]) 168AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)]) 169AC_LINK_IFELSE([AC_LANG_SOURCE([ 170 #include <stdlib.h> /* for arc4random_buf on BSD, for NULL */ 171 #if defined(HAVE_LIBBSD) 172 # include <bsd/stdlib.h> 173 #endif 174 int main() { 175 arc4random_buf(NULL, 0U); 176 return 0; 177 } 178 ])], 179 [AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1], [Define to 1 if you have the `arc4random_buf' function.]) 180 AC_MSG_RESULT([yes])], 181 [AC_MSG_RESULT([no]) 182 183 AC_MSG_CHECKING([for arc4random (BSD, macOS or libbsd)]) 184 AC_LINK_IFELSE([AC_LANG_SOURCE([ 185 #if defined(HAVE_LIBBSD) 186 # include <bsd/stdlib.h> 187 #else 188 # include <stdlib.h> 189 #endif 190 int main() { 191 arc4random(); 192 return 0; 193 } 194 ])], 195 [AC_DEFINE([HAVE_ARC4RANDOM], [1], [Define to 1 if you have the `arc4random' function.]) 196 AC_MSG_RESULT([yes])], 197 [AC_MSG_RESULT([no])])]) 198 199AC_ARG_WITH([getrandom], 200 [AS_HELP_STRING([--with-getrandom], 201 [enforce the use of getrandom function in the system @<:@default=check@:>@]) 202AS_HELP_STRING([--without-getrandom], 203 [skip auto detect of getrandom @<:@default=check@:>@])], 204 [], 205 [with_getrandom=check]) 206 207AS_IF([test "x$with_getrandom" != xno], 208 [AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)]) 209 AC_LINK_IFELSE([AC_LANG_SOURCE([ 210 #include <stdlib.h> /* for NULL */ 211 #include <sys/random.h> 212 int main() { 213 return getrandom(NULL, 0U, 0U); 214 } 215 ])], 216 [AC_DEFINE([HAVE_GETRANDOM], [1], [Define to 1 if you have the `getrandom' function.]) 217 AC_MSG_RESULT([yes])], 218 [AC_MSG_RESULT([no]) 219 AS_IF([test "x$with_getrandom" = xyes], 220 [AC_MSG_ERROR([enforced the use of getrandom --with-getrandom, but not detected])])])]) 221 222AC_ARG_WITH([sys_getrandom], 223 [AS_HELP_STRING([--with-sys-getrandom], 224 [enforce the use of syscall SYS_getrandom function in the system @<:@default=check@:>@]) 225AS_HELP_STRING([--without-sys-getrandom], 226 [skip auto detect of syscall SYS_getrandom @<:@default=check@:>@])], 227 [], 228 [with_sys_getrandom=check]) 229 230AS_IF([test "x$with_sys_getrandom" != xno], 231 [AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)]) 232 AC_LINK_IFELSE([AC_LANG_SOURCE([ 233 #include <stdlib.h> /* for NULL */ 234 #include <unistd.h> /* for syscall */ 235 #include <sys/syscall.h> /* for SYS_getrandom */ 236 int main() { 237 syscall(SYS_getrandom, NULL, 0, 0); 238 return 0; 239 } 240 ])], 241 [AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1], [Define to 1 if you have `syscall' and `SYS_getrandom'.]) 242 AC_MSG_RESULT([yes])], 243 [AC_MSG_RESULT([no]) 244 AS_IF([test "x$with_sys_getrandom" = xyes], 245 [AC_MSG_ERROR([enforced the use of syscall SYS_getrandom --with-sys-getrandom, but not detected])])])]) 246 247dnl Only needed for xmlwf: 248AC_CHECK_HEADERS(fcntl.h unistd.h) 249AC_TYPE_OFF_T 250AC_FUNC_MMAP 251 252AS_IF([test "$ac_cv_func_mmap_fixed_mapped" = "yes"], 253 [AS_VAR_SET(FILEMAP,unixfilemap)], 254 [AS_VAR_SET(FILEMAP,readfilemap)]) 255AC_SUBST(FILEMAP) 256 257 258dnl Some basic configuration: 259AC_DEFINE([XML_NS], 1, 260 [Define to make XML Namespaces functionality available.]) 261AC_DEFINE([XML_DTD], 1, 262 [Define to make parameter entity parsing functionality available.]) 263AC_DEFINE([XML_DEV_URANDOM], 1, 264 [Define to include code reading entropy from `/dev/urandom'.]) 265 266AC_ARG_ENABLE([xml-attr-info], 267 [AS_HELP_STRING([--enable-xml-attr-info], 268 [Enable retrieving the byte offsets for attribute names and values @<:@default=no@:>@])], 269 [], 270 [enable_xml_attr_info=no]) 271AS_IF([test "x${enable_xml_attr_info}" = "xyes"], 272 [AC_DEFINE([XML_ATTR_INFO], 1, 273 [Define to allow retrieving the byte offsets for attribute names and values.])]) 274 275AC_ARG_ENABLE([xml-context], 276 AS_HELP_STRING([--enable-xml-context @<:@COUNT@:>@], 277 [Retain context around the current parse point; 278 default is enabled and a size of 1024 bytes]) 279AS_HELP_STRING([--disable-xml-context], 280 [Do not retain context around the current parse point]), 281 [enable_xml_context=${enableval}]) 282AS_IF([test "x${enable_xml_context}" != "xno"], 283 [AS_IF([test "x${enable_xml_context}" = "xyes" \ 284 -o "x${enable_xml_context}" = "x"], 285 [AS_VAR_SET(enable_xml_context,1024)]) 286 AC_DEFINE_UNQUOTED([XML_CONTEXT_BYTES], [${enable_xml_context}], 287 [Define to specify how much context to retain around the current parse point.])]) 288 289AC_ARG_WITH([docbook], 290 [AS_HELP_STRING([--with-docbook], 291 [enforce XML to man page compilation @<:@default=check@:>@]) 292AS_HELP_STRING([--without-docbook], 293 [skip XML to man page compilation @<:@default=check@:>@])], 294 [], 295 [with_docbook=check]) 296 297AC_ARG_VAR([DOCBOOK_TO_MAN], [docbook2x-man command]) 298AS_IF([test "x$with_docbook" != xno], 299 [AC_CHECK_PROGS([DOCBOOK_TO_MAN], [docbook2x-man db2x_docbook2man docbook2man docbook-to-man])]) 300AS_IF([test "x${DOCBOOK_TO_MAN}" = x -a "x$with_docbook" = xyes], 301 [AC_MSG_ERROR([Required program 'docbook2x-man' not found.])]) 302AS_IF([test "x${DOCBOOK_TO_MAN}" != x -a "x$with_docbook" != xno], 303 [AS_IF([${DOCBOOK_TO_MAN} --help | grep -i -q -F sgmlbase], 304 [AC_MSG_ERROR([Your local ${DOCBOOK_TO_MAN} was found to work with SGML rather 305 than XML. Please install docbook2X and use variable DOCBOOK_TO_MAN to point 306 configure to command docbook2x-man of docbook2X. 307 Or use DOCBOOK_TO_MAN="xmlto man --skip-validation" if you have xmlto around. 308 You can also configure using --without-docbook if you can do without a man 309 page for xmlwf.])])]) 310 311AM_CONDITIONAL(WITH_DOCBOOK, [test "x${DOCBOOK_TO_MAN}" != x]) 312 313 314dnl Configure CMake file templates 315dnl NOTE: The *_TRUE variables read here are Automake conditionals 316dnl that are either set to "" when enabled or to "#" when disabled 317dnl (because they are used to dynamically comment out certain things) 318AS_IF([test "x${enable_xml_attr_info}" = xyes], 319 [EXPAT_ATTR_INFO=ON], 320 [EXPAT_ATTR_INFO=OFF]) 321EXPAT_DTD=ON 322AS_IF([test "x${_INTERNAL_LARGE_SIZE_TRUE}" = x], 323 [EXPAT_LARGE_SIZE=ON], 324 [EXPAT_LARGE_SIZE=OFF]) 325AS_IF([test "x${_INTERNAL_MIN_SIZE_TRUE}" = x], 326 [EXPAT_MIN_SIZE=ON], 327 [EXPAT_MIN_SIZE=OFF]) 328EXPAT_NS=ON 329AS_IF([test "x${enable_xml_context}" != xno], 330 [EXPAT_CONTEXT_BYTES=${enable_xml_context}], 331 [EXPAT_CONTEXT_BYTES=OFF]) 332AS_IF([test "x${UNICODE_TRUE}" = x], 333 [AS_IF( 334 [test "x${_INTERNAL_UNICODE_WCHAR_T_TRUE}" = x], 335 [EXPAT_CHAR_TYPE=wchar_t], 336 [EXPAT_CHAR_TYPE=ushort])], 337 [EXPAT_CHAR_TYPE=char]) 338PACKAGE_INIT="${srcdir}"/cmake/autotools/expat-package-init.cmake 339LIBDIR_BASENAME="$(basename "${libdir}")" 340SO_MAJOR="$(expr "${LIBCURRENT}" - "${LIBAGE}")" 341SO_MINOR="${LIBAGE}" 342SO_PATCH="${LIBREVISION}" 343AC_SUBST([EXPAT_ATTR_INFO]) 344AC_SUBST([EXPAT_DTD]) 345AC_SUBST([EXPAT_LARGE_SIZE]) 346AC_SUBST([EXPAT_MIN_SIZE]) 347AC_SUBST([EXPAT_NS]) 348AC_SUBST([EXPAT_CONTEXT_BYTES]) 349AC_SUBST([EXPAT_CHAR_TYPE]) 350AC_SUBST_FILE([PACKAGE_INIT]) 351AC_SUBST([LIBDIR_BASENAME]) 352AC_SUBST([SO_MAJOR]) 353AC_SUBST([SO_MINOR]) 354AC_SUBST([SO_PATCH]) 355 356 357dnl write the Automake flags we set 358AC_SUBST([AM_CPPFLAGS]) 359AC_SUBST([AM_CFLAGS]) 360AC_SUBST([AM_CXXFLAGS]) 361AC_SUBST([AM_LDFLAGS]) 362 363dnl updating _EXPAT_OUTPUT_NAME variable to effect the package name in expat.pc file (issue #361) 364AC_SUBST(_EXPAT_OUTPUT_NAME, ["$PACKAGE_NAME"]) 365 366AC_CONFIG_FILES([Makefile] 367 [expat.pc] 368 [cmake/expat-config.cmake] 369 [cmake/autotools/expat-config-version.cmake] 370 [cmake/autotools/expat-noconfig.cmake] 371 [doc/Makefile] 372 [examples/Makefile] 373 [lib/Makefile] 374 [tests/Makefile] 375 [tests/benchmark/Makefile] 376 [xmlwf/Makefile]) 377AC_CONFIG_FILES([run.sh], [chmod +x run.sh]) 378AC_OUTPUT 379 380 381AC_MSG_NOTICE([ 382 383Automake flags (can be overridden by user flags): 384 [AM_CPPFLAGS]: ${AM_CPPFLAGS} 385 [AM_CFLAGS]: ${AM_CFLAGS} 386 [AM_CXXFLAGS]: ${AM_CXXFLAGS} 387 [AM_LDFLAGS]: ${AM_LDFLAGS} 388 389User flags (override Automake flags on conflict): 390 CPPFLAGS: ${CPPFLAGS} 391 CFLAGS: ${CFLAGS} 392 CXXFLAGS: ${CXXFLAGS} 393 LDFLAGS: ${LDFLAGS}]) 394