configure.ac 14 KB

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