xref: /aosp_15_r20/external/libxml2/configure.ac (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ([2.63])
3
4m4_define([version_macro], m4_normalize(m4_include([VERSION])))
5
6AC_INIT([libxml2],[version_macro])
7AC_CONFIG_SRCDIR([entities.c])
8AC_CONFIG_HEADERS([config.h])
9AC_CONFIG_MACRO_DIR([m4])
10AC_CANONICAL_HOST
11
12LIBXML_VERSION=version_macro
13LIBXML_MAJOR_VERSION=`echo $LIBXML_VERSION | cut -d . -f 1`
14LIBXML_MINOR_VERSION=`echo $LIBXML_VERSION | cut -d . -f 2`
15LIBXML_MICRO_VERSION=`echo $LIBXML_VERSION | cut -d . -f 3`
16LIBXML_MICRO_VERSION_SUFFIX=
17
18# The oldest minor version we are compatible with.
19LIBXML_MINOR_COMPAT=0
20LIBXML_CURRENT=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`
21LIBXML_AGE=`expr $LIBXML_MINOR_VERSION - $LIBXML_MINOR_COMPAT`
22LIBXML_VERSION_INFO=$LIBXML_CURRENT:$LIBXML_MICRO_VERSION:$LIBXML_AGE
23
24LIBXML_VERSION_NUMBER=`expr $LIBXML_MAJOR_VERSION \* 10000 + $LIBXML_MINOR_VERSION \* 100 + $LIBXML_MICRO_VERSION`
25
26if test -d .git ; then
27  extra=`git describe 2>/dev/null`
28  echo extra=$extra
29  if test "$extra" != ""
30  then
31      LIBXML_VERSION_EXTRA="-GIT$extra"
32  fi
33fi
34
35AC_SUBST(LIBXML_MAJOR_VERSION)
36AC_SUBST(LIBXML_MINOR_VERSION)
37AC_SUBST(LIBXML_MICRO_VERSION)
38AC_SUBST(LIBXML_VERSION)
39AC_SUBST(LIBXML_VERSION_INFO)
40AC_SUBST(LIBXML_VERSION_NUMBER)
41AC_SUBST(LIBXML_VERSION_EXTRA)
42
43VERSION=${LIBXML_VERSION}
44
45AM_INIT_AUTOMAKE([1.16.3 foreign no-dist-gzip dist-xz])
46AM_MAINTAINER_MODE([enable])
47AM_SILENT_RULES([yes])
48
49dnl Checks for programs.
50AC_PROG_CC
51AC_PROG_INSTALL
52AC_PROG_LN_S
53AC_PROG_MKDIR_P
54AC_PATH_PROG(TAR, tar, /bin/tar)
55AC_PATH_PROG(WGET, wget, /usr/bin/wget)
56AC_PATH_PROG(XSLTPROC, xsltproc, /usr/bin/xsltproc)
57PKG_PROG_PKG_CONFIG
58
59LT_INIT([disable-static])
60LT_LIB_M
61
62dnl
63dnl We process the AC_ARG_WITH first so that later we can modify
64dnl some of them to try to prevent impossible combinations.  This
65dnl also allows up so alphabetize the choices
66dnl
67
68AC_ARG_WITH(c14n,
69[  --with-c14n             Canonical XML 1.0 support (on)])
70AC_ARG_WITH(catalog,
71[  --with-catalog          XML Catalogs support (on)])
72AC_ARG_WITH(debug,
73[  --with-debug            debugging module (on)])
74AC_ARG_WITH(history,
75[  --with-history          history support for xmllint shell (off)])
76AC_ARG_WITH(readline,
77[  --with-readline[[=DIR]]   use readline in DIR for shell (off)])
78AC_ARG_WITH(html,
79[  --with-html             HTML parser (on)])
80AC_ARG_WITH(http,
81[  --with-http             HTTP support (off)])
82AC_ARG_WITH(iconv,
83[  --with-iconv[[=DIR]]      iconv support (on)])
84AC_ARG_WITH(icu,
85[  --with-icu              ICU support (off)])
86AC_ARG_WITH(iso8859x,
87[  --with-iso8859x         ISO-8859-X support if no iconv (on)])
88AC_ARG_WITH(lzma,
89[  --with-lzma[[=DIR]]       use liblzma in DIR (off)])
90AC_ARG_WITH(modules,
91[  --with-modules          dynamic modules support (on)])
92AC_ARG_WITH(output,
93[  --with-output           serialization support (on)])
94AC_ARG_WITH(pattern,
95[  --with-pattern          xmlPattern selection interface (on)])
96AC_ARG_WITH(push,
97[  --with-push             push parser interfaces (on)])
98AC_ARG_WITH(python,
99[  --with-python           Python bindings (on)])
100AC_ARG_WITH(reader,
101[  --with-reader           xmlReader parsing interface (on)])
102AC_ARG_WITH(regexps,
103[  --with-regexps          regular expressions support (on)])
104AC_ARG_WITH(sax1,
105[  --with-sax1             older SAX1 interface (on)])
106AC_ARG_WITH(schemas,
107[  --with-schemas          XML Schemas 1.0 and RELAX NG support (on)])
108AC_ARG_WITH(schematron,
109[  --with-schematron       Schematron support (on)])
110AC_ARG_WITH(threads,
111[  --with-threads          multithreading support (on)])
112AC_ARG_WITH(thread-alloc,
113[  --with-thread-alloc     per-thread malloc hooks (off)])
114AC_ARG_WITH(valid,
115[  --with-valid            DTD validation support (on)])
116AC_ARG_WITH(writer,
117[  --with-writer           xmlWriter serialization interface (on)])
118AC_ARG_WITH(xinclude,
119[  --with-xinclude         XInclude 1.0 support (on)])
120AC_ARG_WITH(xpath,
121[  --with-xpath            XPath 1.0 support (on)])
122AC_ARG_WITH(xptr,
123[  --with-xptr             XPointer support (on)])
124AC_ARG_WITH(zlib,
125[  --with-zlib[[=DIR]]       use libz in DIR (off)])
126
127AC_ARG_WITH(minimum,
128[  --with-minimum          build a minimally sized library (off)])
129AC_ARG_WITH(legacy,
130[  --with-legacy           maximum ABI compatibility (off)])
131
132AC_ARG_WITH(tls,
133[  --with-tls              thread-local storage (off)])
134
135dnl
136dnl Legacy defaults
137dnl
138if test "$with_legacy" = "yes"; then
139    if test "$with_http" = ""; then
140        with_http=yes
141    fi
142    if test "$with_lzma" = ""; then
143        with_lzma=yes
144    fi
145    if test "$with_zlib" = ""; then
146        with_zlib=yes
147    fi
148fi
149
150dnl
151dnl hard dependencies on options
152dnl
153if test "$with_c14n" = "yes"; then
154    if test "$with_output" = "no"; then
155        echo WARNING: --with-c14n overrides --without-output
156    fi
157    with_output=yes
158    if test "$with_xpath" = "no"; then
159        echo WARNING: --with-c14n overrides --without-xpath
160    fi
161    with_xpath=yes
162fi
163if test "$with_schemas" = "yes"; then
164    if test "$with_pattern" = "no"; then
165        echo WARNING: --with-schemas overrides --without-pattern
166    fi
167    with_pattern=yes
168    if test "$with_regexps" = "no"; then
169        echo WARNING: --with-schemas overrides --without-regexps
170    fi
171    with_regexps=yes
172fi
173if test "$with_schematron" = "yes"; then
174    if test "$with_pattern" = "no"; then
175        echo WARNING: --with-schematron overrides --without-pattern
176    fi
177    with_pattern=yes
178    if test "$with_xpath" = "no"; then
179        echo WARNING: --with-schematron overrides --without-xpath
180    fi
181    with_xpath=yes
182fi
183if test "$with_reader" = "yes"; then
184    if test "$with_push" = "no"; then
185        echo WARNING: --with-reader overrides --without-push
186    fi
187    with_push=yes
188fi
189if test "$with_writer" = "yes"; then
190    if test "$with_output" = "no"; then
191        echo WARNING: --with-writer overrides --without-output
192    fi
193    with_output=yes
194    if test "$with_push" = "no"; then
195        echo WARNING: --with-writer overrides --without-push
196    fi
197    with_push=yes
198fi
199if test "$with_xinclude" = "yes"; then
200    if test "$with_xpath" = "no"; then
201        echo WARNING: --with-xinclude overrides --without-xpath
202    fi
203    with_xpath=yes
204fi
205if test "$with_xptr" = "yes"; then
206    if test "$with_xpath" = "no"; then
207        echo WARNING: --with-xptr overrides --without-xpath
208    fi
209    with_xpath=yes
210fi
211if test "$with_history" = "yes"; then
212    if test "$with_readline" = "no"; then
213        echo WARNING: --with-history overrides --without-readline
214        with_readline=yes
215    fi
216    if test "$with_readline" = ""; then
217        with_readline=yes
218    fi
219fi
220
221if test "$with_minimum" = "yes"; then
222    dnl
223    dnl option to build a minimal libxml2 library
224    dnl
225    echo "Configuring for a minimal library"
226    test "$with_c14n" = "" && with_c14n=no
227    test "$with_catalog" = "" && with_catalog=no
228    test "$with_debug" = "" && with_debug=no
229    test "$with_history" = "" && with_history=no
230    test "$with_html" = "" && with_html=no
231    test "$with_http" = "" && with_http=no
232    test "$with_iconv" = "" && with_iconv=no
233    test "$with_iso8859x" = "" && with_iso8859x=no
234    test "$with_lzma" = "" && with_lzma=no
235    test "$with_output" = "" && with_output=no
236    test "$with_pattern" = "" && with_pattern=no
237    test "$with_push" = "" && with_push=no
238    test "$with_python" = "" && with_python=no
239    test "$with_reader" = "" && with_reader=no
240    test "$with_readline" = "" && with_readline=no
241    test "$with_regexps" = "" && with_regexps=no
242    test "$with_sax1" = "" && with_sax1=no
243    test "$with_schemas" = "" && with_schemas=no
244    test "$with_schematron" = "" && with_schematron=no
245    test "$with_threads" = "" && with_threads=no
246    test "$with_thread_alloc" = "" && with_thread_alloc=no
247    test "$with_valid" = "" && with_valid=no
248    test "$with_writer" = "" && with_writer=no
249    test "$with_xinclude" = "" && with_xinclude=no
250    test "$with_xpath" = "" && with_xpath=no
251    test "$with_xptr" = "" && with_xptr=no
252    test "$with_zlib" = "" && with_zlib=no
253    test "$with_modules" = "" && with_modules=no
254else
255    dnl
256    dnl Disable dependent modules
257    dnl
258    if test "$with_output" = "no"; then
259        with_c14n=no
260        with_writer=no
261    fi
262    if test "$with_pattern" = "no"; then
263        with_schemas=no
264        with_schematron=no
265    fi
266    if test "$with_push" = "no"; then
267        with_reader=no
268        with_writer=no
269    fi
270    if test "$with_regexps" = "no"; then
271        with_schemas=no
272    fi
273    if test "$with_xpath" = "no"; then
274        with_c14n=no
275        with_schematron=no
276        with_xinclude=no
277        with_xptr=no
278    fi
279fi
280
281dnl
282dnl Extra flags
283dnl
284XML_LIBDIR='-L${libdir}'
285XML_INCLUDEDIR='-I${includedir}/libxml2'
286XML_CFLAGS=""
287XML_STATIC_CFLAGS=""
288XML_PC_CFLAGS_PRIVATE=""
289
290XML_PRIVATE_LIBS=
291XML_PRIVATE_CFLAGS=
292XML_PC_LIBS=
293XML_PC_REQUIRES=
294
295AX_GCC_FUNC_ATTRIBUTE([destructor])
296
297dnl
298dnl Checks for header files.
299dnl
300AC_CHECK_HEADERS([stdint.h])
301
302dnl Checks for library functions.
303AC_CHECK_DECLS([getentropy], [], [], [#include <sys/random.h>])
304AC_CHECK_DECLS([glob], [], [], [#include <glob.h>])
305AC_CHECK_DECLS([mmap], [], [], [#include <sys/mman.h>])
306
307AM_CONDITIONAL(WITH_GLOB, test "$ac_cv_have_decl_glob" = "yes")
308
309dnl
310dnl Checks for inet libraries
311dnl
312if test "$with_http" = "yes"; then
313    AC_CHECK_HEADERS([poll.h])
314
315    case "$host" in
316        *-*-mingw*)
317            dnl AC_SEARCH_LIBS doesn't work because of non-standard calling
318            dnl conventions on 32-bit Windows.
319            NET_LIBS="$NET_LIBS -lws2_32"
320            ;;
321        *)
322            _libs=$LIBS
323            AC_SEARCH_LIBS(gethostbyname, [nsl], [
324                if test "$ac_cv_search_gethostbyname" != "none required"; then
325                    NET_LIBS="$NET_LIBS $ac_cv_search_gethostbyname"
326                fi], [:], [$NET_LIBS])
327            AC_SEARCH_LIBS(connect, [bsd socket inet], [
328                if test "$ac_cv_search_connect" != "none required"; then
329                    NET_LIBS="$NET_LIBS $ac_cv_search_connect"
330                fi], [:], [$NET_LIBS])
331            LIBS=$_libs
332            ;;
333    esac
334
335    XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${NET_LIBS}"
336    XML_PC_LIBS="${XML_PC_LIBS} ${NET_LIBS}"
337fi
338
339dnl Thread-local storage
340if test "$with_tls" = "yes"; then
341    AC_COMPILE_IFELSE([
342        AC_LANG_SOURCE([_Thread_local int v;]) ], [
343        AC_DEFINE([XML_THREAD_LOCAL], [_Thread_local], [TLS specifier]) ], [
344    AC_COMPILE_IFELSE([
345        AC_LANG_SOURCE([__thread int v;]) ], [
346        AC_DEFINE([XML_THREAD_LOCAL], [__thread], [TLS specifier]) ], [
347    AC_COMPILE_IFELSE([
348        AC_LANG_SOURCE([__declspec(thread) int v;]) ], [
349        AC_DEFINE([XML_THREAD_LOCAL], [__declspec(thread)], [TLS specifier]) ], [
350    ])])])
351fi
352
353dnl
354dnl Linker version scripts for symbol versioning
355dnl
356VERSION_SCRIPT_FLAGS=
357if test "$with_legacy" = "yes"; then
358    # lt_cv_prog_gnu_ld is from libtool 2.+
359    if test "$lt_cv_prog_gnu_ld" = yes; then
360        case $host in
361            *-*-cygwin* | *-*-mingw* | *-*-msys* )
362                ;;
363            *)
364                dnl lld 16 defaults to --no-undefined-version but the version
365                dnl script can contain symbols disabled by configuration
366                dnl options.
367                AX_APPEND_LINK_FLAGS([-Wl,--undefined-version], [VERSION_SCRIPT_FLAGS])
368                AX_APPEND_FLAG([-Wl,--version-script=], [VERSION_SCRIPT_FLAGS])
369                ;;
370        esac
371    else
372        case $host in
373        *-*-sunos*) VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,";;
374        esac
375    fi
376    AC_SUBST(VERSION_SCRIPT_FLAGS)
377fi
378AM_CONDITIONAL([USE_VERSION_SCRIPT], [test -n "$VERSION_SCRIPT_FLAGS"])
379
380dnl
381dnl Workaround for native compilers
382dnl  HP  : http://bugs.gnome.org/db/31/3163.html
383dnl  DEC : Enable NaN/Inf
384dnl
385if test "${GCC}" != "yes" ; then
386    case "${host}" in
387          hppa*-*-hpux* )
388	       AM_CFLAGS="${AM_CFLAGS} -Wp,-H30000"
389	       ;;
390          *-dec-osf* )
391               AM_CFLAGS="${AM_CFLAGS} -ieee"
392               ;;
393	  alpha*-*-linux* )
394	       AM_CFLAGS="${AM_CFLAGS} -ieee"
395	       ;;
396    esac
397else
398    # warnings we'd like to see
399    AM_CFLAGS="${AM_CFLAGS} -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
400    # warnings we'd like to suppress
401    AM_CFLAGS="${AM_CFLAGS} -Wno-long-long -Wno-format-extra-args -Wno-array-bounds"
402    case "${host}" in
403          alpha*-*-linux* )
404	       AM_CFLAGS="${AM_CFLAGS} -mieee"
405	       ;;
406	  alpha*-*-osf* )
407	       AM_CFLAGS="${AM_CFLAGS} -mieee"
408	       ;;
409    esac
410fi
411case ${host} in
412    *-*-solaris*)
413        XML_LIBDIR="${XML_LIBDIR} -R${libdir}"
414        ;;
415    *-*-cygwin* | *-*-mingw* | *-*-msys* )
416        # If the host is Windows, and shared libraries are disabled, we
417        # need to add -DLIBXML_STATIC to AM_CFLAGS in order for linking to
418        # work properly (without it, xmlexports.h would force the use of
419        # DLL imports, which obviously aren't present in a static
420        # library).
421        XML_STATIC_CFLAGS="-DLIBXML_STATIC"
422        if test "x$enable_shared" = "xyes"; then
423            XML_PC_CFLAGS_PRIVATE="
424Cflags.private:"
425        else
426            XML_CFLAGS="$XML_STATIC_CFLAGS"
427            AM_CFLAGS="$AM_CFLAGS $XML_STATIC_CFLAGS"
428        fi
429        ;;
430esac
431
432
433dnl
434dnl Simple API modules
435dnl
436
437if test "$with_http" != "yes" ; then
438    WITH_HTTP=0
439else
440    echo Enabling HTTP support
441    WITH_HTTP=1
442fi
443AC_SUBST(WITH_HTTP)
444AM_CONDITIONAL(WITH_HTTP_SOURCES, test "$WITH_HTTP" = "1")
445
446if test "$with_legacy" != "yes" ; then
447    WITH_LEGACY=0
448else
449    echo Enabling deprecated APIs
450    WITH_LEGACY=1
451fi
452AC_SUBST(WITH_LEGACY)
453AM_CONDITIONAL(WITH_LEGACY_SOURCES, test "$WITH_LEGACY" = "1")
454
455if test "$with_reader" = "no" ; then
456    echo Disabling the xmlReader parsing interface
457    WITH_READER=0
458else
459    WITH_READER=1
460fi
461AC_SUBST(WITH_READER)
462AM_CONDITIONAL(WITH_READER_SOURCES, test "$WITH_READER" = "1")
463
464if test "$with_writer" = "no" ; then
465    echo Disabling the xmlWriter saving interface
466    WITH_WRITER=0
467else
468    WITH_WRITER=1
469fi
470AC_SUBST(WITH_WRITER)
471AM_CONDITIONAL(WITH_WRITER_SOURCES, test "$WITH_WRITER" = "1")
472
473if test "$with_pattern" = "no" ; then
474    echo Disabling the xmlPattern parsing interface
475    WITH_PATTERN=0
476else
477    WITH_PATTERN=1
478fi
479AC_SUBST(WITH_PATTERN)
480AM_CONDITIONAL(WITH_PATTERN_SOURCES, test "$WITH_PATTERN" = "1")
481
482if test "$with_sax1" = "no" ; then
483    echo Disabling the older SAX1 interface
484    WITH_SAX1=0
485else
486    WITH_SAX1=1
487fi
488AC_SUBST(WITH_SAX1)
489AM_CONDITIONAL(WITH_SAX1_SOURCES, test "$WITH_SAX1" = "1")
490
491if test "$with_push" = "no" ; then
492    echo Disabling the PUSH parser interfaces
493    WITH_PUSH=0
494else
495    WITH_PUSH=1
496fi
497AC_SUBST(WITH_PUSH)
498
499if test "$with_html" = "no" ; then
500    echo Disabling HTML support
501    WITH_HTML=0
502else
503    WITH_HTML=1
504fi
505AC_SUBST(WITH_HTML)
506AM_CONDITIONAL(WITH_HTML_SOURCES, test "$WITH_HTML" = "1")
507
508if test "$with_valid" = "no" ; then
509    echo Disabling DTD validation support
510    WITH_VALID=0
511else
512    WITH_VALID=1
513fi
514AC_SUBST(WITH_VALID)
515AM_CONDITIONAL(WITH_VALID_SOURCES, test "$WITH_VALID" = "1")
516
517if test "$with_catalog" = "no" ; then
518    echo Disabling Catalog support
519    WITH_CATALOG=0
520else
521    WITH_CATALOG=1
522fi
523AC_SUBST(WITH_CATALOG)
524AM_CONDITIONAL(WITH_CATALOG_SOURCES, test "$WITH_CATALOG" = "1")
525
526if test "$with_xptr" = "no" ; then
527    echo Disabling XPointer support
528    WITH_XPTR=0
529else
530    WITH_XPTR=1
531fi
532AC_SUBST(WITH_XPTR)
533AM_CONDITIONAL(WITH_XPTR_SOURCES, test "$WITH_XPTR" = "1")
534
535if test "$with_c14n" = "no" ; then
536    echo Disabling C14N support
537    WITH_C14N=0
538else
539    WITH_C14N=1
540fi
541AC_SUBST(WITH_C14N)
542AM_CONDITIONAL(WITH_C14N_SOURCES, test "$WITH_C14N" = "1")
543
544if test "$with_xinclude" = "no" ; then
545    echo Disabling XInclude support
546    WITH_XINCLUDE=0
547else
548    WITH_XINCLUDE=1
549fi
550AC_SUBST(WITH_XINCLUDE)
551AM_CONDITIONAL(WITH_XINCLUDE_SOURCES, test "$WITH_XINCLUDE" = "1")
552
553if test "$with_schematron" = "no" ; then
554    echo "Disabling Schematron support"
555    WITH_SCHEMATRON=0
556else
557    WITH_SCHEMATRON=1
558fi
559AC_SUBST(WITH_SCHEMATRON)
560AM_CONDITIONAL(WITH_SCHEMATRON_SOURCES, test "$WITH_SCHEMATRON" = "1")
561
562if test "$with_xpath" = "no" ; then
563    echo Disabling XPATH support
564    WITH_XPATH=0
565else
566    WITH_XPATH=1
567fi
568AC_SUBST(WITH_XPATH)
569AM_CONDITIONAL(WITH_XPATH_SOURCES, test "$WITH_XPATH" = "1")
570
571if test "$with_output" = "no" ; then
572    echo Disabling serialization/saving support
573    WITH_OUTPUT=0
574else
575    WITH_OUTPUT=1
576fi
577AC_SUBST(WITH_OUTPUT)
578AM_CONDITIONAL(WITH_OUTPUT_SOURCES, test "$WITH_OUTPUT" = "1")
579
580if test "$WITH_ICONV" != "1" && test "$with_iso8859x" = "no" ; then
581    echo Disabling ISO8859X support
582    WITH_ISO8859X=0
583else
584    WITH_ISO8859X=1
585fi
586AC_SUBST(WITH_ISO8859X)
587
588if test "$with_schemas" = "no" ; then
589    echo "Disabling Schemas/Relax-NG support"
590    WITH_SCHEMAS=0
591else
592    WITH_SCHEMAS=1
593fi
594AC_SUBST(WITH_SCHEMAS)
595AM_CONDITIONAL(WITH_SCHEMAS_SOURCES, test "$WITH_SCHEMAS" = "1")
596
597if test "$with_regexps" = "no" ; then
598    echo Disabling Regexps support
599    WITH_REGEXPS=0
600else
601    WITH_REGEXPS=1
602fi
603AC_SUBST(WITH_REGEXPS)
604AM_CONDITIONAL(WITH_REGEXPS_SOURCES, test "$WITH_REGEXPS" = "1")
605
606if test "$with_debug" = "no" ; then
607    echo Disabling DEBUG support
608    WITH_DEBUG=0
609else
610    WITH_DEBUG=1
611fi
612AC_SUBST(WITH_DEBUG)
613AM_CONDITIONAL(WITH_DEBUG_SOURCES, test "$WITH_DEBUG" = "1")
614
615dnl
616dnl Check for Python
617dnl
618
619AS_IF([test "x$with_python" != "xno"], [
620    AM_PATH_PYTHON
621    PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
622])
623AM_CONDITIONAL([WITH_PYTHON], [test "x$with_python" != "xno"])
624
625dnl
626dnl Extra Python flags for Windows
627dnl
628PYTHON_LDFLAGS=
629if test "${PYTHON}" != ""; then
630    case "$host" in
631        *-*-mingw* )
632            PYTHON_LDFLAGS="-no-undefined -shrext .pyd"
633            ;;
634        *-*-cygwin* |*-*-msys* )
635            PYTHON_LDFLAGS="-no-undefined"
636            ;;
637    esac
638fi
639AC_SUBST(PYTHON_LDFLAGS)
640
641dnl
642dnl Check for DSO support
643dnl
644WITH_MODULES=0
645
646if test "$with_modules" != "no" ; then
647    case "$host" in
648        *-*-cygwin* | *-*-msys* )
649            MODULE_EXTENSION=".dll"
650            ;;
651        *-*-mingw*)
652            MODULE_EXTENSION=".dll"
653            WITH_MODULES=1
654            ;;
655        *-*-hpux*)
656	    MODULE_EXTENSION=".sl"
657	    ;;
658        *)
659	    MODULE_EXTENSION=".so"
660	    ;;
661    esac
662
663    if test "$WITH_MODULES" = "0"; then
664        _libs=$LIBS
665        AC_SEARCH_LIBS([dlopen], [dl], [
666            WITH_MODULES=1
667            if test "$ac_cv_search_dlopen" != "none required"; then
668                MODULE_LIBS=$ac_cv_search_dlopen
669            fi
670            AC_DEFINE([HAVE_DLOPEN], [], [Have dlopen based dso])], [
671            AC_SEARCH_LIBS([shl_load], [dld], [
672                WITH_MODULES=1
673                if test "$ac_cv_search_shl_load" != "none required"; then
674                    MODULE_LIBS=$ac_cv_search_shl_load
675                fi
676                AC_DEFINE([HAVE_SHLLOAD], [], [Have shl_load based dso])])])
677        LIBS=$_libs
678    fi
679
680    if test "$WITH_MODULES" = "0"; then
681        AC_MSG_ERROR([dlopen or equivalent not found])
682    fi
683
684    XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${MODULE_LIBS}"
685    XML_PC_LIBS="${XML_PC_LIBS} ${MODULE_LIBS}"
686fi
687
688AC_SUBST(WITH_MODULES)
689AC_SUBST(MODULE_EXTENSION)
690AM_CONDITIONAL(WITH_MODULES_SOURCES, test "$WITH_MODULES" = "1")
691
692dnl
693dnl Thread-related stuff
694dnl
695THREAD_LIBS=""
696WITH_THREADS=0
697WITH_THREAD_ALLOC=0
698
699if test "$with_threads" = "no" ; then
700    echo Disabling multithreaded support
701else
702    case $host_os in
703        *mingw*)
704            dnl Default to native threads on Windows
705            WITH_THREADS="1"
706            ;;
707        *)
708            dnl Use pthread by default in other cases
709            _libs=$LIBS
710            AC_CHECK_HEADERS(pthread.h,
711                AC_SEARCH_LIBS([pthread_create], [pthread], [
712                    WITH_THREADS="1"
713                    if test "$ac_cv_search_pthread_create" != "none required"; then
714                        THREAD_LIBS=$ac_cv_search_pthread_create
715                    fi]))
716            LIBS=$_libs
717            ;;
718    esac
719
720    if test "$WITH_THREADS" = "0"; then
721        AC_MSG_ERROR([libpthread not found])
722    fi
723
724    XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${THREAD_LIBS}"
725    XML_PC_LIBS="${XML_PC_LIBS} ${THREAD_LIBS}"
726fi
727if test "$with_thread_alloc" = "yes" && test "$WITH_THREADS" = "1" ; then
728    WITH_THREAD_ALLOC=1
729fi
730
731AC_SUBST(THREAD_LIBS)
732AC_SUBST(WITH_THREADS)
733AC_SUBST(WITH_THREAD_ALLOC)
734
735dnl
736dnl Checks for readline and history libraries.
737dnl
738if test "$with_readline" != "no" && test "$with_readline" != ""; then
739    WITH_READLINE=0
740    WITH_HISTORY=0
741
742    if test "$with_readline" != "yes"; then
743        RDL_DIR=$with_readline
744    fi
745
746    if test "$RDL_DIR" = ""; then
747        PKG_CHECK_MODULES([RDL], [readline], [ WITH_READLINE=1 ], [:])
748    fi
749
750    if test "$WITH_READLINE" = "0"; then
751        _cppflags=$CPPFLAGS
752        _libs=$LIBS
753
754        if test "$RDL_DIR" != ""; then
755            CPPFLAGS="${CPPFLAGS} -I$RDL_DIR/include"
756            LIBS="${LIBS} -L$RDL_DIR/lib"
757        fi
758        AC_CHECK_HEADER(readline/readline.h,
759            AC_CHECK_LIB(readline, readline, [
760                WITH_READLINE=1
761                RDL_LIBS="-lreadline"
762            ], [
763                AC_MSG_ERROR([libreadline not found])
764            ]))
765
766        CPPFLAGS=$_cppflags
767        LIBS=$_libs
768    fi
769
770    AC_DEFINE([HAVE_LIBREADLINE], [],
771              [Define if readline library is available])
772
773    if test "$with_history" = "yes"; then
774        if test "$RDL_DIR" = ""; then
775            PKG_CHECK_MODULES([HISTORY], [history], [
776                WITH_HISTORY=1
777                RDL_CFLAGS="$HISTORY_CFLAGS $RDL_CFLAGS"
778                RDL_LIBS="$HISTORY_LIBS $RDL_LIBS"
779            ], [:])
780        fi
781
782        if test "$WITH_HISTORY" = "0"; then
783            _cppflags=$CPPFLAGS
784            _libs=$LIBS
785
786            if test "$RDL_DIR" != ""; then
787                CPPFLAGS="${CPPFLAGS} -I$RDL_DIR/include"
788                LIBS="${LIBS} -L$RDL_DIR/lib"
789            fi
790            AC_CHECK_HEADER(readline/history.h,
791                AC_CHECK_LIB(history, append_history, [
792                    WITH_HISTORY=1
793                    RDL_LIBS="-lhistory $RDL_LIBS"
794                ], [
795                    AC_MSG_ERROR([libhistory not found])
796                ]))
797
798            CPPFLAGS=$_cppflags
799            LIBS=$_libs
800        fi
801
802        AC_DEFINE([HAVE_LIBHISTORY], [],
803                  [Define if history library is available])
804    fi
805
806    if test "$RDL_DIR" != ""; then
807        RDL_CFLAGS="-I$RDL_DIR/include"
808        RDL_LIBS="-L$RDL_DIR/lib $RDL_LIBS"
809    fi
810fi
811AC_SUBST(RDL_CFLAGS)
812AC_SUBST(RDL_LIBS)
813
814dnl
815dnl Checks for zlib library.
816dnl
817WITH_ZLIB=0
818
819if test "$with_zlib" != "no" && test "$with_zlib" != ""; then
820    echo "Enabling zlib compression support"
821
822    if test "$with_zlib" != "yes"; then
823        Z_DIR=$with_zlib
824    fi
825
826    # Don't run pkg-config if with_zlib contains a path.
827    if test "x$Z_DIR" = "x"; then
828        # Try pkg-config first so that static linking works.
829        PKG_CHECK_MODULES([Z],[zlib],
830            [WITH_ZLIB=1; XML_PC_REQUIRES="${XML_PC_REQUIRES} zlib"],
831            [:])
832    fi
833
834    if test "$WITH_ZLIB" = "0"; then
835        _cppflags=$CPPFLAGS
836        _libs=$LIBS
837        if test "x$Z_DIR" != "x"; then
838            CPPFLAGS="${CPPFLAGS} -I$Z_DIR/include"
839            LIBS="${LIBS} -L$Z_DIR/lib"
840        fi
841        AC_CHECK_HEADERS(zlib.h,
842            AC_CHECK_LIB(z, gzread,[
843                WITH_ZLIB=1
844                if test "x${Z_DIR}" != "x"; then
845                    Z_CFLAGS="-I${Z_DIR}/include"
846                    Z_LIBS="-L${Z_DIR}/lib -lz"
847                    [case ${host} in
848                        *-*-solaris*)
849                            Z_LIBS="-L${Z_DIR}/lib -R${Z_DIR}/lib -lz"
850                            ;;
851                    esac]
852                else
853                    Z_LIBS="-lz"
854                fi])
855                XML_PC_LIBS="${XML_PC_LIBS} ${Z_LIBS}"
856            )
857        CPPFLAGS=$_cppflags
858        LIBS=$_libs
859    fi
860
861    if test "$WITH_ZLIB" = "0"; then
862        AC_MSG_ERROR([zlib not found])
863    fi
864
865    XML_PRIVATE_CFLAGS="${XML_PRIVATE_CFLAGS} ${Z_CFLAGS}"
866    XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${Z_LIBS}"
867fi
868AC_SUBST(WITH_ZLIB)
869
870dnl
871dnl Checks for lzma library.
872dnl
873WITH_LZMA=0
874
875if test "$with_lzma" != "no" && test "$with_lzma" != ""; then
876    echo "Enabling lzma compression support"
877
878    if test "$with_lzma" != "yes"; then
879        LZMA_DIR=$with_lzma
880    fi
881
882    # Don't run pkg-config if with_lzma contains a path.
883    if test "x$LZMA_DIR" = "x"; then
884        # Try pkg-config first so that static linking works.
885        PKG_CHECK_MODULES([LZMA],[liblzma],
886            [WITH_LZMA=1; XML_PC_REQUIRES="${XML_PC_REQUIRES} liblzma"],
887            [:])
888    fi
889
890    # If pkg-config failed, fall back to AC_CHECK_LIB. This
891    # will not pick up the necessary LIBS flags for liblzma's
892    # private dependencies, though, so static linking may fail.
893    if test "$WITH_LZMA" = "0"; then
894        _cppflags=$CPPFLAGS
895        _libs=$LIBS
896        if test "x$LZMA_DIR" != "x"; then
897            CPPFLAGS="${CPPFLAGS} -I$LZMA_DIR/include"
898            LIBS="${LIBS} -L$LZMA_DIR/lib"
899        fi
900        AC_CHECK_HEADERS(lzma.h,
901            AC_CHECK_LIB(lzma, lzma_code,[
902                WITH_LZMA=1
903                if test "x${LZMA_DIR}" != "x"; then
904                    LZMA_CFLAGS="-I${LZMA_DIR}/include"
905                    LZMA_LIBS="-L${LZMA_DIR}/lib -llzma"
906                else
907                    LZMA_LIBS="-llzma"
908                fi])
909                XML_PC_LIBS="${XML_PC_LIBS} ${LZMA_LIBS}"
910            )
911        CPPFLAGS=$_cppflags
912        LIBS=$_libs
913    fi
914
915    if test "$WITH_LZMA" = "0"; then
916        AC_MSG_ERROR([liblzma not found])
917    fi
918
919    XML_PRIVATE_CFLAGS="${XML_PRIVATE_CFLAGS} ${LZMA_CFLAGS}"
920    XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${LZMA_LIBS}"
921fi
922AC_SUBST(WITH_LZMA)
923AM_CONDITIONAL(WITH_LZMA_SOURCES, test "$WITH_LZMA" = "1")
924
925dnl
926dnl Checks for iconv library.
927dnl
928WITH_ICONV=0
929
930if test "$with_iconv" = "no" ; then
931    echo Disabling ICONV support
932else
933    _cppflags=$CPPFLAGS
934    _libs=$LIBS
935    if test "$with_iconv" != "yes" && test "$with_iconv" != "" ; then
936	ICONV_DIR=$with_iconv
937	CPPFLAGS="$CPPFLAGS -I$ICONV_DIR/include"
938	LIBS="$LIBS -L$ICONV_DIR/lib"
939    fi
940    AC_MSG_CHECKING([for libiconv])
941    AC_LINK_IFELSE([
942        AC_LANG_PROGRAM([#include <iconv.h>], [iconv_open(0,0);])
943    ], [
944        WITH_ICONV=1
945        AC_MSG_RESULT([none required])
946    ], [
947        LIBS="$LIBS -liconv"
948        AC_LINK_IFELSE([
949            AC_LANG_PROGRAM([#include <iconv.h>], [iconv_open(0,0);])
950        ], [
951            WITH_ICONV=1
952            ICONV_LIBS="-liconv"
953            AC_MSG_RESULT([yes])
954        ], [
955            AC_MSG_RESULT([no])
956        ])
957    ])
958
959    if test "$WITH_ICONV" = "0"; then
960        AC_MSG_ERROR([libiconv not found])
961    fi
962
963    if test "$WITH_ICONV" = "1" && test "$ICONV_DIR" != ""; then
964        ICONV_CFLAGS="-I$ICONV_DIR/include"
965        ICONV_LIBS="-L$ICONV_DIR/lib $ICONV_LIBS"
966    fi
967    CPPFLAGS=$_cppflags
968    LIBS=$_libs
969
970    XML_PRIVATE_CFLAGS="${XML_PRIVATE_CFLAGS} ${ICONV_CFLAGS}"
971    XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${ICONV_LIBS}"
972    XML_PC_LIBS="${XML_PC_LIBS} ${ICONV_LIBS}"
973fi
974AC_SUBST(WITH_ICONV)
975AC_SUBST(ICONV_CFLAGS)
976
977dnl
978dnl Checks for ICU library.
979dnl
980WITH_ICU=0
981
982if test "$with_icu" != "no" && test "$with_icu" != "" ; then
983    echo Enabling ICU support
984
985    # Try pkg-config first so that static linking works.
986    # If this succeeeds, we ignore the WITH_ICU directory.
987    PKG_CHECK_MODULES([ICU], [icu-i18n], [
988        WITH_ICU=1; XML_PC_REQUIRES="${XML_PC_REQUIRES} icu-i18n"
989        m4_ifdef([PKG_CHECK_VAR],
990            [PKG_CHECK_VAR([ICU_DEFS], [icu-i18n], [DEFS])])
991        if test "x$ICU_DEFS" != "x"; then
992            ICU_CFLAGS="$ICU_CFLAGS $ICU_DEFS"
993        fi],[:])
994
995    if test "$WITH_ICU" = "0"; then
996        ICU_CONFIG=icu-config
997        if ${ICU_CONFIG} --cflags >/dev/null 2>&1
998        then
999            WITH_ICU=1
1000            ICU_CFLAGS=`${ICU_CONFIG} --cflags`
1001            ICU_LIBS=`${ICU_CONFIG} --ldflags`
1002            XML_PC_LIBS="${XML_PC_LIBS} ${ICU_LIBS}"
1003        else
1004            _cppflags="${CPPFLAGS}"
1005            _libs="${LIBS}"
1006            if test "$with_icu" != "yes" ; then
1007                ICU_DIR=$with_icu
1008                CPPFLAGS="${CPPFLAGS} -I$ICU_DIR/include"
1009                LIBS="${LIBS} -L$ICU_DIR/lib"
1010            fi
1011
1012            AC_CHECK_HEADER(unicode/ucnv.h, [
1013                AC_CHECK_LIB([icucore], [ucnv_open], [
1014                    WITH_ICU=1
1015                    ICU_LIBS=-licucore
1016                    if test "$ICU_DIR" != ""; then
1017                        ICU_CFLAGS="-I$ICU_DIR/include"
1018                        ICU_LIBS="-L$ICU_DIR/lib $ICU_LIBS"
1019                    fi])])
1020                    XML_PC_LIBS="${XML_PC_LIBS} ${ICU_LIBS}"
1021            CPPFLAGS=$_cppflags
1022            LIBS=$_libs
1023        fi
1024    fi
1025
1026    if test "$WITH_ICU" = "0"; then
1027        AC_MSG_ERROR([ICU not found])
1028    fi
1029
1030    XML_PRIVATE_CFLAGS="${XML_PRIVATE_CFLAGS} ${ICU_CFLAGS}"
1031    XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${ICU_LIBS}"
1032fi
1033AC_SUBST(WITH_ICU)
1034
1035dnl
1036dnl Crypto libraries
1037dnl
1038case "$host" in
1039    *-*-mingw*)
1040        CRYPTO_LIBS="-lbcrypt"
1041        XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${CRYPTO_LIBS}"
1042        XML_PC_LIBS="${XML_PC_LIBS} ${CRYPTO_LIBS}"
1043        ;;
1044esac
1045
1046XML_LIBS="-lxml2"
1047XML_PC_LIBS="${XML_PC_LIBS} ${LIBM}"
1048XML_PRIVATE_LIBS="${XML_PRIVATE_LIBS} ${LIBM}"
1049
1050dnl When static-only:
1051dnl * Duplicate xml-config static --libs into --dynamic.
1052dnl * Fold pkg-config private fields into main fields.
1053if test "x$enable_shared" = "xno"; then
1054  XML_PRIVATE_LIBS_NO_SHARED="${XML_PRIVATE_LIBS}"
1055  XML_PC_PRIVATE=
1056  XML_PC_LIBS_PRIVATE=
1057else
1058  XML_PRIVATE_LIBS_NO_SHARED=
1059  XML_PC_PRIVATE=".private"
1060  XML_PC_LIBS_PRIVATE="
1061Libs.private:"
1062fi
1063AC_SUBST(XML_PRIVATE_LIBS_NO_SHARED)
1064AC_SUBST(XML_PC_PRIVATE)
1065AC_SUBST(XML_PC_LIBS_PRIVATE)
1066AC_SUBST(XML_PC_CFLAGS_PRIVATE)
1067AM_SUBST_NOTMAKE(XML_PRIVATE_LIBS_NO_SHARED)
1068AM_SUBST_NOTMAKE(XML_PC_PRIVATE)
1069AM_SUBST_NOTMAKE(XML_PC_LIBS_PRIVATE)
1070AM_SUBST_NOTMAKE(XML_PC_CFLAGS_PRIVATE)
1071
1072AC_SUBST(XML_PC_LIBS)
1073AC_SUBST(XML_PC_REQUIRES)
1074AM_SUBST_NOTMAKE(XML_PC_LIBS)
1075AM_SUBST_NOTMAKE(XML_PC_REQUIRES)
1076
1077AC_SUBST(AM_CFLAGS)
1078AC_SUBST(AM_LDFLAGS)
1079AC_SUBST(XML_CFLAGS)
1080AC_SUBST(XML_STATIC_CFLAGS)
1081
1082AC_SUBST(XML_LIBDIR)
1083AC_SUBST(XML_LIBS)
1084AC_SUBST(XML_PRIVATE_LIBS)
1085AC_SUBST(XML_PRIVATE_CFLAGS)
1086AC_SUBST(XML_INCLUDEDIR)
1087
1088# keep on one line for cygwin c.f. #130896
1089AC_CONFIG_FILES([Makefile include/Makefile include/libxml/Makefile include/private/Makefile doc/Makefile doc/devhelp/Makefile example/Makefile fuzz/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h libxml-2.0.pc libxml2-config.cmake])
1090AC_CONFIG_FILES([python/setup.py], [chmod +x python/setup.py])
1091AC_CONFIG_FILES([xml2-config], [chmod +x xml2-config])
1092AC_OUTPUT
1093