1302260Sdelphijdnl configuration script for expat 2302260Sdelphijdnl Process this file with autoconf to produce a configure script. 3302260Sdelphijdnl 4302260Sdelphijdnl Copyright 2000 Clark Cooper 5302260Sdelphijdnl 6302260Sdelphijdnl This file is part of EXPAT. 7302260Sdelphijdnl 8302260Sdelphijdnl EXPAT is free software; you can redistribute it and/or modify it 9302260Sdelphijdnl under the terms of the License (based on the MIT/X license) contained 10302260Sdelphijdnl in the file COPYING that comes with this distribution. 11302260Sdelphijdnl 12302260Sdelphij 13355604Sdelphijdnl Ensure that Expat is configured with autoconf 2.69 or newer. 14355604SdelphijAC_PREREQ(2.69) 15302260Sdelphij 16302260Sdelphijdnl Get the version number of Expat, using m4's esyscmd() command to run 17302260Sdelphijdnl the command at m4-generation time. This allows us to create an m4 18302260Sdelphijdnl symbol holding the correct version number. AC_INIT() requires the 19302260Sdelphijdnl version number at m4-time, rather than when ./configure is run, so 20302260Sdelphijdnl all this must happen as part of m4, not as part of the shell code 21302260Sdelphijdnl contained in ./configure. 22302260Sdelphijdnl 23302260Sdelphijdnl NOTE: esyscmd() is a GNU M4 extension. Thus, we wrap it in an appropriate 24302260Sdelphijdnl test. I believe this test will work, but I don't have a place with non- 25302260Sdelphijdnl GNU M4 to test it right now. 26355604Sdelphijm4_define([expat_version], 27355604Sdelphij m4_ifdef([__gnu__], 28355604Sdelphij [esyscmd(conftools/get-version.sh lib/expat.h)], 29355604Sdelphij [2.2.x])) 30302260SdelphijAC_INIT(expat, expat_version, expat-bugs@libexpat.org) 31355604Sdelphijm4_undefine([expat_version]) 32302260Sdelphij 33355604SdelphijAC_CONFIG_SRCDIR([Makefile.in]) 34355604SdelphijAC_CONFIG_AUX_DIR([conftools]) 35302260SdelphijAC_CONFIG_MACRO_DIR([m4]) 36355604SdelphijAC_CANONICAL_HOST 37355604SdelphijAM_INIT_AUTOMAKE 38302260Sdelphij 39302260Sdelphij 40302260Sdelphijdnl 41302260Sdelphijdnl Increment LIBREVISION if source code has changed at all 42302260Sdelphijdnl 43302260Sdelphijdnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0 44302260Sdelphijdnl 45302260Sdelphijdnl If the API changes compatibly (i.e. simply adding a new function 46302260Sdelphijdnl without changing or removing earlier interfaces), then increment LIBAGE. 47355604Sdelphijdnl 48302260Sdelphijdnl If the API changes incompatibly set LIBAGE back to 0 49302260Sdelphijdnl 50302260Sdelphij 51355604SdelphijLIBCURRENT=7 # sync 52355604SdelphijLIBREVISION=11 # with 53355604SdelphijLIBAGE=6 # CMakeLists.txt! 54302260Sdelphij 55355604SdelphijAX_APPEND_FLAG([-DHAVE_EXPAT_CONFIG_H], [CPPFLAGS]) 56355604SdelphijAC_CONFIG_HEADER([expat_config.h]) 57302260Sdelphij 58355604SdelphijAM_PROG_AR 59355604SdelphijAC_PROG_INSTALL 60355604SdelphijAC_PROG_LN_S 61355604SdelphijAC_PROG_MAKE_SET 62302260Sdelphij 63355604SdelphijLT_PREREQ([2.4]) 64355604SdelphijLT_INIT([win32-dll]) 65302260Sdelphij 66302260SdelphijAC_SUBST(LIBCURRENT) 67302260SdelphijAC_SUBST(LIBREVISION) 68302260SdelphijAC_SUBST(LIBAGE) 69302260Sdelphij 70355604SdelphijAC_LANG([C]) 71355604SdelphijAC_PROG_CC_C99 72355604SdelphijAS_IF([test "$GCC" = yes], 73355604Sdelphij [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [CFLAGS]) 74355604Sdelphij dnl Be careful about adding the -fexceptions option; some versions of 75355604Sdelphij dnl GCC don't support it and it causes extra warnings that are only 76355604Sdelphij dnl distracting; avoid. 77355604Sdelphij AX_APPEND_COMPILE_FLAGS([-fexceptions], [CFLAGS]) 78355604Sdelphij AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -Wmissing-prototypes -Wstrict-prototypes], [CFLAGS]) 79355604Sdelphij AX_APPEND_COMPILE_FLAGS([-pedantic -Wduplicated-cond -Wduplicated-branches -Wlogical-op], [CFLAGS]) 80355604Sdelphij AX_APPEND_COMPILE_FLAGS([-Wrestrict -Wnull-dereference -Wjump-misses-init -Wdouble-promotion], [CFLAGS]) 81355604Sdelphij AX_APPEND_COMPILE_FLAGS([-Wshadow -Wformat=2 -Wmisleading-indentation], [CFLAGS])]) 82355604Sdelphij 83355604SdelphijAC_LANG_PUSH([C++]) 84302260SdelphijAC_PROG_CXX 85355604SdelphijAS_IF([test "$GCC" = yes], 86355604Sdelphij [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [CXXFLAGS]) 87355604Sdelphij dnl Be careful about adding the -fexceptions option; some versions of 88355604Sdelphij dnl GCC don't support it and it causes extra warnings that are only 89355604Sdelphij dnl distracting; avoid. 90355604Sdelphij AX_APPEND_COMPILE_FLAGS([-fexceptions], [CXXFLAGS]) 91355604Sdelphij AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [CXXFLAGS])]) 92355604SdelphijAC_LANG_POP([C++]) 93302260Sdelphij 94355604SdelphijAS_IF([test "$GCC" = yes], 95355604Sdelphij [AX_APPEND_LINK_FLAGS([-fno-strict-aliasing],[LDFLAGS])]) 96302260Sdelphij 97355604Sdelphijdnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang (issue #312) 98355604SdelphijAS_CASE(["$LD"],[*clang*], 99355604Sdelphij [AS_CASE(["${host_os}"], 100355604Sdelphij [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])]) 101355604Sdelphij 102355604SdelphijEXPATCFG_COMPILER_SUPPORTS_VISIBILITY([ 103355604Sdelphij AX_APPEND_FLAG([-fvisibility=hidden], [CFLAGS]) 104355604Sdelphij AX_APPEND_FLAG([-DXML_ENABLE_VISIBILITY=1], [CFLAGS])]) 105355604Sdelphij 106302260Sdelphijdnl Checks for header files. 107302260SdelphijAC_HEADER_STDC 108302260Sdelphij 109302260Sdelphijdnl Checks for typedefs, structures, and compiler characteristics. 110302260Sdelphij 111355604Sdelphijdnl We define BYTEORDER to 1234 when the platform is little endian; it 112355604Sdelphijdnl defines it to 4321 when the platform is big endian. We also define 113355604Sdelphijdnl WORDS_BIGENDIAN to 1 when the platform is big endian. 114355604Sdelphijdnl 115355604Sdelphijdnl A long time ago (early 2000 years) AC_C_BIGENDIAN was considered 116355604Sdelphijdnl wrong when cross compiling, now (2018, GNU Autoconf 2.69) we assume 117355604Sdelphijdnl it is fine. 118355604SdelphijAC_C_BIGENDIAN([AC_DEFINE([WORDS_BIGENDIAN], 1) 119355604Sdelphij AS_VAR_SET([BYTEORDER], 4321)], 120355604Sdelphij [AS_VAR_SET([BYTEORDER], 1234)]) 121355604SdelphijAC_DEFINE_UNQUOTED([BYTEORDER], $BYTEORDER, [1234 = LILENDIAN, 4321 = BIGENDIAN]) 122302260Sdelphij 123302260SdelphijAC_C_CONST 124302260SdelphijAC_TYPE_SIZE_T 125302260Sdelphij 126355604SdelphijAC_ARG_WITH([xmlwf], 127355604Sdelphij [AS_HELP_STRING([--without-xmlwf], [do not build xmlwf])], 128355604Sdelphij [], 129355604Sdelphij [with_xmlwf=yes]) 130355604SdelphijAM_CONDITIONAL([WITH_XMLWF], [test x${with_xmlwf} = xyes]) 131355604Sdelphij 132355604SdelphijAC_ARG_WITH([examples], 133355604Sdelphij [AS_HELP_STRING([--without-examples], [do not build examples @<:@default=included@:>@])], 134355604Sdelphij [], 135355604Sdelphij [with_examples=yes]) 136355604SdelphijAM_CONDITIONAL([WITH_EXAMPLES], [test x${with_examples} = xyes]) 137355604Sdelphij 138355604SdelphijAC_ARG_WITH([tests], 139355604Sdelphij [AS_HELP_STRING([--without-tests], [do not build tests @<:@default=included@:>@])], 140355604Sdelphij [], 141355604Sdelphij [with_tests=yes]) 142355604SdelphijAM_CONDITIONAL([WITH_TESTS], [test x${with_tests} = xyes]) 143355604Sdelphij 144355604Sdelphij 145355604SdelphijAS_VAR_SET([EXPATCFG_ON_MINGW],[no]) 146355604SdelphijAS_CASE("${host_os}", 147355604Sdelphij [mingw*], 148355604Sdelphij [AS_VAR_SET([EXPATCFG_ON_MINGW],[yes]) 149355604Sdelphij AC_MSG_NOTICE([detected OS: MinGW])]) 150355604SdelphijAM_CONDITIONAL([MINGW], [test x${EXPATCFG_ON_MINGW} = xyes]) 151355604Sdelphij 152355604SdelphijAM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE >/dev/null]) 153355604Sdelphij 154355604Sdelphij 155355604SdelphijAC_ARG_WITH([libbsd], 156355604Sdelphij [AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])], 157355604Sdelphij [], 158355604Sdelphij [with_libbsd=no]) 159355604SdelphijAS_IF([test "x${with_libbsd}" != xno], 160355604Sdelphij [AC_CHECK_LIB([bsd], 161355604Sdelphij [arc4random_buf], 162355604Sdelphij [], 163355604Sdelphij [AS_IF([test "x${with_libbsd}" = xyes], 164355604Sdelphij [AC_MSG_ERROR([Enforced use of libbsd cannot be satisfied.])])])]) 165355604SdelphijAC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)]) 166355604SdelphijAC_LINK_IFELSE([AC_LANG_SOURCE([ 167355604Sdelphij #include <stdlib.h> /* for arc4random_buf on BSD, for NULL */ 168355604Sdelphij #if defined(HAVE_LIBBSD) 169355604Sdelphij # include <bsd/stdlib.h> 170355604Sdelphij #endif 171355604Sdelphij int main() { 172355604Sdelphij arc4random_buf(NULL, 0U); 173355604Sdelphij return 0; 174355604Sdelphij } 175355604Sdelphij ])], 176355604Sdelphij [AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1], [Define to 1 if you have the `arc4random_buf' function.]) 177355604Sdelphij AC_MSG_RESULT([yes])], 178355604Sdelphij [AC_MSG_RESULT([no]) 179355604Sdelphij 180355604Sdelphij AC_MSG_CHECKING([for arc4random (BSD, macOS or libbsd)]) 181355604Sdelphij AC_LINK_IFELSE([AC_LANG_SOURCE([ 182355604Sdelphij #if defined(HAVE_LIBBSD) 183355604Sdelphij # include <bsd/stdlib.h> 184355604Sdelphij #else 185355604Sdelphij # include <stdlib.h> 186355604Sdelphij #endif 187355604Sdelphij int main() { 188355604Sdelphij arc4random(); 189355604Sdelphij return 0; 190355604Sdelphij } 191355604Sdelphij ])], 192355604Sdelphij [AC_DEFINE([HAVE_ARC4RANDOM], [1], [Define to 1 if you have the `arc4random' function.]) 193355604Sdelphij AC_MSG_RESULT([yes])], 194355604Sdelphij [AC_MSG_RESULT([no])])]) 195355604Sdelphij 196355604SdelphijAC_ARG_WITH([getrandom], 197355604Sdelphij [AS_HELP_STRING([--with-getrandom], 198355604Sdelphij [enforce the use of getrandom function in the system @<:@default=check@:>@]) 199355604SdelphijAS_HELP_STRING([--without-getrandom], 200355604Sdelphij [skip auto detect of getrandom @<:@default=check@:>@])], 201355604Sdelphij [], 202355604Sdelphij [with_getrandom=check]) 203355604Sdelphij 204355604SdelphijAS_IF([test "x$with_getrandom" != xno], 205355604Sdelphij [AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)]) 206355604Sdelphij AC_LINK_IFELSE([AC_LANG_SOURCE([ 207355604Sdelphij #include <stdlib.h> /* for NULL */ 208355604Sdelphij #include <sys/random.h> 209355604Sdelphij int main() { 210355604Sdelphij return getrandom(NULL, 0U, 0U); 211355604Sdelphij } 212355604Sdelphij ])], 213355604Sdelphij [AC_DEFINE([HAVE_GETRANDOM], [1], [Define to 1 if you have the `getrandom' function.]) 214355604Sdelphij AC_MSG_RESULT([yes])], 215355604Sdelphij [AC_MSG_RESULT([no]) 216355604Sdelphij AS_IF([test "x$with_getrandom" = xyes], 217355604Sdelphij [AC_MSG_ERROR([enforced the use of getrandom --with-getrandom, but not detected])])])]) 218355604Sdelphij 219355604SdelphijAC_ARG_WITH([sys_getrandom], 220355604Sdelphij [AS_HELP_STRING([--with-sys-getrandom], 221355604Sdelphij [enforce the use of syscall SYS_getrandom function in the system @<:@default=check@:>@]) 222355604SdelphijAS_HELP_STRING([--without-sys-getrandom], 223355604Sdelphij [skip auto detect of syscall SYS_getrandom @<:@default=check@:>@])], 224355604Sdelphij [], 225355604Sdelphij [with_sys_getrandom=check]) 226355604Sdelphij 227355604SdelphijAS_IF([test "x$with_sys_getrandom" != xno], 228355604Sdelphij [AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)]) 229355604Sdelphij AC_LINK_IFELSE([AC_LANG_SOURCE([ 230355604Sdelphij #include <stdlib.h> /* for NULL */ 231355604Sdelphij #include <unistd.h> /* for syscall */ 232355604Sdelphij #include <sys/syscall.h> /* for SYS_getrandom */ 233355604Sdelphij int main() { 234355604Sdelphij syscall(SYS_getrandom, NULL, 0, 0); 235355604Sdelphij return 0; 236355604Sdelphij } 237355604Sdelphij ])], 238355604Sdelphij [AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1], [Define to 1 if you have `syscall' and `SYS_getrandom'.]) 239355604Sdelphij AC_MSG_RESULT([yes])], 240355604Sdelphij [AC_MSG_RESULT([no]) 241355604Sdelphij AS_IF([test "x$with_sys_getrandom" = xyes], 242355604Sdelphij [AC_MSG_ERROR([enforced the use of syscall SYS_getrandom --with-sys-getrandom, but not detected])])])]) 243355604Sdelphij 244302260Sdelphijdnl Only needed for xmlwf: 245302260SdelphijAC_CHECK_HEADERS(fcntl.h unistd.h) 246302260SdelphijAC_TYPE_OFF_T 247302260SdelphijAC_FUNC_MMAP 248302260Sdelphij 249355604SdelphijAS_IF([test "$ac_cv_func_mmap_fixed_mapped" = "yes"], 250355604Sdelphij [AS_VAR_SET(FILEMAP,unixfilemap)], 251355604Sdelphij [AS_VAR_SET(FILEMAP,readfilemap)]) 252302260SdelphijAC_SUBST(FILEMAP) 253302260Sdelphij 254302260Sdelphij 255302260Sdelphijdnl Some basic configuration: 256302260SdelphijAC_DEFINE([XML_NS], 1, 257302260Sdelphij [Define to make XML Namespaces functionality available.]) 258302260SdelphijAC_DEFINE([XML_DTD], 1, 259302260Sdelphij [Define to make parameter entity parsing functionality available.]) 260355604SdelphijAC_DEFINE([XML_DEV_URANDOM], 1, 261355604Sdelphij [Define to include code reading entropy from `/dev/urandom'.]) 262302260Sdelphij 263355604SdelphijAC_ARG_ENABLE([xml-attr-info], 264355604Sdelphij [AS_HELP_STRING([--enable-xml-attr-info], 265355604Sdelphij [Enable retrieving the byte offsets for attribute names and values @<:@default=no@:>@])], 266355604Sdelphij [], 267355604Sdelphij [enable_xml_attr_info=no]) 268355604SdelphijAS_IF([test "x${enable_xml_attr_info}" = "xyes"], 269355604Sdelphij [AC_DEFINE([XML_ATTR_INFO], 1, 270355604Sdelphij [Define to allow retrieving the byte offsets for attribute names and values.])]) 271355604Sdelphij 272355604SdelphijAC_ARG_ENABLE([xml-context], 273355604Sdelphij AS_HELP_STRING([--enable-xml-context @<:@COUNT@:>@], 274355604Sdelphij [Retain context around the current parse point; 275355604Sdelphij default is enabled and a size of 1024 bytes]) 276355604SdelphijAS_HELP_STRING([--disable-xml-context], 277355604Sdelphij [Do not retain context around the current parse point]), 278355604Sdelphij [enable_xml_context=${enableval}]) 279355604SdelphijAS_IF([test "x${enable_xml_context}" != "xno"], 280355604Sdelphij [AS_IF([test "x${enable_xml_context}" = "xyes" \ 281355604Sdelphij -o "x${enable_xml_context}" = "x"], 282355604Sdelphij [AS_VAR_SET(enable_xml_context,1024)]) 283355604Sdelphij AC_DEFINE_UNQUOTED([XML_CONTEXT_BYTES], [${enable_xml_context}], 284355604Sdelphij [Define to specify how much context to retain around the current parse point.])]) 285355604Sdelphij 286355604SdelphijAC_ARG_WITH([docbook], 287355604Sdelphij [AS_HELP_STRING([--with-docbook], 288355604Sdelphij [enforce XML to man page compilation @<:@default=check@:>@]) 289355604SdelphijAS_HELP_STRING([--without-docbook], 290355604Sdelphij [skip XML to man page compilation @<:@default=check@:>@])], 291355604Sdelphij [], 292355604Sdelphij [with_docbook=check]) 293355604Sdelphij 294355604SdelphijAC_ARG_VAR([DOCBOOK_TO_MAN], [docbook2x-man command]) 295355604SdelphijAS_IF([test "x$with_docbook" != xno], 296355604Sdelphij [AC_CHECK_PROGS([DOCBOOK_TO_MAN], [docbook2x-man db2x_docbook2man docbook2man docbook-to-man])]) 297355604SdelphijAS_IF([test "x${DOCBOOK_TO_MAN}" = x -a "x$with_docbook" = xyes], 298355604Sdelphij [AC_MSG_ERROR([Required program 'docbook2x-man' not found.])]) 299355604SdelphijAS_IF([test "x${DOCBOOK_TO_MAN}" != x -a "x$with_docbook" != xno], 300355604Sdelphij [AS_IF([${DOCBOOK_TO_MAN} --help | grep -i -q -F sgmlbase], 301355604Sdelphij [AC_MSG_ERROR([Your local ${DOCBOOK_TO_MAN} was found to work with SGML rather 302355604Sdelphij than XML. Please install docbook2X and use variable DOCBOOK_TO_MAN to point 303355604Sdelphij configure to command docbook2x-man of docbook2X. 304355604Sdelphij Or use DOCBOOK_TO_MAN="xmlto man --skip-validation" if you have xmlto around. 305355604Sdelphij You can also configure using --without-docbook if you can do without a man 306355604Sdelphij page for xmlwf.])])]) 307355604Sdelphij 308355604SdelphijAM_CONDITIONAL(WITH_DOCBOOK, [test "x${DOCBOOK_TO_MAN}" != x]) 309355604Sdelphij 310355604SdelphijAC_CONFIG_FILES([Makefile] 311355604Sdelphij [expat.pc] 312355604Sdelphij [doc/Makefile] 313355604Sdelphij [examples/Makefile] 314355604Sdelphij [lib/Makefile] 315355604Sdelphij [tests/Makefile] 316355604Sdelphij [tests/benchmark/Makefile] 317355604Sdelphij [xmlwf/Makefile]) 318355604SdelphijAC_CONFIG_FILES([run.sh], [chmod +x run.sh]) 319302260SdelphijAC_OUTPUT 320