• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ([2.63])
3
4m4_define([MAJOR_VERSION], 2)
5m4_define([MINOR_VERSION], 9)
6m4_define([MICRO_VERSION], 11)
7
8AC_INIT([libxml2],[MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION])
9AC_CONFIG_SRCDIR([entities.c])
10AC_CONFIG_HEADERS([config.h])
11AM_MAINTAINER_MODE([enable])
12AC_CONFIG_MACRO_DIR([m4])
13AC_CANONICAL_HOST
14
15LIBXML_MAJOR_VERSION=MAJOR_VERSION
16LIBXML_MINOR_VERSION=MINOR_VERSION
17LIBXML_MICRO_VERSION=MICRO_VERSION
18LIBXML_MICRO_VERSION_SUFFIX=
19LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION$LIBXML_MICRO_VERSION_SUFFIX
20LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
21
22LIBXML_VERSION_NUMBER=`expr $LIBXML_MAJOR_VERSION \* 10000 + $LIBXML_MINOR_VERSION \* 100 + $LIBXML_MICRO_VERSION`
23
24if test -f CVS/Entries ; then
25  extra=`grep ChangeLog CVS/Entries | grep -v LIBXML | sed -e s\%/ChangeLog/1\.%% -e s\%/.*$%%`
26  echo extra=$extra
27  if test "$extra" != ""
28  then
29      LIBXML_VERSION_EXTRA="-CVS$extra"
30  fi
31else if test -d .svn ; then
32  extra=`svn info | grep Revision | sed 's+Revision: ++'`
33  echo extra=$extra
34  if test "$extra" != ""
35  then
36      LIBXML_VERSION_EXTRA="-SVN$extra"
37  fi
38else if test -d .git ; then
39  extra=`git describe 2>/dev/null | sed 's+LIBXML[[0-9.]]*-++'`
40  echo extra=$extra
41  if test "$extra" != ""
42  then
43      LIBXML_VERSION_EXTRA="-GIT$extra"
44  fi
45fi
46fi
47fi
48AC_SUBST(LIBXML_MAJOR_VERSION)
49AC_SUBST(LIBXML_MINOR_VERSION)
50AC_SUBST(LIBXML_MICRO_VERSION)
51AC_SUBST(LIBXML_VERSION)
52AC_SUBST(LIBXML_VERSION_INFO)
53AC_SUBST(LIBXML_VERSION_NUMBER)
54AC_SUBST(LIBXML_VERSION_EXTRA)
55
56VERSION=${LIBXML_VERSION}
57
58AM_INIT_AUTOMAKE([foreign])
59
60# Support silent build rules, requires at least automake-1.11. Disable
61# by either passing --disable-silent-rules to configure or passing V=1
62# to make
63m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
64
65dnl Checks for programs.
66AC_PROG_CC
67AC_PROG_INSTALL
68AC_PROG_LN_S
69AC_PROG_MKDIR_P
70AC_PROG_CPP
71AC_PATH_PROG(MV, mv, /bin/mv)
72AC_PATH_PROG(TAR, tar, /bin/tar)
73AC_PATH_PROG(PERL, perl, /usr/bin/perl)
74AC_PATH_PROG(WGET, wget, /usr/bin/wget)
75AC_PATH_PROG(XMLLINT, xmllint, /usr/bin/xmllint)
76AC_PATH_PROG(XSLTPROC, xsltproc, /usr/bin/xsltproc)
77PKG_PROG_PKG_CONFIG
78
79LT_INIT
80
81dnl
82dnl if the system support linker version scripts for symbol versioning
83dnl then add it
84dnl
85VERSION_SCRIPT_FLAGS=
86# lt_cv_prog_gnu_ld is from libtool 2.+
87if test "$lt_cv_prog_gnu_ld" = yes; then
88  VERSION_SCRIPT_FLAGS=-Wl,--version-script=
89else
90  case $host in
91  *-*-sunos*) VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,";;
92  esac
93fi
94AC_SUBST(VERSION_SCRIPT_FLAGS)
95AM_CONDITIONAL([USE_VERSION_SCRIPT], [test -n "$VERSION_SCRIPT_FLAGS"])
96
97dnl
98dnl We process the AC_ARG_WITH first so that later we can modify
99dnl some of them to try to prevent impossible combinations.  This
100dnl also allows up so alphabetize the choices
101dnl
102
103dnl
104dnl zlib option might change flags, so we save them initially
105dnl
106_cppflags="${CPPFLAGS}"
107_libs="${LIBS}"
108
109AC_ARG_WITH(c14n,
110[  --with-c14n             add the Canonicalization support (on)])
111AC_ARG_WITH(catalog,
112[  --with-catalog          add the Catalog support (on)])
113AC_ARG_WITH(debug,
114[  --with-debug            add the debugging module (on)])
115AC_ARG_WITH(docbook,
116[  --with-docbook          add Docbook SGML support (on)])
117AC_ARG_WITH(fexceptions,
118[  --with-fexceptions      add GCC flag -fexceptions for C++ exceptions (off)])
119AC_ARG_WITH(ftp,
120[  --with-ftp              add the FTP support (on)])
121AC_ARG_WITH(history,
122[  --with-history          add history support to xmllint shell(off)])
123AC_ARG_WITH(html,
124[  --with-html             add the HTML support (on)])
125dnl Specific dir for HTML output ?
126AC_ARG_WITH(html-dir, AS_HELP_STRING([--with-html-dir=path],
127            [path to base html directory, default $datadir/doc/html]),
128            [HTML_DIR=$withval], [HTML_DIR='$(datadir)/doc'])
129
130AC_ARG_WITH(html-subdir, AS_HELP_STRING([--with-html-subdir=path],
131            [directory used under html-dir, default $PACKAGE-$VERSION/html]),
132            [test "x$withval" != "x" && HTML_DIR="$HTML_DIR/$withval"],
133            [HTML_DIR="$HTML_DIR/\$(PACKAGE)-\$(VERSION)/html"])
134AC_SUBST(HTML_DIR)
135AC_ARG_WITH(http,
136[  --with-http             add the HTTP support (on)])
137AC_ARG_WITH(iconv,
138[  --with-iconv[[=DIR]]      add ICONV support (on)])
139AC_ARG_WITH(icu,
140[  --with-icu                add ICU support (off)])
141AC_ARG_WITH(iso8859x,
142[  --with-iso8859x         add ISO8859X support if no iconv (on)])
143AC_ARG_WITH(legacy,
144[  --with-legacy           add deprecated APIs for compatibility (on)])
145AC_ARG_WITH(mem_debug,
146[  --with-mem-debug        add the memory debugging module (off)])
147AC_ARG_WITH(minimum,
148[  --with-minimum          build a minimally sized library (off)])
149AC_ARG_WITH(output,
150[  --with-output           add the serialization support (on)])
151AC_ARG_WITH(pattern,
152[  --with-pattern          add the xmlPattern selection interface (on)])
153AC_ARG_WITH(push,
154[  --with-push             add the PUSH parser interfaces (on)])
155AC_ARG_WITH(python,
156[  --with-python[[=DIR]]     build Python bindings if found])
157AC_ARG_WITH(python_install_dir,
158[  --with-python-install-dir=DIR
159                          install Python bindings in DIR])
160AC_ARG_WITH(reader,
161[  --with-reader           add the xmlReader parsing interface (on)])
162AC_ARG_WITH(readline,
163[  --with-readline=DIR     use readline in DIR],[
164  if test "$withval" != "no" -a "$withval" != "yes"; then
165    RDL_DIR=$withval
166    CPPFLAGS="${CPPFLAGS} -I$withval/include"
167    LDFLAGS="${LDFLAGS} -L$withval/lib"
168  fi
169])
170AC_ARG_WITH(regexps,
171[  --with-regexps          add Regular Expressions support (on)])
172AC_ARG_WITH(run_debug,
173[  --with-run-debug        add the runtime debugging module (off)])
174AC_ARG_WITH(sax1,
175[  --with-sax1             add the older SAX1 interface (on)])
176AC_ARG_WITH(schemas,
177[  --with-schemas          add Relax-NG and Schemas support (on)])
178AC_ARG_WITH(schematron,
179[  --with-schematron       add Schematron support (on)])
180AC_ARG_WITH(threads,
181[  --with-threads          add multithread support(on)])
182AC_ARG_WITH(thread-alloc,
183[  --with-thread-alloc     add per-thread memory(off)])
184AC_ARG_WITH(tree,
185[  --with-tree             add the DOM like tree manipulation APIs (on)])
186AC_ARG_WITH(valid,
187[  --with-valid            add the DTD validation support (on)])
188AC_ARG_WITH(writer,
189[  --with-writer           add the xmlWriter saving interface (on)])
190AC_ARG_WITH(xinclude,
191[  --with-xinclude         add the XInclude support (on)])
192AC_ARG_WITH(xpath,
193[  --with-xpath            add the XPATH support (on)])
194AC_ARG_WITH(xptr,
195[  --with-xptr             add the XPointer support (on)])
196AC_ARG_WITH(modules,
197[  --with-modules          add the dynamic modules support (on)])
198AC_ARG_WITH(zlib,
199[  --with-zlib[[=DIR]]       use libz in DIR],[
200  if test "$withval" != "no" -a "$withval" != "yes"; then
201    Z_DIR=$withval
202    CPPFLAGS="${CPPFLAGS} -I$withval/include"
203    LDFLAGS="${LDFLAGS} -L$withval/lib"
204  fi
205])
206AC_ARG_WITH(lzma,
207[  --with-lzma[[=DIR]]       use liblzma in DIR],[
208  if test "$withval" != "no" -a "$withval" != "yes"; then
209    LZMA_DIR=$withval
210    CPPFLAGS="${CPPFLAGS} -I$withval/include"
211    LDFLAGS="${LDFLAGS} -L$withval/lib"
212  fi
213])
214AC_ARG_WITH(coverage,
215[  --with-coverage         build for code coverage with GCC (off)])
216
217AC_ARG_ENABLE(rebuild-docs,
218[  --enable-rebuild-docs[[=yes/no]]  rebuild some generated docs [[default=no]]])
219if test "$enable_rebuild_docs" = "yes" -a "$srcdir" != "."; then
220  AC_MSG_ERROR([cannot rebuild docs when builddir != srcdir])
221fi
222AM_CONDITIONAL([REBUILD_DOCS], [test "$enable_rebuild_docs" = "yes" -o "$USER" = "veillard"])
223
224dnl
225dnl hard dependencies on options
226dnl
227if test "$with_schemas" = "yes"
228then
229    with_pattern=yes
230    with_regexps=yes
231fi
232if test "$with_schematron" = "yes"
233then
234    with_pattern=yes
235    with_tree=yes
236    with_xpath=yes
237fi
238if test "$with_reader" = "yes"
239then
240    with_push=yes
241fi
242if test "$with_xptr" = "yes"
243then
244    with_xpath=yes
245fi
246dnl
247dnl option to build a minimal libxml2 library
248dnl
249if test "$with_minimum" = "yes"
250then
251    echo "Configuring for a minimal library"
252    if test "$with_c14n" = ""
253    then
254      with_c14n=no
255    fi
256    if test "$with_catalog" = ""
257    then
258      with_catalog=no
259    fi
260    echo So far so good!
261    if test "$with_debug" = ""
262    then
263      with_debug=no
264    fi
265    if test "$with_docbook" = ""
266    then
267      with_docbook=no
268    fi
269    if test "$with_fexceptions" = ""
270    then
271      with_fexceptions=no
272    fi
273    if test "$with_ftp" = ""
274    then
275      with_ftp=no
276    fi
277    if test "$with_history" = ""
278    then
279      with_history=no
280    fi
281    if test "$with_html" = ""
282    then
283      with_html=no
284    fi
285    if test "$with_http" = ""
286    then
287      with_http=no
288    fi
289    if test "$with_iconv" = ""
290    then
291      with_iconv=no
292    fi
293    if test "$with_iso8859x" = ""
294    then
295      with_iso8859x=no
296    fi
297    if test "$with_legacy" = ""
298    then
299      with_legacy=no
300    fi
301    if test "$with_mem_debug" = ""
302    then
303      with_mem_debug=no
304    fi
305    if test "$with_output" = ""
306    then
307      with_output=no
308    fi
309    if test "$with_pattern" = ""
310    then
311      with_pattern=no
312    fi
313    if test "$with_push" = ""
314    then
315      with_push=no
316    fi
317    if test "$with_python" = ""
318    then
319      with_python=no
320    fi
321    if test "$with_reader" = ""
322    then
323      with_reader=no
324    fi
325    if test "$with_readline" = ""
326    then
327      with_readline=no
328    fi
329    if test "$with_regexps" = ""
330    then
331      with_regexps=no
332    fi
333    if test "$with_run_debug" = ""
334    then
335      with_run_debug=no
336    fi
337    if test "$with_sax1" = ""
338    then
339      with_sax1=no
340    fi
341    if test "$with_schemas" = ""
342    then
343      with_schemas=no
344    fi
345    if test "$with_schematron" = ""
346    then
347      with_schematron=no
348    fi
349    if test "$with_threads" = ""
350    then
351      with_threads=no
352    fi
353    if test "$with_thread_alloc" = ""
354    then
355      with_thread_alloc=no
356   fi
357    if test "$with_tree" = ""
358    then
359      with_tree=no
360    fi
361    if test "$with_valid" = ""
362    then
363      with_valid=no
364    fi
365    if test "$with_writer" = ""
366    then
367      with_writer=no
368    fi
369    if test "$with_xinclude" = ""
370    then
371      with_xinclude=no
372    fi
373    if test "$with_xpath" = ""
374    then
375      with_xpath=no
376    fi
377    if test "$with_xptr" = ""
378    then
379      with_xptr=no
380    fi
381    if test "$with_zlib" = ""
382    then
383      with_zlib=no
384    fi
385    if test "$with_modules" = ""
386    then
387      with_modules=no
388    fi
389fi
390
391echo Checking zlib
392
393dnl Checks for zlib library.
394
395WITH_ZLIB=0
396if test "$with_zlib" = "no"; then
397    echo "Disabling zlib compression support"
398else
399    # Don't run pkg-config if with_zlib contains a path.
400    if test "x$Z_DIR" = "x"; then
401        # Try pkg-config first so that static linking works.
402        PKG_CHECK_MODULES([Z],[zlib],
403            [WITH_ZLIB=1],
404            [:])
405    fi
406
407    if test "$WITH_ZLIB" = "0"; then
408        AC_CHECK_HEADERS(zlib.h,
409            AC_CHECK_LIB(z, gzread,[
410                WITH_ZLIB=1
411                if test "x${Z_DIR}" != "x"; then
412                    Z_CFLAGS="-I${Z_DIR}/include"
413                    Z_LIBS="-L${Z_DIR}/lib -lz"
414                    [case ${host} in
415                        *-*-solaris*)
416                            Z_LIBS="-L${Z_DIR}/lib -R${Z_DIR}/lib -lz"
417                            ;;
418                    esac]
419                else
420                    Z_LIBS="-lz"
421                fi])
422            )
423    fi
424fi
425
426AC_SUBST(Z_CFLAGS)
427AC_SUBST(Z_LIBS)
428AC_SUBST(WITH_ZLIB)
429
430echo Checking lzma
431
432dnl Checks for lzma library.
433
434WITH_LZMA=0
435if test "$with_lzma" = "no"; then
436    echo "Disabling lzma compression support"
437else
438    # Don't run pkg-config if with_lzma contains a path.
439    if test "x$LZMA_DIR" = "x"; then
440        # Try pkg-config first so that static linking works.
441        PKG_CHECK_MODULES([LZMA],[liblzma],
442            [WITH_LZMA=1],
443            [:])
444    fi
445
446    # If pkg-config failed, fall back to AC_CHECK_LIB. This
447    # will not pick up the necessary LIBS flags for liblzma's
448    # private dependencies, though, so static linking may fail.
449    if test "$WITH_LZMA" = "0"; then
450        AC_CHECK_HEADERS(lzma.h,
451            AC_CHECK_LIB(lzma, lzma_code,[
452                WITH_LZMA=1
453                if test "x${LZMA_DIR}" != "x"; then
454                    LZMA_CFLAGS="-I${LZMA_DIR}/include"
455                    LZMA_LIBS="-L${LZMA_DIR}/lib -llzma"
456                else
457                    LZMA_LIBS="-llzma"
458                fi])
459            )
460    fi
461fi
462
463AC_SUBST(LZMA_CFLAGS)
464AC_SUBST(LZMA_LIBS)
465AC_SUBST(WITH_LZMA)
466
467CPPFLAGS=${_cppflags}
468LIBS=${_libs}
469
470echo Checking headers
471
472dnl Checks for header files.
473AC_HEADER_DIRENT
474AC_HEADER_STDC
475AC_CHECK_HEADERS([fcntl.h])
476AC_CHECK_HEADERS([unistd.h])
477AC_CHECK_HEADERS([ctype.h])
478AC_CHECK_HEADERS([dirent.h])
479AC_CHECK_HEADERS([errno.h])
480AC_CHECK_HEADERS([malloc.h])
481AC_CHECK_HEADERS([stdarg.h])
482AC_CHECK_HEADERS([sys/stat.h])
483AC_CHECK_HEADERS([sys/types.h])
484AC_CHECK_HEADERS([stdint.h])
485AC_CHECK_HEADERS([inttypes.h])
486AC_CHECK_HEADERS([time.h])
487AC_CHECK_HEADERS([math.h])
488AC_CHECK_HEADERS([limits.h])
489AC_CHECK_HEADERS([float.h])
490AC_CHECK_HEADERS([stdlib.h])
491AC_CHECK_HEADERS([sys/socket.h], [], [],
492[#if HAVE_SYS_TYPES_H
493# include <sys/types.h>
494# endif
495])
496AC_CHECK_HEADERS([netinet/in.h], [], [],
497[#if HAVE_SYS_TYPES_H
498# include <sys/types.h>
499# endif
500])
501AC_CHECK_HEADERS([arpa/inet.h], [], [],
502[#if HAVE_SYS_TYPES_H
503# include <sys/types.h>
504# endif
505#if HAVE_ARPA_INET_H
506# include <arpa/inet.h>
507# endif
508])
509AC_CHECK_HEADERS([netdb.h])
510AC_CHECK_HEADERS([sys/time.h])
511AC_CHECK_HEADERS([sys/select.h])
512AC_CHECK_HEADERS([poll.h])
513AC_CHECK_HEADERS([sys/mman.h])
514AC_CHECK_HEADERS([sys/timeb.h])
515AC_CHECK_HEADERS([signal.h])
516AC_CHECK_HEADERS([arpa/nameser.h], [], [],
517[#if HAVE_SYS_TYPES_H
518# include <sys/types.h>
519# endif
520])
521AC_CHECK_HEADERS([resolv.h], [], [],
522[#if HAVE_SYS_TYPES_H
523# include <sys/types.h>
524# endif
525#if HAVE_NETINET_IN_H
526# include <netinet/in.h>
527# endif
528#if HAVE_ARPA_NAMESER_H
529# include <arpa/nameser.h>
530# endif
531])
532AC_CHECK_HEADERS([dl.h])
533AC_CHECK_HEADERS([dlfcn.h])
534
535
536echo Checking types
537
538AC_TYPE_UINT32_T
539
540
541echo Checking libraries
542
543dnl Checks for library functions.
544AC_FUNC_STRFTIME
545AC_CHECK_FUNCS(strftime localtime gettimeofday ftime)
546AC_CHECK_FUNCS(stat signal)
547AC_CHECK_FUNCS(rand rand_r srand time)
548AC_CHECK_FUNCS(isascii mmap munmap putenv)
549
550AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */
551#if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
552#  undef /**/ HAVE_MMAP
553#endif])
554
555dnl Checking for va_copy availability
556AC_MSG_CHECKING([for va_copy])
557AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
558va_list ap1,ap2;]], [[va_copy(ap1,ap2);]])],
559have_va_copy=yes,
560have_va_copy=no)
561AC_MSG_RESULT($have_va_copy)
562if test x"$have_va_copy" = x"yes"; then
563    AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
564else
565    AC_MSG_CHECKING([for __va_copy])
566    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
567    va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],
568    have___va_copy=yes,
569    have___va_copy=no)
570    AC_MSG_RESULT($have___va_copy)
571    if test x"$have___va_copy" = x"yes"; then
572        AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
573    fi
574fi
575
576dnl Checking whether va_list is an array type
577AC_MSG_CHECKING([whether va_list is an array type])
578AC_TRY_COMPILE2([
579#include <stdarg.h>
580void a(va_list * ap) {}],[
581va_list ap1, ap2; a(&ap1); ap2 = (va_list) ap1],[
582  AC_MSG_RESULT(no)],[
583  AC_MSG_RESULT(yes)
584  AC_DEFINE([VA_LIST_IS_ARRAY], [1],[Define if va_list is an array type])])
585
586dnl Checks for inet libraries:
587AC_SEARCH_LIBS(gethostent, [nsl])
588AC_SEARCH_LIBS(setsockopt, [socket net network])
589AC_SEARCH_LIBS(connect, [inet])
590
591dnl Determine what socket length (socklen_t) data type is
592AC_MSG_CHECKING([for type of socket length (socklen_t)])
593AC_TRY_COMPILE2([
594#include <stddef.h>
595#include <sys/types.h>
596#include <sys/socket.h>],[
597(void)getsockopt (1, 1, 1, NULL, (socklen_t *)NULL)],[
598  AC_MSG_RESULT(socklen_t *)
599  XML_SOCKLEN_T=socklen_t],[
600  AC_TRY_COMPILE2([
601#include <stddef.h>
602#include <sys/types.h>
603#include <sys/socket.h>],[
604(void)getsockopt (1, 1, 1, NULL, (size_t *)NULL)],[
605    AC_MSG_RESULT(size_t *)
606    XML_SOCKLEN_T=size_t],[
607    AC_TRY_COMPILE2([
608#include <stddef.h>
609#include <sys/types.h>
610#include <sys/socket.h>],[
611(void)getsockopt (1, 1, 1, NULL, (int *)NULL)],[
612      AC_MSG_RESULT(int *)
613      XML_SOCKLEN_T=int],[
614      AC_MSG_WARN(could not determine)
615      XML_SOCKLEN_T="int"])])])
616AC_DEFINE_UNQUOTED(XML_SOCKLEN_T, $XML_SOCKLEN_T, [Determine what socket length (socklen_t) data type is])
617
618dnl Checking if gethostbyname() argument is const.
619AC_MSG_CHECKING([for const gethostbyname() argument])
620AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
621    [[(void)gethostbyname((const char *)"");]])],
622have_gethostbyname_const_arg=yes,
623have_gethostbyname_const_arg=no)
624AC_MSG_RESULT($have_gethostbyname_const_arg)
625if test x"$have_gethostbyname_const_arg" = x"yes"; then
626    AC_DEFINE([GETHOSTBYNAME_ARG_CAST], [],
627      [Type cast for the gethostbyname() argument])
628else
629    AC_DEFINE([GETHOSTBYNAME_ARG_CAST], [(char *)],
630      [Type cast for the gethostbyname() argument])
631fi
632
633dnl Checking if send() second argument is const.
634AC_MSG_CHECKING([for const send() second argument])
635AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
636#include <sys/socket.h>]],
637    [[(void)send(1,(const char *)"",1,1);]])],
638have_send_const_arg2=yes,
639have_send_const_arg2=no)
640AC_MSG_RESULT($have_send_const_arg2)
641if test x"$have_send_const_arg2" = x"yes"; then
642    AC_DEFINE([SEND_ARG2_CAST], [],
643      [Type cast for the send() function 2nd arg])
644else
645    AC_DEFINE([SEND_ARG2_CAST], [(char *)],
646      [Type cast for the send() function 2nd arg])
647fi
648
649dnl Checking whether __attribute__((destructor)) is accepted by the compiler
650AC_MSG_CHECKING([whether __attribute__((destructor)) is accepted])
651AC_TRY_COMPILE2([
652void __attribute__((destructor))
653f(void) {}], [], [
654  AC_MSG_RESULT(yes)
655  AC_DEFINE([HAVE_ATTRIBUTE_DESTRUCTOR], [1],[Define if __attribute__((destructor)) is accepted])
656  AC_DEFINE([ATTRIBUTE_DESTRUCTOR], [__attribute__((destructor))],[A form that will not confuse apibuild.py])],[
657  AC_MSG_RESULT(no)])
658
659
660dnl ***********************Checking for availability of IPv6*******************
661
662AC_MSG_CHECKING([whether to enable IPv6])
663AC_ARG_ENABLE(ipv6, [  --enable-ipv6[[=yes/no]]  enables compilation of IPv6 code [[default=yes]]],, enable_ipv6=yes)
664if test "$with_minimum" = "yes"
665then
666    enable_ipv6=no
667fi
668if test $enable_ipv6 = yes; then
669  have_ipv6=no
670  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
671#   include <sys/types.h>
672#   include <sys/socket.h>
673    ]], [[
674    struct sockaddr_storage ss;
675    socket(AF_INET6, SOCK_STREAM, 0)
676    ]])],
677    have_ipv6=yes,
678    have_ipv6=no
679  )
680  AC_MSG_RESULT($have_ipv6)
681
682  if test $have_ipv6 = yes; then
683    AC_DEFINE([SUPPORT_IP6], [], [Support for IPv6])
684    have_broken_ss_family=no
685
686    dnl *********************************************************************
687    dnl on some platforms (like AIX 5L), the structure sockaddr doesn't have
688    dnl a ss_family member, but rather __ss_family. Let's detect that
689    dnl and define the HAVE_BROKEN_SS_FAMILY when we are on one of these
690    dnl platforms.  However, we should only do this if ss_family is not
691    dnl present.
692    dnl ********************************************************************
693    AC_MSG_CHECKING([struct sockaddr::ss_family])
694    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
695#     include <sys/types.h>
696#     include <sys/socket.h>
697      ]], [[
698      struct sockaddr_storage ss ;
699      ss.ss_family = 0 ;
700      ]])],
701      have_ss_family=yes,
702      have_ss_family=no
703    )
704    AC_MSG_RESULT($have_ss_family)
705    if test x$have_ss_family = xno ; then
706      AC_MSG_CHECKING([broken struct sockaddr::ss_family])
707      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
708#       include <sys/types.h>
709#       include <sys/socket.h>
710        ]], [[
711        struct sockaddr_storage ss ;
712        ss.__ss_family = 0 ;
713        ]])],
714        have_broken_ss_family=yes,
715        have_broken_ss_family=no
716      )
717      AC_MSG_RESULT($have_broken_ss_family)
718      if test x$have_broken_ss_family = xyes ; then
719        AC_DEFINE(HAVE_BROKEN_SS_FAMILY, [],
720	  [Whether struct sockaddr::__ss_family exists])
721        AC_DEFINE(ss_family, __ss_family,
722	  [ss_family is not defined here, use __ss_family instead])
723      else
724        AC_MSG_WARN(ss_family and __ss_family not found)
725      fi
726    fi
727
728    have_getaddrinfo=no
729    AC_CHECK_FUNC(getaddrinfo, have_getaddrinfo=yes)
730    if test $have_getaddrinfo != yes; then
731      for lib in bsd socket inet; do
732        AC_CHECK_LIB($lib, getaddrinfo, [LIBS="$LIBS -l$lib";have_getaddrinfo=yes;break])
733      done
734    fi
735
736    if test $have_getaddrinfo = yes; then
737      AC_DEFINE([HAVE_GETADDRINFO], [], [Define if getaddrinfo is there])
738    fi
739  fi
740fi
741
742dnl ******************************End IPv6 checks******************************
743
744dnl Checks for isnan in libm if not in libc
745AC_CHECK_FUNC(isnan, AC_DEFINE([HAVE_ISNAN],[], [Define if isnan is there]) , AC_CHECK_LIB(m, isnan,
746  [AC_DEFINE([HAVE_ISNAN],[], [Define if isnan is there])]))
747
748AC_CHECK_FUNC(isinf, AC_DEFINE([HAVE_ISINF], [], [Define if isinf is there]) , AC_CHECK_LIB(m, isinf,
749  [AC_DEFINE([HAVE_ISINF], [], [Define if isinf is there])]))
750
751XML_LIBDIR='-L${libdir}'
752XML_INCLUDEDIR='-I${includedir}/libxml2'
753
754dnl
755dnl Extra flags
756dnl
757XML_CFLAGS=""
758RDL_LIBS=""
759
760dnl
761dnl Workaround for native compilers
762dnl  HP  : http://bugs.gnome.org/db/31/3163.html
763dnl  DEC : Enable NaN/Inf
764dnl
765if test "${GCC}" != "yes" ; then
766    case "${host}" in
767          hppa*-*-hpux* )
768	       EXTRA_CFLAGS="${EXTRA_CFLAGS} -Wp,-H30000"
769	       ;;
770          *-dec-osf* )
771               EXTRA_CFLAGS="${EXTRA_CFLAGS} -ieee"
772               ;;
773	  alpha*-*-linux* )
774	       EXTRA_CFLAGS="${EXTRA_CFLAGS} -ieee"
775	       ;;
776    esac
777else
778    if test "$with_fexceptions" = "yes"
779    then
780        #
781	# Not activated by default because this inflates the code size
782	# Used to allow propagation of C++ exceptions through the library
783	#
784	EXTRA_CFLAGS="${EXTRA_CFLAGS} -fexceptions"
785    fi
786
787    # warnings we'd like to see
788    EXTRA_CFLAGS="${EXTRA_CFLAGS} -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls"
789    # warnings we'd like to suppress
790    EXTRA_CFLAGS="${EXTRA_CFLAGS} -Wno-long-long -Wno-format-extra-args"
791    case "${host}" in
792          alpha*-*-linux* )
793	       EXTRA_CFLAGS="${EXTRA_CFLAGS} -mieee"
794	       ;;
795	  alpha*-*-osf* )
796	       EXTRA_CFLAGS="${EXTRA_CFLAGS} -mieee"
797	       ;;
798    esac
799fi
800case ${host} in
801    *-*-solaris*)
802        XML_LIBDIR="${XML_LIBDIR} -R${libdir}"
803        ;;
804    hppa*-hp-mpeix)
805        NEED_TRIO=1
806	;;
807    *-*-mingw* | *-*-cygwin* | *-*-msvc* )
808        # If the host is Windows, and shared libraries are disabled, we
809        # need to add -DLIBXML_STATIC to EXTRA_CFLAGS in order for linking to
810        # work properly (without it, xmlexports.h would force the use of
811        # DLL imports, which obviously aren't present in a static
812        # library).
813        if test "x$enable_shared" = "xno"; then
814            XML_CFLAGS="$XML_CFLAGS -DLIBXML_STATIC"
815            EXTRA_CFLAGS="$EXTRA_CFLAGS -DLIBXML_STATIC"
816        fi
817        ;;
818esac
819
820
821dnl
822dnl check for python
823dnl
824
825PYTHON_VERSION=
826PYTHON_INCLUDES=
827PYTHON_SITE_PACKAGES=
828PYTHON_TESTS=
829pythondir=
830if test "$with_python" != "no" ; then
831    if test -x "$with_python/bin/python"
832    then
833        echo Found python in $with_python/bin/python
834        PYTHON="$with_python/bin/python"
835    else
836        if test -x "$with_python/python.exe"
837        then
838            echo Found python in $with_python/python.exe
839            PYTHON="$with_python/python.exe"
840        else
841            if test -x "$with_python"
842            then
843                echo Found python in $with_python
844                PYTHON="$with_python"
845            else
846                if test -x "$PYTHON"
847                then
848                    echo Found python in environment PYTHON=$PYTHON
849                    with_python=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
850                else
851                    AC_PATH_PROG(PYTHON, python python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5)
852		fi
853	    fi
854	fi
855    fi
856    if test "$PYTHON" != ""
857    then
858        PYTHON_VERSION=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_version())"`
859	PYTHON_INCLUDES=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_inc())"`
860# does not work as it produce a /usr/lib/python path instead of/usr/lib64/python
861#
862#	PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_lib())"`
863	echo Found Python version $PYTHON_VERSION
864    fi
865    if test "$PYTHON_VERSION" != "" -a "$PYTHON_INCLUDES" = ""
866    then
867	if test -r $with_python/include/python$PYTHON_VERSION/Python.h
868	then
869	    PYTHON_INCLUDES=$with_python/include/python$PYTHON_VERSION
870	else
871	    if test -r $prefix/include/python$PYTHON_VERSION/Python.h
872	    then
873	        PYTHON_INCLUDES=$prefix/include/python$PYTHON_VERSION
874	    else
875		if test -r /usr/include/python$PYTHON_VERSION/Python.h
876		then
877		    PYTHON_INCLUDES=/usr/include/python$PYTHON_VERSION
878		else
879	            if test -r $with_python/include/Python.h
880	            then
881	                PYTHON_INCLUDES=$with_python/include
882	            else
883		        echo could not find python$PYTHON_VERSION/Python.h or $with_python/include/Python.h
884		    fi
885		fi
886	    fi
887	fi
888    fi
889    if test "$with_python_install_dir" != ""
890    then
891	PYTHON_SITE_PACKAGES="$with_python_install_dir"
892    fi
893    if test "$PYTHON_VERSION" != "" -a "$PYTHON_SITE_PACKAGES" = ""
894    then
895	if test -d $libdir/python$PYTHON_VERSION/site-packages
896	then
897	    PYTHON_SITE_PACKAGES=$libdir/python$PYTHON_VERSION/site-packages
898	else
899	    if test -d $with_python/lib/site-packages
900	    then
901		PYTHON_SITE_PACKAGES=$with_python/lib/site-packages
902	    else
903		PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_lib())"`
904	    fi
905	fi
906    fi
907    pythondir='$(PYTHON_SITE_PACKAGES)'
908    PYTHON_LIBS=`python$PYTHON_VERSION-config --ldflags`
909else
910    PYTHON=
911fi
912AM_CONDITIONAL(WITH_PYTHON, test "$PYTHON_INCLUDES" != "")
913if test "$PYTHON_INCLUDES" != ""
914then
915    PYTHON_SUBDIR=python
916else
917    PYTHON_SUBDIR=
918fi
919AC_SUBST(pythondir)
920AC_SUBST(PYTHON_SUBDIR)
921AC_SUBST(PYTHON_LIBS)
922
923dnl check for dso support
924WITH_MODULES=0
925TEST_MODULES=
926
927if test "$with_modules" != "no" ; then
928 case "$host" in
929  *-*-cygwin*)
930  MODULE_EXTENSION=".dll"
931  AC_CHECK_LIB(cygwin, dlopen, [
932    WITH_MODULES=1
933    MODULE_PLATFORM_LIBS=
934    AC_DEFINE([HAVE_DLOPEN], [], [Have dlopen based dso])
935  ])
936  ;;
937  *-*-mingw*)
938  MODULE_EXTENSION=".dll"
939  WITH_MODULES=1
940  ;;
941  *)
942  AC_CHECK_FUNC(shl_load, libxml_have_shl_load=yes, [
943    AC_CHECK_LIB(dld, shl_load, [
944      MODULE_PLATFORM_LIBS="-ldld"
945      libxml_have_shl_load=yes], [
946      AC_CHECK_FUNC(dlopen, libxml_have_dlopen=yes, [
947        AC_CHECK_LIB(dl, dlopen, [
948          MODULE_PLATFORM_LIBS="-ldl"
949          libxml_have_dlopen=yes])])])])
950
951  if test "${libxml_have_shl_load}" = "yes"; then
952    MODULE_EXTENSION=".sl"
953    WITH_MODULES=1
954    AC_DEFINE([HAVE_SHLLOAD], [], [Have shl_load based dso])
955  fi
956
957  if test "${libxml_have_dlopen}" = "yes"; then
958    case "${host}" in
959      *-*-hpux* )
960	MODULE_EXTENSION=".sl"
961	;;
962      * )
963	MODULE_EXTENSION=".so"
964	;;
965    esac
966
967    WITH_MODULES=1
968    AC_DEFINE([HAVE_DLOPEN], [], [Have dlopen based dso])
969  fi
970 ;;
971 esac
972fi
973
974if test "${WITH_MODULES}" = "1"; then
975  TEST_MODULES="ModuleTests"
976fi
977
978AC_SUBST(WITH_MODULES)
979AC_SUBST(MODULE_PLATFORM_LIBS)
980AC_SUBST(MODULE_EXTENSION)
981AC_SUBST(TEST_MODULES)
982
983dnl
984dnl Tester makes use of readline if present
985dnl
986
987dnl
988dnl specific tests to setup DV and Bill's devel environments with debug etc ...
989dnl (-Wunreachable-code)
990dnl
991if [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/XML" ]] || \
992   [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/home/veillard/libxml2" ]] || \
993   [[ "${LOGNAME}" = "bill" -a "`pwd`" = "/home/bill/gnomesvn/libxml2" ]]
994   then
995    if test "$with_minimum" != "yes"
996    then
997	if test "${with_mem_debug}" = "" ; then
998	    echo Activating memory debugging
999	    with_mem_debug="yes"
1000	    with_run_debug="yes"
1001	fi
1002	if test "${with_docbook}" = "" ; then
1003	    with_docbook="yes"
1004	fi
1005    fi
1006    if test "${GCC}" = "yes" ; then
1007    EXTRA_CFLAGS="-g -O -pedantic -W -Wformat -Wno-format-extra-args -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wall"
1008    fi
1009    STATIC_BINARIES="-static"
1010dnl -Wcast-qual -ansi
1011else
1012    STATIC_BINARIES=
1013fi
1014AC_SUBST(STATIC_BINARIES)
1015
1016dnl
1017dnl Check for trio string functions
1018dnl
1019
1020if test "${NEED_TRIO}" = "1" ; then
1021    echo Adding trio library for string functions
1022    WITH_TRIO=1
1023else
1024    WITH_TRIO=0
1025fi
1026AM_CONDITIONAL(WITH_TRIO_SOURCES, test "${NEED_TRIO}" = "1")
1027AC_SUBST(WITH_TRIO)
1028
1029dnl
1030dnl Allow to enable/disable various pieces
1031dnl
1032echo Checking configuration requirements
1033
1034dnl
1035dnl Thread-related stuff
1036dnl
1037THREAD_LIBS=""
1038BASE_THREAD_LIBS=""
1039WITH_THREADS=0
1040THREAD_CFLAGS=""
1041TEST_THREADS=""
1042THREADS_W32=""
1043WITH_THREAD_ALLOC=0
1044
1045if test "$with_threads" = "no" ; then
1046    echo Disabling multithreaded support
1047else
1048    echo Enabling multithreaded support
1049
1050    dnl Default to native threads on Windows
1051    case $host_os in
1052       *mingw*) if test "$with_threads" != "pthread" && test "$with_threads" != "no"; then
1053               WITH_THREADS="1"
1054               THREADS_W32="1"
1055               THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_WIN32_THREADS"
1056           fi
1057       ;;
1058    esac
1059
1060    dnl Use pthread by default in other cases
1061    if test -z "$THREADS_W32"; then
1062        if test "$with_threads" = "pthread" || test "$with_threads" = "" || test "$with_threads" = "yes" ; then
1063            AC_CHECK_HEADER(pthread.h,
1064                AC_CHECK_LIB(pthread, pthread_join,[
1065                THREAD_LIBS="-lpthread"
1066                AC_DEFINE([HAVE_LIBPTHREAD], [], [Define if pthread library is there (-lpthread)])
1067                AC_DEFINE([HAVE_PTHREAD_H], [], [Define if <pthread.h> is there])
1068                WITH_THREADS="1"]))
1069        fi
1070    fi
1071
1072    case $host_os in
1073       *cygwin*) THREAD_LIBS=""
1074       ;;
1075       *beos*) WITH_THREADS="1"
1076	   THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_BEOS_THREADS"
1077       ;;
1078       *linux*)
1079           if test "${GCC}" = "yes" ; then
1080	       GCC_VERSION=`${CC} --version | head -1 | awk '{print $3}'`
1081	       GCC_MAJOR=`echo ${GCC_VERSION} | sed 's+\..*++'`
1082	       GCC_MEDIUM=`echo ${GCC_VERSION} | sed 's+[[0-9]]*\.++' | sed 's+\..*++'`
1083	       if test "${THREAD_LIBS}" = "-lpthread" ; then
1084	           if expr ${GCC_MEDIUM} \> 2 \& ${GCC_MAJOR} = 3 > /dev/null
1085		   then
1086		       THREAD_LIBS=""
1087		       BASE_THREAD_LIBS="-lpthread"
1088		   else
1089		   if expr ${GCC_MAJOR} \> 3 > /dev/null
1090		   then
1091		       THREAD_LIBS=""
1092		       BASE_THREAD_LIBS="-lpthread"
1093		   else
1094		       echo old GCC disabling weak symbols for pthread
1095		   fi
1096		   fi
1097	       fi
1098	   fi
1099       ;;
1100    esac
1101    if test "$WITH_THREADS" = "1" ; then
1102	THREAD_CFLAGS="$THREAD_CFLAGS -D_REENTRANT"
1103	TEST_THREADS="Threadtests"
1104    fi
1105fi
1106if test "$with_thread_alloc" = "yes" -a "$WITH_THREADS" = "1" ; then
1107    WITH_THREAD_ALLOC=1
1108fi
1109
1110AC_SUBST(THREAD_LIBS)
1111AC_SUBST(BASE_THREAD_LIBS)
1112AC_SUBST(WITH_THREADS)
1113AC_SUBST(THREAD_CFLAGS)
1114AC_SUBST(TEST_THREADS)
1115AC_SUBST(WITH_THREAD_ALLOC)
1116AM_CONDITIONAL([THREADS_W32],[test -n "$THREADS_W32"])
1117
1118dnl
1119dnl xmllint shell history
1120dnl
1121if test "$with_history" = "yes" ; then
1122    echo Enabling xmllint shell history
1123    dnl check for terminal library. this is a very cool solution
1124    dnl from octave's configure.in
1125    unset tcap
1126    for termlib in ncurses curses termcap terminfo termlib; do
1127	AC_CHECK_LIB(${termlib}, tputs, [tcap="-l$termlib"])
1128	test -n "$tcap" && break
1129    done
1130
1131    AC_CHECK_HEADER(readline/history.h,
1132	AC_CHECK_LIB(history, append_history,[
1133	   RDL_LIBS="-lhistory"
1134	   AC_DEFINE([HAVE_LIBHISTORY], [], [Define if history library is there (-lhistory)])]))
1135    AC_CHECK_HEADER(readline/readline.h,
1136	AC_CHECK_LIB(readline, readline,[
1137	   RDL_LIBS="-lreadline $RDL_LIBS $tcap"
1138	   AC_DEFINE([HAVE_LIBREADLINE], [], [Define if readline library is there (-lreadline)])], , $tcap))
1139    if test -n "$RDL_DIR" -a -n "$RDL_LIBS"; then
1140	CPPFLAGS="$CPPFLAGS -I${RDL_DIR}/include"
1141	RDL_LIBS="-L${RDL_DIR}/lib $RDL_LIBS"
1142    fi
1143fi
1144
1145dnl
1146dnl Tree functions
1147dnl
1148if test "$with_tree" = "no" ; then
1149    echo Disabling DOM like tree manipulation APIs
1150    WITH_TREE=0
1151else
1152    WITH_TREE=1
1153fi
1154AC_SUBST(WITH_TREE)
1155
1156if test "$with_ftp" = "no" ; then
1157    echo Disabling FTP support
1158    WITH_FTP=0
1159    FTP_OBJ=
1160else
1161    WITH_FTP=1
1162    FTP_OBJ=nanoftp.o
1163fi
1164AC_SUBST(WITH_FTP)
1165AC_SUBST(FTP_OBJ)
1166
1167if test "$with_http" = "no" ; then
1168    echo Disabling HTTP support
1169    WITH_HTTP=0
1170    HTTP_OBJ=
1171else
1172    WITH_HTTP=1
1173    HTTP_OBJ=nanohttp.o
1174fi
1175AC_SUBST(WITH_HTTP)
1176AC_SUBST(HTTP_OBJ)
1177
1178if test "$with_legacy" = "no" ; then
1179    echo Disabling deprecated APIs
1180    WITH_LEGACY=0
1181else
1182    WITH_LEGACY=1
1183fi
1184AC_SUBST(WITH_LEGACY)
1185
1186if test "$with_reader" = "no" ; then
1187    echo Disabling the xmlReader parsing interface
1188    WITH_READER=0
1189    READER_TEST=
1190else
1191    WITH_READER=1
1192    READER_TEST=Readertests
1193    if test "$with_push" = "no" ; then
1194        echo xmlReader requires Push interface - enabling it
1195	with_push=yes
1196    fi
1197fi
1198AC_SUBST(WITH_READER)
1199AC_SUBST(READER_TEST)
1200
1201if test "$with_writer" = "no" ; then
1202    echo Disabling the xmlWriter saving interface
1203    WITH_WRITER=0
1204#    WRITER_TEST=
1205else
1206    WITH_WRITER=1
1207#    WRITER_TEST=Writertests
1208    if test "$with_push" = "no" ; then
1209        echo xmlWriter requires Push interface - enabling it
1210	with_push=yes
1211    fi
1212    if test "$with_output" = "no" ; then
1213        echo xmlWriter requires Output interface - enabling it
1214	with_output=yes
1215    fi
1216fi
1217AC_SUBST(WITH_WRITER)
1218#AC_SUBST(WRITER_TEST)
1219
1220if test "$with_pattern" = "no" ; then
1221    echo Disabling the xmlPattern parsing interface
1222    WITH_PATTERN=0
1223    TEST_PATTERN=
1224else
1225    WITH_PATTERN=1
1226    TEST_PATTERN=Patterntests
1227fi
1228AC_SUBST(WITH_PATTERN)
1229AC_SUBST(TEST_PATTERN)
1230
1231if test "$with_sax1" = "no" ; then
1232    echo Disabling the older SAX1 interface
1233    WITH_SAX1=0
1234    TEST_SAX=
1235else
1236    WITH_SAX1=1
1237    TEST_SAX=SAXtests
1238fi
1239AC_SUBST(WITH_SAX1)
1240AM_CONDITIONAL(WITH_SAX1_SOURCES, test "${WITH_TRIO}" = "1")
1241AC_SUBST(TEST_SAX)
1242
1243if test "$with_push" = "no" ; then
1244    echo Disabling the PUSH parser interfaces
1245    WITH_PUSH=0
1246    TEST_PUSH=
1247else
1248    WITH_PUSH=1
1249    TEST_PUSH="XMLPushtests"
1250fi
1251AC_SUBST(WITH_PUSH)
1252AC_SUBST(TEST_PUSH)
1253
1254if test "$with_html" = "no" ; then
1255    echo Disabling HTML support
1256    WITH_HTML=0
1257    HTML_OBJ=
1258    TEST_HTML=
1259else
1260    WITH_HTML=1
1261    HTML_OBJ="HTMLparser.o HTMLtree.o"
1262    TEST_HTML=HTMLtests
1263    if test "$with_push" != "no" ; then
1264        TEST_PHTML=HTMLPushtests
1265    else
1266        TEST_PHTML=
1267    fi
1268fi
1269AC_SUBST(WITH_HTML)
1270AC_SUBST(HTML_OBJ)
1271AC_SUBST(TEST_HTML)
1272AC_SUBST(TEST_PHTML)
1273
1274if test "$with_valid" = "no" ; then
1275    echo Disabling DTD validation support
1276    WITH_VALID=0
1277    TEST_VALID=
1278    TEST_VTIME=
1279else
1280    WITH_VALID=1
1281    TEST_VALID=Validtests
1282    TEST_VTIME=VTimingtests
1283fi
1284AC_SUBST(WITH_VALID)
1285AC_SUBST(TEST_VALID)
1286AC_SUBST(TEST_VTIME)
1287
1288if test "$with_catalog" = "no" ; then
1289    echo Disabling Catalog support
1290    WITH_CATALOG=0
1291    CATALOG_OBJ=
1292    TEST_CATALOG=
1293else
1294    WITH_CATALOG=1
1295    CATALOG_OBJ="catalog.o"
1296    TEST_CATALOG=Catatests
1297fi
1298AC_SUBST(WITH_CATALOG)
1299AC_SUBST(CATALOG_OBJ)
1300AC_SUBST(TEST_CATALOG)
1301
1302if test "$with_docbook" = "no" ; then
1303    echo Disabling Docbook support
1304    WITH_DOCB=0
1305    DOCB_OBJ=
1306else
1307    WITH_DOCB=1
1308    DOCB_OBJ="DOCBparser.o"
1309fi
1310AC_SUBST(WITH_DOCB)
1311AC_SUBST(DOCB_OBJ)
1312
1313
1314if test "$with_xptr" = "no" ; then
1315    echo Disabling XPointer support
1316    WITH_XPTR=0
1317    XPTR_OBJ=
1318    TEST_XPTR=
1319else
1320    WITH_XPTR=1
1321    XPTR_OBJ=xpointer.o
1322    TEST_XPTR=XPtrtests
1323    if test "$with_xpath" = "no" ; then
1324        echo XPointer requires XPath support - enabling it
1325	with_xpath=yes
1326    fi
1327fi
1328AC_SUBST(WITH_XPTR)
1329AC_SUBST(XPTR_OBJ)
1330AC_SUBST(TEST_XPTR)
1331
1332if test "$with_c14n" = "no" ; then
1333    echo Disabling C14N support
1334    WITH_C14N=0
1335    C14N_OBJ=
1336    TEST_C14N=
1337else
1338    WITH_C14N=1
1339    C14N_OBJ="c14n.c"
1340    TEST_C14N=C14Ntests
1341    if test "$with_xpath" = "no" ; then
1342        echo C14N requires XPath support - enabling it
1343	with_xpath=yes
1344    fi
1345fi
1346AC_SUBST(WITH_C14N)
1347AC_SUBST(C14N_OBJ)
1348AC_SUBST(TEST_C14N)
1349
1350if test "$with_xinclude" = "no" ; then
1351    echo Disabling XInclude support
1352    WITH_XINCLUDE=0
1353    XINCLUDE_OBJ=
1354    with_xinclude="no"
1355    TEST_XINCLUDE=
1356else
1357    WITH_XINCLUDE=1
1358    XINCLUDE_OBJ=xinclude.o
1359    TEST_XINCLUDE=XIncludetests
1360    if test "$with_xpath" = "no" ; then
1361        echo XInclude requires XPath support - enabling it
1362	with_xpath=yes
1363    fi
1364fi
1365AC_SUBST(WITH_XINCLUDE)
1366AC_SUBST(XINCLUDE_OBJ)
1367AC_SUBST(TEST_XINCLUDE)
1368
1369if test "$with_xptr" = "" -a "$with_xpath" = "no" ; then
1370    with_xptr=no
1371fi
1372
1373if test "$with_schematron" = "" -a "$with_xpath" = "no" ; then
1374    with_schematron=no
1375fi
1376
1377if test "$with_schematron" = "no" ; then
1378    echo "Disabling Schematron support"
1379    WITH_SCHEMATRON=0
1380    TEST_SCHEMATRON=
1381else
1382    echo "Enabled Schematron support"
1383    WITH_SCHEMATRON=1
1384    TEST_SCHEMATRON="Schematrontests"
1385    with_xpath=yes
1386    with_pattern=yes
1387    with_schematron=yes
1388fi
1389AC_SUBST(WITH_SCHEMATRON)
1390AC_SUBST(TEST_SCHEMATRON)
1391
1392if test "$with_xpath" = "no" ; then
1393    echo Disabling XPATH support
1394    WITH_XPATH=0
1395    XPATH_OBJ=
1396    TEST_XPATH=
1397else
1398    WITH_XPATH=1
1399    XPATH_OBJ=xpath.o
1400    TEST_XPATH=XPathtests
1401fi
1402AC_SUBST(WITH_XPATH)
1403AC_SUBST(XPATH_OBJ)
1404AC_SUBST(TEST_XPATH)
1405
1406dnl
1407dnl output functions
1408dnl
1409if test "$with_output" = "no" ; then
1410    echo Disabling serialization/saving support
1411    WITH_OUTPUT=0
1412else
1413    WITH_OUTPUT=1
1414fi
1415AC_SUBST(WITH_OUTPUT)
1416
1417WITH_ICONV=0
1418if test "$with_iconv" = "no" ; then
1419    echo Disabling ICONV support
1420else
1421    if test "$with_iconv" != "yes" -a "$with_iconv" != "" ; then
1422	CPPFLAGS="${CPPFLAGS} -I$with_iconv/include"
1423	# Export this since our headers include iconv.h
1424	XML_INCLUDEDIR="${XML_INCLUDEDIR} -I$with_iconv/include"
1425	ICONV_LIBS="-L$with_iconv/lib"
1426    fi
1427
1428    AC_CHECK_HEADER(iconv.h,
1429	AC_MSG_CHECKING(for iconv)
1430	AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
1431#include <iconv.h>]],[[
1432iconv_t cd = iconv_open ("","");
1433iconv (cd, NULL, NULL, NULL, NULL);]])],[
1434	    AC_MSG_RESULT(yes)
1435	    WITH_ICONV=1],[
1436	    AC_MSG_RESULT(no)
1437	    AC_MSG_CHECKING(for iconv in -liconv)
1438
1439	    _ldflags="${LDFLAGS}"
1440	    _libs="${LIBS}"
1441	    LDFLAGS="${LDFLAGS} ${ICONV_LIBS}"
1442	    LIBS="${LIBS} -liconv"
1443
1444	    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
1445#include <iconv.h>]],[[
1446iconv_t cd = iconv_open ("","");
1447iconv (cd, NULL, NULL, NULL, NULL);]])],[
1448		AC_MSG_RESULT(yes)
1449		WITH_ICONV=1
1450		ICONV_LIBS="${ICONV_LIBS} -liconv"
1451		LIBS="${_libs}"
1452		LDFLAGS="${_ldflags}"],[
1453		AC_MSG_RESULT(no)
1454		LIBS="${_libs}"
1455		LDFLAGS="${_ldflags}"])]))
1456
1457	if test "$WITH_ICONV" = "1" ; then
1458		AC_MSG_CHECKING([for iconv declaration])
1459		AC_CACHE_VAL(xml_cv_iconv_arg2, [
1460			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
1461#include <iconv.h>
1462extern
1463#ifdef __cplusplus
1464"C"
1465#endif
1466#if defined(__STDC__) || defined(__cplusplus)
1467size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
1468#else
1469size_t iconv();
1470#endif
1471]], [])], xml_cv_iconv_arg2="", xml_cv_iconv_arg2="const")])
1472
1473		xml_cv_iconv_decl="extern size_t iconv (iconv_t cd, $xml_cv_iconv_arg2 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
1474		AC_MSG_RESULT([${xml_xxx:-
1475	}$xml_cv_iconv_decl])
1476		AC_DEFINE_UNQUOTED(ICONV_CONST, $xml_cv_iconv_arg2,
1477			[Define as const if the declaration of iconv() needs const.])
1478	fi
1479fi
1480case "$host" in
1481	*mingw*) M_LIBS=""
1482	;;
1483	*beos*) M_LIBS=""
1484	;;
1485        *haiku*) M_LIBS=""
1486        ;;
1487	*) M_LIBS="-lm"
1488	;;
1489esac
1490AC_SUBST(WITH_ICONV)
1491
1492WITH_ICU=0
1493ICU_LIBS=""
1494if test "$with_icu" != "yes" ; then
1495    echo Disabling ICU support
1496else
1497    # Try pkg-config first so that static linking works.
1498    # If this succeeeds, we ignore the WITH_ICU directory.
1499    PKG_CHECK_MODULES([ICU],[icu-i18n],
1500        [have_libicu=yes],
1501        [have_libicu=no])
1502
1503    # If pkg-config failed, fall back to AC_CHECK_LIB. This
1504    # will not pick up the necessary LIBS flags for liblzma's
1505    # private dependencies, though, so static linking may fail.
1506    if test "x$have_libicu" = "xno"; then
1507        ICU_CONFIG=icu-config
1508        if ${ICU_CONFIG} --cflags >/dev/null 2>&1
1509        then
1510            ICU_LIBS=`${ICU_CONFIG} --ldflags`
1511            have_libicu=yes
1512            echo Enabling ICU support
1513        else
1514            if test "$with_icu" != "yes" -a "$with_iconv" != "" ; then
1515                CPPFLAGS="${CPPFLAGS} -I$with_icu"
1516                # Export this since our headers include icu.h
1517                XML_INCLUDEDIR="${XML_INCLUDEDIR} -I$with_icu"
1518            fi
1519
1520            AC_CHECK_HEADER(unicode/ucnv.h,
1521            AC_MSG_CHECKING(for icu)
1522            AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unicode/ucnv.h>]], [[
1523        UConverter *utf = ucnv_open("UTF-8", NULL);]])],[
1524                AC_MSG_RESULT(yes)
1525                have_libicu=yes],[
1526                AC_MSG_RESULT(no)
1527                AC_MSG_CHECKING(for icu in -licucore)
1528
1529                _ldflags="${LDFLAGS}"
1530                _libs="${LIBS}"
1531                LDFLAGS="${LDFLAGS} ${ICU_LIBS}"
1532                LIBS="${LIBS} -licucore"
1533
1534                AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unicode/ucnv.h>]], [[
1535        UConverter *utf = ucnv_open("UTF-8", NULL);]])],[
1536                    AC_MSG_RESULT(yes)
1537                    have_libicu=yes
1538                    ICU_LIBS="${ICU_LIBS} -licucore"
1539                    LIBS="${_libs}"
1540                    LDFLAGS="${_ldflags}"],[
1541                    AC_MSG_RESULT(no)
1542                    LIBS="${_libs}"
1543                LDFLAGS="${_ldflags}"])]))
1544        fi
1545    fi
1546
1547    # Found the library via either method?
1548    if test "x$have_libicu" = "xyes"; then
1549        WITH_ICU=1
1550    fi
1551fi
1552XML_LIBS="-lxml2"
1553XML_PRIVATE_LIBS="$Z_LIBS $LZMA_LIBS $THREAD_LIBS $ICONV_LIBS $ICU_LIBS $M_LIBS $LIBS"
1554XML_LIBTOOLLIBS="libxml2.la"
1555AC_SUBST(WITH_ICU)
1556
1557WITH_ISO8859X=1
1558if test "$WITH_ICONV" != "1" ; then
1559if test "$with_iso8859x" = "no" ; then
1560    echo Disabling ISO8859X support
1561    WITH_ISO8859X=0
1562fi
1563fi
1564AC_SUBST(WITH_ISO8859X)
1565
1566if test "$with_schemas" = "no" ; then
1567    echo "Disabling Schemas/Relax-NG support"
1568    WITH_SCHEMAS=0
1569    TEST_SCHEMAS=
1570else
1571    echo "Enabled Schemas/Relax-NG support"
1572    WITH_SCHEMAS=1
1573    TEST_SCHEMAS="Schemastests Relaxtests"
1574    if test "$PYTHON_INCLUDES" != "" ; then
1575        PYTHON_TESTS="$PYTHON_TESTS RelaxNGPythonTests SchemasPythonTests"
1576    fi
1577    with_regexps=yes
1578fi
1579AC_SUBST(WITH_SCHEMAS)
1580AC_SUBST(TEST_SCHEMAS)
1581
1582if test "$with_regexps" = "no" ; then
1583    echo Disabling Regexps support
1584    WITH_REGEXPS=0
1585    TEST_REGEXPS=
1586else
1587    WITH_REGEXPS=1
1588    TEST_REGEXPS="Regexptests Automatatests"
1589fi
1590AC_SUBST(WITH_REGEXPS)
1591AC_SUBST(TEST_REGEXPS)
1592
1593if test "$with_debug" = "no" ; then
1594    echo Disabling DEBUG support
1595    WITH_DEBUG=0
1596    DEBUG_OBJ=
1597    TEST_DEBUG=
1598else
1599    WITH_DEBUG=1
1600    DEBUG_OBJ=debugXML.o
1601    TEST_DEBUG=Scripttests
1602fi
1603AC_SUBST(WITH_DEBUG)
1604AC_SUBST(DEBUG_OBJ)
1605AC_SUBST(TEST_DEBUG)
1606
1607if test "$with_mem_debug" = "yes" ; then
1608    if test "$with_thread_alloc" = "yes" ; then
1609        echo Disabling memory debug - cannot use mem-debug with thread-alloc!
1610	WITH_MEM_DEBUG=0
1611    else
1612        echo Enabling memory debug support
1613        WITH_MEM_DEBUG=1
1614    fi
1615else
1616    WITH_MEM_DEBUG=0
1617fi
1618AC_SUBST(WITH_MEM_DEBUG)
1619
1620if test "$with_run_debug" = "yes" ; then
1621    echo Enabling runtime debug support
1622    WITH_RUN_DEBUG=1
1623else
1624    WITH_RUN_DEBUG=0
1625fi
1626AC_SUBST(WITH_RUN_DEBUG)
1627
1628WIN32_EXTRA_LIBADD=
1629WIN32_EXTRA_LDFLAGS=
1630CYGWIN_EXTRA_LDFLAGS=
1631CYGWIN_EXTRA_PYTHON_LIBADD=
1632WIN32_EXTRA_PYTHON_LIBADD=
1633case "$host" in
1634 *-*-mingw*)
1635 CPPFLAGS="$CPPFLAGS -DWIN32"
1636 WIN32_EXTRA_LIBADD="-lws2_32"
1637 WIN32_EXTRA_LDFLAGS="-no-undefined"
1638 if test "${PYTHON}" != ""
1639 then
1640   case "$host" in
1641     *-w64-mingw*)
1642       WIN32_EXTRA_PYTHON_LIBADD="-shrext .pyd -L${pythondir}/../../lib -lpython${PYTHON_VERSION}"
1643       ;;
1644     *)
1645       WIN32_EXTRA_PYTHON_LIBADD="-L${pythondir}/../../libs -lpython$(echo ${PYTHON_VERSION} | tr -d .)"
1646       ;;
1647   esac
1648 fi
1649 ;;
1650 *-*-cygwin*)
1651 CYGWIN_EXTRA_LDFLAGS="-no-undefined"
1652 if test "${PYTHON}" != ""
1653 then
1654   CYGWIN_EXTRA_PYTHON_LIBADD="-L/usr/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
1655 fi
1656 ;;
1657esac
1658AC_SUBST(WIN32_EXTRA_LIBADD)
1659AC_SUBST(WIN32_EXTRA_LDFLAGS)
1660AC_SUBST(WIN32_EXTRA_PYTHON_LIBADD)
1661AC_SUBST(CYGWIN_EXTRA_LDFLAGS)
1662AC_SUBST(CYGWIN_EXTRA_PYTHON_LIBADD)
1663
1664dnl Checking the standard string functions availability
1665dnl
1666dnl Note mingw* has C99 implementation that produce expected xml numbers
1667dnl if code use {v}snprintf functions.
1668dnl If you like to activate at run-time C99 compatible number output
1669dnl see release note for mingw runtime 3.15:
1670dnl  http://sourceforge.net/project/shownotes.php?release_id=24832
1671dnl
1672dnl Also *win32*config.h files redefine them for various MSC compilers.
1673dnl
1674dnl So do not redefine {v}snprintf to _{v}snprintf like following:
1675dnl  AC_DEFINE([snprintf],[_snprintf],[Win32 Std C name mangling work-around])
1676dnl  AC_DEFINE([vsnprintf],[_vsnprintf],[Win32 Std C name mangling work-around])
1677dnl and do not redefine those functions is C-source files.
1678dnl
1679AC_CHECK_FUNCS(printf sprintf fprintf snprintf vfprintf vsprintf vsnprintf sscanf,,
1680	NEED_TRIO=1)
1681
1682if test "$with_coverage" = "yes" -a "${GCC}" = "yes"
1683then
1684    echo Enabling code coverage for GCC
1685    EXTRA_CFLAGS="$EXTRA_CFLAGS -fprofile-arcs -ftest-coverage"
1686    LDFLAGS="$LDFLAGS -fprofile-arcs -ftest-coverage"
1687else
1688    echo Disabling code coverage for GCC
1689fi
1690
1691AC_SUBST(CPPFLAGS)
1692AC_SUBST(EXTRA_CFLAGS)
1693AC_SUBST(LDFLAGS)
1694AC_SUBST(XML_CFLAGS)
1695
1696AC_SUBST(XML_LIBDIR)
1697AC_SUBST(XML_LIBS)
1698AC_SUBST(XML_PRIVATE_LIBS)
1699AC_SUBST(XML_LIBTOOLLIBS)
1700AC_SUBST(ICONV_LIBS)
1701AC_SUBST(ICU_LIBS)
1702AC_SUBST(XML_INCLUDEDIR)
1703AC_SUBST(HTML_DIR)
1704AC_SUBST(HAVE_ISNAN)
1705AC_SUBST(HAVE_ISINF)
1706AC_SUBST(PYTHON)
1707AC_SUBST(PYTHON_VERSION)
1708AC_SUBST(PYTHON_INCLUDES)
1709AC_SUBST(PYTHON_SITE_PACKAGES)
1710
1711AC_SUBST(M_LIBS)
1712AC_SUBST(RDL_LIBS)
1713
1714dnl for the spec file
1715RELDATE=`date +'%a %b %e %Y'`
1716AC_SUBST(RELDATE)
1717AC_SUBST(PYTHON_TESTS)
1718
1719rm -f COPYING.LIB COPYING
1720ln -s $srcdir/Copyright COPYING
1721
1722# keep on one line for cygwin c.f. #130896
1723AC_CONFIG_FILES([libxml2.spec:libxml.spec.in Makefile include/Makefile include/libxml/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile fuzz/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h libxml-2.0.pc libxml-2.0-uninstalled.pc libxml2-config.cmake])
1724AC_CONFIG_FILES([python/setup.py], [chmod +x python/setup.py])
1725AC_CONFIG_FILES([xml2-config], [chmod +x xml2-config])
1726AC_OUTPUT
1727
1728echo Done configuring
1729