configure.ac 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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.58 or newer
  13. AC_PREREQ(2.58)
  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. define([expat_version], ifdef([__gnu__],
  25. [esyscmd(conftools/get-version.sh lib/expat.h)],
  26. [2.2.x]))
  27. AC_INIT(expat, expat_version, [email protected])
  28. undefine([expat_version])
  29. AC_CONFIG_SRCDIR(Makefile.in)
  30. AC_CONFIG_AUX_DIR(conftools)
  31. AM_INIT_AUTOMAKE
  32. AC_CONFIG_MACRO_DIR([m4])
  33. dnl
  34. dnl Increment LIBREVISION if source code has changed at all
  35. dnl
  36. dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
  37. dnl
  38. dnl If the API changes compatibly (i.e. simply adding a new function
  39. dnl without changing or removing earlier interfaces), then increment LIBAGE.
  40. dnl
  41. dnl If the API changes incompatibly set LIBAGE back to 0
  42. dnl
  43. LIBCURRENT=7 # sync
  44. LIBREVISION=8 # with
  45. LIBAGE=6 # CMakeLists.txt!
  46. CPPFLAGS="${CPPFLAGS} -DHAVE_EXPAT_CONFIG_H"
  47. AC_CONFIG_HEADER(expat_config.h)
  48. sinclude(conftools/ac_c_bigendian_cross.m4)
  49. AC_LIBTOOL_WIN32_DLL
  50. AC_PROG_LIBTOOL
  51. AC_SUBST(LIBCURRENT)
  52. AC_SUBST(LIBREVISION)
  53. AC_SUBST(LIBAGE)
  54. dnl Checks for programs.
  55. AC_PROG_CC_C99
  56. AC_PROG_CXX
  57. AC_PROG_INSTALL
  58. if test "$GCC" = yes ; then
  59. dnl
  60. dnl Be careful about adding the -fexceptions option; some versions of
  61. dnl GCC don't support it and it causes extra warnings that are only
  62. dnl distracting; avoid.
  63. dnl
  64. OLDCFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes"
  65. CFLAGS="$OLDCFLAGS -fexceptions"
  66. AC_MSG_CHECKING(whether $CC accepts -fexceptions)
  67. AC_TRY_LINK( , ,
  68. AC_MSG_RESULT(yes),
  69. AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS")
  70. if test "x$CXXFLAGS" = x ; then
  71. CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'`
  72. fi
  73. CFLAGS="${CFLAGS} -fno-strict-aliasing"
  74. CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
  75. LDFLAGS="${LDFLAGS} -fno-strict-aliasing"
  76. fi
  77. dnl Checks for header files.
  78. AC_HEADER_STDC
  79. dnl Checks for typedefs, structures, and compiler characteristics.
  80. dnl Note: Avoid using AC_C_BIGENDIAN because it does not
  81. dnl work in a cross compile.
  82. AC_C_BIGENDIAN_CROSS
  83. AC_C_CONST
  84. AC_TYPE_SIZE_T
  85. AC_CHECK_FUNCS(memmove bcopy)
  86. AC_ARG_WITH([xmlwf], [
  87. AS_HELP_STRING([--without-xmlwf], [do not build xmlwf])], [], [with_xmlwf=yes])
  88. AM_CONDITIONAL([WITH_XMLWF], [test x${with_xmlwf} = xyes])
  89. AM_CONDITIONAL([MINGW], [echo -- "${host}" | ${FGREP} mingw >/dev/null])
  90. AM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE >/dev/null])
  91. AC_ARG_WITH([libbsd], [
  92. AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])
  93. ], [], [with_libbsd=no])
  94. AS_IF([test "x${with_libbsd}" != xno], [
  95. AC_CHECK_LIB([bsd], [arc4random_buf], [], [
  96. AS_IF([test "x${with_libbsd}" = xyes], [
  97. AC_MSG_ERROR([Enforced use of libbsd cannot be satisfied.])
  98. ])
  99. ])
  100. ])
  101. AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)])
  102. AC_LINK_IFELSE([AC_LANG_SOURCE([
  103. #include <stdlib.h> /* for arc4random_buf on BSD, for NULL */
  104. #if defined(HAVE_LIBBSD)
  105. # include <bsd/stdlib.h>
  106. #endif
  107. int main() {
  108. arc4random_buf(NULL, 0U);
  109. return 0;
  110. }
  111. ])], [
  112. AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1],
  113. [Define to 1 if you have the `arc4random_buf' function.])
  114. AC_MSG_RESULT([yes])
  115. ], [
  116. AC_MSG_RESULT([no])
  117. AC_MSG_CHECKING([for arc4random (BSD, macOS or libbsd)])
  118. AC_LINK_IFELSE([AC_LANG_SOURCE([
  119. #if defined(HAVE_LIBBSD)
  120. # include <bsd/stdlib.h>
  121. #else
  122. # include <stdlib.h>
  123. #endif
  124. int main() {
  125. arc4random();
  126. return 0;
  127. }
  128. ])], [
  129. AC_DEFINE([HAVE_ARC4RANDOM], [1],
  130. [Define to 1 if you have the `arc4random' function.])
  131. AC_MSG_RESULT([yes])
  132. ], [
  133. AC_MSG_RESULT([no])
  134. ])
  135. ])
  136. AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
  137. AC_LINK_IFELSE([AC_LANG_SOURCE([
  138. #include <stdlib.h> /* for NULL */
  139. #include <sys/random.h>
  140. int main() {
  141. return getrandom(NULL, 0U, 0U);
  142. }
  143. ])], [
  144. AC_DEFINE([HAVE_GETRANDOM], [1],
  145. [Define to 1 if you have the `getrandom' function.])
  146. AC_MSG_RESULT([yes])
  147. ], [
  148. AC_MSG_RESULT([no])
  149. AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)])
  150. AC_LINK_IFELSE([AC_LANG_SOURCE([
  151. #include <stdlib.h> /* for NULL */
  152. #include <unistd.h> /* for syscall */
  153. #include <sys/syscall.h> /* for SYS_getrandom */
  154. int main() {
  155. syscall(SYS_getrandom, NULL, 0, 0);
  156. return 0;
  157. }
  158. ])], [
  159. AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1],
  160. [Define to 1 if you have `syscall' and `SYS_getrandom'.])
  161. AC_MSG_RESULT([yes])
  162. ], [
  163. AC_MSG_RESULT([no])
  164. ])
  165. ])
  166. dnl Only needed for xmlwf:
  167. AC_CHECK_HEADERS(fcntl.h unistd.h)
  168. AC_TYPE_OFF_T
  169. AC_FUNC_MMAP
  170. if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then
  171. FILEMAP=unixfilemap
  172. else
  173. FILEMAP=readfilemap
  174. fi
  175. AC_SUBST(FILEMAP)
  176. dnl Some basic configuration:
  177. AC_DEFINE([XML_NS], 1,
  178. [Define to make XML Namespaces functionality available.])
  179. AC_DEFINE([XML_DTD], 1,
  180. [Define to make parameter entity parsing functionality available.])
  181. AC_DEFINE([XML_DEV_URANDOM], 1,
  182. [Define to include code reading entropy from `/dev/urandom'.])
  183. AC_ARG_ENABLE([xml-context],
  184. AS_HELP_STRING([--enable-xml-context @<:@COUNT@:>@],
  185. [Retain context around the current parse point;
  186. default is enabled and a size of 1024 bytes])
  187. AS_HELP_STRING([--disable-xml-context],
  188. [Do not retain context around the current parse point]),
  189. [enable_xml_context=${enableval}])
  190. AS_IF([test "x${enable_xml_context}" != "xno"], [
  191. AS_IF([test "x${enable_xml_context}" = "xyes" \
  192. -o "x${enable_xml_context}" = "x"], [
  193. enable_xml_context=1024
  194. ])
  195. AC_DEFINE_UNQUOTED([XML_CONTEXT_BYTES], [${enable_xml_context}],
  196. [Define to specify how much context to retain around the current parse point.])
  197. ])
  198. AC_ARG_WITH([docbook], [AS_HELP_STRING([--with-docbook],
  199. [enforce XML to man page compilation @<:@default=check@:>@])
  200. AS_HELP_STRING([--without-docbook],
  201. [skip XML to man page compilation @<:@default=check@:>@])],
  202. [],
  203. [with_docbook=check])
  204. AC_ARG_VAR([DOCBOOK_TO_MAN], [docbook2x-man command])
  205. AS_IF([test "x$with_docbook" != xno],
  206. [AC_CHECK_PROGS([DOCBOOK_TO_MAN], [docbook2x-man db2x_docbook2man docbook2man docbook-to-man])])
  207. AS_IF([test "x${DOCBOOK_TO_MAN}" = x -a "x$with_docbook" = xyes],
  208. [AC_MSG_ERROR([Required program 'docbook2x-man' not found.])])
  209. AS_IF([test "x${DOCBOOK_TO_MAN}" != x -a "x$with_docbook" != xno],
  210. [AS_IF([${DOCBOOK_TO_MAN} --help | grep -i -q -F sgmlbase],
  211. [AC_MSG_ERROR([Your local ${DOCBOOK_TO_MAN} was found to work with SGML rather
  212. than XML. Please install docbook2X and use variable DOCBOOK_TO_MAN to point
  213. configure to command docbook2x-man of docbook2X.
  214. Or use DOCBOOK_TO_MAN="xmlto man --skip-validation" if you have xmlto around.
  215. You can also configure using --without-docbook if you can do without a man
  216. page for xmlwf.])])])
  217. AM_CONDITIONAL(WITH_DOCBOOK, [test "x${DOCBOOK_TO_MAN}" != x])
  218. AC_CONFIG_FILES([Makefile expat.pc])
  219. AC_CONFIG_FILES([
  220. doc/Makefile
  221. examples/Makefile
  222. lib/Makefile
  223. tests/Makefile
  224. tests/benchmark/Makefile
  225. xmlwf/Makefile
  226. ])
  227. AC_CONFIG_FILES([run.sh], [chmod +x run.sh])
  228. AC_OUTPUT