Skip to content
142 changes: 77 additions & 65 deletions opal/mca/hwloc/external/configure.m4
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- shell-script -*-
#
# Copyright (c) 2009-2017 Cisco Systems, Inc. All rights reserved
# Copyright (c) 2014-2017 Research Organization for Information Science
# Copyright (c) 2014-2018 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
#
# Copyright (c) 2018 Intel, Inc. All rights reserved.
Expand Down Expand Up @@ -84,7 +84,7 @@ AC_DEFUN([MCA_opal_hwloc_external_POST_CONFIG],[
AC_DEFUN([MCA_opal_hwloc_external_CONFIG],[
AC_CONFIG_FILES([opal/mca/hwloc/external/Makefile])

OPAL_VAR_SCOPE_PUSH([opal_hwloc_external_CPPFLAGS_save opal_hwloc_external_CFLAGS_save opal_hwloc_external_LDFLAGS_save opal_hwloc_external_LIBS_save opal_hwloc_external_want opal_hwloc_external_tmp opal_hwloc_external_lstopo])
OPAL_VAR_SCOPE_PUSH([opal_hwloc_external_CPPFLAGS_save opal_hwloc_external_CFLAGS_save opal_hwloc_external_LDFLAGS_save opal_hwloc_external_LIBS_save opal_hwloc_external_tmp opal_hwloc_external_lstopo opal_hwloc_summary_msg])

AC_ARG_WITH([hwloc-libdir],
[AC_HELP_STRING([--with-hwloc-libdir=DIR],
Expand All @@ -98,19 +98,9 @@ AC_DEFUN([MCA_opal_hwloc_external_CONFIG],[
AC_MSG_WARN([were specified, which does not make sense.])
AC_MSG_ERROR([Cannot continue])])

# Do we want this external component? (slightly redundant logic,
# but hopefully slightly more clear...)
opal_hwloc_external_want=no
AS_IF([test "$with_hwloc_libdir" != ""], [opal_hwloc_external_want=yes])
AS_IF([test "$with_hwloc" = "external"], [opal_hwloc_external_want=yes])
AS_IF([test "$with_hwloc" != "" && \
test "$with_hwloc" != "no" && \
test "$with_hwloc" != "internal" && \
test "$with_hwloc" != "future"], [opal_hwloc_external_want=yes])
AS_IF([test "$with_hwloc" = "no"], [opal_hwloc_external_want=no])

# If we still want external support, try it
AS_IF([test "$opal_hwloc_external_want" = "yes"],
opal_hwloc_summary_msg="internal"
# Try external support if needed
AS_IF([test "$with_hwloc" != "internal"],
[OPAL_CHECK_WITHDIR([hwloc-libdir], [$with_hwloc_libdir],
[libhwloc.*])

Expand Down Expand Up @@ -144,64 +134,86 @@ AC_DEFUN([MCA_opal_hwloc_external_CONFIG],[
LDFLAGS="$LDFLAGS $opal_hwloc_external_LDFLAGS"
LIBS="$LIBS $opal_hwloc_external_LIBS"
AC_CHECK_DECLS([HWLOC_OBJ_OSDEV_COPROC], [], [], [#include <hwloc.h>])
AC_CHECK_FUNCS([hwloc_topology_dup])])
AC_CHECK_FUNCS([hwloc_topology_dup])

CPPFLAGS=$opal_hwloc_external_CPPFLAGS_save
CFLAGS=$opal_hwloc_external_CFLAGS_save
LDFLAGS=$opal_hwloc_external_LDFLAGS_save
LIBS=$opal_hwloc_external_LIBS_save
])

# Done!
AS_IF([test "$opal_hwloc_external_support" = "yes"],
[AC_DEFINE_UNQUOTED([HWLOC_EXTERNAL_HWLOC_VERSION],
[external],
[Version of hwloc])

# See if the external hwloc supports XML
AC_MSG_CHECKING([if external hwloc supports XML])
AS_IF([test "$opal_hwloc_dir" != ""],
[opal_hwloc_external_lstopo="$opal_hwloc_dir/bin/lstopo"],
[OPAL_WHICH(lstopo, opal_hwloc_external_lstopo)])
opal_hwloc_external_tmp=`$opal_hwloc_external_lstopo --help | $GREP "Supported output file formats" | grep xml`
AS_IF([test "$opal_hwloc_external_tmp" = ""],
[opal_hwloc_external_enable_xml=0
AC_MSG_RESULT([no])],
[opal_hwloc_external_enable_xml=1
AC_MSG_RESULT([yes])])

AC_CHECK_HEADERS([infiniband/verbs.h])

AC_MSG_CHECKING([if external hwloc version is 1.5 or greater])
AS_IF([test "$opal_hwloc_dir" != ""],
[opal_hwloc_external_CFLAGS_save=$CFLAGS
CFLAGS="-I$opal_hwloc_dir/include $opal_hwloc_external_CFLAGS_save"])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <hwloc.h>]],
[[
AC_MSG_CHECKING([if external hwloc version is 1.5 or greater])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <hwloc.h>]],
[[
#if HWLOC_API_VERSION < 0x00010500
#error "hwloc API version is less than 0x00010500"
#endif
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([Cannot continue])])

AS_IF([test "$opal_hwloc_dir" != ""],
[CFLAGS=$opal_hwloc_external_CFLAGS_save])
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
opal_hwloc_external_support=no])])

# These flags need to get passed to the wrapper compilers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsquyres this illustrates my latest comment in #5031

# (this is unnecessary for the internal/embedded hwloc)
# If external hwloc is not explicitly requested, check external version
# is not lower than the internal one
AS_IF([test "$opal_hwloc_external_support" = "yes"],
[AS_IF([test -z "$with_hwloc" || test "$with_hwloc" = "yes"],
[AC_MSG_CHECKING([if external hwloc version is 2.0 or greater])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <hwloc.h>]],
[[
#if HWLOC_API_VERSION < 0x00020000
#error "hwloc API version is less than 0x00020000"
#endif
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
opal_hwloc_summary_msg="internal (external hlwoc version is less than internal version 2.0)"
AC_MSG_WARN([external hwloc version is less than internal version 2.0])
AC_MSG_WARN([using internal hwloc])
opal_hwloc_external_support=no])])])

# Finally, add some flags to the wrapper compiler if we're
# building with developer headers so that our headers can
# be found.
hwloc_external_WRAPPER_EXTRA_CPPFLAGS=$opal_hwloc_external_CPPFLAGS
hwloc_external_WRAPPER_EXTRA_LDFLAGS=$opal_hwloc_external_LDFLAGS
hwloc_external_WRAPPER_EXTRA_LIBS=$opal_hwloc_external_LIBS
AS_IF([test "$opal_hwloc_external_support" = "yes"],
[AC_DEFINE_UNQUOTED([HWLOC_EXTERNAL_HWLOC_VERSION],
[external],
[Version of hwloc])

# See if the external hwloc supports XML
AC_MSG_CHECKING([if external hwloc supports XML])
AS_IF([test "$opal_hwloc_dir" != ""],
[opal_hwloc_external_lstopo="$opal_hwloc_dir/bin/lstopo"],
[OPAL_WHICH(lstopo, opal_hwloc_external_lstopo)])
opal_hwloc_external_tmp=`$opal_hwloc_external_lstopo --help | $GREP "Supported output file formats" | grep xml`
AS_IF([test "$opal_hwloc_external_tmp" = ""],
[opal_hwloc_external_enable_xml=0
AC_MSG_RESULT([no])],
[opal_hwloc_external_enable_xml=1
AC_MSG_RESULT([yes])])

AC_CHECK_HEADERS([infiniband/verbs.h])

# These flags need to get passed to the wrapper compilers
# (this is unnecessary for the internal/embedded hwloc)

# Finally, add some flags to the wrapper compiler if we're
# building with developer headers so that our headers can
# be found.
hwloc_external_WRAPPER_EXTRA_CPPFLAGS=$opal_hwloc_external_CPPFLAGS
hwloc_external_WRAPPER_EXTRA_LDFLAGS=$opal_hwloc_external_LDFLAGS
hwloc_external_WRAPPER_EXTRA_LIBS=$opal_hwloc_external_LIBS])

CPPFLAGS=$opal_hwloc_external_CPPFLAGS_save
CFLAGS=$opal_hwloc_external_CFLAGS_save
LDFLAGS=$opal_hwloc_external_LDFLAGS_save
LIBS=$opal_hwloc_external_LIBS_save
])

# Done!
AS_IF([test "$opal_hwloc_external_support" = "yes"],
[opal_hwloc_summary_msg="external"
$1],
[$2])
[# Abort is external hwloc was explicitly requested but cannot be built
AS_IF([test "$with_hwloc" != internal &&
test -n "$with_hwloc"],
[AC_MSG_WARN([external hwloc cannot be built])
AC_MSG_ERROR([Cannot continue.])])
$2])

OPAL_SUMMARY_ADD([[Miscellaneous]],[[HWLOC support]], [], [$opal_hwloc_summary_msg])

AC_SUBST(opal_hwloc_external_LDFLAGS)
AC_SUBST(opal_hwloc_external_LIBS)
Expand Down
4 changes: 2 additions & 2 deletions opal/mca/hwloc/hwloc201/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Copyright (c) 2009-2017 Cisco Systems, Inc. All rights reserved
# Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
# Copyright (c) 2015-2017 Research Organization for Information Science
# Copyright (c) 2015-2018 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# Copyright (c) 2016 Los Alamos National Security, LLC. All rights
# reserved.
Expand All @@ -17,7 +17,7 @@
#
# Priority
#
AC_DEFUN([MCA_opal_hwloc_hwloc201_PRIORITY], [90])
AC_DEFUN([MCA_opal_hwloc_hwloc201_PRIORITY], [80])

#
# Force this component to compile in static-only mode
Expand Down