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