expat.m4 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. AM_CONDITIONAL(EXPAT_INSTALLED, test $with_expat != no)
  15. EXPAT_CFLAGS=
  16. EXPAT_LIBS=
  17. if test $with_expat != no; then
  18. if test $with_expat != yes; then
  19. EXPAT_CFLAGS="-I$with_expat/include"
  20. EXPAT_LIBS="-L$with_expat/lib"
  21. fi
  22. AC_CHECK_LIB(expat, XML_ParserCreate,
  23. [ EXPAT_LIBS="$EXPAT_LIBS -lexpat"
  24. expat_found=yes ],
  25. [ expat_found=no ],
  26. "$EXPAT_LIBS")
  27. if test $expat_found = no; then
  28. AC_MSG_ERROR([Could not find the Expat library])
  29. fi
  30. expat_save_CFLAGS="$CFLAGS"
  31. CFLAGS="$CFLAGS $EXPAT_CFLAGS"
  32. AC_CHECK_HEADERS(expat.h, , expat_found=no)
  33. if test $expat_found = no; then
  34. AC_MSG_ERROR([Could not find expat.h])
  35. fi
  36. CFLAGS="$expat_save_CFLAGS"
  37. fi
  38. AC_SUBST(EXPAT_CFLAGS)
  39. AC_SUBST(EXPAT_LIBS)
  40. ])