configure.ac 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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=7 # sync
  46. LIBREVISION=10 # with
  47. LIBAGE=6 # CMakeLists.txt!
  48. AX_APPEND_FLAG([-DHAVE_EXPAT_CONFIG_H], [CPPFLAGS])
  49. AC_CONFIG_HEADER([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], [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], [CFLAGS])
  67. AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -Wmissing-prototypes -Wstrict-prototypes], [CFLAGS])
  68. AX_APPEND_COMPILE_FLAGS([-pedantic -Wduplicated-cond -Wduplicated-branches -Wlogical-op], [CFLAGS])
  69. AX_APPEND_COMPILE_FLAGS([-Wrestrict -Wnull-dereference -Wjump-misses-init -Wdouble-promotion], [CFLAGS])
  70. AX_APPEND_COMPILE_FLAGS([-Wshadow -Wformat=2 -Wmisleading-indentation], [CFLAGS])])
  71. AC_LANG_PUSH([C++])
  72. AC_PROG_CXX
  73. AS_IF([test "$GCC" = yes],
  74. [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [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], [CXXFLAGS])
  79. AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [CXXFLAGS])])
  80. AC_LANG_POP([C++])
  81. AS_IF([test "$GCC" = yes],
  82. [AX_APPEND_LINK_FLAGS([-fno-strict-aliasing],[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], [CFLAGS])
  89. AX_APPEND_FLAG([-DXML_ENABLE_VISIBILITY=1], [CFLAGS])])
  90. dnl Checks for header files.
  91. AC_HEADER_STDC
  92. dnl Checks for typedefs, structures, and compiler characteristics.
  93. dnl We define BYTEORDER to 1234 when the platform is little endian; it
  94. dnl defines it to 4321 when the platform is big endian. We also define
  95. dnl WORDS_BIGENDIAN to 1 when the platform is big endian.
  96. dnl
  97. dnl A long time ago (early 2000 years) AC_C_BIGENDIAN was considered
  98. dnl wrong when cross compiling, now (2018, GNU Autoconf 2.69) we assume
  99. dnl it is fine.
  100. AC_C_BIGENDIAN([AC_DEFINE([WORDS_BIGENDIAN], 1)
  101. AS_VAR_SET([BYTEORDER], 4321)],
  102. [AS_VAR_SET([BYTEORDER], 1234)])
  103. AC_DEFINE_UNQUOTED([BYTEORDER], $BYTEORDER, [1234 = LILENDIAN, 4321 = BIGENDIAN])
  104. AC_C_CONST
  105. AC_TYPE_SIZE_T
  106. AC_ARG_WITH([xmlwf],
  107. [AS_HELP_STRING([--without-xmlwf], [do not build xmlwf])],
  108. [],
  109. [with_xmlwf=yes])
  110. AM_CONDITIONAL([WITH_XMLWF], [test x${with_xmlwf} = xyes])
  111. AC_ARG_WITH([examples],
  112. [AS_HELP_STRING([--without-examples], [do not build examples @<:@default=included@:>@])],
  113. [],
  114. [with_examples=yes])
  115. AM_CONDITIONAL([WITH_EXAMPLES], [test x${with_examples} = xyes])
  116. AC_ARG_WITH([tests],
  117. [AS_HELP_STRING([--without-tests], [do not build tests @<:@default=included@:>@])],
  118. [],
  119. [with_tests=yes])
  120. AM_CONDITIONAL([WITH_TESTS], [test x${with_tests} = xyes])
  121. AS_VAR_SET([EXPATCFG_ON_MINGW],[no])
  122. AS_CASE("${host_os}",
  123. [mingw*],
  124. [AS_VAR_SET([EXPATCFG_ON_MINGW],[yes])
  125. AC_MSG_NOTICE([detected OS: MinGW])])
  126. AM_CONDITIONAL([MINGW], [test x${EXPATCFG_ON_MINGW} = xyes])
  127. AM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE >/dev/null])
  128. AC_ARG_WITH([libbsd],
  129. [AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])],
  130. [],
  131. [with_libbsd=no])
  132. AS_IF([test "x${with_libbsd}" != xno],
  133. [AC_CHECK_LIB([bsd],
  134. [arc4random_buf],
  135. [],
  136. [AS_IF([test "x${with_libbsd}" = xyes],
  137. [AC_MSG_ERROR([Enforced use of libbsd cannot be satisfied.])])])])
  138. AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)])
  139. AC_LINK_IFELSE([AC_LANG_SOURCE([
  140. #include <stdlib.h> /* for arc4random_buf on BSD, for NULL */
  141. #if defined(HAVE_LIBBSD)
  142. # include <bsd/stdlib.h>
  143. #endif
  144. int main() {
  145. arc4random_buf(NULL, 0U);
  146. return 0;
  147. }
  148. ])],
  149. [AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1], [Define to 1 if you have the `arc4random_buf' function.])
  150. AC_MSG_RESULT([yes])],
  151. [AC_MSG_RESULT([no])
  152. AC_MSG_CHECKING([for arc4random (BSD, macOS or libbsd)])
  153. AC_LINK_IFELSE([AC_LANG_SOURCE([
  154. #if defined(HAVE_LIBBSD)
  155. # include <bsd/stdlib.h>
  156. #else
  157. # include <stdlib.h>
  158. #endif
  159. int main() {
  160. arc4random();
  161. return 0;
  162. }
  163. ])],
  164. [AC_DEFINE([HAVE_ARC4RANDOM], [1], [Define to 1 if you have the `arc4random' function.])
  165. AC_MSG_RESULT([yes])],
  166. [AC_MSG_RESULT([no])])])
  167. AC_ARG_WITH([getrandom],
  168. [AS_HELP_STRING([--with-getrandom],
  169. [enforce the use of getrandom function in the system @<:@default=check@:>@])
  170. AS_HELP_STRING([--without-getrandom],
  171. [skip auto detect of getrandom @<:@default=check@:>@])],
  172. [],
  173. [with_getrandom=check])
  174. AS_IF([test "x$with_getrandom" != xno],
  175. [AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
  176. AC_LINK_IFELSE([AC_LANG_SOURCE([
  177. #include <stdlib.h> /* for NULL */
  178. #include <sys/random.h>
  179. int main() {
  180. return getrandom(NULL, 0U, 0U);
  181. }
  182. ])],
  183. [AC_DEFINE([HAVE_GETRANDOM], [1], [Define to 1 if you have the `getrandom' function.])
  184. AC_MSG_RESULT([yes])],
  185. [AC_MSG_RESULT([no])
  186. AS_IF([test "x$with_getrandom" = xyes],
  187. [AC_MSG_ERROR([enforced the use of getrandom --with-getrandom, but not detected])])])])
  188. AC_ARG_WITH([sys_getrandom],
  189. [AS_HELP_STRING([--with-sys-getrandom],
  190. [enforce the use of syscall SYS_getrandom function in the system @<:@default=check@:>@])
  191. AS_HELP_STRING([--without-sys-getrandom],
  192. [skip auto detect of syscall SYS_getrandom @<:@default=check@:>@])],
  193. [],
  194. [with_sys_getrandom=check])
  195. AS_IF([test "x$with_sys_getrandom" != xno],
  196. [AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)])
  197. AC_LINK_IFELSE([AC_LANG_SOURCE([
  198. #include <stdlib.h> /* for NULL */
  199. #include <unistd.h> /* for syscall */
  200. #include <sys/syscall.h> /* for SYS_getrandom */
  201. int main() {
  202. syscall(SYS_getrandom, NULL, 0, 0);
  203. return 0;
  204. }
  205. ])],
  206. [AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1], [Define to 1 if you have `syscall' and `SYS_getrandom'.])
  207. AC_MSG_RESULT([yes])],
  208. [AC_MSG_RESULT([no])
  209. AS_IF([test "x$with_sys_getrandom" = xyes],
  210. [AC_MSG_ERROR([enforced the use of syscall SYS_getrandom --with-sys-getrandom, but not detected])])])])
  211. dnl Only needed for xmlwf:
  212. AC_CHECK_HEADERS(fcntl.h unistd.h)
  213. AC_TYPE_OFF_T
  214. AC_FUNC_MMAP
  215. AS_IF([test "$ac_cv_func_mmap_fixed_mapped" = "yes"],
  216. [AS_VAR_SET(FILEMAP,unixfilemap)],
  217. [AS_VAR_SET(FILEMAP,readfilemap)])
  218. AC_SUBST(FILEMAP)
  219. dnl Some basic configuration:
  220. AC_DEFINE([XML_NS], 1,
  221. [Define to make XML Namespaces functionality available.])
  222. AC_DEFINE([XML_DTD], 1,
  223. [Define to make parameter entity parsing functionality available.])
  224. AC_DEFINE([XML_DEV_URANDOM], 1,
  225. [Define to include code reading entropy from `/dev/urandom'.])
  226. AC_ARG_ENABLE([xml-attr-info],
  227. [AS_HELP_STRING([--enable-xml-attr-info],
  228. [Enable retrieving the byte offsets for attribute names and values @<:@default=no@:>@])],
  229. [],
  230. [enable_xml_attr_info=no])
  231. AS_IF([test "x${enable_xml_attr_info}" = "xyes"],
  232. [AC_DEFINE([XML_ATTR_INFO], 1,
  233. [Define to allow retrieving the byte offsets for attribute names and values.])])
  234. AC_ARG_ENABLE([xml-context],
  235. AS_HELP_STRING([--enable-xml-context @<:@COUNT@:>@],
  236. [Retain context around the current parse point;
  237. default is enabled and a size of 1024 bytes])
  238. AS_HELP_STRING([--disable-xml-context],
  239. [Do not retain context around the current parse point]),
  240. [enable_xml_context=${enableval}])
  241. AS_IF([test "x${enable_xml_context}" != "xno"],
  242. [AS_IF([test "x${enable_xml_context}" = "xyes" \
  243. -o "x${enable_xml_context}" = "x"],
  244. [AS_VAR_SET(enable_xml_context,1024)])
  245. AC_DEFINE_UNQUOTED([XML_CONTEXT_BYTES], [${enable_xml_context}],
  246. [Define to specify how much context to retain around the current parse point.])])
  247. AC_ARG_WITH([docbook],
  248. [AS_HELP_STRING([--with-docbook],
  249. [enforce XML to man page compilation @<:@default=check@:>@])
  250. AS_HELP_STRING([--without-docbook],
  251. [skip XML to man page compilation @<:@default=check@:>@])],
  252. [],
  253. [with_docbook=check])
  254. AC_ARG_VAR([DOCBOOK_TO_MAN], [docbook2x-man command])
  255. AS_IF([test "x$with_docbook" != xno],
  256. [AC_CHECK_PROGS([DOCBOOK_TO_MAN], [docbook2x-man db2x_docbook2man docbook2man docbook-to-man])])
  257. AS_IF([test "x${DOCBOOK_TO_MAN}" = x -a "x$with_docbook" = xyes],
  258. [AC_MSG_ERROR([Required program 'docbook2x-man' not found.])])
  259. AS_IF([test "x${DOCBOOK_TO_MAN}" != x -a "x$with_docbook" != xno],
  260. [AS_IF([${DOCBOOK_TO_MAN} --help | grep -i -q -F sgmlbase],
  261. [AC_MSG_ERROR([Your local ${DOCBOOK_TO_MAN} was found to work with SGML rather
  262. than XML. Please install docbook2X and use variable DOCBOOK_TO_MAN to point
  263. configure to command docbook2x-man of docbook2X.
  264. Or use DOCBOOK_TO_MAN="xmlto man --skip-validation" if you have xmlto around.
  265. You can also configure using --without-docbook if you can do without a man
  266. page for xmlwf.])])])
  267. AM_CONDITIONAL(WITH_DOCBOOK, [test "x${DOCBOOK_TO_MAN}" != x])
  268. AC_CONFIG_FILES([Makefile]
  269. [expat.pc]
  270. [doc/Makefile]
  271. [examples/Makefile]
  272. [lib/Makefile]
  273. [tests/Makefile]
  274. [tests/benchmark/Makefile]
  275. [xmlwf/Makefile])
  276. AC_CONFIG_FILES([run.sh], [chmod +x run.sh])
  277. AC_OUTPUT