@@ -19,42 +19,37 @@ dnl configure, abort.
19
19
dnl
20
20
dnl This macro will change the environment in the following way:
21
21
dnl
22
- dnl * opal_hwloc_header [legacy] - will be set if building
23
- dnl internally, to the header file that should be included for
24
- dnl embedded builds. This is used by PRRTE, but should not
25
- dnl be used by new code.
26
22
dnl * opal_hwloc_mode - either external or internal. If internal,
27
23
dnl --with-hwloc should be ignored by other packages
28
- dnl * opal_hwloc_CPPFLAGS - the C Preprocessor flags necessary to
29
- dnl run the preprocessor on a file which relies on Hwloc
30
- dnl headers. This will be folded into the global CPPFLAGS,
31
- dnl so most people should never need this.
32
- dnl * opal_hwloc_LDFLAGS - the linker flags necessary to run the
33
- dnl linker on a file which relies on Hwloc libraries. This
34
- dnl will be folded into the global CPPFLAGS, so most people
35
- dnl should never need this.
36
- dnl * opal_hwloc_LIBS - the libraries necessary to link source which
37
- dnl uses Hwloc. Cannot be added to LIBS yet, because then
38
- dnl other execution tests later in configure (there are sadly
39
- dnl some) would fail if the path in LDFLAGS was not added to
40
- dnl LD_LIBRARY_PATH.
41
- dnl * opal_hwloc_WRAPPER_LDFLAGS - the linker flags necessary to
42
- dnl add to the wrapper compilers in order to link an opal
43
- dnl application when opal is built as a static library.
24
+ dnl * CPPFLAGS, LDFLAGS, LIBS - Updated to build against hwloc.
25
+ dnl Note that the values may be updated right before
26
+ dnl config.status.
27
+ dnl
28
+ dnl OPAL_WRAPPER_FLAGS_ADD will be called to add the correct LDFLAGS,
29
+ dnl STATIC_LDFLAGS, LIBS, and STATIC_LIBS for hwloc.
30
+ dnl
31
+ dnl The following environment variables will only be set if
32
+ dnl opal_hwloc_mode is "internal":
33
+ dnl
34
+ dnl * opal_hwloc_BUILD_CPPFLAGS - the C Preprocessor flags
35
+ dnl necessary to run the preprocessor on a file which relies
36
+ dnl on hwloc headers. This will be folded into the global
37
+ dnl CPPFLAGS (see note above).
38
+ dnl * opal_hwloc_BUILD_LIBS - the libraries necessary to link
39
+ dnl source which uses hwloc. Cannot be added to LIBS yet,
40
+ dnl because then other execution tests later in configure
41
+ dnl (there are sadly some) would fail if the path in LDFLAGS
42
+ dnl was not added to LD_LIBRARY_PATH.
44
43
dnl * opal_hwloc_WRAPPER_LIBS - the linker flags necessary to
45
44
dnl add to the wrapper compilers in order to link an opal
46
45
dnl application when opal is built as a static library.
47
- dnl * CPPFLAGS, LDFLAGS - Updated opal_hwloc_CPPFLAGS and
48
- dnl opal_hwloc_LDFLAGS.
49
46
AC_DEFUN ( [ OPAL_CONFIG_HWLOC] , [
50
- OPAL_VAR_SCOPE_PUSH([ external_hwloc_happy internal_hwloc_happy pkg_config_file pkg_config_happy pkg_config_ldflags pkg_config_libs ] )
47
+ OPAL_VAR_SCOPE_PUSH([ external_hwloc_happy internal_hwloc_happy opal_hwloc_STATIC_LDFLAGS opal_hwloc_LIBS opal_hwloc_STATIC_LIBS ] )
51
48
52
49
opal_show_subtitle "Configuring hwloc"
53
50
54
51
OPAL_3RDPARTY_WITH([ hwloc] , [ hwloc] , [ package_hwloc] )
55
52
56
- opal_hwloc_header=""
57
-
58
53
# unless internal specifically requested by the user, try to find
59
54
# an external that works.
60
55
external_hwloc_happy=0
@@ -75,79 +70,54 @@ AC_DEFUN([OPAL_CONFIG_HWLOC], [
75
70
AS_IF ( [ test "$external_hwloc_happy" = "0" -a "$internal_hwloc_happy" = "0"] ,
76
71
[ AC_MSG_ERROR ( [ Could not find viable hwloc build.] ) ] )
77
72
78
- AS_IF ( [ test "$opal_hwloc_mode" = "internal"] ,
79
- [ pkg_config_file="${OMPI_TOP_BUILDDIR}/3rd-party/hwloc_directory/hwloc.pc"
80
- PKG_CONFIG_PATH="${OMPI_TOP_BUILDDIR}/3rd-party/hwloc_directory:${PKG_CONFIG_PATH}"] ,
81
- [ test -n "$with_hwloc"] ,
82
- [ pkg_config_file="${with_hwloc}/lib/pkgconfig/hwloc.pc"
83
- PKG_CONFIG_PATH="${with_hwloc}/lib/pkgconfig:${PKG_CONFIG_PATH}"] ,
84
- [ pkg_config_file="hwloc"] )
85
-
86
- pkg_config_happy=1
87
- OPAL_GET_LDFLAGS_FROM_PC([ $pkg_config_file] , [ pkg_config_ldflags] , [ pkg_config_happy=0] )
88
- OPAL_GET_LIBS_FROM_PC([ $pkg_config_file] , [ pkg_config_libs] , [ pkg_config_happy=0] )
89
-
90
- AS_IF ( [ test $pkg_config_happy -ne 0] ,
91
- [ opal_hwloc_WRAPPER_LDFLAGS="$pkg_config_ldflags"
92
- opal_hwloc_WRAPPER_LIBS="$pkg_config_libs"] ,
93
- [ # guess that what we have from compiling OMPI is good enough
94
- AS_IF ( [ test -z "$opal_hwloc_WRAPPER_LDFLAGS"] ,
95
- [ opal_hwloc_WRAPPER_LDFLAGS="$opal_hwloc_LDFLAGS"] )
96
- AS_IF ( [ test -z "$opal_hwloc_WRAPPER_LIBS"] ,
97
- [ opal_hwloc_WRAPPER_LIBS="$opal_hwloc_LIBS"] ) ] )
98
-
99
- OPAL_WRAPPER_FLAGS_ADD([ LDFLAGS] , [ $opal_hwloc_WRAPPER_LDFLAGS] )
100
- OPAL_WRAPPER_FLAGS_ADD([ LIBS] , [ $opal_hwloc_WRAPPER_LIBS] )
101
-
102
- # this will work even if there is no hwloc package included,
103
- # because hwloc_tarball and hwloc_directory will evaluate to an
104
- # empty string. These are relative to the 3rd-party/ directory.
73
+ dnl this will work even if there is no hwloc package included,
74
+ dnl because hwloc_tarball and hwloc_directory will evaluate to an
75
+ dnl empty string. These are relative to the 3rd-party/ directory.
105
76
OPAL_3RDPARTY_EXTRA_DIST="$OPAL_3RDPARTY_EXTRA_DIST hwloc_tarball"
106
77
OPAL_3RDPARTY_DISTCLEAN_DIRS="$OPAL_3RDPARTY_DISTCLEAN_DIRS hwloc_directory"
107
78
108
- AC_SUBST ( opal_hwloc_CPPFLAGS )
109
- AC_SUBST ( opal_hwloc_LIBS )
110
- AC_SUBST ( opal_hwloc_LDFLAGS )
79
+ OPAL_WRAPPER_FLAGS_ADD([ LDFLAGS] , [ ${opal_hwloc_LDFLAGS}] )
80
+ OPAL_WRAPPER_FLAGS_ADD([ STATIC_LDFLAGS] , [ ${opal_hwloc_STATIC_LDFLAGS}] )
81
+ OPAL_WRAPPER_FLAGS_ADD([ LIBS] , [ ${opal_hwloc_LIBS}] )
82
+ OPAL_WRAPPER_FLAGS_ADD([ STATIC_LIBS] , [ ${opal_hwloc_STATIC_LIBS}] )
83
+ OPAL_WRAPPER_FLAGS_ADD([ PC_MODULES] , [ ${opal_hwloc_PC_MODULES}] )
84
+
85
+ AC_CONFIG_COMMANDS_PRE ( [ OPAL_CONFIG_HWLOC_INTERNAL_LIBS_HANDLER] )
111
86
112
87
OPAL_SUMMARY_ADD([ Miscellaneous] , [ hwloc] , [ ] , [ $opal_hwloc_mode] )
113
88
114
89
OPAL_VAR_SCOPE_POP
115
90
] )
116
91
92
+
117
93
dnl _OPAL_CONFIG_HWLOC_EXTERNAL(action-if-happy, action-if-not-happy)
118
94
dnl
119
95
dnl only safe to call from OPAL_CONFIG_HWLOC, assumes variables from
120
96
dnl there are set.
121
97
AC_DEFUN ( [ _OPAL_CONFIG_HWLOC_EXTERNAL] , [
122
98
OPAL_VAR_SCOPE_PUSH([ opal_hwloc_CPPFLAGS_save opal_hwloc_LDFLAGS_save opal_hwloc_LIBS_save opal_hwloc_external_support] )
123
99
100
+ OAC_CHECK_PACKAGE([ hwloc] ,
101
+ [ opal_hwloc] ,
102
+ [ hwloc.h] ,
103
+ [ hwloc] ,
104
+ [ hwloc_topology_init] ,
105
+ [ opal_hwloc_external_support=yes] ,
106
+ [ opal_hwloc_external_support=no] )
107
+
108
+ # need these set for the tests below.
124
109
opal_hwloc_CPPFLAGS_save=$CPPFLAGS
125
110
opal_hwloc_LDFLAGS_save=$LDFLAGS
126
111
opal_hwloc_LIBS_save=$LIBS
127
112
128
- AS_IF ( [ test ! -z "$with_hwloc_libdir"] ,
129
- [ OPAL_CHECK_WITHDIR([ hwloc-libdir] , [ $with_hwloc_libdir] ,
130
- [ libhwloc.*] )] )
131
-
132
- OPAL_CHECK_PACKAGE([ opal_hwloc] ,
133
- [ hwloc.h] ,
134
- [ hwloc] ,
135
- [ hwloc_topology_init] ,
136
- [ ] ,
137
- [ $with_hwloc] ,
138
- [ $with_hwloc_libdir] ,
139
- [ opal_hwloc_external_support=yes] ,
140
- [ opal_hwloc_external_support=no] )
141
-
142
- # need these set for the tests below. If things fail, will undo at the end.
143
- CPPFLAGS="$opal_hwloc_CPPFLAGS_save $opal_hwloc_CPPFLAGS"
144
- LDFLAGS="$opal_hwloc_LDFLAGS_save $opal_hwloc_LDFLAGS"
145
- LIBS="$opal_hwloc_LIBS_save $opal_hwloc_LIBS"
113
+ OPAL_FLAGS_APPEND_UNIQ([ CPPFLAGS] , [ $opal_hwloc_CPPFLAGS] )
114
+ OPAL_FLAGS_APPEND_UNIQ([ LDFLAGS] , [ $opal_hwloc_LDFLAGS] )
115
+ OPAL_FLAGS_APPEND_UNIQ([ LIBS] , [ $opal_hwloc_LIBS] )
146
116
147
117
AS_IF ( [ test "$opal_hwloc_external_support" = "yes"] ,
148
118
[ AC_MSG_CHECKING ( [ if external hwloc version is 1.11.0 or greater] )
149
- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [ #include <hwloc.h>] ] ,
150
- [ [
119
+ AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [ #include <hwloc.h>
120
+ ] ] , [ [
151
121
#if HWLOC_API_VERSION < 0x00010500
152
122
#error "hwloc API version is less than 0x00011100"
153
123
#endif
@@ -158,16 +128,21 @@ AC_DEFUN([_OPAL_CONFIG_HWLOC_EXTERNAL], [
158
128
opal_hwloc_external_support="no"] ) ] )
159
129
160
130
AS_IF ( [ test "$opal_hwloc_external_support" = "yes"] ,
161
- [ AC_CHECK_DECLS ( [ HWLOC_OBJ_OSDEV_COPROC] , [ ] , [ ] , [ #include <hwloc.h>] )
131
+ [ AC_CHECK_DECLS ( [ HWLOC_OBJ_OSDEV_COPROC] , [ ] , [ ] , [ #include <hwloc.h>
132
+ ] )
162
133
AC_CHECK_FUNCS ( [ hwloc_topology_dup] ) ] )
163
134
135
+ CPPFLAGS="$opal_hwloc_CPPFLAGS_save"
164
136
LDFLAGS="$opal_hwloc_LDFLAGS_save"
165
137
LIBS="$opal_hwloc_LIBS_save"
166
138
167
139
AS_IF ( [ test "$opal_hwloc_external_support" = "yes"] ,
168
- [ $1 ] ,
169
- [ CPPFLAGS="$opal_hwloc_CPPFLAGS_save"
170
- $2 ] )
140
+ [ dnl Do not add hwloc libs to LIBS until late, because
141
+ dnl it will screw up other tests (like the pthread tests)
142
+ opal_hwloc_BUILD_LIBS="${opal_hwloc_LIBS}"
143
+
144
+ $1 ] ,
145
+ [ $2 ] )
171
146
172
147
OPAL_VAR_SCOPE_POP
173
148
] )
@@ -179,7 +154,7 @@ dnl external hwloc is not going to be used. Assumes that if
179
154
dnl this function is called, that success means the internal package
180
155
dnl will be used.
181
156
AC_DEFUN ( [ _OPAL_CONFIG_HWLOC_INTERNAL] , [
182
- OPAL_VAR_SCOPE_PUSH([ subconfig_happy internal_hwloc_location extra_configure_args found_enable_plugins hwloc_config_arg] )
157
+ OPAL_VAR_SCOPE_PUSH([ subconfig_happy internal_hwloc_location extra_configure_args found_enable_plugins hwloc_config_arg pkg_config_file pkg_config_happy ] )
183
158
184
159
extra_configure_args=
185
160
@@ -215,20 +190,42 @@ AC_DEFUN([_OPAL_CONFIG_HWLOC_INTERNAL], [
215
190
[ subconfig_happy=1] , [ subconfig_happy=0] )
216
191
OPAL_SUBDIR_ENV_RESTORE([ opal_hwloc_configure] )
217
192
218
- AS_IF ( [ test "$ subconfig_happy" = "1" ] ,
193
+ AS_IF ( [ test ${ subconfig_happy} -eq 1 ] ,
219
194
[ internal_hwloc_location="3rd-party/hwloc_directory"
220
- # note: because we only ship/commit a tarball (and not the source
221
- # directory), the source is always expanded in the builddir, so we
222
- # only need to add a -I to the builddir.
195
+
196
+ dnl We do not consider it an error if pkg-config doesn't work / exist / etc.
197
+ pkg_config_file="${OMPI_TOP_BUILDDIR}/3rd-party/hwloc_directory/hwloc.pc"
198
+ pkg_config_happy=0
199
+
200
+ OAC_CHECK_PACKAGE_PARSE_PKGCONFIG([ hwloc_internal] , [ opal_hwloc] , [ ${pkg_config_file}] , [ pkg_config_happy=1] )
201
+
202
+ dnl Don't pull LDFLAGS, because we don't have a good way to avoid
203
+ dnl a -L to our install directory, which can cause some weirdness
204
+ dnl if there's an old OMPI install there. And it makes filtering
205
+ dnl redundant flags easier.
206
+ opal_hwloc_LDFLAGS=
207
+
208
+ dnl with no pkg-config data, guess. assume that -L${libdir} is already added to LDFLAGS
209
+ AS_IF ( [ test $pkg_config_happy -eq 0] ,
210
+ [ opal_hwloc_STATIC_LDFLAGS=
211
+ opal_hwloc_LIBS="-lhwloc"
212
+ opal_hwloc_STATIC_LIBS=
213
+ opal_hwloc_PC_MODULES=] )
214
+
215
+ # note: because we only ship/commit a tarball (and not the
216
+ # source directory), the source is always expanded in the
217
+ # builddir, so we only need to add a -I to the builddir.
218
+ # Overwrite the OAC_CHECK_PACKAGE_PARSE PKGCONFIG results,
219
+ # because it's the install dir location, not the build
220
+ # location.
223
221
opal_hwloc_CPPFLAGS="-I$OMPI_TOP_BUILDDIR/$internal_hwloc_location/include -I$OMPI_TOP_SRCDIR/$internal_hwloc_location/include"
224
- CPPFLAGS="$CPPFLAGS $opal_hwloc_CPPFLAGS"
222
+ opal_hwloc_BUILD_CPPFLAGS="${opal_hwloc_CPPFLAGS}"
223
+
225
224
# No need to update LDFLAGS, because they will install into
226
225
# our tree and in the mean time are referenced by their .la
227
226
# files.
228
- opal_hwloc_LIBS="$OMPI_TOP_BUILDDIR/$internal_hwloc_location/hwloc/libhwloc.la"
229
- opal_hwloc_WRAPPER_LIBS="-lhwloc"
230
-
231
- opal_hwloc_header="$OMPI_TOP_BUILDDIR/$internal_hwloc_location/include/hwloc.h"
227
+ opal_hwloc_BUILD_LIBS="$OMPI_TOP_BUILDDIR/$internal_hwloc_location/hwloc/libhwloc.la"
228
+ opal_hwloc_WRAPPER_LIBS="${opal_hwloc_LIBS}"
232
229
233
230
# no need to add to DIST_SUBDIRS, because we only ship the
234
231
# tarball. This is relative to the 3rd-party/ directory.
@@ -238,3 +235,12 @@ AC_DEFUN([_OPAL_CONFIG_HWLOC_INTERNAL], [
238
235
239
236
OPAL_VAR_SCOPE_POP
240
237
] )
238
+
239
+
240
+ dnl We need to delay adding .la files to LIBS until the very end of
241
+ dnl configure, to avoid pulling it into other configure tests.
242
+ AC_DEFUN ( [ OPAL_CONFIG_HWLOC_INTERNAL_LIBS_HANDLER] , [
243
+ OPAL_FLAGS_APPEND_UNIQ([ CPPFLAGS] , [ ${opal_hwloc_CPPFLAGS}] )
244
+ OPAL_FLAGS_APPEND_UNIQ([ LDFLAGS] , [ $opal_hwloc_LDFLAGS] )
245
+ OPAL_FLAGS_APPEND_MOVE([ LIBS] , [ ${opal_hwloc_BUILD_LIBS}] )
246
+ ] )
0 commit comments