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