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