x_ac_munge.m4 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ##*****************************************************************************
  2. # AUTHOR:
  3. # Chris Dunlap <cdunlap@llnl.gov> (originally for OpenSSL)
  4. # Modified for munge by Christopher Morrone <morrone2@llnl.gov>
  5. #
  6. # SYNOPSIS:
  7. # X_AC_MUNGE()
  8. #
  9. # DESCRIPTION:
  10. # Check the usual suspects for an munge installation,
  11. # updating CPPFLAGS and LDFLAGS as necessary.
  12. #
  13. # WARNINGS:
  14. # This macro must be placed after AC_PROG_CC and before AC_PROG_LIBTOOL.
  15. ##*****************************************************************************
  16. AC_DEFUN([X_AC_MUNGE], [
  17. _x_ac_munge_dirs="/usr /usr/local /opt/freeware /opt/munge"
  18. _x_ac_munge_libs="lib64 lib"
  19. AC_ARG_WITH(
  20. [munge],
  21. AS_HELP_STRING(--with-munge=PATH,Specify path to munge installation),
  22. [AS_IF([test "x$with_munge" != xno],[_x_ac_munge_dirs="$with_munge $_x_ac_munge_dirs"])])
  23. if [test "x$with_munge" = xno]; then
  24. AC_MSG_WARN([support for munge disabled])
  25. else
  26. AC_CACHE_CHECK(
  27. [for munge installation],
  28. [x_ac_cv_munge_dir],
  29. [
  30. for d in $_x_ac_munge_dirs; do
  31. test -d "$d" || continue
  32. test -d "$d/include" || continue
  33. test -f "$d/include/munge.h" || continue
  34. for bit in $_x_ac_munge_libs; do
  35. test -d "$d/$bit" || continue
  36. _x_ac_munge_libs_save="$LIBS"
  37. LIBS="-L$d/$bit -lmunge $LIBS"
  38. AC_LINK_IFELSE(
  39. [AC_LANG_CALL([], munge_encode)],
  40. AS_VAR_SET(x_ac_cv_munge_dir, $d))
  41. LIBS="$_x_ac_munge_libs_save"
  42. test -n "$x_ac_cv_munge_dir" && break
  43. done
  44. test -n "$x_ac_cv_munge_dir" && break
  45. done
  46. ])
  47. if test -z "$x_ac_cv_munge_dir"; then
  48. AC_MSG_WARN([unable to locate munge installation])
  49. else
  50. MUNGE_LIBS="-lmunge"
  51. MUNGE_CPPFLAGS="-I$x_ac_cv_munge_dir/include"
  52. MUNGE_DIR="$x_ac_cv_munge_dir"
  53. if test "$ac_with_rpath" = "yes"; then
  54. MUNGE_LDFLAGS="-Wl,-rpath -Wl,$x_ac_cv_munge_dir/$bit -L$x_ac_cv_munge_dir/$bit"
  55. else
  56. MUNGE_LDFLAGS="-L$x_ac_cv_munge_dir/$bit"
  57. fi
  58. fi
  59. AC_SUBST(MUNGE_LIBS)
  60. AC_SUBST(MUNGE_CPPFLAGS)
  61. AC_SUBST(MUNGE_LDFLAGS)
  62. AC_SUBST(MUNGE_DIR)
  63. fi
  64. AM_CONDITIONAL(WITH_MUNGE, test -n "$x_ac_cv_munge_dir")
  65. ])