3 dnl Copyright © 2009-2018 Inria. All rights reserved.
4 dnl Copyright © 2009-2012, 2015-2017 Université Bordeaux
5 dnl Copyright © 2004-2005 The Trustees of Indiana University and Indiana
6 dnl University Research and Technology
7 dnl Corporation. All rights reserved.
8 dnl Copyright © 2004-2012 The Regents of the University of California.
9 dnl All rights reserved.
10 dnl Copyright © 2004-2008 High Performance Computing Center Stuttgart,
11 dnl University of Stuttgart. All rights reserved.
12 dnl Copyright © 2006-2017 Cisco Systems, Inc. All rights reserved.
13 dnl Copyright © 2012 Blue Brain Project, BBP/EPFL. All rights reserved.
14 dnl Copyright © 2012 Oracle and/or its affiliates. All rights reserved.
15 dnl See COPYING in top-level directory.
17 # Main hwloc m4 macro, to be invoked by the user
19 # Expects two or three paramters:
20 # 1. Configuration prefix
21 # 2. What to do upon success
22 # 3. What to do upon failure
23 # 4. If non-empty, print the announcement banner
25 AC_DEFUN([HWLOC_SETUP_CORE],[
26 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
27 AC_REQUIRE([AC_CANONICAL_TARGET])
28 AC_REQUIRE([AC_PROG_CC])
30 AS_IF([test "x$4" != "x"],
34 ### Configuring hwloc core
38 # If no prefix was defined, set a good value
40 [m4_define([hwloc_config_prefix],[$1/])],
41 [m4_define([hwloc_config_prefix], [])])
43 # Unless previously set to "standalone" mode, default to embedded
45 AS_IF([test "$hwloc_mode" = ""], [hwloc_mode=embedded])
46 AC_MSG_CHECKING([hwloc building mode])
47 AC_MSG_RESULT([$hwloc_mode])
49 # Get hwloc's absolute top builddir (which may not be the same as
50 # the real $top_builddir, because we may be building in embedded
53 if test x"hwloc_config_prefix" != "x" -a ! -d "hwloc_config_prefix"; then
54 mkdir -p "hwloc_config_prefix"
56 if test x"hwloc_config_prefix" != "x"; then
57 cd "hwloc_config_prefix"
59 HWLOC_top_builddir=`pwd`
60 AC_SUBST(HWLOC_top_builddir)
62 # Get hwloc's absolute top srcdir (which may not be the same as
63 # the real $top_srcdir, because we may be building in embedded
64 # mode). First, go back to the startdir incase the $srcdir is
68 cd "$srcdir"/hwloc_config_prefix
69 HWLOC_top_srcdir="`pwd`"
70 AC_SUBST(HWLOC_top_srcdir)
72 # Go back to where we started
75 AC_MSG_NOTICE([hwloc builddir: $HWLOC_top_builddir])
76 AC_MSG_NOTICE([hwloc srcdir: $HWLOC_top_srcdir])
77 if test "$HWLOC_top_builddir" != "$HWLOC_top_srcdir"; then
78 AC_MSG_NOTICE([Detected VPATH build])
81 # Get the version of hwloc that we are installing
82 AC_MSG_CHECKING([for hwloc version])
83 HWLOC_VERSION="`$HWLOC_top_srcdir/config/hwloc_get_version.sh $HWLOC_top_srcdir/VERSION`"
84 if test "$?" != "0"; then
85 AC_MSG_ERROR([Cannot continue])
87 HWLOC_RELEASE_DATE="`$HWLOC_top_srcdir/config/hwloc_get_version.sh $HWLOC_top_srcdir/VERSION --release-date`"
88 AC_SUBST(HWLOC_VERSION)
89 AC_DEFINE_UNQUOTED([HWLOC_VERSION], ["$HWLOC_VERSION"],
90 [The library version, always available, even in embedded mode, contrary to VERSION])
91 AC_SUBST(HWLOC_RELEASE_DATE)
92 AC_MSG_RESULT([$HWLOC_VERSION])
95 AC_MSG_CHECKING([if want hwloc maintainer support])
98 # Unconditionally disable debug mode in embedded mode; if someone
99 # asks, we can add a configure-time option for it. Disable it
100 # now, however, because --enable-debug is not even added as an
101 # option when configuring in embedded mode, and we wouldn't want
102 # to hijack the enclosing application's --enable-debug configure
104 AS_IF([test "$hwloc_mode" = "embedded"],
106 hwloc_debug_msg="disabled (embedded mode)"])
107 AS_IF([test "$hwloc_debug" = "" -a "$enable_debug" = "yes"],
109 hwloc_debug_msg="enabled"])
110 AS_IF([test "$hwloc_debug" = ""],
112 hwloc_debug_msg="disabled"])
113 # Grr; we use #ifndef for HWLOC_DEBUG! :-(
114 AH_TEMPLATE(HWLOC_DEBUG, [Whether we are in debugging mode or not])
115 AS_IF([test "$hwloc_debug" = "1"], [AC_DEFINE([HWLOC_DEBUG])])
116 AC_MSG_RESULT([$hwloc_debug_msg])
118 # We need to set a path for header, etc files depending on whether
119 # we're standalone or embedded. this is taken care of by HWLOC_EMBEDDED.
121 AC_MSG_CHECKING([for hwloc directory prefix])
122 AC_MSG_RESULT(m4_ifval([$1], hwloc_config_prefix, [(none)]))
124 # Note that private/config.h *MUST* be listed first so that it
125 # becomes the "main" config header file. Any AC-CONFIG-HEADERS
126 # after that (hwloc/config.h) will only have selective #defines
127 # replaced, not the entire file.
128 AC_CONFIG_HEADERS(hwloc_config_prefix[include/private/autogen/config.h])
129 AC_CONFIG_HEADERS(hwloc_config_prefix[include/hwloc/autogen/config.h])
131 # What prefix are we using?
132 AC_MSG_CHECKING([for hwloc symbol prefix])
133 AS_IF([test "$hwloc_symbol_prefix_value" = ""],
134 [AS_IF([test "$with_hwloc_symbol_prefix" = ""],
135 [hwloc_symbol_prefix_value=hwloc_],
136 [hwloc_symbol_prefix_value=$with_hwloc_symbol_prefix])])
137 AC_DEFINE_UNQUOTED(HWLOC_SYM_PREFIX, [$hwloc_symbol_prefix_value],
138 [The hwloc symbol prefix])
139 # Ensure to [] escape the whole next line so that we can get the
141 [hwloc_symbol_prefix_value_caps="`echo $hwloc_symbol_prefix_value | tr '[:lower:]' '[:upper:]'`"]
142 AC_DEFINE_UNQUOTED(HWLOC_SYM_PREFIX_CAPS, [$hwloc_symbol_prefix_value_caps],
143 [The hwloc symbol prefix in all caps])
144 AC_MSG_RESULT([$hwloc_symbol_prefix_value])
146 # Give an easy #define to know if we need to transform all the
148 AH_TEMPLATE([HWLOC_SYM_TRANSFORM], [Whether we need to re-define all the hwloc public symbols or not])
149 AS_IF([test "$hwloc_symbol_prefix_value" = "hwloc_"],
150 [AC_DEFINE([HWLOC_SYM_TRANSFORM], [0])],
151 [AC_DEFINE([HWLOC_SYM_TRANSFORM], [1])])
154 if test "x$GCC" = "xyes"; then
155 HWLOC_GCC_CFLAGS="-Wall -Wmissing-prototypes -Wundef"
156 HWLOC_GCC_CFLAGS="$HWLOC_GCC_CFLAGS -Wpointer-arith -Wcast-align"
159 # Enample system extensions for O_DIRECTORY, fdopen, fssl, etc.
160 AH_VERBATIM([USE_HPUX_SYSTEM_EXTENSIONS],
161 [/* Enable extensions on HP-UX. */
166 AC_DEFINE([_HPUX_SOURCE], [1], [Are we building for HP-UX?])
170 # Check to see if we're producing a 32 or 64 bit executable by
171 # checking the sizeof void*. Note that AC CHECK_SIZEOF even works
172 # when cross compiling (!), according to the AC 2.64 docs. This
173 # check is needed because on some systems, you can instruct the
174 # compiler to specifically build 32 or 64 bit executables -- even
175 # though the $target may indicate something different.
176 AC_CHECK_SIZEOF([void *])
179 # List of components to be built, either statically or dynamically.
180 # To be enlarged below.
182 hwloc_components="noos xml synthetic custom xml_nolibxml"
187 AC_MSG_CHECKING([which OS support to include])
189 powerpc64-bgq-linux*) # must be before Linux
190 AC_DEFINE(HWLOC_BGQ_SYS, 1, [Define to 1 on BlueGene/Q])
193 hwloc_components="$hwloc_components bgq"
196 AC_DEFINE(HWLOC_LINUX_SYS, 1, [Define to 1 on Linux])
198 AC_MSG_RESULT([Linux])
199 hwloc_components="$hwloc_components linux"
200 if test x$enable_pci != xno; then
201 hwloc_components="$hwloc_components linuxpci"
202 AC_DEFINE(HWLOC_HAVE_LINUXPCI, 1, [Define to 1 if building the Linux PCI component])
203 hwloc_linuxpci_happy=yes
207 AC_DEFINE(HWLOC_IRIX_SYS, 1, [Define to 1 on Irix])
209 AC_MSG_RESULT([IRIX])
210 # no irix component yet
213 AC_DEFINE(HWLOC_DARWIN_SYS, 1, [Define to 1 on Darwin])
215 AC_MSG_RESULT([Darwin])
216 hwloc_components="$hwloc_components darwin"
219 AC_DEFINE(HWLOC_SOLARIS_SYS, 1, [Define to 1 on Solaris])
221 AC_MSG_RESULT([Solaris])
222 hwloc_components="$hwloc_components solaris"
225 AC_DEFINE(HWLOC_AIX_SYS, 1, [Define to 1 on AIX])
228 hwloc_components="$hwloc_components aix"
231 AC_DEFINE(HWLOC_OSF_SYS, 1, [Define to 1 on OSF])
234 hwloc_components="$hwloc_components osf"
237 AC_DEFINE(HWLOC_HPUX_SYS, 1, [Define to 1 on HP-UX])
239 AC_MSG_RESULT([HP-UX])
240 hwloc_components="$hwloc_components hpux"
242 *-*-mingw*|*-*-cygwin*)
243 AC_DEFINE(HWLOC_WIN_SYS, 1, [Define to 1 on WINDOWS])
245 AC_MSG_RESULT([Windows])
246 hwloc_components="$hwloc_components windows"
249 AC_DEFINE(HWLOC_FREEBSD_SYS, 1, [Define to 1 on *FREEBSD])
251 AC_MSG_RESULT([FreeBSD])
252 hwloc_components="$hwloc_components freebsd"
255 AC_DEFINE(HWLOC_NETBSD_SYS, 1, [Define to 1 on *NETBSD])
257 AC_MSG_RESULT([NetBSD])
258 hwloc_components="$hwloc_components netbsd"
261 AC_MSG_RESULT([Unsupported! ($target)])
262 AC_DEFINE(HWLOC_UNSUPPORTED_SYS, 1, [Define to 1 on unsupported systems])
263 AC_MSG_WARN([***********************************************************])
264 AC_MSG_WARN([*** hwloc does not support this system.])
265 AC_MSG_WARN([*** hwloc will *attempt* to build (but it may not work).])
266 AC_MSG_WARN([*** hwloc run-time results may be reduced to showing just one processor,])
267 AC_MSG_WARN([*** and binding will likely not be supported.])
268 AC_MSG_WARN([*** You have been warned.])
269 AC_MSG_WARN([*** Pausing to give you time to read this message...])
270 AC_MSG_WARN([***********************************************************])
278 AC_MSG_CHECKING([which CPU support to include])
280 i*86-*-*|x86_64-*-*|amd64-*-*)
281 case ${ac_cv_sizeof_void_p} in
283 AC_DEFINE(HWLOC_X86_32_ARCH, 1, [Define to 1 on x86_32])
285 HWLOC_MS_LIB_ARCH=X86
286 AC_MSG_RESULT([x86_32])
289 AC_DEFINE(HWLOC_X86_64_ARCH, 1, [Define to 1 on x86_64])
291 HWLOC_MS_LIB_ARCH=X64
292 AC_MSG_RESULT([x86_64])
295 AC_DEFINE(HWLOC_X86_64_ARCH, 1, [Define to 1 on x86_64])
297 HWLOC_MS_LIB_ARCH=X64
298 AC_MSG_RESULT([unknown -- assuming x86_64])
303 AC_MSG_RESULT([unknown])
306 AC_SUBST(HWLOC_MS_LIB_ARCH)
308 AC_CHECK_SIZEOF([unsigned long])
309 AC_DEFINE_UNQUOTED([HWLOC_SIZEOF_UNSIGNED_LONG], $ac_cv_sizeof_unsigned_long, [The size of `unsigned long', as computed by sizeof])
310 AC_CHECK_SIZEOF([unsigned int])
311 AC_DEFINE_UNQUOTED([HWLOC_SIZEOF_UNSIGNED_INT], $ac_cv_sizeof_unsigned_int, [The size of `unsigned int', as computed by sizeof])
314 # Check for compiler attributes and visibility
316 _HWLOC_C_COMPILER_VENDOR([hwloc_c_vendor])
317 _HWLOC_CHECK_ATTRIBUTES
318 _HWLOC_CHECK_VISIBILITY
319 HWLOC_CFLAGS="$HWLOC_FLAGS $HWLOC_VISIBILITY_CFLAGS"
320 AS_IF([test "$HWLOC_VISIBILITY_CFLAGS" != ""],
321 [AC_MSG_WARN(["$HWLOC_VISIBILITY_CFLAGS" has been added to the hwloc CFLAGS])])
323 # Make sure the compiler returns an error code when function arg
324 # count is wrong, otherwise sched_setaffinity checks may fail.
325 HWLOC_STRICT_ARGS_CFLAGS=
327 AC_MSG_CHECKING([whether the C compiler rejects function calls with too many arguments])
328 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
329 extern int one_arg(int x);
330 int foo(void) { return one_arg(1, 2); }
332 [AC_MSG_RESULT([no])],
334 AC_MSG_RESULT([yes])])
335 AC_MSG_CHECKING([whether the C compiler rejects function calls with too few arguments])
336 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
337 extern int two_arg(int x, int y);
338 int foo(void) { return two_arg(3); }
340 [AC_MSG_RESULT([no])],
341 [hwloc_args_check=`expr $hwloc_args_check + 1`
342 AC_MSG_RESULT([yes])])
343 AS_IF([test "$hwloc_args_check" != "2"],[
344 AC_MSG_WARN([Your C compiler does not consider incorrect argument counts to be a fatal error.])
345 case "$hwloc_c_vendor" in
347 HWLOC_STRICT_ARGS_CFLAGS="-qhalt=e"
350 HWLOC_STRICT_ARGS_CFLAGS="-we140"
353 HWLOC_STRICT_ARGS_CFLAGS=FAIL
354 AC_MSG_WARN([Please report this warning and configure using a different C compiler if possible.])
357 AS_IF([test "$HWLOC_STRICT_ARGS_CFLAGS" != "FAIL"],[
358 AC_MSG_WARN([Configure will append '$HWLOC_STRICT_ARGS_CFLAGS' to the value of CFLAGS when needed.])
359 AC_MSG_WARN([Alternatively you may configure with a different compiler.])
367 AC_CHECK_HEADERS([unistd.h])
368 AC_CHECK_HEADERS([dirent.h])
369 AC_CHECK_HEADERS([strings.h])
370 AC_CHECK_HEADERS([ctype.h])
372 AC_CHECK_FUNCS([strcasecmp], [
373 _HWLOC_CHECK_DECL([strcasecmp], [
374 AC_DEFINE([HWLOC_HAVE_DECL_STRCASECMP], [1], [Define to 1 if function `strcasecmp' is declared by system headers])
377 AC_CHECK_FUNCS([strncasecmp], [
378 _HWLOC_CHECK_DECL([strncasecmp], [
379 AC_DEFINE([HWLOC_HAVE_DECL_STRNCASECMP], [1], [Define to 1 if function `strncasecmp' is declared by system headers])
383 AC_CHECK_FUNCS([strftime])
384 AC_CHECK_FUNCS([setlocale])
386 AC_CHECK_HEADER([stdint.h], [
387 AC_DEFINE([HWLOC_HAVE_STDINT_H], [1], [Define to 1 if you have the <stdint.h> header file.])
389 AC_CHECK_HEADERS([sys/mman.h])
391 old_CPPFLAGS="$CPPFLAGS"
392 CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0601"
393 AC_CHECK_TYPES([KAFFINITY,
394 PROCESSOR_CACHE_TYPE,
396 LOGICAL_PROCESSOR_RELATIONSHIP,
397 RelationProcessorPackage,
398 SYSTEM_LOGICAL_PROCESSOR_INFORMATION,
400 PROCESSOR_RELATIONSHIP,
401 NUMA_NODE_RELATIONSHIP,
403 PROCESSOR_GROUP_INFO,
405 SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX,
406 PSAPI_WORKING_SET_EX_BLOCK,
407 PSAPI_WORKING_SET_EX_INFORMATION,
409 [],[],[[#include <windows.h>]])
410 CPPFLAGS="$old_CPPFLAGS"
411 AC_CHECK_LIB([gdi32], [main],
412 [HWLOC_LIBS="-lgdi32 $HWLOC_LIBS"
413 AC_DEFINE([HAVE_LIBGDI32], 1, [Define to 1 if we have -lgdi32])])
414 AC_CHECK_LIB([user32], [PostQuitMessage], [hwloc_have_user32="yes"])
416 AC_CHECK_HEADER([windows.h], [
417 AC_DEFINE([HWLOC_HAVE_WINDOWS_H], [1], [Define to 1 if you have the `windows.h' header.])
420 AC_CHECK_HEADERS([sys/lgrp_user.h], [
421 AC_CHECK_LIB([lgrp], [lgrp_init],
422 [HWLOC_LIBS="-llgrp $HWLOC_LIBS"
423 AC_DEFINE([HAVE_LIBLGRP], 1, [Define to 1 if we have -llgrp])
424 AC_CHECK_DECLS([lgrp_latency_cookie],,,[[#include <sys/lgrp_user.h>]])
427 AC_CHECK_HEADERS([kstat.h], [
428 AC_CHECK_LIB([kstat], [main],
429 [HWLOC_LIBS="-lkstat $HWLOC_LIBS"
430 AC_DEFINE([HAVE_LIBKSTAT], 1, [Define to 1 if we have -lkstat])])
433 AC_CHECK_DECLS([fabsf], [
434 AC_CHECK_LIB([m], [fabsf],
436 ], [], [[#include <math.h>]])
437 AC_CHECK_DECLS([modff], [
438 AC_CHECK_LIB([m], [modff],
440 ], [], [[#include <math.h>]])
441 if test x$need_libm = xyes; then
442 HWLOC_LIBS="-lm $HWLOC_LIBS"
445 AC_CHECK_HEADERS([picl.h], [
446 AC_CHECK_LIB([picl], [picl_initialize],
447 [HWLOC_LIBS="-lpicl $HWLOC_LIBS"])])
449 AC_CHECK_DECLS([_SC_NPROCESSORS_ONLN,
450 _SC_NPROCESSORS_CONF,
455 _SC_LARGE_PAGESIZE],,[:],[[#include <unistd.h>]])
457 AC_HAVE_HEADERS([mach/mach_host.h])
458 AC_HAVE_HEADERS([mach/mach_init.h], [
459 AC_CHECK_FUNCS([host_info])
462 AC_CHECK_HEADERS([sys/param.h])
463 AC_CHECK_HEADERS([sys/sysctl.h], [
464 AC_CHECK_DECLS([CTL_HW, HW_NCPU],,,[[
466 #include <sys/param.h>
468 #include <sys/sysctl.h>
473 #include <sys/param.h>
477 AC_CHECK_DECLS([strtoull], [], [AC_CHECK_FUNCS([strtoull])], [AC_INCLUDES_DEFAULT])
479 # Needed for Windows in private/misc.h
480 AC_CHECK_TYPES([ssize_t])
481 AC_CHECK_DECLS([snprintf], [], [], [AC_INCLUDES_DEFAULT])
482 # strdup and putenv are declared in windows headers but marked deprecated
483 AC_CHECK_DECLS([_strdup], [], [], [AC_INCLUDES_DEFAULT])
484 AC_CHECK_DECLS([_putenv], [], [], [AC_INCLUDES_DEFAULT])
485 # Could add mkdir and access for hwloc-gather-cpuid.c on Windows
487 if test "x$hwloc_linux" != "xyes" ; then
488 # Don't detect sysctl* on Linux because its sysctl() syscall is
489 # long deprecated and unneeded. Some libc still expose the symbol
490 # and raise a big warning at link time.
492 # Do a full link test instead of just using AC_CHECK_FUNCS, which
493 # just checks to see if the symbol exists or not. For example,
494 # the prototype of sysctl uses u_int, which on some platforms
495 # (such as FreeBSD) is only defined under __BSD_VISIBLE, __USE_BSD
496 # or other similar definitions. So while the symbols "sysctl" and
497 # "sysctlbyname" might still be available in libc (which autoconf
498 # checks for), they might not be actually usable.
499 AC_MSG_CHECKING([for sysctl])
502 #include <sys/types.h>
503 #include <sys/sysctl.h>
505 [return sysctl(NULL,0,NULL,NULL,NULL,0);],
506 [AC_DEFINE([HAVE_SYSCTL],[1],[Define to '1' if sysctl is present and usable])
509 AC_MSG_CHECKING([for sysctlbyname])
512 #include <sys/types.h>
513 #include <sys/sysctl.h>
515 [return sysctlbyname(NULL,NULL,NULL,NULL,0);],
516 [AC_DEFINE([HAVE_SYSCTLBYNAME],[1],[Define to '1' if sysctlbyname is present and usable])
521 AC_CHECK_DECLS([getprogname], [], [], [AC_INCLUDES_DEFAULT])
522 AC_CHECK_DECLS([getexecname], [], [], [AC_INCLUDES_DEFAULT])
523 AC_CHECK_DECLS([GetModuleFileName], [], [], [#include <windows.h>])
524 # program_invocation_name and __progname may be available but not exported in headers
525 AC_MSG_CHECKING([for program_invocation_name])
532 extern char *program_invocation_name;
534 return printf("%s\n", program_invocation_name);
536 [AC_DEFINE([HAVE_PROGRAM_INVOCATION_NAME], [1], [Define to '1' if program_invocation_name is present and usable])
538 ],[AC_MSG_RESULT([no])])
539 AC_MSG_CHECKING([for __progname])
542 extern char *__progname;
544 return printf("%s\n", __progname);
546 [AC_DEFINE([HAVE___PROGNAME], [1], [Define to '1' if __progname is present and usable])
548 ],[AC_MSG_RESULT([no])])
551 *-*-mingw*|*-*-cygwin*)
553 hwloc_thread_t=HANDLE
557 AC_CHECK_TYPES([pthread_t], [hwloc_thread_t=pthread_t], [:], [[#include <pthread.h>]])
560 AC_DEFINE_UNQUOTED(hwloc_pid_t, $hwloc_pid_t, [Define this to the process ID type])
561 if test "x$hwloc_thread_t" != "x" ; then
562 AC_DEFINE_UNQUOTED(hwloc_thread_t, $hwloc_thread_t, [Define this to the thread ID type])
565 AC_CHECK_DECLS([sched_getcpu],,[:],[[
572 _HWLOC_CHECK_DECL([sched_setaffinity], [
573 AC_DEFINE([HWLOC_HAVE_SCHED_SETAFFINITY], [1], [Define to 1 if glibc provides a prototype of sched_setaffinity()])
574 AS_IF([test "$HWLOC_STRICT_ARGS_CFLAGS" = "FAIL"],[
575 AC_MSG_WARN([Support for sched_setaffinity() requires a C compiler which])
576 AC_MSG_WARN([considers incorrect argument counts to be a fatal error.])
577 AC_MSG_ERROR([Cannot continue.])
579 AC_MSG_CHECKING([for old prototype of sched_setaffinity])
580 hwloc_save_CFLAGS=$CFLAGS
581 CFLAGS="$CFLAGS $HWLOC_STRICT_ARGS_CFLAGS"
588 static unsigned long mask;
589 ]], [[ sched_setaffinity(0, (void*) &mask); ]])],
590 [AC_DEFINE([HWLOC_HAVE_OLD_SCHED_SETAFFINITY], [1], [Define to 1 if glibc provides the old prototype (without length) of sched_setaffinity()])
591 AC_MSG_RESULT([yes])],
592 [AC_MSG_RESULT([no])])
593 CFLAGS=$hwloc_save_CFLAGS
601 AC_MSG_CHECKING([for working CPU_SET])
606 ]], [[ CPU_ZERO(&set); CPU_SET(0, &set);]])],
607 [AC_DEFINE([HWLOC_HAVE_CPU_SET], [1], [Define to 1 if the CPU_SET macro works])
608 AC_MSG_RESULT([yes])],
609 [AC_MSG_RESULT([no])])
611 AC_MSG_CHECKING([for working CPU_SET_S])
617 set = CPU_ALLOC(1024);
618 CPU_ZERO_S(CPU_ALLOC_SIZE(1024), set);
619 CPU_SET_S(CPU_ALLOC_SIZE(1024), 0, set);
622 [AC_DEFINE([HWLOC_HAVE_CPU_SET_S], [1], [Define to 1 if the CPU_SET_S macro works])
623 AC_MSG_RESULT([yes])],
624 [AC_MSG_RESULT([no])])
626 AC_MSG_CHECKING([for working syscall])
630 #include <sys/syscall.h>
631 ]], [[syscall(1, 2, 3);]])],
632 [AC_DEFINE([HWLOC_HAVE_SYSCALL], [1], [Define to 1 if function `syscall' is available])
633 AC_MSG_RESULT([yes])],
634 [AC_MSG_RESULT([no])])
636 # Check for kerrighed, but don't abort if not found. It's illegal
637 # to pass in an empty 3rd argument, but we trust the output of
638 # pkg-config, so just give it a value that will always work:
640 HWLOC_PKG_CHECK_MODULES([KERRIGHED], [kerrighed >= 2.0], [printf], [stdio.h], [], [:])
642 AC_PATH_PROGS([HWLOC_MS_LIB], [lib])
643 AC_ARG_VAR([HWLOC_MS_LIB], [Path to Microsoft's Visual Studio `lib' tool])
645 AC_PATH_PROG([BASH], [bash])
647 AC_CHECK_FUNCS([ffs], [
648 _HWLOC_CHECK_DECL([ffs],[
649 AC_DEFINE([HWLOC_HAVE_DECL_FFS], [1], [Define to 1 if function `ffs' is declared by system headers])
651 AC_DEFINE([HWLOC_HAVE_FFS], [1], [Define to 1 if you have the `ffs' function.])
652 if ( $CC --version | grep gccfss ) >/dev/null 2>&1 ; then
653 dnl May be broken due to
654 dnl https://forums.oracle.com/forums/thread.jspa?threadID=1997328
655 dnl TODO: a more selective test, since bug may be version dependent.
656 dnl We can't use AC_TRY_LINK because the failure does not appear until
657 dnl run/load time and there is currently no precedent for AC_TRY_RUN
658 dnl use in hwloc. --PHH
659 dnl For now, we're going with "all gccfss compilers are broken".
660 dnl Better to be safe and correct; it's not like this is
661 dnl performance-critical code, after all.
662 AC_DEFINE([HWLOC_HAVE_BROKEN_FFS], [1],
663 [Define to 1 if your `ffs' function is known to be broken.])
666 AC_CHECK_FUNCS([ffsl], [
667 _HWLOC_CHECK_DECL([ffsl],[
668 AC_DEFINE([HWLOC_HAVE_DECL_FFSL], [1], [Define to 1 if function `ffsl' is declared by system headers])
670 AC_DEFINE([HWLOC_HAVE_FFSL], [1], [Define to 1 if you have the `ffsl' function.])
673 AC_CHECK_FUNCS([fls], [
674 _HWLOC_CHECK_DECL([fls],[
675 AC_DEFINE([HWLOC_HAVE_DECL_FLS], [1], [Define to 1 if function `fls' is declared by system headers])
677 AC_DEFINE([HWLOC_HAVE_FLS], [1], [Define to 1 if you have the `fls' function.])
679 AC_CHECK_FUNCS([flsl], [
680 _HWLOC_CHECK_DECL([flsl],[
681 AC_DEFINE([HWLOC_HAVE_DECL_FLSL], [1], [Define to 1 if function `flsl' is declared by system headers])
683 AC_DEFINE([HWLOC_HAVE_FLSL], [1], [Define to 1 if you have the `flsl' function.])
686 AC_CHECK_FUNCS([clz], [
687 _HWLOC_CHECK_DECL([clz],[
688 AC_DEFINE([HWLOC_HAVE_DECL_CLZ], [1], [Define to 1 if function `clz' is declared by system headers])
690 AC_DEFINE([HWLOC_HAVE_CLZ], [1], [Define to 1 if you have the `clz' function.])
692 AC_CHECK_FUNCS([clzl], [
693 _HWLOC_CHECK_DECL([clzl],[
694 AC_DEFINE([HWLOC_HAVE_DECL_CLZL], [1], [Define to 1 if function `clzl' is declared by system headers])
696 AC_DEFINE([HWLOC_HAVE_CLZL], [1], [Define to 1 if you have the `clzl' function.])
699 AS_IF([test "$hwloc_c_vendor" != "android"], [AC_CHECK_FUNCS([openat], [hwloc_have_openat=yes])])
702 AC_CHECK_HEADERS([malloc.h])
703 AC_CHECK_FUNCS([getpagesize memalign posix_memalign])
705 AC_CHECK_HEADERS([sys/utsname.h])
706 AC_CHECK_FUNCS([uname])
708 dnl Don't check for valgrind in embedded mode because this may conflict
709 dnl with the embedder projects also checking for it.
710 dnl We only use Valgrind to nicely disable the x86 backend with a warning,
711 dnl but we can live without it in embedded mode (it auto-disables itself
712 dnl because of invalid CPUID outputs).
713 dnl Non-embedded checks usually go to hwloc_internal.m4 but this one is
714 dnl is really for the core library.
715 AS_IF([test "$hwloc_mode" != "embedded"],
716 [AC_CHECK_HEADERS([valgrind/valgrind.h])
717 AC_CHECK_DECLS([RUNNING_ON_VALGRIND],,[:],[[#include <valgrind/valgrind.h>]])
719 AC_DEFINE([HAVE_DECL_RUNNING_ON_VALGRIND], [0], [Embedded mode; just assume we do not have Valgrind support])
722 AC_CHECK_HEADERS([pthread_np.h])
723 AC_CHECK_DECLS([pthread_setaffinity_np],,[:],[[
725 #ifdef HAVE_PTHREAD_NP_H
726 # include <pthread_np.h>
729 AC_CHECK_DECLS([pthread_getaffinity_np],,[:],[[
731 #ifdef HAVE_PTHREAD_NP_H
732 # include <pthread_np.h>
735 AC_CHECK_FUNC([sched_setaffinity], [hwloc_have_sched_setaffinity=yes])
736 AC_CHECK_HEADERS([sys/cpuset.h],,,[[#include <sys/param.h>]])
737 AC_CHECK_FUNCS([cpuset_setaffinity])
738 AC_SEARCH_LIBS([pthread_getthrds_np], [pthread],
739 AC_DEFINE([HWLOC_HAVE_PTHREAD_GETTHRDS_NP], 1, `Define to 1 if you have pthread_getthrds_np')
741 AC_CHECK_FUNCS([cpuset_setid])
743 # Linux libnuma support
744 hwloc_linux_libnuma_happy=no
745 if test "x$enable_libnuma" != "xno"; then
746 hwloc_linux_libnuma_happy=yes
747 AC_CHECK_HEADERS([numaif.h], [
748 AC_CHECK_LIB([numa], [numa_available], [HWLOC_LINUX_LIBNUMA_LIBS="-lnuma"], [hwloc_linux_libnuma_happy=no])
749 ], [hwloc_linux_libnuma_happy=no])
751 AC_SUBST(HWLOC_LINUX_LIBNUMA_LIBS)
752 # If we asked for Linux libnuma support but couldn't deliver, fail
753 HWLOC_LIBS="$HWLOC_LIBS $HWLOC_LINUX_LIBNUMA_LIBS"
754 AS_IF([test "$enable_libnuma" = "yes" -a "$hwloc_linux_libnuma_happy" = "no"],
755 [AC_MSG_WARN([Specified --enable-libnuma switch, but could not])
756 AC_MSG_WARN([find appropriate support])
757 AC_MSG_ERROR([Cannot continue])])
758 if test "x$hwloc_linux_libnuma_happy" = "xyes"; then
759 tmp_save_LIBS="$LIBS"
760 LIBS="$LIBS $HWLOC_LINUX_LIBNUMA_LIBS"
762 AC_CHECK_LIB([numa], [set_mempolicy], [
763 enable_set_mempolicy=yes
764 AC_DEFINE([HWLOC_HAVE_SET_MEMPOLICY], [1], [Define to 1 if set_mempolicy is available.])
766 AC_CHECK_LIB([numa], [mbind], [
768 AC_DEFINE([HWLOC_HAVE_MBIND], [1], [Define to 1 if mbind is available.])
770 AC_CHECK_LIB([numa], [migrate_pages], [
771 enable_migrate_pages=yes
772 AC_DEFINE([HWLOC_HAVE_MIGRATE_PAGES], [1], [Define to 1 if migrate_pages is available.])
774 AC_CHECK_LIB([numa], [move_pages], [
775 AC_DEFINE([HWLOC_HAVE_MOVE_PAGES], [1], [Define to 1 if move_pages is available.])
778 LIBS="$tmp_save_LIBS"
781 # Linux libudev support
782 if test "x$enable_libudev" != xno; then
783 AC_CHECK_HEADERS([libudev.h], [
784 AC_CHECK_LIB([udev], [udev_device_new_from_subsystem_sysname], [
785 HWLOC_LIBS="$HWLOC_LIBS -ludev"
786 AC_DEFINE([HWLOC_HAVE_LIBUDEV], [1], [Define to 1 if you have libudev.])
791 # PCI support via libpciaccess. NOTE: we do not support
792 # libpci/pciutils because that library is GPL and is incompatible
793 # with our BSD license.
795 if test "x$enable_pci" != xno; then
797 HWLOC_PKG_CHECK_MODULES([PCIACCESS], [pciaccess], [pci_slot_match_iterator_create], [pciaccess.h], [:], [hwloc_pci_happy=no])
799 # Only add the REQUIRES if we got pciaccess through pkg-config.
800 # Otherwise we don't know if pciaccess.pc is installed
801 AS_IF([test "$hwloc_pci_happy" = "yes"], [HWLOC_PCIACCESS_REQUIRES=pciaccess])
803 # Just for giggles, if we didn't find a pciaccess pkg-config,
804 # just try looking for its header file and library.
805 AS_IF([test "$hwloc_pci_happy" != "yes"],
806 [AC_CHECK_HEADER([pciaccess.h],
807 [AC_CHECK_LIB([pciaccess], [pci_slot_match_iterator_create],
809 HWLOC_PCIACCESS_LIBS="-lpciaccess"])
813 AS_IF([test "$hwloc_pci_happy" = "yes"],
814 [hwloc_pci_lib=pciaccess
815 hwloc_components="$hwloc_components pci"
816 hwloc_pci_component_maybeplugin=1])
818 # If we asked for pci support but couldn't deliver, fail
819 AS_IF([test "$enable_pci" = "yes" -a "$hwloc_pci_happy" = "no"],
820 [AC_MSG_WARN([Specified --enable-pci switch, but could not])
821 AC_MSG_WARN([find appropriate support])
822 AC_MSG_ERROR([Cannot continue])])
823 # don't add LIBS/CFLAGS/REQUIRES yet, depends on plugins
826 hwloc_opencl_happy=no
827 if test "x$enable_opencl" != "xno"; then
828 hwloc_opencl_happy=yes
831 # On Darwin, only use the OpenCL framework
832 AC_CHECK_HEADERS([OpenCL/cl_ext.h], [
833 AC_MSG_CHECKING([for the OpenCL framework])
834 tmp_save_LDFLAGS="$LDFLAGS"
835 LDFLAGS="$LDFLAGS -framework OpenCL"
838 #include <OpenCL/opencl.h>
840 return clGetDeviceIDs(0, 0, 0, NULL, NULL);
843 HWLOC_OPENCL_LDFLAGS="-framework OpenCL"],
845 hwloc_opencl_happy=no])
846 LDFLAGS="$tmp_save_LDFLAGS"
847 ], [hwloc_opencl_happy=no])
850 # On Others, look for OpenCL at normal locations
851 AC_CHECK_HEADERS([CL/cl_ext.h], [
852 AC_CHECK_LIB([OpenCL], [clGetDeviceIDs], [HWLOC_OPENCL_LIBS="-lOpenCL"], [hwloc_opencl_happy=no])
853 ], [hwloc_opencl_happy=no])
857 AC_SUBST(HWLOC_OPENCL_CFLAGS)
858 AC_SUBST(HWLOC_OPENCL_LIBS)
859 AC_SUBST(HWLOC_OPENCL_LDFLAGS)
860 # Check if required extensions are available
861 if test "x$hwloc_opencl_happy" = "xyes"; then
862 tmp_save_CFLAGS="$CFLAGS"
863 CFLAGS="$CFLAGS $HWLOC_OPENCL_CFLAGS"
864 tmp_save_LIBS="$LIBS"
865 LIBS="$LIBS $HWLOC_OPENCL_LIBS"
866 AC_CHECK_DECLS([CL_DEVICE_TOPOLOGY_AMD],[hwloc_opencl_amd_happy=yes],[:],[[#include <CL/cl_ext.h>]])
867 CFLAGS="$tmp_save_CFLAGS"
868 LIBS="$tmp_save_LIBS"
869 # We can't do anything without CL_DEVICE_TOPOLOGY_AMD so far, so disable OpenCL entirely if not found
870 test "x$hwloc_opencl_amd_happy" != "xyes" && hwloc_opencl_happy=no
872 # If we asked for opencl support but couldn't deliver, fail
873 AS_IF([test "$enable_opencl" = "yes" -a "$hwloc_opencl_happy" = "no"],
874 [AC_MSG_WARN([Specified --enable-opencl switch, but could not])
875 AC_MSG_WARN([find appropriate support])
876 AC_MSG_ERROR([Cannot continue])])
877 if test "x$hwloc_opencl_happy" = "xyes"; then
878 AC_DEFINE([HWLOC_HAVE_OPENCL], [1], [Define to 1 if you have the `OpenCL' library.])
879 AC_SUBST([HWLOC_HAVE_OPENCL], [1])
880 hwloc_components="$hwloc_components opencl"
881 hwloc_opencl_component_maybeplugin=1
883 AC_SUBST([HWLOC_HAVE_OPENCL], [0])
885 # don't add LIBS/CFLAGS/REQUIRES yet, depends on plugins
890 if test "x$enable_cuda" != "xno"; then
891 AC_CHECK_HEADERS([cuda.h], [
892 AC_MSG_CHECKING(if CUDA_VERSION >= 3020)
893 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
896 #error CUDA_VERSION undefined
897 #elif CUDA_VERSION < 3020
898 #error CUDA_VERSION too old
899 #endif]], [[int i = 3;]])],
901 AC_CHECK_LIB([cuda], [cuInit],
902 [AC_DEFINE([HAVE_CUDA], 1, [Define to 1 if we have -lcuda])
903 hwloc_have_cuda=yes])],
904 [AC_MSG_RESULT(no)])])
906 AC_CHECK_HEADERS([cuda_runtime_api.h], [
907 AC_MSG_CHECKING(if CUDART_VERSION >= 3020)
908 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
909 #include <cuda_runtime_api.h>
910 #ifndef CUDART_VERSION
911 #error CUDART_VERSION undefined
912 #elif CUDART_VERSION < 3020
913 #error CUDART_VERSION too old
914 #endif]], [[int i = 3;]])],
916 AC_CHECK_LIB([cudart], [cudaGetDeviceProperties], [
917 HWLOC_CUDA_LIBS="-lcudart"
918 AC_SUBST(HWLOC_CUDA_LIBS)
919 hwloc_have_cudart=yes
920 AC_DEFINE([HWLOC_HAVE_CUDART], [1], [Define to 1 if you have the `cudart' SDK.])
925 AS_IF([test "$enable_cuda" = "yes" -a "$hwloc_have_cudart" = "no"],
926 [AC_MSG_WARN([Specified --enable-cuda switch, but could not])
927 AC_MSG_WARN([find appropriate support])
928 AC_MSG_ERROR([Cannot continue])])
930 if test "x$hwloc_have_cudart" = "xyes"; then
931 hwloc_components="$hwloc_components cuda"
932 hwloc_cuda_component_maybeplugin=1
935 # don't add LIBS/CFLAGS yet, depends on plugins
939 if test "x$enable_nvml" != "xno"; then
941 AC_CHECK_HEADERS([nvml.h], [
942 AC_CHECK_LIB([nvidia-ml], [nvmlInit], [HWLOC_NVML_LIBS="-lnvidia-ml"], [hwloc_nvml_happy=no])
943 ], [hwloc_nvml_happy=no])
945 if test "x$hwloc_nvml_happy" = "xyes"; then
946 tmp_save_CFLAGS="$CFLAGS"
947 CFLAGS="$CFLAGS $HWLOC_NVML_CFLAGS"
948 tmp_save_LIBS="$LIBS"
949 LIBS="$LIBS $HWLOC_NVML_LIBS"
950 AC_CHECK_DECLS([nvmlDeviceGetMaxPcieLinkGeneration],,[:],[[#include <nvml.h>]])
951 CFLAGS="$tmp_save_CFLAGS"
952 LIBS="$tmp_save_LIBS"
954 AC_SUBST(HWLOC_NVML_LIBS)
955 # If we asked for nvml support but couldn't deliver, fail
956 AS_IF([test "$enable_nvml" = "yes" -a "$hwloc_nvml_happy" = "no"],
957 [AC_MSG_WARN([Specified --enable-nvml switch, but could not])
958 AC_MSG_WARN([find appropriate support])
959 AC_MSG_ERROR([Cannot continue])])
960 if test "x$hwloc_nvml_happy" = "xyes"; then
961 AC_DEFINE([HWLOC_HAVE_NVML], [1], [Define to 1 if you have the `NVML' library.])
962 AC_SUBST([HWLOC_HAVE_NVML], [1])
963 hwloc_components="$hwloc_components nvml"
964 hwloc_nvml_component_maybeplugin=1
966 AC_SUBST([HWLOC_HAVE_NVML], [0])
968 # don't add LIBS/CFLAGS/REQUIRES yet, depends on plugins
973 CPPFLAGS_save=$CPPFLAGS
976 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
977 LIBS="$LIBS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS"
978 AC_CHECK_HEADERS([X11/Xlib.h],
979 [AC_CHECK_LIB([X11], [XOpenDisplay],
981 # the GL backend just needs XOpenDisplay
984 AC_CHECK_HEADERS([X11/Xutil.h],
985 [AC_CHECK_HEADERS([X11/keysym.h],
986 [AC_DEFINE([HWLOC_HAVE_X11_KEYSYM], [1], [Define to 1 if X11 headers including Xutil.h and keysym.h are available.])
987 HWLOC_X11_CPPFLAGS="$X_CFLAGS"
988 AC_SUBST([HWLOC_X11_CPPFLAGS])
989 HWLOC_X11_LIBS="$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
990 AC_SUBST([HWLOC_X11_LIBS])])
991 ], [], [#include <X11/Xlib.h>])
994 CPPFLAGS=$CPPFLAGS_save
999 if test "x$enable_gl" != "xno"; then
1002 AS_IF([test "$hwloc_enable_X11" != "yes"],
1003 [AC_MSG_WARN([X11 not found; GL disabled])
1006 AC_CHECK_HEADERS([NVCtrl/NVCtrl.h], [
1007 AC_CHECK_LIB([XNVCtrl], [XNVCTRLQueryTargetAttribute], [:], [hwloc_gl_happy=no], [-lXext])
1008 ], [hwloc_gl_happy=no])
1010 if test "x$hwloc_gl_happy" = "xyes"; then
1011 AC_DEFINE([HWLOC_HAVE_GL], [1], [Define to 1 if you have the GL module components.])
1012 HWLOC_GL_LIBS="-lXNVCtrl -lXext -lX11"
1013 AC_SUBST(HWLOC_GL_LIBS)
1014 # FIXME we actually don't know if xext.pc and x11.pc are installed
1015 # since we didn't look for Xext and X11 using pkg-config
1016 HWLOC_GL_REQUIRES="xext x11"
1018 hwloc_components="$hwloc_components gl"
1019 hwloc_gl_component_maybeplugin=1
1021 AS_IF([test "$enable_gl" = "yes"], [
1022 AC_MSG_WARN([Specified --enable-gl switch, but could not])
1023 AC_MSG_WARN([find appropriate support])
1024 AC_MSG_ERROR([Cannot continue])
1028 # don't add LIBS/CFLAGS yet, depends on plugins
1031 hwloc_libxml2_happy=
1032 if test "x$enable_libxml2" != "xno"; then
1033 HWLOC_PKG_CHECK_MODULES([LIBXML2], [libxml-2.0], [xmlNewDoc], [libxml/parser.h],
1034 [hwloc_libxml2_happy=yes],
1035 [hwloc_libxml2_happy=no])
1037 if test "x$hwloc_libxml2_happy" = "xyes"; then
1038 HWLOC_LIBXML2_REQUIRES="libxml-2.0"
1039 AC_DEFINE([HWLOC_HAVE_LIBXML2], [1], [Define to 1 if you have the `libxml2' library.])
1040 AC_SUBST([HWLOC_HAVE_LIBXML2], [1])
1042 hwloc_components="$hwloc_components xml_libxml"
1043 hwloc_xml_libxml_component_maybeplugin=1
1045 AC_SUBST([HWLOC_HAVE_LIBXML2], [0])
1046 AS_IF([test "$enable_libxml2" = "yes"],
1047 [AC_MSG_WARN([--enable-libxml2 requested, but libxml2 was not found])
1048 AC_MSG_ERROR([Cannot continue])])
1050 # don't add LIBS/CFLAGS/REQUIRES yet, depends on plugins
1052 # Try to compile the x86 cpuid inlines
1053 if test "x$enable_cpuid" != "xno"; then
1054 AC_MSG_CHECKING([for x86 cpuid])
1055 old_CPPFLAGS="$CPPFLAGS"
1056 CPPFLAGS="$CPPFLAGS -I$HWLOC_top_srcdir/include"
1057 # We need hwloc_uint64_t but we can't use hwloc/autogen/config.h before configure ends.
1058 # So pass #include/#define manually here for now.
1059 CPUID_CHECK_HEADERS=
1061 if test "x$hwloc_windows" = xyes; then
1062 X86_CPUID_CHECK_HEADERS="#include <windows.h>"
1063 X86_CPUID_CHECK_DEFINE="#define hwloc_uint64_t DWORDLONG"
1065 X86_CPUID_CHECK_DEFINE="#define hwloc_uint64_t uint64_t"
1066 if test "x$ac_cv_header_stdint_h" = xyes; then
1067 X86_CPUID_CHECK_HEADERS="#include <stdint.h>"
1070 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1072 $X86_CPUID_CHECK_HEADERS
1073 $X86_CPUID_CHECK_DEFINE
1074 #define __hwloc_inline
1075 #include <private/cpuid-x86.h>
1077 if (hwloc_have_x86_cpuid()) {
1078 unsigned eax = 0, ebx, ecx = 0, edx;
1079 hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
1080 printf("highest x86 cpuid %x\n", eax);
1084 [AC_MSG_RESULT([yes])
1085 AC_DEFINE(HWLOC_HAVE_X86_CPUID, 1, [Define to 1 if you have x86 cpuid])
1086 hwloc_have_x86_cpuid=yes],
1087 [AC_MSG_RESULT([no])])
1088 if test "x$hwloc_have_x86_cpuid" = xyes; then
1089 hwloc_components="$hwloc_components x86"
1091 CPPFLAGS="$old_CPPFLAGS"
1094 # Components require pthread_mutex, see if it needs -lpthread
1095 hwloc_pthread_mutex_happy=no
1096 # Try without explicit -lpthread first
1097 AC_CHECK_FUNC([pthread_mutex_lock],
1098 [hwloc_pthread_mutex_happy=yes
1099 HWLOC_LIBS_PRIVATE="$HWLOC_LIBS_PRIVATE -lpthread"
1101 [AC_MSG_CHECKING([for pthread_mutex_lock with -lpthread])
1102 # Try again with explicit -lpthread, but don't use AC_CHECK_FUNC to avoid the cache
1104 LIBS="$LIBS -lpthread"
1105 AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_mutex_lock])],
1106 [hwloc_pthread_mutex_happy=yes
1107 HWLOC_LIBS="$HWLOC_LIBS -lpthread"
1109 AC_MSG_RESULT([$hwloc_pthread_mutex_happy])
1110 LIBS="$tmp_save_LIBS"
1112 AS_IF([test "x$hwloc_pthread_mutex_happy" = "xyes"],
1113 [AC_DEFINE([HWLOC_HAVE_PTHREAD_MUTEX], 1, [Define to 1 if pthread mutexes are available])])
1115 AS_IF([test "x$hwloc_pthread_mutex_happy" != xyes -a "x$hwloc_windows" != xyes],
1116 [AC_MSG_WARN([pthread_mutex_lock not available, required for thread-safe initialization on non-Windows platforms.])
1117 AC_MSG_WARN([Please report this to the hwloc-devel mailing list.])
1118 AC_MSG_ERROR([Cannot continue])])
1121 # Now enable registration of listed components
1125 AC_MSG_CHECKING([if plugin support is enabled])
1126 # Plugins (even core support) are totally disabled by default
1127 AS_IF([test "x$enable_plugins" = "x"], [enable_plugins=no])
1128 AS_IF([test "x$enable_plugins" != "xno"], [hwloc_have_plugins=yes], [hwloc_have_plugins=no])
1129 AC_MSG_RESULT([$hwloc_have_plugins])
1130 AS_IF([test "x$hwloc_have_plugins" = "xyes"],
1131 [AC_DEFINE([HWLOC_HAVE_PLUGINS], 1, [Define to 1 if the hwloc library should support dynamically-loaded plugins])])
1133 # Some sanity checks about plugins
1134 # libltdl doesn't work on AIX as of 2.4.2
1135 AS_IF([test "x$enable_plugins" = "xyes" -a "x$hwloc_aix" = "xyes"],
1136 [AC_MSG_WARN([libltdl does not work on AIX, plugins support cannot be enabled.])
1137 AC_MSG_ERROR([Cannot continue])])
1138 # posix linkers don't work well with plugins and windows dll constraints
1139 AS_IF([test "x$enable_plugins" = "xyes" -a "x$hwloc_windows" = "xyes"],
1140 [AC_MSG_WARN([Plugins not supported on non-native Windows build, plugins support cannot be enabled.])
1141 AC_MSG_ERROR([Cannot continue])])
1143 # If we want plugins, look for ltdl.h and libltdl
1144 if test "x$hwloc_have_plugins" = xyes; then
1145 AC_CHECK_HEADER([ltdl.h], [],
1146 [AC_MSG_WARN([Plugin support requested, but could not find ltdl.h])
1147 AC_MSG_ERROR([Cannot continue])])
1148 AC_CHECK_LIB([ltdl], [lt_dlopenext],
1149 [HWLOC_LIBS="$HWLOC_LIBS -lltdl"],
1150 [AC_MSG_WARN([Plugin support requested, but could not find libltdl])
1151 AC_MSG_ERROR([Cannot continue])])
1152 # Add libltdl static-build dependencies to hwloc.pc
1153 HWLOC_CHECK_LTDL_DEPS
1156 AC_ARG_WITH([hwloc-plugins-path],
1157 AC_HELP_STRING([--with-hwloc-plugins-path=dir:...],
1158 [Colon-separated list of plugin directories. Default: "$prefix/lib/hwloc". Plugins will be installed in the first directory. They will be loaded from all of them, in order.]),
1159 [HWLOC_PLUGINS_PATH="$with_hwloc_plugins_path"],
1160 [HWLOC_PLUGINS_PATH="\$(libdir)/hwloc"])
1161 AC_SUBST(HWLOC_PLUGINS_PATH)
1162 HWLOC_PLUGINS_DIR=`echo "$HWLOC_PLUGINS_PATH" | cut -d: -f1`
1163 AC_SUBST(HWLOC_PLUGINS_DIR)
1165 # Static components output file
1166 hwloc_static_components_dir=${HWLOC_top_builddir}/src
1167 mkdir -p ${hwloc_static_components_dir}
1168 hwloc_static_components_file=${hwloc_static_components_dir}/static-components.h
1169 rm -f ${hwloc_static_components_file}
1171 # Make $enable_plugins easier to use (it contains either "yes" (all) or a list of <name>)
1172 HWLOC_PREPARE_FILTER_COMPONENTS([$enable_plugins])
1173 # Now we have some hwloc_<name>_component_wantplugin=1
1175 # See which core components want plugin and support it
1176 HWLOC_FILTER_COMPONENTS
1177 # Now we have some hwloc_<name>_component=plugin/static
1178 # and hwloc_static/plugin_components
1179 AC_MSG_CHECKING([components to build statically])
1180 AC_MSG_RESULT($hwloc_static_components)
1181 HWLOC_LIST_STATIC_COMPONENTS([$hwloc_static_components_file], [$hwloc_static_components])
1182 AC_MSG_CHECKING([components to build as plugins])
1183 AC_MSG_RESULT([$hwloc_plugin_components])
1185 AS_IF([test "$hwloc_pci_component" = "static"],
1186 [HWLOC_LIBS="$HWLOC_LIBS $HWLOC_PCIACCESS_LIBS"
1187 HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_PCIACCESS_CFLAGS"
1188 HWLOC_REQUIRES="$HWLOC_PCIACCESS_REQUIRES $HWLOC_REQUIRES"])
1189 AS_IF([test "$hwloc_opencl_component" = "static"],
1190 [HWLOC_LIBS="$HWLOC_LIBS $HWLOC_OPENCL_LIBS"
1191 HWLOC_LDFLAGS="$HWLOC_LDFLAGS $HWLOC_OPENCL_LDFLAGS"
1192 HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_OPENCL_CFLAGS"
1193 HWLOC_REQUIRES="$HWLOC_OPENCL_REQUIRES $HWLOC_REQUIRES"])
1194 AS_IF([test "$hwloc_cuda_component" = "static"],
1195 [HWLOC_LIBS="$HWLOC_LIBS $HWLOC_CUDA_LIBS"
1196 HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_CUDA_CFLAGS"
1197 HWLOC_REQUIRES="$HWLOC_CUDA_REQUIRES $HWLOC_REQUIRES"])
1198 AS_IF([test "$hwloc_nvml_component" = "static"],
1199 [HWLOC_LIBS="$HWLOC_LIBS $HWLOC_NVML_LIBS"
1200 HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_NVML_CFLAGS"
1201 HWLOC_REQUIRES="$HWLOC_NVML_REQUIRES $HWLOC_REQUIRES"])
1202 AS_IF([test "$hwloc_gl_component" = "static"],
1203 [HWLOC_LIBS="$HWLOC_LIBS $HWLOC_GL_LIBS"
1204 HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_GL_CFLAGS"
1205 HWLOC_REQUIRES="$HWLOC_GL_REQUIRES $HWLOC_REQUIRES"])
1206 AS_IF([test "$hwloc_xml_libxml_component" = "static"],
1207 [HWLOC_LIBS="$HWLOC_LIBS $HWLOC_LIBXML2_LIBS"
1208 HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_LIBXML2_CFLAGS"
1209 HWLOC_REQUIRES="$HWLOC_LIBXML2_REQUIRES $HWLOC_REQUIRES"])
1212 # Setup HWLOC's C, CPP, and LD flags, and LIBS
1214 AC_SUBST(HWLOC_REQUIRES)
1215 AC_SUBST(HWLOC_CFLAGS)
1216 HWLOC_CPPFLAGS='-I$(HWLOC_top_builddir)/include -I$(HWLOC_top_srcdir)/include'
1217 AC_SUBST(HWLOC_CPPFLAGS)
1218 AC_SUBST(HWLOC_LDFLAGS)
1219 AC_SUBST(HWLOC_LIBS)
1220 AC_SUBST(HWLOC_LIBS_PRIVATE)
1222 # Set these values explicitly for embedded builds. Exporting
1223 # these values through *_EMBEDDED_* values gives us the freedom to
1224 # do something different someday if we ever need to. There's no
1225 # need to fill these values in unless we're in embedded mode.
1226 # Indeed, if we're building in embedded mode, we want HWLOC_LIBS
1227 # to be empty so that nothing is linked into libhwloc_embedded.la
1228 # itself -- only the upper-layer will link in anything required.
1230 AS_IF([test "$hwloc_mode" = "embedded"],
1231 [HWLOC_EMBEDDED_CFLAGS=$HWLOC_CFLAGS
1232 HWLOC_EMBEDDED_CPPFLAGS=$HWLOC_CPPFLAGS
1233 HWLOC_EMBEDDED_LDADD='$(HWLOC_top_builddir)/src/libhwloc_embedded.la'
1234 HWLOC_EMBEDDED_LIBS=$HWLOC_LIBS
1236 AC_SUBST(HWLOC_EMBEDDED_CFLAGS)
1237 AC_SUBST(HWLOC_EMBEDDED_CPPFLAGS)
1238 AC_SUBST(HWLOC_EMBEDDED_LDADD)
1239 AC_SUBST(HWLOC_EMBEDDED_LIBS)
1241 # Always generate these files
1243 hwloc_config_prefix[Makefile]
1244 hwloc_config_prefix[include/Makefile]
1245 hwloc_config_prefix[src/Makefile ]
1255 #-----------------------------------------------------------------------
1257 # Specify the symbol prefix
1258 AC_DEFUN([HWLOC_SET_SYMBOL_PREFIX],[
1259 hwloc_symbol_prefix_value=$1
1262 #-----------------------------------------------------------------------
1264 # This must be a standalone routine so that it can be called both by
1265 # HWLOC_INIT and an external caller (if HWLOC_INIT is not invoked).
1266 AC_DEFUN([HWLOC_DO_AM_CONDITIONALS],[
1267 AS_IF([test "$hwloc_did_am_conditionals" != "yes"],[
1268 AM_CONDITIONAL([HWLOC_BUILD_STANDALONE], [test "$hwloc_mode" = "standalone"])
1270 AM_CONDITIONAL([HWLOC_HAVE_GCC], [test "x$GCC" = "xyes"])
1271 AM_CONDITIONAL([HWLOC_HAVE_MS_LIB], [test "x$HWLOC_MS_LIB" != "x"])
1272 AM_CONDITIONAL([HWLOC_HAVE_OPENAT], [test "x$hwloc_have_openat" = "xyes"])
1273 AM_CONDITIONAL([HWLOC_HAVE_LINUX_LIBNUMA],
1274 [test "x$hwloc_have_linux_libnuma" = "xyes"])
1275 AM_CONDITIONAL([HWLOC_HAVE_SCHED_SETAFFINITY],
1276 [test "x$hwloc_have_sched_setaffinity" = "xyes"])
1277 AM_CONDITIONAL([HWLOC_HAVE_PTHREAD],
1278 [test "x$hwloc_have_pthread" = "xyes"])
1279 AM_CONDITIONAL([HWLOC_HAVE_LIBIBVERBS],
1280 [test "x$hwloc_have_libibverbs" = "xyes"])
1281 AM_CONDITIONAL([HWLOC_HAVE_CUDA],
1282 [test "x$hwloc_have_cuda" = "xyes"])
1283 AM_CONDITIONAL([HWLOC_HAVE_GL],
1284 [test "x$hwloc_have_gl" = "xyes"])
1285 AM_CONDITIONAL([HWLOC_HAVE_MYRIEXPRESS],
1286 [test "x$hwloc_have_myriexpress" = "xyes"])
1287 AM_CONDITIONAL([HWLOC_HAVE_CUDART],
1288 [test "x$hwloc_have_cudart" = "xyes"])
1289 AM_CONDITIONAL([HWLOC_HAVE_LIBXML2], [test "$hwloc_libxml2_happy" = "yes"])
1290 AM_CONDITIONAL([HWLOC_HAVE_CAIRO], [test "$hwloc_cairo_happy" = "yes"])
1291 AM_CONDITIONAL([HWLOC_HAVE_PCI], [test "$hwloc_pci_happy" = "yes"])
1292 AM_CONDITIONAL([HWLOC_HAVE_OPENCL], [test "$hwloc_opencl_happy" = "yes"])
1293 AM_CONDITIONAL([HWLOC_HAVE_NVML], [test "$hwloc_nvml_happy" = "yes"])
1294 AM_CONDITIONAL([HWLOC_HAVE_SET_MEMPOLICY], [test "x$enable_set_mempolicy" != "xno"])
1295 AM_CONDITIONAL([HWLOC_HAVE_MBIND], [test "x$enable_mbind" != "xno"])
1296 AM_CONDITIONAL([HWLOC_HAVE_BUNZIPP], [test "x$BUNZIPP" != "xfalse"])
1297 AM_CONDITIONAL([HWLOC_HAVE_USER32], [test "x$hwloc_have_user32" = "xyes"])
1299 AM_CONDITIONAL([HWLOC_BUILD_DOXYGEN],
1300 [test "x$hwloc_generate_doxs" = "xyes"])
1301 AM_CONDITIONAL([HWLOC_BUILD_README],
1302 [test "x$hwloc_generate_readme" = "xyes" -a \( "x$hwloc_install_doxs" = "xyes" -o "x$hwloc_generate_doxs" = "xyes" \) ])
1303 AM_CONDITIONAL([HWLOC_INSTALL_DOXYGEN],
1304 [test "x$hwloc_install_doxs" = "xyes"])
1306 AM_CONDITIONAL([HWLOC_HAVE_LINUX], [test "x$hwloc_linux" = "xyes"])
1307 AM_CONDITIONAL([HWLOC_HAVE_BGQ], [test "x$hwloc_bgq" = "xyes"])
1308 AM_CONDITIONAL([HWLOC_HAVE_IRIX], [test "x$hwloc_irix" = "xyes"])
1309 AM_CONDITIONAL([HWLOC_HAVE_DARWIN], [test "x$hwloc_darwin" = "xyes"])
1310 AM_CONDITIONAL([HWLOC_HAVE_FREEBSD], [test "x$hwloc_freebsd" = "xyes"])
1311 AM_CONDITIONAL([HWLOC_HAVE_NETBSD], [test "x$hwloc_netbsd" = "xyes"])
1312 AM_CONDITIONAL([HWLOC_HAVE_SOLARIS], [test "x$hwloc_solaris" = "xyes"])
1313 AM_CONDITIONAL([HWLOC_HAVE_AIX], [test "x$hwloc_aix" = "xyes"])
1314 AM_CONDITIONAL([HWLOC_HAVE_OSF], [test "x$hwloc_osf" = "xyes"])
1315 AM_CONDITIONAL([HWLOC_HAVE_HPUX], [test "x$hwloc_hpux" = "xyes"])
1316 AM_CONDITIONAL([HWLOC_HAVE_WINDOWS], [test "x$hwloc_windows" = "xyes"])
1317 AM_CONDITIONAL([HWLOC_HAVE_MINGW32], [test "x$target_os" = "xmingw32"])
1319 AM_CONDITIONAL([HWLOC_HAVE_X86], [test "x$hwloc_x86_32" = "xyes" -o "x$hwloc_x86_64" = "xyes"])
1320 AM_CONDITIONAL([HWLOC_HAVE_X86_32], [test "x$hwloc_x86_32" = "xyes"])
1321 AM_CONDITIONAL([HWLOC_HAVE_X86_64], [test "x$hwloc_x86_64" = "xyes"])
1322 AM_CONDITIONAL([HWLOC_HAVE_X86_CPUID], [test "x$hwloc_have_x86_cpuid" = "xyes"])
1324 AM_CONDITIONAL([HWLOC_HAVE_PLUGINS], [test "x$hwloc_have_plugins" = "xyes"])
1325 AM_CONDITIONAL([HWLOC_PCI_BUILD_STATIC], [test "x$hwloc_pci_component" = "xstatic"])
1326 AM_CONDITIONAL([HWLOC_OPENCL_BUILD_STATIC], [test "x$hwloc_opencl_component" = "xstatic"])
1327 AM_CONDITIONAL([HWLOC_CUDA_BUILD_STATIC], [test "x$hwloc_cuda_component" = "xstatic"])
1328 AM_CONDITIONAL([HWLOC_NVML_BUILD_STATIC], [test "x$hwloc_nvml_component" = "xstatic"])
1329 AM_CONDITIONAL([HWLOC_GL_BUILD_STATIC], [test "x$hwloc_gl_component" = "xstatic"])
1330 AM_CONDITIONAL([HWLOC_XML_LIBXML_BUILD_STATIC], [test "x$hwloc_xml_libxml_component" = "xstatic"])
1332 AM_CONDITIONAL([HWLOC_HAVE_CXX], [test "x$hwloc_have_cxx" = "xyes"])
1334 hwloc_did_am_conditionals=yes
1337 #-----------------------------------------------------------------------
1339 dnl HWLOC_CHECK_DECL
1341 dnl Check that the declaration of the given function has a complete prototype
1342 dnl with argument list by trying to call it with an insane dnl number of
1343 dnl arguments (10). Success means the compiler couldn't really check.
1344 AC_DEFUN([_HWLOC_CHECK_DECL], [
1345 AC_CHECK_DECL([$1], [
1346 AC_MSG_CHECKING([whether function $1 has a complete prototype])
1347 AC_REQUIRE([AC_PROG_CC])
1348 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1349 [AC_INCLUDES_DEFAULT([$4])],
1350 [$1(1,2,3,4,5,6,7,8,9,10);]
1352 [AC_MSG_RESULT([no])
1354 [AC_MSG_RESULT([yes])
1360 #-----------------------------------------------------------------------
1362 dnl HWLOC_CHECK_DECLS
1364 dnl Same as HWLOCK_CHECK_DECL, but defines HAVE_DECL_foo to 1 or 0 depending on
1366 AC_DEFUN([_HWLOC_CHECK_DECLS], [
1367 HWLOC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])
1368 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_DECL_$1]), [$ac_have_decl],
1369 [Define to 1 if you have the declaration of `$1', and to 0 if you don't])
1372 #-----------------------------------------------------------------------
1374 dnl HWLOC_CHECK_LTDL_DEPS
1376 dnl Add ltdl dependencies to HWLOC_LIBS_PRIVATE
1377 AC_DEFUN([HWLOC_CHECK_LTDL_DEPS], [
1378 # save variables that we'll modify below
1379 save_lt_cv_dlopen="$lt_cv_dlopen"
1380 save_lt_cv_dlopen_libs="$lt_cv_dlopen_libs"
1381 save_lt_cv_dlopen_self="$lt_cv_dlopen_self"
1382 ###########################################################
1383 # code stolen from LT_SYS_DLOPEN_SELF in libtool.m4
1386 lt_cv_dlopen="load_add_on"
1388 lt_cv_dlopen_self=yes
1391 mingw* | pw32* | cegcc*)
1392 lt_cv_dlopen="LoadLibrary"
1397 lt_cv_dlopen="dlopen"
1402 # if libdl is installed we need to link against it
1403 AC_CHECK_LIB([dl], [dlopen],
1404 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
1407 lt_cv_dlopen_self=yes
1412 AC_CHECK_FUNC([shl_load],
1413 [lt_cv_dlopen="shl_load"],
1414 [AC_CHECK_LIB([dld], [shl_load],
1415 [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
1416 [AC_CHECK_FUNC([dlopen],
1417 [lt_cv_dlopen="dlopen"],
1418 [AC_CHECK_LIB([dl], [dlopen],
1419 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
1420 [AC_CHECK_LIB([svld], [dlopen],
1421 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
1422 [AC_CHECK_LIB([dld], [dld_link],
1423 [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
1431 # end of code stolen from LT_SYS_DLOPEN_SELF in libtool.m4
1432 ###########################################################
1434 HWLOC_LIBS_PRIVATE="$HWLOC_LIBS_PRIVATE $lt_cv_dlopen_libs"
1436 # restore modified variable in case the actual libtool code uses them
1437 lt_cv_dlopen="$save_lt_cv_dlopen"
1438 lt_cv_dlopen_libs="$save_lt_cv_dlopen_libs"
1439 lt_cv_dlopen_self="$save_lt_cv_dlopen_self"