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