x_ac_hwloc.m4 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ##*****************************************************************************
  2. # AUTHOR:
  3. # Morris Jette <jette1@llnl.gov>
  4. #
  5. # SYNOPSIS:
  6. # X_AC_HWLOC
  7. #
  8. # DESCRIPTION:
  9. # Determine if the HWLOC libraries exists and if they support PCI data.
  10. ##*****************************************************************************
  11. AC_DEFUN([X_AC_HWLOC],
  12. [
  13. _x_ac_hwloc_dirs="/usr /usr/local"
  14. _x_ac_hwloc_libs="lib64 lib"
  15. x_ac_cv_hwloc_pci="no"
  16. AC_ARG_WITH(
  17. [hwloc],
  18. AS_HELP_STRING(--with-hwloc=PATH,Specify path to hwloc installation),
  19. [AS_IF([test "x$with_hwloc" != xno],[_x_ac_hwloc_dirs="$with_hwloc $_x_ac_hwloc_dirs"])])
  20. if [test "x$with_hwloc" = xno]; then
  21. AC_MSG_WARN([support for hwloc disabled])
  22. else
  23. AC_CACHE_CHECK(
  24. [for hwloc installation],
  25. [x_ac_cv_hwloc_dir],
  26. [
  27. for d in $_x_ac_hwloc_dirs; do
  28. test -d "$d" || continue
  29. test -d "$d/include" || continue
  30. test -f "$d/include/hwloc.h" || continue
  31. for bit in $_x_ac_hwloc_libs; do
  32. test -d "$d/$bit" || continue
  33. _x_ac_hwloc_cppflags_save="$CPPFLAGS"
  34. CPPFLAGS="-I$d/include $CPPFLAGS"
  35. _x_ac_hwloc_libs_save="$LIBS"
  36. LIBS="-L$d/$bit -lhwloc $LIBS"
  37. AC_LINK_IFELSE(
  38. [AC_LANG_CALL([], hwloc_topology_init)],
  39. AS_VAR_SET(x_ac_cv_hwloc_dir, $d))
  40. AC_TRY_LINK([#include <hwloc.h>],
  41. [int i = HWLOC_OBJ_PCI_DEVICE;],
  42. [x_ac_cv_hwloc_pci="yes"], [])
  43. CPPFLAGS="$_x_ac_hwloc_cppflags_save"
  44. LIBS="$_x_ac_hwloc_libs_save"
  45. test -n "$x_ac_cv_hwloc_dir" && break
  46. done
  47. test -n "$x_ac_cv_hwloc_dir" && break
  48. done
  49. ])
  50. if test -z "$x_ac_cv_hwloc_dir"; then
  51. AC_MSG_WARN([unable to locate hwloc installation])
  52. else
  53. HWLOC_CPPFLAGS="-I$x_ac_cv_hwloc_dir/include"
  54. if test "$ac_with_rpath" = "yes"; then
  55. HWLOC_LDFLAGS="-Wl,-rpath -Wl,$x_ac_cv_hwloc_dir/$bit -L$x_ac_cv_hwloc_dir/$bit"
  56. else
  57. HWLOC_LDFLAGS="-L$x_ac_cv_hwloc_dir/$bit"
  58. fi
  59. HWLOC_LIBS="-lhwloc"
  60. AC_DEFINE(HAVE_HWLOC, 1, [Define to 1 if hwloc library found])
  61. if test "$x_ac_cv_hwloc_pci" = "yes"; then
  62. AC_DEFINE(HAVE_HWLOC_PCI, 1, [Define to 1 if hwloc library supports PCI devices])
  63. fi
  64. fi
  65. AC_SUBST(HWLOC_LIBS)
  66. AC_SUBST(HWLOC_CPPFLAGS)
  67. AC_SUBST(HWLOC_LDFLAGS)
  68. fi
  69. ])