Browse Source

configure.ac: always use pkg-config when detecting hwloc availability

Nathalie Furmento 8 years ago
parent
commit
230a6d5b42
1 changed files with 15 additions and 31 deletions
  1. 15 31
      configure.ac

+ 15 - 31
configure.ac

@@ -2575,20 +2575,25 @@ AM_CONDITIONAL(BUILD_STARPUFFT_EXAMPLES, [test x$enable_starpufft_examples = xye
 # hwloc                                  #
 # hwloc                                  #
 ##########################################
 ##########################################
 
 
+have_valid_hwloc=no
+SAVED_LDFLAGS="${LDFLAGS}"
+SAVED_CPPFLAGS="${CPPFLAGS}"
+SAVED_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
 AC_ARG_WITH([hwloc],
 AC_ARG_WITH([hwloc],
 	[AS_HELP_STRING([--without-hwloc], [Disable hwloc (enabled by default)])],
 	[AS_HELP_STRING([--without-hwloc], [Disable hwloc (enabled by default)])],
 	[
 	[
 		if test x$withval != xno; then
 		if test x$withval != xno; then
 			if test "$withval" = "yes" ; then
 			if test "$withval" = "yes" ; then
-				use_hwloc_from_system=yes
 				use_hwloc=yes
 				use_hwloc=yes
 			else
 			else
 				# use specified path
 				# use specified path
-				use_hwloc_from_system=no
 				if test ! -d "$withval" ; then
 				if test ! -d "$withval" ; then
 				   AC_MSG_ERROR("Directory specified for hwloc <$withval> does not exist")
 				   AC_MSG_ERROR("Directory specified for hwloc <$withval> does not exist")
 				fi
 				fi
-				hwloc_dir=$withval
+				if test ! -d "$withval/lib/pkgconfig" ; then
+				   AC_MSG_ERROR("Hwloc directory <$withval> does not have a subdirectory lib/pkgconfig")
+				fi
+				export PKG_CONFIG_PATH=$withval/lib/pkgconfig:$PKG_CONFIG_PATH
 				use_hwloc=yes
 				use_hwloc=yes
 			fi
 			fi
 		else
 		else
@@ -2597,28 +2602,10 @@ AC_ARG_WITH([hwloc],
 	],
 	],
 	[
 	[
 		use_hwloc=maybe
 		use_hwloc=maybe
-		use_hwloc_from_system=yes
 	])
 	])
-SAVED_LDFLAGS="${LDFLAGS}"
-SAVED_CPPFLAGS="${CPPFLAGS}"
-AS_IF([test "$use_hwloc" = "no"],
-  [have_valid_hwloc=no],
-  [AS_IF([test "$use_hwloc_from_system" = "yes"],
-  	  [PKG_CHECK_MODULES([HWLOC],[hwloc], [
-	      	have_valid_hwloc=yes
-            have_pkgconfig_hwloc=yes],
-		[
-            have_valid_hwloc=no
-            have_pkgconfig_hwloc=no])
-	  ],
-	  #else
-	  [have_pkgconfig_hwloc=no
-	   CPPFLAGS="${SAVED_CPPFLAGS} -I$hwloc_dir/include"
-	   AC_CHECK_HEADER([hwloc.h],[have_valid_hwloc=yes],[have_valid_hwloc=no])
-	   LDFLAGS="${SAVED_LDFLAGS} -L$hwloc_dir/lib"
-       AC_HAVE_LIBRARY([hwloc],[have_valid_hwloc=yes],[have_valid_hwloc=no])
-	  ])
-  ])
+AS_IF([test "$use_hwloc" != "no"],
+      [PKG_CHECK_MODULES([HWLOC],[hwloc], [have_valid_hwloc=yes], [have_valid_hwloc=no])]
+     )
 AM_CONDITIONAL(STARPU_HAVE_HWLOC, test "x$have_valid_hwloc" = "xyes")
 AM_CONDITIONAL(STARPU_HAVE_HWLOC, test "x$have_valid_hwloc" = "xyes")
 # in case hwloc was explicitely required, but is not available, this is an error
 # in case hwloc was explicitely required, but is not available, this is an error
 AS_IF([test "$use_hwloc" = "yes" -a "$have_valid_hwloc" = "no"],
 AS_IF([test "$use_hwloc" = "yes" -a "$have_valid_hwloc" = "no"],
@@ -2629,25 +2616,22 @@ AS_IF([test "$have_valid_hwloc" = "no" -a "$use_hwloc" != "no"],
       [AC_MSG_ERROR([libhwloc was not found on your system. If the target machine is hyperthreaded the performance may be impacted a lot.  It is strongly recommended to install libhwloc. However, if you really want to use StarPU without enabling libhwloc, please restart configure by specifying the option '--without-hwloc'.])]
       [AC_MSG_ERROR([libhwloc was not found on your system. If the target machine is hyperthreaded the performance may be impacted a lot.  It is strongly recommended to install libhwloc. However, if you really want to use StarPU without enabling libhwloc, please restart configure by specifying the option '--without-hwloc'.])]
      )
      )
 
 
+LDFLAGS="${HWLOC_LIBS} ${SAVED_LDFLAGS}"
+CPPFLAGS="${HWLOC_CFLAGS} ${SAVED_CPPFLAGS}"
+
 AS_IF([test "$have_valid_hwloc" = "yes"],
 AS_IF([test "$have_valid_hwloc" = "yes"],
       [AC_DEFINE([STARPU_HAVE_HWLOC], [1], [Define to 1 if you have the hwloc library.])
       [AC_DEFINE([STARPU_HAVE_HWLOC], [1], [Define to 1 if you have the hwloc library.])
        HWLOC_REQUIRES=hwloc
        HWLOC_REQUIRES=hwloc
        AC_SUBST([STARPU_HAVE_HWLOC], [1])
        AC_SUBST([STARPU_HAVE_HWLOC], [1])
        AC_CHECK_DECLS([hwloc_cuda_get_device_osdev_by_index], [], [], [[#include <hwloc/cuda.h>]])
        AC_CHECK_DECLS([hwloc_cuda_get_device_osdev_by_index], [], [], [[#include <hwloc/cuda.h>]])
-       AS_IF([test "$have_pkgconfig_hwloc" = "no"],
-             [HWLOC_CFLAGS="-I$hwloc_dir/include"
-          HWLOC_LIBS="-L$hwloc_dir/lib -lhwloc"
-          # TODO: either detect this or make the API compatible with older hwloc versions
-          ],)
       ])
       ])
 
 
-LDFLAGS="${HWLOC_LIBS} ${SAVED_LDFLAGS}"
-CPPFLAGS="${HWLOC_CFLAGS} ${SAVED_CPPFLAGS}"
 AC_CHECK_FUNCS([hwloc_topology_dup])
 AC_CHECK_FUNCS([hwloc_topology_dup])
 AM_CONDITIONAL(STARPU_HWLOC_HAVE_TOPOLOGY_DUP, test $ac_cv_func_hwloc_topology_dup = yes)
 AM_CONDITIONAL(STARPU_HWLOC_HAVE_TOPOLOGY_DUP, test $ac_cv_func_hwloc_topology_dup = yes)
 
 
 LDFLAGS="${SAVED_LDFLAGS}"
 LDFLAGS="${SAVED_LDFLAGS}"
 CPPFLAGS="${SAVED_CPPFLAGS}"
 CPPFLAGS="${SAVED_CPPFLAGS}"
+export PKG_CONFIG_PATH=$SAVED_PKG_CONFIG_PATH
 
 
 AC_MSG_CHECKING(whether hwloc should be used)
 AC_MSG_CHECKING(whether hwloc should be used)
 AC_MSG_RESULT($have_valid_hwloc)
 AC_MSG_RESULT($have_valid_hwloc)