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