Import expat-2.0.1
[dragonfly.git] / contrib / expat / conftools / expat.m4
1 dnl Check if --with-expat[=PREFIX] is specified and
2 dnl Expat >= 1.95.0 is installed in the system.
3 dnl If yes, substitute EXPAT_CFLAGS, EXPAT_LIBS with regard to
4 dnl the specified PREFIX and set with_expat to PREFIX, or 'yes' if PREFIX
5 dnl has not been specified. Also HAVE_LIBEXPAT, HAVE_EXPAT_H are defined.
6 dnl If --with-expat has not been specified, set with_expat to 'no'.
7 dnl In addition, an Automake conditional EXPAT_INSTALLED is set accordingly.
8 dnl This is necessary to adapt a whole lot of packages that have expat
9 dnl bundled as a static library.
10 AC_DEFUN(AM_WITH_EXPAT,
11 [ AC_ARG_WITH(expat,
12               [  --with-expat=PREFIX     Use system Expat library],
13               , with_expat=no)
14
15   AM_CONDITIONAL(EXPAT_INSTALLED, test $with_expat != no)
16
17   EXPAT_CFLAGS=
18   EXPAT_LIBS=
19   if test $with_expat != no; then
20         if test $with_expat != yes; then
21                 EXPAT_CFLAGS="-I$with_expat/include"
22                 EXPAT_LIBS="-L$with_expat/lib"
23         fi
24         AC_CHECK_LIB(expat, XML_ParserCreate,
25                      [ EXPAT_LIBS="$EXPAT_LIBS -lexpat"
26                        expat_found=yes ],
27                      [ expat_found=no ],
28                      "$EXPAT_LIBS")
29         if test $expat_found = no; then
30                 AC_MSG_ERROR([Could not find the Expat library])
31         fi
32         expat_save_CFLAGS="$CFLAGS"
33         CFLAGS="$CFLAGS $EXPAT_CFLAGS"
34         AC_CHECK_HEADERS(expat.h, , expat_found=no)
35         if test $expat_found = no; then
36                 AC_MSG_ERROR([Could not find expat.h])
37         fi
38         CFLAGS="$expat_save_CFLAGS"
39   fi
40
41   AC_SUBST(EXPAT_CFLAGS)
42   AC_SUBST(EXPAT_LIBS)
43 ])