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