Skip to content

Commit 6ebef9a

Browse files
committed
build/libnl: Cache libnl version sanity checks
Cache the results of the checks to verify which versions of libnl packages link against. Signed-off-by: Brian Barrett <[email protected]>
1 parent 4e05258 commit 6ebef9a

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

config/opal_check_libnl.m4

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -144,33 +144,38 @@ dnl
144144
AC_DEFUN([OPAL_LIBNL_SANITY_CHECK_LINUX], [
145145
OPAL_VAR_SCOPE_PUSH([this_requires_v1 libnl_sane this_requires_v3 ldd_output result_msg])
146146

147-
AC_LANG_PUSH(C)
147+
AS_VAR_PUSHDEF([libnl_check_lib], [opal_libnl_sanity_check_cv_$1])
148148

149-
AC_MSG_CHECKING([if $1 requires libnl v1 or v3])
150-
cat > conftest_c.$ac_ext << EOF
149+
AC_CACHE_CHECK([if $1 requires libnl v1 or v3],
150+
[libnl_check_lib],
151+
[AC_LANG_PUSH([C])
152+
cat > conftest_c.$ac_ext << EOF
151153
extern void $2 (void);
152154
int main(int argc, char *argv[[]]) {
153155
$2 ();
154156
return 0;
155157
}
156158
EOF
157159

160+
result_msg=
161+
OPAL_LOG_COMMAND([$CC -o conftest $CFLAGS $CPPFLAGS conftest_c.$ac_ext $LDFLAGS $LIBS $3],
162+
[ldd_output=`ldd conftest`
163+
AS_IF([echo $ldd_output | grep -q libnl-3.so],
164+
[result_msg="v3"])
165+
AS_IF([echo $ldd_output | grep -q libnl.so],
166+
[OPAL_APPEND([result_msg], ["v1"])])
167+
AS_IF([test -z "${result_msg}"], [result_msg="none"])],
168+
[AC_MSG_WARN([Could not link a simple program with lib $1])])
169+
AC_LANG_POP([C])
170+
AS_VAR_SET([libnl_check_lib], [${result_msg}])
171+
rm -f conftest conftest_c.$ac_ext])
172+
AS_VAR_COPY([result_msg], [libnl_check_lib])
158173
this_requires_v1=0
159174
this_requires_v3=0
160-
result_msg=
161-
OPAL_LOG_COMMAND([$CC -o conftest $CFLAGS $CPPFLAGS conftest_c.$ac_ext $LDFLAGS $LIBS $3],
162-
[ldd_output=`ldd conftest`
163-
AS_IF([echo $ldd_output | grep -q libnl-3.so],
164-
[this_requires_v3=1
165-
result_msg="v3"])
166-
AS_IF([echo $ldd_output | grep -q libnl.so],
167-
[this_requires_v1=1
168-
result_msg="v1 $result_msg"])
169-
AS_IF([test -z "${result_msg}"], [result_msg="none"])
170-
AC_MSG_RESULT([$result_msg])
171-
],
172-
[AC_MSG_WARN([Could not link a simple program with lib $1])
173-
])
175+
AS_IF([echo "${result_msg}" | grep -q v1], [this_requires_v1=1])
176+
AS_IF([echo "${result_msg}" | grep -q v3], [this_requires_v3=1])
177+
178+
AS_VAR_POPDEF([libnl_check_lib])
174179

175180
# Assume that our configuration is sane; this may get reset below
176181
libnl_sane=1
@@ -202,17 +207,14 @@ EOF
202207
# v1? If so, fail.
203208
AS_IF([test $libnl_sane -eq 1 && test $this_requires_v3 -eq 1],
204209
[AS_IF([test $opal_libnl_version -eq 1],
205-
[AC_MSG_WARN([libnl version conflict: $opal_libnlv1_libs requires libnl whereas 1 requires libnl-3])
210+
[AC_MSG_WARN([libnl version conflict: $opal_libnlv1_libs requires libnl whereas $1 requires libnl-3])
206211
OPAL_LIBNL_SANITY_FAIL_MSG($1)
207212
libnl_sane=0],
208213
[opal_libnlv3_libs="$opal_libnlv3_libs $1"
209214
OPAL_UNIQ([opal_libnlv3_libs])
210215
opal_libnl_version=3])
211216
])
212217

213-
AC_LANG_POP(C)
214-
rm -f conftest conftest_c.$ac_ext
215-
216218
$4=$libnl_sane
217219

218220
OPAL_VAR_SCOPE_POP([ldd_output libnl_sane this_requires_v1 this_requires_v3 result_msg])

0 commit comments

Comments
 (0)