• 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=8
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 zlib compression support"
393else
394    # Don't run pkg-config if with_zlib contains a path.
395    if test "x$Z_DIR" = "x"; then
396        # Try pkg-config first so that static linking works.
397        PKG_CHECK_MODULES([Z],[zlib],
398            [WITH_ZLIB=1],
399            [ ])
400    fi
401
402    if test "$WITH_ZLIB" = "0"; then
403        AC_CHECK_HEADERS(zlib.h,
404            AC_CHECK_LIB(z, gzread,[
405                WITH_ZLIB=1
406                if test "x${Z_DIR}" != "x"; then
407                    Z_CFLAGS="-I${Z_DIR}/include"
408                    Z_LIBS="-L${Z_DIR}/lib -lz"
409                    [case ${host} in
410                        *-*-solaris*)
411                            Z_LIBS="-L${Z_DIR}/lib -R${Z_DIR}/lib -lz"
412                            ;;
413                    esac]
414                else
415                    Z_LIBS="-lz"
416                fi])
417            )
418    fi
419fi
420
421AC_SUBST(Z_CFLAGS)
422AC_SUBST(Z_LIBS)
423AC_SUBST(WITH_ZLIB)
424
425echo Checking lzma
426
427dnl Checks for lzma library.
428
429WITH_LZMA=0
430if test "$with_lzma" = "no"; then
431    echo "Disabling lzma compression support"
432else
433    # Don't run pkg-config if with_lzma contains a path.
434    if test "x$LZMA_DIR" = "x"; then
435        # Try pkg-config first so that static linking works.
436        PKG_CHECK_MODULES([LZMA],[liblzma],
437            [WITH_LZMA=1],
438            [ ])
439    fi
440
441    # If pkg-config failed, fall back to AC_CHECK_LIB. This
442    # will not pick up the necessary LIBS flags for liblzma's
443    # private dependencies, though, so static linking may fail.
444    if test "$WITH_LZMA" = "0"; then
445        AC_CHECK_HEADERS(lzma.h,
446            AC_CHECK_LIB(lzma, lzma_code,[
447                WITH_LZMA=1
448                if test "x${LZMA_DIR}" != "x"; then
449                    LZMA_CFLAGS="-I${LZMA_DIR}/include"
450                    LZMA_LIBS="-L${LZMA_DIR}/lib -llzma"
451                else
452                    LZMA_LIBS="-llzma"
453                fi])
454            )
455    fi
456fi
457
458AC_SUBST(LZMA_CFLAGS)
459AC_SUBST(LZMA_LIBS)
460AC_SUBST(WITH_LZMA)
461
462CPPFLAGS=${_cppflags}
463LIBS=${_libs}
464
465echo Checking headers
466
467dnl Checks for header files.
468AC_HEADER_DIRENT
469AC_HEADER_STDC
470AC_CHECK_HEADERS([fcntl.h])
471AC_CHECK_HEADERS([unistd.h])
472AC_CHECK_HEADERS([ctype.h])
473AC_CHECK_HEADERS([dirent.h])
474AC_CHECK_HEADERS([errno.h])
475AC_CHECK_HEADERS([malloc.h])
476AC_CHECK_HEADERS([stdarg.h])
477AC_CHECK_HEADERS([sys/stat.h])
478AC_CHECK_HEADERS([sys/types.h])
479AC_CHECK_HEADERS([stdint.h])
480AC_CHECK_HEADERS([inttypes.h])
481AC_CHECK_HEADERS([time.h])
482AC_CHECK_HEADERS([math.h])
483AC_CHECK_HEADERS([limits.h])
484AC_CHECK_HEADERS([float.h])
485AC_CHECK_HEADERS([stdlib.h])
486AC_CHECK_HEADERS([sys/socket.h], [], [],
487[#if HAVE_SYS_TYPES_H
488# include <sys/types.h>
489# endif
490])
491AC_CHECK_HEADERS([netinet/in.h], [], [],
492[#if HAVE_SYS_TYPES_H
493# include <sys/types.h>
494# endif
495])
496AC_CHECK_HEADERS([arpa/inet.h], [], [],
497[#if HAVE_SYS_TYPES_H
498# include <sys/types.h>
499# endif
500#if HAVE_ARPA_INET_H
501# include <arpa/inet.h>
502# endif
503])
504AC_CHECK_HEADERS([netdb.h])
505AC_CHECK_HEADERS([sys/time.h])
506AC_CHECK_HEADERS([sys/select.h])
507AC_CHECK_HEADERS([poll.h])
508AC_CHECK_HEADERS([sys/mman.h])
509AC_CHECK_HEADERS([sys/timeb.h])
510AC_CHECK_HEADERS([signal.h])
511AC_CHECK_HEADERS([arpa/nameser.h], [], [],
512[#if HAVE_SYS_TYPES_H
513# include <sys/types.h>
514# endif
515])
516AC_CHECK_HEADERS([resolv.h], [], [],
517[#if HAVE_SYS_TYPES_H
518# include <sys/types.h>
519# endif
520#if HAVE_NETINET_IN_H
521# include <netinet/in.h>
522# endif
523#if HAVE_ARPA_NAMESER_H
524# include <arpa/nameser.h>
525# endif
526])
527AC_CHECK_HEADERS([dl.h])
528AC_CHECK_HEADERS([dlfcn.h])
529
530
531echo Checking types
532
533AC_TYPE_UINT32_T
534
535
536echo Checking libraries
537
538dnl Checks for library functions.
539AC_FUNC_STRFTIME
540AC_CHECK_FUNCS(strftime localtime gettimeofday ftime)
541AC_CHECK_FUNCS(stat signal)
542AC_CHECK_FUNCS(rand rand_r srand time)
543AC_CHECK_FUNCS(isascii mmap munmap putenv)
544
545AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */
546#if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
547#  undef /**/ HAVE_MMAP
548#endif])
549
550dnl Checking for va_copy availability
551AC_MSG_CHECKING([for va_copy])
552AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
553va_list ap1,ap2;]], [[va_copy(ap1,ap2);]])],
554have_va_copy=yes,
555have_va_copy=no)
556AC_MSG_RESULT($have_va_copy)
557if test x"$have_va_copy" = x"yes"; then
558    AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
559else
560    AC_MSG_CHECKING([for __va_copy])
561    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
562    va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],
563    have___va_copy=yes,
564    have___va_copy=no)
565    AC_MSG_RESULT($have___va_copy)
566    if test x"$have___va_copy" = x"yes"; then
567        AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
568    fi
569fi
570
571dnl Checking whether va_list is an array type
572AC_MSG_CHECKING([whether va_list is an array type])
573AC_TRY_COMPILE2([
574#include <stdarg.h>
575void a(va_list * ap) {}],[
576va_list ap1, ap2; a(&ap1); ap2 = (va_list) ap1],[
577  AC_MSG_RESULT(no)],[
578  AC_MSG_RESULT(yes)
579  AC_DEFINE([VA_LIST_IS_ARRAY], [1],[Define if va_list is an array type])])
580
581dnl Checks for inet libraries:
582AC_SEARCH_LIBS(gethostent, [nsl])
583AC_SEARCH_LIBS(setsockopt, [socket net network])
584AC_SEARCH_LIBS(connect, [inet])
585
586dnl Determine what socket length (socklen_t) data type is
587AC_MSG_CHECKING([for type of socket length (socklen_t)])
588AC_TRY_COMPILE2([
589#include <stddef.h>
590#include <sys/types.h>
591#include <sys/socket.h>],[
592(void)getsockopt (1, 1, 1, NULL, (socklen_t *)NULL)],[
593  AC_MSG_RESULT(socklen_t *)
594  XML_SOCKLEN_T=socklen_t],[
595  AC_TRY_COMPILE2([
596#include <stddef.h>
597#include <sys/types.h>
598#include <sys/socket.h>],[
599(void)getsockopt (1, 1, 1, NULL, (size_t *)NULL)],[
600    AC_MSG_RESULT(size_t *)
601    XML_SOCKLEN_T=size_t],[
602    AC_TRY_COMPILE2([
603#include <stddef.h>
604#include <sys/types.h>
605#include <sys/socket.h>],[
606(void)getsockopt (1, 1, 1, NULL, (int *)NULL)],[
607      AC_MSG_RESULT(int *)
608      XML_SOCKLEN_T=int],[
609      AC_MSG_WARN(could not determine)
610      XML_SOCKLEN_T="int"])])])
611AC_DEFINE_UNQUOTED(XML_SOCKLEN_T, $XML_SOCKLEN_T, [Determine what socket length (socklen_t) data type is])
612
613dnl Checking if gethostbyname() argument is const.
614AC_MSG_CHECKING([for const gethostbyname() argument])
615AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
616    [[(void)gethostbyname((const char *)"");]])],
617have_gethostbyname_const_arg=yes,
618have_gethostbyname_const_arg=no)
619AC_MSG_RESULT($have_gethostbyname_const_arg)
620if test x"$have_gethostbyname_const_arg" = x"yes"; then
621    AC_DEFINE([GETHOSTBYNAME_ARG_CAST], [],
622      [Type cast for the gethostbyname() argument])
623else
624    AC_DEFINE([GETHOSTBYNAME_ARG_CAST], [(char *)],
625      [Type cast for the gethostbyname() argument])
626fi
627
628dnl Checking if send() second argument is const.
629AC_MSG_CHECKING([for const send() second argument])
630AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
631#include <sys/socket.h>]],
632    [[(void)send(1,(const char *)"",1,1);]])],
633have_send_const_arg2=yes,
634have_send_const_arg2=no)
635AC_MSG_RESULT($have_send_const_arg2)
636if test x"$have_send_const_arg2" = x"yes"; then
637    AC_DEFINE([SEND_ARG2_CAST], [],
638      [Type cast for the send() function 2nd arg])
639else
640    AC_DEFINE([SEND_ARG2_CAST], [(char *)],
641      [Type cast for the send() function 2nd arg])
642fi
643
644dnl ***********************Checking for availability of IPv6*******************
645
646AC_MSG_CHECKING([whether to enable IPv6])
647AC_ARG_ENABLE(ipv6, [  --enable-ipv6[[=yes/no]]  enables compilation of IPv6 code [[default=yes]]],, enable_ipv6=yes)
648if test "$with_minimum" = "yes"
649then
650    enable_ipv6=no
651fi
652if test $enable_ipv6 = yes; then
653  have_ipv6=no
654  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
655#   include <sys/types.h>
656#   include <sys/socket.h>
657    ]], [[
658    struct sockaddr_storage ss;
659    socket(AF_INET6, SOCK_STREAM, 0)
660    ]])],
661    have_ipv6=yes,
662    have_ipv6=no
663  )
664  AC_MSG_RESULT($have_ipv6)
665
666  if test $have_ipv6 = yes; then
667    AC_DEFINE([SUPPORT_IP6], [], [Support for IPv6])
668    have_broken_ss_family=no
669
670    dnl *********************************************************************
671    dnl on some platforms (like AIX 5L), the structure sockaddr doesn't have
672    dnl a ss_family member, but rather __ss_family. Let's detect that
673    dnl and define the HAVE_BROKEN_SS_FAMILY when we are on one of these
674    dnl platforms.  However, we should only do this if ss_family is not
675    dnl present.
676    dnl ********************************************************************
677    AC_MSG_CHECKING([struct sockaddr::ss_family])
678    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
679#     include <sys/types.h>
680#     include <sys/socket.h>
681      ]], [[
682      struct sockaddr_storage ss ;
683      ss.ss_family = 0 ;
684      ]])],
685      have_ss_family=yes,
686      have_ss_family=no
687    )
688    AC_MSG_RESULT($have_ss_family)
689    if test x$have_ss_family = xno ; then
690      AC_MSG_CHECKING([broken struct sockaddr::ss_family])
691      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
692#       include <sys/types.h>
693#       include <sys/socket.h>
694        ]], [[
695        struct sockaddr_storage ss ;
696        ss.__ss_family = 0 ;
697        ]])],
698        have_broken_ss_family=yes,
699        have_broken_ss_family=no
700      )
701      AC_MSG_RESULT($have_broken_ss_family)
702      if test x$have_broken_ss_family = xyes ; then
703        AC_DEFINE(HAVE_BROKEN_SS_FAMILY, [],
704	  [Whether struct sockaddr::__ss_family exists])
705        AC_DEFINE(ss_family, __ss_family,
706	  [ss_family is not defined here, use __ss_family instead])
707      else
708        AC_MSG_WARN(ss_family and __ss_family not found)
709      fi
710    fi
711
712    have_getaddrinfo=no
713    AC_CHECK_FUNC(getaddrinfo, have_getaddrinfo=yes)
714    if test $have_getaddrinfo != yes; then
715      for lib in bsd socket inet; do
716        AC_CHECK_LIB($lib, getaddrinfo, [LIBS="$LIBS -l$lib";have_getaddrinfo=yes;break])
717      done
718    fi
719
720    if test $have_getaddrinfo = yes; then
721      AC_DEFINE([HAVE_GETADDRINFO], [], [Define if getaddrinfo is there])
722    fi
723  fi
724fi
725
726dnl ******************************End IPv6 checks******************************
727
728dnl Checks for isnan in libm if not in libc
729AC_CHECK_FUNC(isnan, AC_DEFINE([HAVE_ISNAN],[], [Define if isnan is there]) , AC_CHECK_LIB(m, isnan,
730  [AC_DEFINE([HAVE_ISNAN],[], [Define if isnan is there])]))
731
732AC_CHECK_FUNC(isinf, AC_DEFINE([HAVE_ISINF], [], [Define if isinf is there]) , AC_CHECK_LIB(m, isinf,
733  [AC_DEFINE([HAVE_ISINF], [], [Define if isinf is there])]))
734
735XML_LIBDIR='-L${libdir}'
736XML_INCLUDEDIR='-I${includedir}/libxml2'
737
738dnl
739dnl Extra flags
740dnl
741XML_CFLAGS=""
742RDL_LIBS=""
743
744dnl
745dnl Workaround for native compilers
746dnl  HP  : http://bugs.gnome.org/db/31/3163.html
747dnl  DEC : Enable NaN/Inf
748dnl
749if test "${GCC}" != "yes" ; then
750    case "${host}" in
751          hppa*-*-hpux* )
752	       EXTRA_CFLAGS="${EXTRA_CFLAGS} -Wp,-H30000"
753	       ;;
754          *-dec-osf* )
755               EXTRA_CFLAGS="${EXTRA_CFLAGS} -ieee"
756               ;;
757	  alpha*-*-linux* )
758	       EXTRA_CFLAGS="${EXTRA_CFLAGS} -ieee"
759	       ;;
760    esac
761else
762    if test "$with_fexceptions" = "yes"
763    then
764        #
765	# Not activated by default because this inflates the code size
766	# Used to allow propagation of C++ exceptions through the library
767	#
768	EXTRA_CFLAGS="${EXTRA_CFLAGS} -fexceptions"
769    fi
770
771    # warnings we'd like to see
772    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"
773    # warnings we'd like to supress
774    EXTRA_CFLAGS="${EXTRA_CFLAGS} -Wno-long-long -Wno-format-extra-args -Wno-array-bounds"
775    case "${host}" in
776          alpha*-*-linux* )
777	       EXTRA_CFLAGS="${EXTRA_CFLAGS} -mieee"
778	       ;;
779	  alpha*-*-osf* )
780	       EXTRA_CFLAGS="${EXTRA_CFLAGS} -mieee"
781	       ;;
782    esac
783fi
784case ${host} in
785    *-*-solaris*)
786        XML_LIBDIR="${XML_LIBDIR} -R${libdir}"
787        ;;
788    hppa*-hp-mpeix)
789        NEED_TRIO=1
790	;;
791    *-*-mingw* | *-*-cygwin* | *-*-msvc* )
792        # If the host is Windows, and shared libraries are disabled, we
793        # need to add -DLIBXML_STATIC to EXTRA_CFLAGS in order for linking to
794        # work properly (without it, xmlexports.h would force the use of
795        # DLL imports, which obviously aren't present in a static
796        # library).
797        if test "x$enable_shared" = "xno"; then
798            XML_CFLAGS="$XML_CFLAGS -DLIBXML_STATIC"
799            EXTRA_CFLAGS="$EXTRA_CFLAGS -DLIBXML_STATIC"
800        fi
801        ;;
802esac
803
804
805dnl
806dnl check for python
807dnl
808
809PYTHON_VERSION=
810PYTHON_INCLUDES=
811PYTHON_SITE_PACKAGES=
812PYTHON_TESTS=
813pythondir=
814if test "$with_python" != "no" ; then
815    if test -x "$with_python/bin/python"
816    then
817        echo Found python in $with_python/bin/python
818        PYTHON="$with_python/bin/python"
819    else
820        if test -x "$with_python/python.exe"
821        then
822            echo Found python in $with_python/python.exe
823            PYTHON="$with_python/python.exe"
824        else
825            if test -x "$with_python"
826            then
827                echo Found python in $with_python
828                PYTHON="$with_python"
829            else
830                if test -x "$PYTHON"
831                then
832                    echo Found python in environment PYTHON=$PYTHON
833                    with_python=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
834                else
835                    AC_PATH_PROG(PYTHON, python python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5)
836		fi
837	    fi
838	fi
839    fi
840    if test "$PYTHON" != ""
841    then
842        PYTHON_VERSION=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_version())"`
843	PYTHON_INCLUDES=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_inc())"`
844# does not work as it produce a /usr/lib/python path instead of/usr/lib64/python
845#
846#	PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_lib())"`
847	echo Found Python version $PYTHON_VERSION
848    fi
849    if test "$PYTHON_VERSION" != "" -a "$PYTHON_INCLUDES" = ""
850    then
851	if test -r $with_python/include/python$PYTHON_VERSION/Python.h
852	then
853	    PYTHON_INCLUDES=$with_python/include/python$PYTHON_VERSION
854	else
855	    if test -r $prefix/include/python$PYTHON_VERSION/Python.h
856	    then
857	        PYTHON_INCLUDES=$prefix/include/python$PYTHON_VERSION
858	    else
859		if test -r /usr/include/python$PYTHON_VERSION/Python.h
860		then
861		    PYTHON_INCLUDES=/usr/include/python$PYTHON_VERSION
862		else
863	            if test -r $with_python/include/Python.h
864	            then
865	                PYTHON_INCLUDES=$with_python/include
866	            else
867		        echo could not find python$PYTHON_VERSION/Python.h or $with_python/include/Python.h
868		    fi
869		fi
870	    fi
871	fi
872    fi
873    if test "$with_python_install_dir" != ""
874    then
875	PYTHON_SITE_PACKAGES="$with_python_install_dir"
876    fi
877    if test "$PYTHON_VERSION" != "" -a "$PYTHON_SITE_PACKAGES" = ""
878    then
879	if test -d $libdir/python$PYTHON_VERSION/site-packages
880	then
881	    PYTHON_SITE_PACKAGES=$libdir/python$PYTHON_VERSION/site-packages
882	else
883	    if test -d $with_python/lib/site-packages
884	    then
885		PYTHON_SITE_PACKAGES=$with_python/lib/site-packages
886	    else
887		PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_lib())"`
888	    fi
889	fi
890    fi
891    pythondir='$(PYTHON_SITE_PACKAGES)'
892    PYTHON_LIBS=`python$PYTHON_VERSION-config --ldflags`
893else
894    PYTHON=
895fi
896AM_CONDITIONAL(WITH_PYTHON, test "$PYTHON_INCLUDES" != "")
897if test "$PYTHON_INCLUDES" != ""
898then
899    PYTHON_SUBDIR=python
900else
901    PYTHON_SUBDIR=
902fi
903AC_SUBST(pythondir)
904AC_SUBST(PYTHON_SUBDIR)
905AC_SUBST(PYTHON_LIBS)
906
907dnl check for dso support
908WITH_MODULES=0
909TEST_MODULES=
910
911if test "$with_modules" != "no" ; then
912 case "$host" in
913  *-*-cygwin*)
914  MODULE_EXTENSION=".dll"
915  AC_CHECK_LIB(cygwin, dlopen, [
916    WITH_MODULES=1
917    MODULE_PLATFORM_LIBS=
918    AC_DEFINE([HAVE_DLOPEN], [], [Have dlopen based dso])
919  ])
920  ;;
921  *-*-mingw*)
922  MODULE_EXTENSION=".dll"
923  WITH_MODULES=1
924  ;;
925  *)
926  AC_CHECK_FUNC(shl_load, libxml_have_shl_load=yes, [
927    AC_CHECK_LIB(dld, shl_load, [
928      MODULE_PLATFORM_LIBS="-ldld"
929      libxml_have_shl_load=yes], [
930      AC_CHECK_FUNC(dlopen, libxml_have_dlopen=yes, [
931        AC_CHECK_LIB(dl, dlopen, [
932          MODULE_PLATFORM_LIBS="-ldl"
933          libxml_have_dlopen=yes])])])])
934
935  if test "${libxml_have_shl_load}" = "yes"; then
936    MODULE_EXTENSION=".sl"
937    WITH_MODULES=1
938    AC_DEFINE([HAVE_SHLLOAD], [], [Have shl_load based dso])
939  fi
940
941  if test "${libxml_have_dlopen}" = "yes"; then
942    case "${host}" in
943      *-*-hpux* )
944	MODULE_EXTENSION=".sl"
945	;;
946      * )
947	MODULE_EXTENSION=".so"
948	;;
949    esac
950
951    WITH_MODULES=1
952    AC_DEFINE([HAVE_DLOPEN], [], [Have dlopen based dso])
953  fi
954 ;;
955 esac
956fi
957
958if test "${WITH_MODULES}" = "1"; then
959  TEST_MODULES="ModuleTests"
960fi
961
962AC_SUBST(WITH_MODULES)
963AC_SUBST(MODULE_PLATFORM_LIBS)
964AC_SUBST(MODULE_EXTENSION)
965AC_SUBST(TEST_MODULES)
966
967dnl
968dnl Tester makes use of readline if present
969dnl
970
971dnl
972dnl specific tests to setup DV and Bill's devel environments with debug etc ...
973dnl (-Wunreachable-code)
974dnl
975if [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/XML" ]] || \
976   [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/home/veillard/libxml2" ]] || \
977   [[ "${LOGNAME}" = "bill" -a "`pwd`" = "/home/bill/gnomesvn/libxml2" ]]
978   then
979    if test "$with_minimum" != "yes"
980    then
981	if test "${with_mem_debug}" = "" ; then
982	    echo Activating memory debugging
983	    with_mem_debug="yes"
984	    with_run_debug="yes"
985	fi
986	if test "${with_docbook}" = "" ; then
987	    with_docbook="yes"
988	fi
989    fi
990    if test "${GCC}" = "yes" ; then
991    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"
992    fi
993    STATIC_BINARIES="-static"
994dnl -Wcast-qual -ansi
995else
996    STATIC_BINARIES=
997fi
998AC_SUBST(STATIC_BINARIES)
999
1000dnl
1001dnl Check for trio string functions
1002dnl
1003
1004if test "${NEED_TRIO}" = "1" ; then
1005    echo Adding trio library for string functions
1006    WITH_TRIO=1
1007else
1008    WITH_TRIO=0
1009fi
1010AM_CONDITIONAL(WITH_TRIO_SOURCES, test "${NEED_TRIO}" = "1")
1011AC_SUBST(WITH_TRIO)
1012
1013dnl
1014dnl Allow to enable/disable various pieces
1015dnl
1016echo Checking configuration requirements
1017
1018dnl
1019dnl Thread-related stuff
1020dnl
1021THREAD_LIBS=""
1022BASE_THREAD_LIBS=""
1023WITH_THREADS=0
1024THREAD_CFLAGS=""
1025TEST_THREADS=""
1026THREADS_W32=""
1027WITH_THREAD_ALLOC=0
1028
1029if test "$with_threads" = "no" ; then
1030    echo Disabling multithreaded support
1031else
1032    echo Enabling multithreaded support
1033
1034    dnl Default to native threads on Windows
1035    case $host_os in
1036       *mingw*) if test "$with_threads" != "pthread" && test "$with_threads" != "no"; then
1037               WITH_THREADS="1"
1038               THREADS_W32="1"
1039               THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_WIN32_THREADS"
1040           fi
1041       ;;
1042    esac
1043
1044    dnl Use pthread by default in other cases
1045    if test -z "$THREADS_W32"; then
1046        if test "$with_threads" = "pthread" || test "$with_threads" = "" || test "$with_threads" = "yes" ; then
1047            AC_CHECK_HEADER(pthread.h,
1048                AC_CHECK_LIB(pthread, pthread_join,[
1049                THREAD_LIBS="-lpthread"
1050                AC_DEFINE([HAVE_LIBPTHREAD], [], [Define if pthread library is there (-lpthread)])
1051                AC_DEFINE([HAVE_PTHREAD_H], [], [Define if <pthread.h> is there])
1052                WITH_THREADS="1"]))
1053        fi
1054    fi
1055
1056    case $host_os in
1057       *cygwin*) THREAD_LIBS=""
1058       ;;
1059       *beos*) WITH_THREADS="1"
1060	   THREAD_CFLAGS="$THREAD_CFLAGS -DHAVE_BEOS_THREADS"
1061       ;;
1062       *linux*)
1063           if test "${GCC}" = "yes" ; then
1064	       GCC_VERSION=`${CC} --version | head -1 | awk '{print $3}'`
1065	       GCC_MAJOR=`echo ${GCC_VERSION} | sed 's+\..*++'`
1066	       GCC_MEDIUM=`echo ${GCC_VERSION} | sed 's+[[0-9]]*\.++' | sed 's+\..*++'`
1067	       if test "${THREAD_LIBS}" = "-lpthread" ; then
1068	           if expr ${GCC_MEDIUM} \> 2 \& ${GCC_MAJOR} = 3 > /dev/null
1069		   then
1070		       THREAD_LIBS=""
1071		       BASE_THREAD_LIBS="-lpthread"
1072		   else
1073		   if expr ${GCC_MAJOR} \> 3 > /dev/null
1074		   then
1075		       THREAD_LIBS=""
1076		       BASE_THREAD_LIBS="-lpthread"
1077		   else
1078		       echo old GCC disabling weak symbols for pthread
1079		   fi
1080		   fi
1081	       fi
1082	   fi
1083       ;;
1084    esac
1085    if test "$WITH_THREADS" = "1" ; then
1086	THREAD_CFLAGS="$THREAD_CFLAGS -D_REENTRANT"
1087	TEST_THREADS="Threadtests"
1088    fi
1089fi
1090if test "$with_thread_alloc" = "yes" -a "$WITH_THREADS" = "1" ; then
1091    WITH_THREAD_ALLOC=1
1092fi
1093
1094AC_SUBST(THREAD_LIBS)
1095AC_SUBST(BASE_THREAD_LIBS)
1096AC_SUBST(WITH_THREADS)
1097AC_SUBST(THREAD_CFLAGS)
1098AC_SUBST(TEST_THREADS)
1099AC_SUBST(WITH_THREAD_ALLOC)
1100AM_CONDITIONAL([THREADS_W32],[test -n "$THREADS_W32"])
1101
1102dnl
1103dnl xmllint shell history
1104dnl
1105if test "$with_history" = "yes" ; then
1106    echo Enabling xmllint shell history
1107    dnl check for terminal library. this is a very cool solution
1108    dnl from octave's configure.in
1109    unset tcap
1110    for termlib in ncurses curses termcap terminfo termlib; do
1111	AC_CHECK_LIB(${termlib}, tputs, [tcap="-l$termlib"])
1112	test -n "$tcap" && break
1113    done
1114
1115    AC_CHECK_HEADER(readline/history.h,
1116	AC_CHECK_LIB(history, append_history,[
1117	   RDL_LIBS="-lhistory"
1118	   AC_DEFINE([HAVE_LIBHISTORY], [], [Define if history library is there (-lhistory)])]))
1119    AC_CHECK_HEADER(readline/readline.h,
1120	AC_CHECK_LIB(readline, readline,[
1121	   RDL_LIBS="-lreadline $RDL_LIBS $tcap"
1122	   AC_DEFINE([HAVE_LIBREADLINE], [], [Define if readline library is there (-lreadline)])], , $tcap))
1123    if test -n "$RDL_DIR" -a -n "$RDL_LIBS"; then
1124	CPPFLAGS="$CPPFLAGS -I${RDL_DIR}/include"
1125	RDL_LIBS="-L${RDL_DIR}/lib $RDL_LIBS"
1126    fi
1127fi
1128
1129dnl
1130dnl Tree functions
1131dnl
1132if test "$with_tree" = "no" ; then
1133    echo Disabling DOM like tree manipulation APIs
1134    WITH_TREE=0
1135else
1136    WITH_TREE=1
1137fi
1138AC_SUBST(WITH_TREE)
1139
1140if test "$with_ftp" = "no" ; then
1141    echo Disabling FTP support
1142    WITH_FTP=0
1143    FTP_OBJ=
1144else
1145    WITH_FTP=1
1146    FTP_OBJ=nanoftp.o
1147fi
1148AC_SUBST(WITH_FTP)
1149AC_SUBST(FTP_OBJ)
1150
1151if test "$with_http" = "no" ; then
1152    echo Disabling HTTP support
1153    WITH_HTTP=0
1154    HTTP_OBJ=
1155else
1156    WITH_HTTP=1
1157    HTTP_OBJ=nanohttp.o
1158fi
1159AC_SUBST(WITH_HTTP)
1160AC_SUBST(HTTP_OBJ)
1161
1162if test "$with_legacy" = "no" ; then
1163    echo Disabling deprecated APIs
1164    WITH_LEGACY=0
1165else
1166    WITH_LEGACY=1
1167fi
1168AC_SUBST(WITH_LEGACY)
1169
1170if test "$with_reader" = "no" ; then
1171    echo Disabling the xmlReader parsing interface
1172    WITH_READER=0
1173    READER_TEST=
1174else
1175    WITH_READER=1
1176    READER_TEST=Readertests
1177    if test "$with_push" = "no" ; then
1178        echo xmlReader requires Push interface - enabling it
1179	with_push=yes
1180    fi
1181fi
1182AC_SUBST(WITH_READER)
1183AC_SUBST(READER_TEST)
1184
1185if test "$with_writer" = "no" ; then
1186    echo Disabling the xmlWriter saving interface
1187    WITH_WRITER=0
1188#    WRITER_TEST=
1189else
1190    WITH_WRITER=1
1191#    WRITER_TEST=Writertests
1192    if test "$with_push" = "no" ; then
1193        echo xmlWriter requires Push interface - enabling it
1194	with_push=yes
1195    fi
1196    if test "$with_output" = "no" ; then
1197        echo xmlWriter requires Output interface - enabling it
1198	with_output=yes
1199    fi
1200fi
1201AC_SUBST(WITH_WRITER)
1202#AC_SUBST(WRITER_TEST)
1203
1204if test "$with_pattern" = "no" ; then
1205    echo Disabling the xmlPattern parsing interface
1206    WITH_PATTERN=0
1207    TEST_PATTERN=
1208else
1209    WITH_PATTERN=1
1210    TEST_PATTERN=Patterntests
1211fi
1212AC_SUBST(WITH_PATTERN)
1213AC_SUBST(TEST_PATTERN)
1214
1215if test "$with_sax1" = "no" ; then
1216    echo Disabling the older SAX1 interface
1217    WITH_SAX1=0
1218    TEST_SAX=
1219else
1220    WITH_SAX1=1
1221    TEST_SAX=SAXtests
1222fi
1223AC_SUBST(WITH_SAX1)
1224AM_CONDITIONAL(WITH_SAX1_SOURCES, test "${WITH_TRIO}" = "1")
1225AC_SUBST(TEST_SAX)
1226
1227if test "$with_push" = "no" ; then
1228    echo Disabling the PUSH parser interfaces
1229    WITH_PUSH=0
1230    TEST_PUSH=
1231else
1232    WITH_PUSH=1
1233    TEST_PUSH="XMLPushtests"
1234fi
1235AC_SUBST(WITH_PUSH)
1236AC_SUBST(TEST_PUSH)
1237
1238if test "$with_html" = "no" ; then
1239    echo Disabling HTML support
1240    WITH_HTML=0
1241    HTML_OBJ=
1242    TEST_HTML=
1243else
1244    WITH_HTML=1
1245    HTML_OBJ="HTMLparser.o HTMLtree.o"
1246    TEST_HTML=HTMLtests
1247    if test "$with_push" != "no" ; then
1248        TEST_PHTML=HTMLPushtests
1249    else
1250        TEST_PHTML=
1251    fi
1252fi
1253AC_SUBST(WITH_HTML)
1254AC_SUBST(HTML_OBJ)
1255AC_SUBST(TEST_HTML)
1256AC_SUBST(TEST_PHTML)
1257
1258if test "$with_valid" = "no" ; then
1259    echo Disabling DTD validation support
1260    WITH_VALID=0
1261    TEST_VALID=
1262    TEST_VTIME=
1263else
1264    WITH_VALID=1
1265    TEST_VALID=Validtests
1266    TEST_VTIME=VTimingtests
1267fi
1268AC_SUBST(WITH_VALID)
1269AC_SUBST(TEST_VALID)
1270AC_SUBST(TEST_VTIME)
1271
1272if test "$with_catalog" = "no" ; then
1273    echo Disabling Catalog support
1274    WITH_CATALOG=0
1275    CATALOG_OBJ=
1276    TEST_CATALOG=
1277else
1278    WITH_CATALOG=1
1279    CATALOG_OBJ="catalog.o"
1280    TEST_CATALOG=Catatests
1281fi
1282AC_SUBST(WITH_CATALOG)
1283AC_SUBST(CATALOG_OBJ)
1284AC_SUBST(TEST_CATALOG)
1285
1286if test "$with_docbook" = "no" ; then
1287    echo Disabling Docbook support
1288    WITH_DOCB=0
1289    DOCB_OBJ=
1290else
1291    WITH_DOCB=1
1292    DOCB_OBJ="DOCBparser.o"
1293fi
1294AC_SUBST(WITH_DOCB)
1295AC_SUBST(DOCB_OBJ)
1296
1297
1298if test "$with_xptr" = "no" ; then
1299    echo Disabling XPointer support
1300    WITH_XPTR=0
1301    XPTR_OBJ=
1302    TEST_XPTR=
1303else
1304    WITH_XPTR=1
1305    XPTR_OBJ=xpointer.o
1306    TEST_XPTR=XPtrtests
1307    if test "$with_xpath" = "no" ; then
1308        echo XPointer requires XPath support - enabling it
1309	with_xpath=yes
1310    fi
1311fi
1312AC_SUBST(WITH_XPTR)
1313AC_SUBST(XPTR_OBJ)
1314AC_SUBST(TEST_XPTR)
1315
1316if test "$with_c14n" = "no" ; then
1317    echo Disabling C14N support
1318    WITH_C14N=0
1319    C14N_OBJ=
1320    TEST_C14N=
1321else
1322    WITH_C14N=1
1323    C14N_OBJ="c14n.c"
1324    TEST_C14N=C14Ntests
1325    if test "$with_xpath" = "no" ; then
1326        echo C14N requires XPath support - enabling it
1327	with_xpath=yes
1328    fi
1329fi
1330AC_SUBST(WITH_C14N)
1331AC_SUBST(C14N_OBJ)
1332AC_SUBST(TEST_C14N)
1333
1334if test "$with_xinclude" = "no" ; then
1335    echo Disabling XInclude support
1336    WITH_XINCLUDE=0
1337    XINCLUDE_OBJ=
1338    with_xinclude="no"
1339    TEST_XINCLUDE=
1340else
1341    WITH_XINCLUDE=1
1342    XINCLUDE_OBJ=xinclude.o
1343    TEST_XINCLUDE=XIncludetests
1344    if test "$with_xpath" = "no" ; then
1345        echo XInclude requires XPath support - enabling it
1346	with_xpath=yes
1347    fi
1348fi
1349AC_SUBST(WITH_XINCLUDE)
1350AC_SUBST(XINCLUDE_OBJ)
1351AC_SUBST(TEST_XINCLUDE)
1352
1353if test "$with_xptr" = "" -a "$with_xpath" = "no" ; then
1354    with_xptr=no
1355fi
1356
1357if test "$with_schematron" = "" -a "$with_xpath" = "no" ; then
1358    with_schematron=no
1359fi
1360
1361if test "$with_schematron" = "no" ; then
1362    echo "Disabling Schematron support"
1363    WITH_SCHEMATRON=0
1364    TEST_SCHEMATRON=
1365else
1366    echo "Enabled Schematron support"
1367    WITH_SCHEMATRON=1
1368    TEST_SCHEMATRON="Schematrontests"
1369    with_xpath=yes
1370    with_pattern=yes
1371    with_schematron=yes
1372fi
1373AC_SUBST(WITH_SCHEMATRON)
1374AC_SUBST(TEST_SCHEMATRON)
1375
1376if test "$with_xpath" = "no" ; then
1377    echo Disabling XPATH support
1378    WITH_XPATH=0
1379    XPATH_OBJ=
1380    TEST_XPATH=
1381else
1382    WITH_XPATH=1
1383    XPATH_OBJ=xpath.o
1384    TEST_XPATH=XPathtests
1385fi
1386AC_SUBST(WITH_XPATH)
1387AC_SUBST(XPATH_OBJ)
1388AC_SUBST(TEST_XPATH)
1389
1390dnl
1391dnl output functions
1392dnl
1393if test "$with_output" = "no" ; then
1394    echo Disabling serialization/saving support
1395    WITH_OUTPUT=0
1396else
1397    WITH_OUTPUT=1
1398fi
1399AC_SUBST(WITH_OUTPUT)
1400
1401WITH_ICONV=0
1402if test "$with_iconv" = "no" ; then
1403    echo Disabling ICONV support
1404else
1405    if test "$with_iconv" != "yes" -a "$with_iconv" != "" ; then
1406	CPPFLAGS="${CPPFLAGS} -I$with_iconv/include"
1407	# Export this since our headers include iconv.h
1408	XML_INCLUDEDIR="${XML_INCLUDEDIR} -I$with_iconv/include"
1409	ICONV_LIBS="-L$with_iconv/lib"
1410    fi
1411
1412    AC_CHECK_HEADER(iconv.h,
1413	AC_MSG_CHECKING(for iconv)
1414	AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
1415#include <iconv.h>]],[[
1416iconv_t cd = iconv_open ("","");
1417iconv (cd, NULL, NULL, NULL, NULL);]])],[
1418	    AC_MSG_RESULT(yes)
1419	    WITH_ICONV=1],[
1420	    AC_MSG_RESULT(no)
1421	    AC_MSG_CHECKING(for iconv in -liconv)
1422
1423	    _ldflags="${LDFLAGS}"
1424	    _libs="${LIBS}"
1425	    LDFLAGS="${LDFLAGS} ${ICONV_LIBS}"
1426	    LIBS="${LIBS} -liconv"
1427
1428	    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
1429#include <iconv.h>]],[[
1430iconv_t cd = iconv_open ("","");
1431iconv (cd, NULL, NULL, NULL, NULL);]])],[
1432		AC_MSG_RESULT(yes)
1433		WITH_ICONV=1
1434		ICONV_LIBS="${ICONV_LIBS} -liconv"
1435		LIBS="${_libs}"
1436		LDFLAGS="${_ldflags}"],[
1437		AC_MSG_RESULT(no)
1438		LIBS="${_libs}"
1439		LDFLAGS="${_ldflags}"])]))
1440
1441	if test "$WITH_ICONV" = "1" ; then
1442		AC_MSG_CHECKING([for iconv declaration])
1443		AC_CACHE_VAL(xml_cv_iconv_arg2, [
1444			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
1445#include <iconv.h>
1446extern
1447#ifdef __cplusplus
1448"C"
1449#endif
1450#if defined(__STDC__) || defined(__cplusplus)
1451size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
1452#else
1453size_t iconv();
1454#endif
1455]], [])], xml_cv_iconv_arg2="", xml_cv_iconv_arg2="const")])
1456
1457		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);"
1458		AC_MSG_RESULT([${xml_xxx:-
1459	}$xml_cv_iconv_decl])
1460		AC_DEFINE_UNQUOTED(ICONV_CONST, $xml_cv_iconv_arg2,
1461			[Define as const if the declaration of iconv() needs const.])
1462	fi
1463fi
1464case "$host" in
1465	*mingw*) M_LIBS=""
1466	;;
1467	*beos*) M_LIBS=""
1468	;;
1469        *haiku*) M_LIBS=""
1470        ;;
1471	*) M_LIBS="-lm"
1472	;;
1473esac
1474AC_SUBST(WITH_ICONV)
1475
1476WITH_ICU=0
1477ICU_LIBS=""
1478if test "$with_icu" != "yes" ; then
1479    echo Disabling ICU support
1480else
1481    # Try pkg-config first so that static linking works.
1482    # If this succeeeds, we ignore the WITH_ICU directory.
1483    PKG_CHECK_MODULES([ICU],[icu-i18n],
1484        [have_libicu=yes],
1485        [have_libicu=no])
1486
1487    # If pkg-config failed, fall back to AC_CHECK_LIB. This
1488    # will not pick up the necessary LIBS flags for liblzma's
1489    # private dependencies, though, so static linking may fail.
1490    if test "x$have_libicu" = "xno"; then
1491        ICU_CONFIG=icu-config
1492        if ${ICU_CONFIG} --cflags >/dev/null 2>&1
1493        then
1494            ICU_LIBS=`${ICU_CONFIG} --ldflags`
1495            have_libicu=yes
1496            echo Enabling ICU support
1497        else
1498            if test "$with_icu" != "yes" -a "$with_iconv" != "" ; then
1499                CPPFLAGS="${CPPFLAGS} -I$with_icu"
1500                # Export this since our headers include icu.h
1501                XML_INCLUDEDIR="${XML_INCLUDEDIR} -I$with_icu"
1502            fi
1503
1504            AC_CHECK_HEADER(unicode/ucnv.h,
1505            AC_MSG_CHECKING(for icu)
1506            AC_TRY_LINK([#include <unicode/ucnv.h>],[
1507        UConverter *utf = ucnv_open("UTF-8", NULL);],[
1508                AC_MSG_RESULT(yes)
1509                have_libicu=yes],[
1510                AC_MSG_RESULT(no)
1511                AC_MSG_CHECKING(for icu in -licucore)
1512
1513                _ldflags="${LDFLAGS}"
1514                _libs="${LIBS}"
1515                LDFLAGS="${LDFLAGS} ${ICU_LIBS}"
1516                LIBS="${LIBS} -licucore"
1517
1518                AC_TRY_LINK([#include <unicode/ucnv.h>],[
1519        UConverter *utf = ucnv_open("UTF-8", NULL);],[
1520                    AC_MSG_RESULT(yes)
1521                    have_libicu=yes
1522                    ICU_LIBS="${ICU_LIBS} -licucore"
1523                    LIBS="${_libs}"
1524                    LDFLAGS="${_ldflags}"],[
1525                    AC_MSG_RESULT(no)
1526                    LIBS="${_libs}"
1527                LDFLAGS="${_ldflags}"])]))
1528        fi
1529    fi
1530
1531    # Found the library via either method?
1532    if test "x$have_libicu" = "xyes"; then
1533        WITH_ICU=1
1534    fi
1535fi
1536XML_LIBS="-lxml2 $Z_LIBS $LZMA_LIBS $THREAD_LIBS $ICONV_LIBS $ICU_LIBS $M_LIBS $LIBS"
1537XML_LIBTOOLLIBS="libxml2.la"
1538AC_SUBST(WITH_ICU)
1539
1540WITH_ISO8859X=1
1541if test "$WITH_ICONV" != "1" ; then
1542if test "$with_iso8859x" = "no" ; then
1543    echo Disabling ISO8859X support
1544    WITH_ISO8859X=0
1545fi
1546fi
1547AC_SUBST(WITH_ISO8859X)
1548
1549if test "$with_schemas" = "no" ; then
1550    echo "Disabling Schemas/Relax-NG support"
1551    WITH_SCHEMAS=0
1552    TEST_SCHEMAS=
1553else
1554    echo "Enabled Schemas/Relax-NG support"
1555    WITH_SCHEMAS=1
1556    TEST_SCHEMAS="Schemastests Relaxtests"
1557    if test "$PYTHON_INCLUDES" != "" ; then
1558        PYTHON_TESTS="$PYTHON_TESTS RelaxNGPythonTests SchemasPythonTests"
1559    fi
1560    with_regexps=yes
1561fi
1562AC_SUBST(WITH_SCHEMAS)
1563AC_SUBST(TEST_SCHEMAS)
1564
1565if test "$with_regexps" = "no" ; then
1566    echo Disabling Regexps support
1567    WITH_REGEXPS=0
1568    TEST_REGEXPS=
1569else
1570    WITH_REGEXPS=1
1571    TEST_REGEXPS="Regexptests Automatatests"
1572fi
1573AC_SUBST(WITH_REGEXPS)
1574AC_SUBST(TEST_REGEXPS)
1575
1576if test "$with_debug" = "no" ; then
1577    echo Disabling DEBUG support
1578    WITH_DEBUG=0
1579    DEBUG_OBJ=
1580    TEST_DEBUG=
1581else
1582    WITH_DEBUG=1
1583    DEBUG_OBJ=debugXML.o
1584    TEST_DEBUG=Scripttests
1585fi
1586AC_SUBST(WITH_DEBUG)
1587AC_SUBST(DEBUG_OBJ)
1588AC_SUBST(TEST_DEBUG)
1589
1590if test "$with_mem_debug" = "yes" ; then
1591    if test "$with_thread_alloc" = "yes" ; then
1592        echo Disabling memory debug - cannot use mem-debug with thread-alloc!
1593	WITH_MEM_DEBUG=0
1594    else
1595        echo Enabling memory debug support
1596        WITH_MEM_DEBUG=1
1597    fi
1598else
1599    WITH_MEM_DEBUG=0
1600fi
1601AC_SUBST(WITH_MEM_DEBUG)
1602
1603if test "$with_run_debug" = "yes" ; then
1604    echo Enabling runtime debug support
1605    WITH_RUN_DEBUG=1
1606else
1607    WITH_RUN_DEBUG=0
1608fi
1609AC_SUBST(WITH_RUN_DEBUG)
1610
1611WIN32_EXTRA_LIBADD=
1612WIN32_EXTRA_LDFLAGS=
1613CYGWIN_EXTRA_LDFLAGS=
1614CYGWIN_EXTRA_PYTHON_LIBADD=
1615WIN32_EXTRA_PYTHON_LIBADD=
1616case "$host" in
1617 *-*-mingw*)
1618 CPPFLAGS="$CPPFLAGS -DWIN32"
1619 WIN32_EXTRA_LIBADD="-lws2_32"
1620 WIN32_EXTRA_LDFLAGS="-no-undefined"
1621 if test "${PYTHON}" != ""
1622 then
1623   WIN32_EXTRA_PYTHON_LIBADD="-L${pythondir}/../../libs -lpython$(echo ${PYTHON_VERSION} | tr -d .)"
1624 fi
1625 ;;
1626 *-*-cygwin*)
1627 CYGWIN_EXTRA_LDFLAGS="-no-undefined"
1628 if test "${PYTHON}" != ""
1629 then
1630   CYGWIN_EXTRA_PYTHON_LIBADD="-L/usr/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
1631 fi
1632 ;;
1633esac
1634AC_SUBST(WIN32_EXTRA_LIBADD)
1635AC_SUBST(WIN32_EXTRA_LDFLAGS)
1636AC_SUBST(WIN32_EXTRA_PYTHON_LIBADD)
1637AC_SUBST(CYGWIN_EXTRA_LDFLAGS)
1638AC_SUBST(CYGWIN_EXTRA_PYTHON_LIBADD)
1639
1640dnl Checking the standard string functions availability
1641dnl
1642dnl Note mingw* has C99 implementation that produce expected xml numbers
1643dnl if code use {v}snprintf functions.
1644dnl If you like to activate at run-time C99 compatible number output
1645dnl see release note for mingw runtime 3.15:
1646dnl  http://sourceforge.net/project/shownotes.php?release_id=24832
1647dnl
1648dnl Also *win32*config.h files redefine them for various MSC compilers.
1649dnl
1650dnl So do not redefine {v}snprintf to _{v}snprintf like follwing:
1651dnl  AC_DEFINE([snprintf],[_snprintf],[Win32 Std C name mangling work-around])
1652dnl  AC_DEFINE([vsnprintf],[_vsnprintf],[Win32 Std C name mangling work-around])
1653dnl and do not redefine those functions is C-source files.
1654dnl
1655AC_CHECK_FUNCS(printf sprintf fprintf snprintf vfprintf vsprintf vsnprintf sscanf,,
1656	NEED_TRIO=1)
1657
1658if test "$with_coverage" = "yes" -a "${GCC}" = "yes"
1659then
1660    echo Enabling code coverage for GCC
1661    EXTRA_CFLAGS="$EXTRA_CFLAGS -fprofile-arcs -ftest-coverage"
1662    LDFLAGS="$LDFLAGS -fprofile-arcs -ftest-coverage"
1663else
1664    echo Disabling code coverage for GCC
1665fi
1666
1667AC_SUBST(CPPFLAGS)
1668AC_SUBST(EXTRA_CFLAGS)
1669AC_SUBST(LDFLAGS)
1670AC_SUBST(XML_CFLAGS)
1671
1672AC_SUBST(XML_LIBDIR)
1673AC_SUBST(XML_LIBS)
1674AC_SUBST(XML_LIBTOOLLIBS)
1675AC_SUBST(ICONV_LIBS)
1676AC_SUBST(ICU_LIBS)
1677AC_SUBST(XML_INCLUDEDIR)
1678AC_SUBST(HTML_DIR)
1679AC_SUBST(HAVE_ISNAN)
1680AC_SUBST(HAVE_ISINF)
1681AC_SUBST(PYTHON)
1682AC_SUBST(PYTHON_VERSION)
1683AC_SUBST(PYTHON_INCLUDES)
1684AC_SUBST(PYTHON_SITE_PACKAGES)
1685
1686AC_SUBST(M_LIBS)
1687AC_SUBST(RDL_LIBS)
1688
1689dnl for the spec file
1690RELDATE=`date +'%a %b %e %Y'`
1691AC_SUBST(RELDATE)
1692AC_SUBST(PYTHON_TESTS)
1693
1694rm -f COPYING.LIB COPYING
1695ln -s $srcdir/Copyright COPYING
1696
1697# keep on one line for cygwin c.f. #130896
1698AC_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])
1699AC_CONFIG_FILES([python/setup.py], [chmod +x python/setup.py])
1700AC_CONFIG_FILES([xml2-config], [chmod +x xml2-config])
1701AC_OUTPUT
1702
1703echo Done configuring
1704