x_ac_freeipmi.m4 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ##*****************************************************************************
  2. # AUTHOR:
  3. # Thomas Cadeau<thomas.cadeau@ext.bull.net>
  4. #
  5. # SYNOPSIS:
  6. # X_AC_FREEIPMI
  7. #
  8. # DESCRIPTION:
  9. # Determine if the FREEIPMI libraries exists
  10. ##*****************************************************************************
  11. AC_DEFUN([X_AC_FREEIPMI],
  12. [
  13. _x_ac_freeipmi_dirs="/usr /usr/local"
  14. _x_ac_freeipmi_libs="lib64 lib"
  15. AC_ARG_WITH(
  16. [freeipmi],
  17. AS_HELP_STRING(--with-freeipmi=PATH,Specify path to freeipmi installation),
  18. [AS_IF([test "x$with_freeipmi" != xno],[_x_ac_freeipmi_dirs="$with_freeipmi $_x_ac_freeipmi_dirs"])])
  19. if [test "x$with_freeipmi" = xno]; then
  20. AC_MSG_WARN([support for freeipmi disabled])
  21. else
  22. AC_CACHE_CHECK(
  23. [for freeipmi installation],
  24. [x_ac_cv_freeipmi_dir],
  25. [
  26. for d in $_x_ac_freeipmi_dirs; do
  27. test -d "$d" || continue
  28. test -d "$d/include" || continue
  29. test -f "$d/include/ipmi_monitoring.h" || continue
  30. for bit in $_x_ac_freeipmi_libs; do
  31. test -d "$d/$bit" || continue
  32. _x_ac_freeipmi_cppflags_save="$CPPFLAGS"
  33. CPPFLAGS="-I$d/include $CPPFLAGS"
  34. _x_ac_freeipmi_libs_save="$LIBS"
  35. LIBS="-L$d/$bit -lipmimonitoring $LIBS"
  36. AC_TRY_LINK([#include <ipmi_monitoring.h>
  37. #include <ipmi_monitoring_bitmasks.h>],
  38. [int err;]
  39. [unsigned int flag = 0;]
  40. [return ipmi_monitoring_init (flag, &err);],
  41. AS_VAR_SET(x_ac_cv_freeipmi_dir, $d), [])
  42. CPPFLAGS="$_x_ac_freeipmi_cppflags_save"
  43. LIBS="$_x_ac_freeipmi_libs_save"
  44. test -n "$x_ac_cv_freeipmi_dir" && break
  45. done
  46. test -n "$x_ac_cv_freeipmi_dir" && break
  47. done
  48. ])
  49. if test -z "$x_ac_cv_freeipmi_dir"; then
  50. AC_MSG_WARN([unable to locate freeipmi installation])
  51. else
  52. FREEIPMI_CPPFLAGS="-I$x_ac_cv_freeipmi_dir/include"
  53. if test "$ac_with_rpath" = "yes"; then
  54. FREEIPMI_LDFLAGS="-Wl,-rpath -Wl,$x_ac_cv_freeipmi_dir/$bit -L$x_ac_cv_freeipmi_dir/$bit"
  55. else
  56. FREEIPMI_LDFLAGS="-L$x_ac_cv_freeipmi_dir/$bit"
  57. fi
  58. FREEIPMI_LIBS="-lipmimonitoring"
  59. AC_DEFINE(HAVE_FREEIPMI, 1, [Define to 1 if freeipmi library found])
  60. fi
  61. AC_SUBST(FREEIPMI_LIBS)
  62. AC_SUBST(FREEIPMI_CPPFLAGS)
  63. AC_SUBST(FREEIPMI_LDFLAGS)
  64. fi
  65. AM_CONDITIONAL(BUILD_IPMI, test -n "$x_ac_cv_freeipmi_dir")
  66. ])