• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl   configuration script for expat
2dnl   Process this file with autoconf to produce a configure script.
3dnl                            __  __            _
4dnl                         ___\ \/ /_ __   __ _| |_
5dnl                        / _ \\  /| '_ \ / _` | __|
6dnl                       |  __//  \| |_) | (_| | |_
7dnl                        \___/_/\_\ .__/ \__,_|\__|
8dnl                                 |_| XML parser
9dnl
10dnl   Copyright (c) 2000      Clark Cooper <coopercc@users.sourceforge.net>
11dnl   Copyright (c) 2000-2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
12dnl   Copyright (c) 2001-2003 Greg Stein <gstein@users.sourceforge.net>
13dnl   Copyright (c) 2006-2012 Karl Waclawek <karl@waclawek.net>
14dnl   Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
15dnl   Copyright (c) 2017      S. P. Zeidler <spz@netbsd.org>
16dnl   Copyright (c) 2017      Stephen Groat <stephen@groat.us>
17dnl   Copyright (c) 2017-2020 Joe Orton <jorton@redhat.com>
18dnl   Copyright (c) 2018      Yury Gribov <tetra2005@gmail.com>
19dnl   Copyright (c) 2018      Benjamin Peterson <benjamin@python.org>
20dnl   Copyright (c) 2018      Marco Maggi <marco.maggi-ipsu@poste.it>
21dnl   Copyright (c) 2018      KangLin <kl222@126.com>
22dnl   Copyright (c) 2019      Mohammed Khajapasha <mohammed.khajapasha@intel.com>
23dnl   Copyright (c) 2019      Kishore Kunche <kishore.kunche@intel.com>
24dnl   Copyright (c) 2020      Jeffrey Walton <noloader@gmail.com>
25dnl   Licensed under the MIT license:
26dnl
27dnl   Permission is  hereby granted,  free of charge,  to any  person obtaining
28dnl   a  copy  of  this  software   and  associated  documentation  files  (the
29dnl   "Software"),  to  deal in  the  Software  without restriction,  including
30dnl   without  limitation the  rights  to use,  copy,  modify, merge,  publish,
31dnl   distribute, sublicense, and/or sell copies of the Software, and to permit
32dnl   persons  to whom  the Software  is  furnished to  do so,  subject to  the
33dnl   following conditions:
34dnl
35dnl   The above copyright  notice and this permission notice  shall be included
36dnl   in all copies or substantial portions of the Software.
37dnl
38dnl   THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
39dnl   EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
40dnl   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
41dnl   NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
42dnl   DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
43dnl   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
44dnl   USE OR OTHER DEALINGS IN THE SOFTWARE.
45
46dnl Ensure that Expat is configured with autoconf 2.69 or newer.
47AC_PREREQ([2.69])
48
49dnl Get the version number of Expat, using m4's esyscmd() command to run
50dnl the command at m4-generation time. This allows us to create an m4
51dnl symbol holding the correct version number. AC_INIT requires the
52dnl version number at m4-time, rather than when ./configure is run, so
53dnl all this must happen as part of m4, not as part of the shell code
54dnl contained in ./configure.
55dnl
56dnl NOTE: esyscmd() is a GNU M4 extension. Thus, we wrap it in an appropriate
57dnl test. I believe this test will work, but I don't have a place with non-
58dnl GNU M4 to test it right now.
59m4_define([expat_version],
60  m4_ifdef([__gnu__],
61           [esyscmd(conftools/get-version.sh lib/expat.h)],
62           [2.2.x]))
63AC_INIT([expat], expat_version, [expat-bugs@libexpat.org])
64m4_undefine([expat_version])
65
66AC_CONFIG_SRCDIR([Makefile.in])
67AC_CONFIG_AUX_DIR([conftools])
68AC_CONFIG_MACRO_DIR([m4])
69AC_CANONICAL_HOST
70AM_INIT_AUTOMAKE
71
72
73dnl
74dnl Increment LIBREVISION if source code has changed at all
75dnl
76dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
77dnl
78dnl If the API changes compatibly (i.e. simply adding a new function
79dnl without changing or removing earlier interfaces), then increment LIBAGE.
80dnl
81dnl If the API changes incompatibly set LIBAGE back to 0
82dnl
83
84LIBCURRENT=9   # sync
85LIBREVISION=1  # with
86LIBAGE=8       # CMakeLists.txt!
87
88AC_CONFIG_HEADERS([expat_config.h])
89
90AM_PROG_AR
91AC_PROG_INSTALL
92AC_PROG_LN_S
93AC_PROG_MAKE_SET
94
95LT_PREREQ([2.4])
96LT_INIT([win32-dll])
97
98AC_SUBST(LIBCURRENT)
99AC_SUBST(LIBREVISION)
100AC_SUBST(LIBAGE)
101
102AC_LANG([C])
103AC_PROG_CC_C99
104
105AS_IF([test "$GCC" = yes],
106  [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [AM_CFLAGS])
107   dnl Be careful about adding the -fexceptions option; some versions of
108   dnl GCC don't support it and it causes extra warnings that are only
109   dnl distracting; avoid.
110   AX_APPEND_COMPILE_FLAGS([-fexceptions], [AM_CFLAGS])
111   AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -Wmissing-prototypes -Wstrict-prototypes], [AM_CFLAGS])
112   AX_APPEND_COMPILE_FLAGS([-pedantic -Wduplicated-cond -Wduplicated-branches -Wlogical-op], [AM_CFLAGS])
113   AX_APPEND_COMPILE_FLAGS([-Wrestrict -Wnull-dereference -Wjump-misses-init -Wdouble-promotion], [AM_CFLAGS])
114   AX_APPEND_COMPILE_FLAGS([-Wshadow -Wformat=2 -Wno-pedantic-ms-format -Wmisleading-indentation], [AM_CFLAGS])])
115
116AC_LANG_PUSH([C++])
117AC_PROG_CXX
118
119AS_IF([test "$GCC" = yes],
120  [AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [AM_CXXFLAGS])
121   dnl Be careful about adding the -fexceptions option; some versions of
122   dnl GCC don't support it and it causes extra warnings that are only
123   dnl distracting; avoid.
124   AX_APPEND_COMPILE_FLAGS([-fexceptions], [AM_CXXFLAGS])
125   AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [AM_CXXFLAGS])])
126AC_LANG_POP([C++])
127
128AS_IF([test "$GCC" = yes],
129  [AX_APPEND_LINK_FLAGS([-fno-strict-aliasing],[AM_LDFLAGS])])
130
131dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang (issue #312)
132AS_CASE(["$LD"],[*clang*],
133  [AS_CASE(["${host_os}"],
134     [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
135
136EXPATCFG_COMPILER_SUPPORTS_VISIBILITY([
137  AX_APPEND_FLAG([-fvisibility=hidden],       [AM_CFLAGS])
138  AX_APPEND_FLAG([-DXML_ENABLE_VISIBILITY=1], [AM_CPPFLAGS])])
139
140dnl Checks for typedefs, structures, and compiler characteristics.
141
142dnl We define BYTEORDER to 1234 when the platform is little endian; it
143dnl defines it to 4321 when the  platform is big endian.  We also define
144dnl WORDS_BIGENDIAN to 1 when the platform is big endian.
145dnl
146dnl A  long time  ago (early 2000  years) AC_C_BIGENDIAN  was considered
147dnl wrong when cross compiling, now (2018, GNU Autoconf 2.69) we assume
148dnl it is fine.
149AC_C_BIGENDIAN([AC_DEFINE([WORDS_BIGENDIAN], 1)
150                AS_VAR_SET([BYTEORDER], 4321)],
151               [AS_VAR_SET([BYTEORDER], 1234)])
152AC_DEFINE_UNQUOTED([BYTEORDER], $BYTEORDER, [1234 = LILENDIAN, 4321 = BIGENDIAN])
153
154AC_C_CONST
155AC_TYPE_SIZE_T
156
157AC_ARG_WITH([xmlwf],
158  [AS_HELP_STRING([--without-xmlwf], [do not build xmlwf])],
159  [],
160  [with_xmlwf=yes])
161AM_CONDITIONAL([WITH_XMLWF], [test x${with_xmlwf} = xyes])
162
163AC_ARG_WITH([examples],
164  [AS_HELP_STRING([--without-examples], [do not build examples @<:@default=included@:>@])],
165  [],
166  [with_examples=yes])
167AM_CONDITIONAL([WITH_EXAMPLES], [test x${with_examples} = xyes])
168
169AC_ARG_WITH([tests],
170  [AS_HELP_STRING([--without-tests], [do not build tests @<:@default=included@:>@])],
171  [],
172  [with_tests=yes])
173AM_CONDITIONAL([WITH_TESTS], [test x${with_tests} = xyes])
174
175
176AS_VAR_SET([EXPATCFG_ON_MINGW],[no])
177AS_CASE("${host_os}",
178  [mingw*],
179  [AS_VAR_SET([EXPATCFG_ON_MINGW],[yes])
180   AC_MSG_NOTICE([detected OS: MinGW])])
181AM_CONDITIONAL([MINGW], [test x${EXPATCFG_ON_MINGW} = xyes])
182
183dnl Note: Prefix "_INTERNAL_" here means exclusive use inside of file configure.ac
184AM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE >/dev/null])
185AM_CONDITIONAL([_INTERNAL_UNICODE_WCHAR_T], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE_WCHAR_T >/dev/null])
186AM_CONDITIONAL([_INTERNAL_MIN_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_MIN_SIZE >/dev/null])
187AM_CONDITIONAL([_INTERNAL_LARGE_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_LARGE_SIZE >/dev/null])
188
189
190AC_ARG_WITH([libbsd],
191  [AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])],
192  [],
193  [with_libbsd=no])
194AS_IF([test "x${with_libbsd}" != xno],
195  [AC_CHECK_LIB([bsd],
196     [arc4random_buf],
197     [],
198     [AS_IF([test "x${with_libbsd}" = xyes],
199        [AC_MSG_ERROR([Enforced use of libbsd cannot be satisfied.])])])])
200AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)])
201AC_LINK_IFELSE([AC_LANG_SOURCE([
202    #include <stdlib.h>  /* for arc4random_buf on BSD, for NULL */
203    #if defined(HAVE_LIBBSD)
204    # include <bsd/stdlib.h>
205    #endif
206    int main() {
207      arc4random_buf(NULL, 0U);
208      return 0;
209    }
210  ])],
211  [AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1], [Define to 1 if you have the `arc4random_buf' function.])
212   AC_MSG_RESULT([yes])],
213  [AC_MSG_RESULT([no])
214
215   AC_MSG_CHECKING([for arc4random (BSD, macOS or libbsd)])
216   AC_LINK_IFELSE([AC_LANG_SOURCE([
217       #if defined(HAVE_LIBBSD)
218       # include <bsd/stdlib.h>
219       #else
220       # include <stdlib.h>
221       #endif
222       int main() {
223          arc4random();
224          return 0;
225       }
226     ])],
227     [AC_DEFINE([HAVE_ARC4RANDOM], [1], [Define to 1 if you have the `arc4random' function.])
228      AC_MSG_RESULT([yes])],
229     [AC_MSG_RESULT([no])])])
230
231AC_ARG_WITH([getrandom],
232  [AS_HELP_STRING([--with-getrandom],
233                  [enforce the use of getrandom function in the system @<:@default=check@:>@])
234AS_HELP_STRING([--without-getrandom],
235               [skip auto detect of getrandom @<:@default=check@:>@])],
236  [],
237  [with_getrandom=check])
238
239AS_IF([test "x$with_getrandom" != xno],
240  [AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
241   AC_LINK_IFELSE([AC_LANG_SOURCE([
242       #include <stdlib.h>  /* for NULL */
243       #include <sys/random.h>
244       int main() {
245         return getrandom(NULL, 0U, 0U);
246       }
247     ])],
248     [AC_DEFINE([HAVE_GETRANDOM], [1], [Define to 1 if you have the `getrandom' function.])
249      AC_MSG_RESULT([yes])],
250     [AC_MSG_RESULT([no])
251      AS_IF([test "x$with_getrandom" = xyes],
252        [AC_MSG_ERROR([enforced the use of getrandom --with-getrandom, but not detected])])])])
253
254AC_ARG_WITH([sys_getrandom],
255  [AS_HELP_STRING([--with-sys-getrandom],
256                  [enforce the use of syscall SYS_getrandom function in the system @<:@default=check@:>@])
257AS_HELP_STRING([--without-sys-getrandom],
258               [skip auto detect of syscall SYS_getrandom @<:@default=check@:>@])],
259  [],
260  [with_sys_getrandom=check])
261
262AS_IF([test "x$with_sys_getrandom" != xno],
263  [AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)])
264   AC_LINK_IFELSE([AC_LANG_SOURCE([
265       #include <stdlib.h>  /* for NULL */
266       #include <unistd.h>  /* for syscall */
267       #include <sys/syscall.h>  /* for SYS_getrandom */
268       int main() {
269         syscall(SYS_getrandom, NULL, 0, 0);
270         return 0;
271     }
272   ])],
273     [AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1], [Define to 1 if you have `syscall' and `SYS_getrandom'.])
274      AC_MSG_RESULT([yes])],
275     [AC_MSG_RESULT([no])
276      AS_IF([test "x$with_sys_getrandom" = xyes],
277        [AC_MSG_ERROR([enforced the use of syscall SYS_getrandom --with-sys-getrandom, but not detected])])])])
278
279dnl Only needed for xmlwf:
280AC_CHECK_HEADERS(fcntl.h unistd.h)
281AC_TYPE_OFF_T
282AC_FUNC_MMAP
283
284AS_IF([test "$ac_cv_func_mmap_fixed_mapped" = "yes"],
285  [AS_VAR_SET(FILEMAP,unixfilemap)],
286  [AS_VAR_SET(FILEMAP,readfilemap)])
287AC_SUBST(FILEMAP)
288
289
290dnl Some basic configuration:
291AC_DEFINE([XML_NS], 1,
292          [Define to make XML Namespaces functionality available.])
293AC_DEFINE([XML_DTD], 1,
294          [Define to make parameter entity parsing functionality available.])
295AC_DEFINE([XML_DEV_URANDOM], 1,
296          [Define to include code reading entropy from `/dev/urandom'.])
297
298AC_ARG_ENABLE([xml-attr-info],
299  [AS_HELP_STRING([--enable-xml-attr-info],
300     [Enable retrieving the byte offsets for attribute names and values @<:@default=no@:>@])],
301  [],
302  [enable_xml_attr_info=no])
303AS_IF([test "x${enable_xml_attr_info}" = "xyes"],
304      [AC_DEFINE([XML_ATTR_INFO], 1,
305         [Define to allow retrieving the byte offsets for attribute names and values.])])
306
307AC_ARG_ENABLE([xml-context],
308  AS_HELP_STRING([--enable-xml-context @<:@COUNT@:>@],
309    [Retain context around the current parse point;
310     default is enabled and a size of 1024 bytes])
311AS_HELP_STRING([--disable-xml-context],
312    [Do not retain context around the current parse point]),
313    [enable_xml_context=${enableval}])
314AS_IF([test "x${enable_xml_context}" != "xno"],
315  [AS_IF([test "x${enable_xml_context}" = "xyes" \
316            -o "x${enable_xml_context}" = "x"],
317     [AS_VAR_SET(enable_xml_context,1024)])
318   AC_DEFINE_UNQUOTED([XML_CONTEXT_BYTES], [${enable_xml_context}],
319     [Define to specify how much context to retain around the current parse point.])])
320
321AC_ARG_WITH([docbook],
322  [AS_HELP_STRING([--with-docbook],
323                  [enforce XML to man page compilation @<:@default=check@:>@])
324AS_HELP_STRING([--without-docbook],
325               [skip XML to man page compilation @<:@default=check@:>@])],
326  [],
327  [with_docbook=check])
328
329AC_ARG_VAR([DOCBOOK_TO_MAN], [docbook2x-man command])
330AS_IF([test "x$with_docbook" != xno],
331  [AC_CHECK_PROGS([DOCBOOK_TO_MAN], [docbook2x-man db2x_docbook2man docbook2man docbook-to-man])])
332AS_IF([test "x${DOCBOOK_TO_MAN}" = x -a "x$with_docbook" = xyes],
333  [AC_MSG_ERROR([Required program 'docbook2x-man' not found.])])
334AS_IF([test "x${DOCBOOK_TO_MAN}" != x -a "x$with_docbook" != xno],
335  [AS_IF([${DOCBOOK_TO_MAN} --help | grep -i -q -F sgmlbase],
336    [AC_MSG_ERROR([Your local ${DOCBOOK_TO_MAN} was found to work with SGML rather
337  than XML. Please install docbook2X and use variable DOCBOOK_TO_MAN to point
338  configure to command docbook2x-man of docbook2X.
339  Or use DOCBOOK_TO_MAN="xmlto man --skip-validation" if you have xmlto around.
340  You can also configure using --without-docbook if you can do without a man
341  page for xmlwf.])])])
342
343AM_CONDITIONAL(WITH_DOCBOOK, [test "x${DOCBOOK_TO_MAN}" != x])
344
345
346dnl Configure CMake file templates
347dnl NOTE: The *_TRUE variables read here are Automake conditionals
348dnl       that are either set to "" when enabled or to "#" when disabled
349dnl       (because they are used to dynamically comment out certain things)
350AS_IF([test "x${enable_xml_attr_info}" = xyes],
351  [EXPAT_ATTR_INFO=ON],
352  [EXPAT_ATTR_INFO=OFF])
353EXPAT_DTD=ON
354AS_IF([test "x${_INTERNAL_LARGE_SIZE_TRUE}" = x],
355  [EXPAT_LARGE_SIZE=ON],
356  [EXPAT_LARGE_SIZE=OFF])
357AS_IF([test "x${_INTERNAL_MIN_SIZE_TRUE}" = x],
358  [EXPAT_MIN_SIZE=ON],
359  [EXPAT_MIN_SIZE=OFF])
360EXPAT_NS=ON
361AS_IF([test "x${enable_xml_context}" != xno],
362  [EXPAT_CONTEXT_BYTES=${enable_xml_context}],
363  [EXPAT_CONTEXT_BYTES=OFF])
364AS_IF([test "x${UNICODE_TRUE}" = x],
365  [AS_IF(
366     [test "x${_INTERNAL_UNICODE_WCHAR_T_TRUE}" = x],
367        [EXPAT_CHAR_TYPE=wchar_t],
368        [EXPAT_CHAR_TYPE=ushort])],
369  [EXPAT_CHAR_TYPE=char])
370PACKAGE_INIT="${srcdir}"/cmake/autotools/expat-package-init.cmake
371LIBDIR_BASENAME="$(basename "${libdir}")"
372SO_MAJOR="$(expr "${LIBCURRENT}" - "${LIBAGE}")"
373SO_MINOR="${LIBAGE}"
374SO_PATCH="${LIBREVISION}"
375AC_CHECK_SIZEOF([void *])  # sets ac_cv_sizeof_void_p
376AC_SUBST([EXPAT_ATTR_INFO])
377AC_SUBST([EXPAT_DTD])
378AC_SUBST([EXPAT_LARGE_SIZE])
379AC_SUBST([EXPAT_MIN_SIZE])
380AC_SUBST([EXPAT_NS])
381AC_SUBST([EXPAT_CONTEXT_BYTES])
382AC_SUBST([EXPAT_CHAR_TYPE])
383AC_SUBST_FILE([PACKAGE_INIT])
384AC_SUBST([LIBDIR_BASENAME])
385AC_SUBST([SO_MAJOR])
386AC_SUBST([SO_MINOR])
387AC_SUBST([SO_PATCH])
388AC_SUBST([ac_cv_sizeof_void_p])
389
390
391dnl write the Automake flags we set
392AC_SUBST([AM_CPPFLAGS])
393AC_SUBST([AM_CFLAGS])
394AC_SUBST([AM_CXXFLAGS])
395AC_SUBST([AM_LDFLAGS])
396
397dnl updating _EXPAT_OUTPUT_NAME variable to effect the package name in expat.pc file (issue #361)
398AC_SUBST(_EXPAT_OUTPUT_NAME, ["$PACKAGE_NAME"])
399
400AS_CASE("${host_os}",
401  [darwin*], [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__macos.cmake.in],
402  [mingw*], [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__windows.cmake.in],
403  [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__linux.cmake.in])
404AC_CONFIG_FILES([Makefile]
405  [expat.pc]
406  [cmake/expat-config.cmake]
407  [cmake/autotools/expat-config-version.cmake]
408  [cmake/autotools/expat-noconfig.cmake:${CMAKE_NOCONFIG_SOURCE}]
409  [doc/Makefile]
410  [examples/Makefile]
411  [lib/Makefile]
412  [tests/Makefile]
413  [tests/benchmark/Makefile]
414  [xmlwf/Makefile])
415AC_CONFIG_FILES([run.sh], [chmod +x run.sh])
416AC_OUTPUT
417
418
419AC_MSG_NOTICE([
420
421Automake flags (can be overridden by user flags):
422  [AM_CPPFLAGS]: ${AM_CPPFLAGS}
423    [AM_CFLAGS]: ${AM_CFLAGS}
424  [AM_CXXFLAGS]: ${AM_CXXFLAGS}
425   [AM_LDFLAGS]: ${AM_LDFLAGS}
426
427User flags (override Automake flags on conflict):
428     CPPFLAGS: ${CPPFLAGS}
429       CFLAGS: ${CFLAGS}
430     CXXFLAGS: ${CXXFLAGS}
431      LDFLAGS: ${LDFLAGS}])
432