Skip to content

Commit

Permalink
build/libnl: Cache libnl version sanity checks
Browse files Browse the repository at this point in the history
Cache the results of the checks to verify which versions of libnl
packages link against.

Signed-off-by: Brian Barrett <bbarrett@amazon.com>
  • Loading branch information
bwbarrett committed Mar 29, 2022
1 parent e461456 commit dd8fa8f
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions config/opal_check_libnl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -144,33 +144,38 @@ dnl
AC_DEFUN([OPAL_LIBNL_SANITY_CHECK_LINUX], [
OPAL_VAR_SCOPE_PUSH([this_requires_v1 libnl_sane this_requires_v3 ldd_output result_msg])

AC_LANG_PUSH(C)
AS_VAR_PUSHDEF([libnl_check_lib], [opal_libnl_sanity_check_cv_$1])

AC_MSG_CHECKING([if $1 requires libnl v1 or v3])
cat > conftest_c.$ac_ext << EOF
AC_CACHE_CHECK([if $1 requires libnl v1 or v3],
[libnl_check_lib],
[AC_LANG_PUSH([C])
cat > conftest_c.$ac_ext << EOF
extern void $2 (void);
int main(int argc, char *argv[[]]) {
$2 ();
return 0;
}
EOF

result_msg=
OPAL_LOG_COMMAND([$CC -o conftest $CFLAGS $CPPFLAGS conftest_c.$ac_ext $LDFLAGS $LIBS $3],
[ldd_output=`ldd conftest`
AS_IF([echo $ldd_output | grep -q libnl-3.so],
[result_msg="v3"])
AS_IF([echo $ldd_output | grep -q libnl.so],
[OPAL_APPEND([result_msg], ["v1"])])
AS_IF([test -z "${result_msg}"], [result_msg="none"])],
[AC_MSG_WARN([Could not link a simple program with lib $1])])
AC_LANG_POP([C])
AS_VAR_SET([libnl_check_lib], [${result_msg}])
rm -f conftest conftest_c.$ac_ext])
AS_VAR_COPY([result_msg], [libnl_check_lib])
this_requires_v1=0
this_requires_v3=0
result_msg=
OPAL_LOG_COMMAND([$CC -o conftest $CFLAGS $CPPFLAGS conftest_c.$ac_ext $LDFLAGS $LIBS $3],
[ldd_output=`ldd conftest`
AS_IF([echo $ldd_output | grep -q libnl-3.so],
[this_requires_v3=1
result_msg="v3"])
AS_IF([echo $ldd_output | grep -q libnl.so],
[this_requires_v1=1
result_msg="v1 $result_msg"])
AS_IF([test -z "${result_msg}"], [result_msg="none"])
AC_MSG_RESULT([$result_msg])
],
[AC_MSG_WARN([Could not link a simple program with lib $1])
])
AS_IF([echo "${result_msg}" | grep -q v1], [this_requires_v1=1])
AS_IF([echo "${result_msg}" | grep -q v3], [this_requires_v3=1])

AS_VAR_POPDEF([libnl_check_lib])

# Assume that our configuration is sane; this may get reset below
libnl_sane=1
Expand Down Expand Up @@ -202,17 +207,14 @@ EOF
# v1? If so, fail.
AS_IF([test $libnl_sane -eq 1 && test $this_requires_v3 -eq 1],
[AS_IF([test $opal_libnl_version -eq 1],
[AC_MSG_WARN([libnl version conflict: $opal_libnlv1_libs requires libnl whereas 1 requires libnl-3])
[AC_MSG_WARN([libnl version conflict: $opal_libnlv1_libs requires libnl whereas $1 requires libnl-3])
OPAL_LIBNL_SANITY_FAIL_MSG($1)
libnl_sane=0],
[opal_libnlv3_libs="$opal_libnlv3_libs $1"
OPAL_UNIQ([opal_libnlv3_libs])
opal_libnl_version=3])
])

AC_LANG_POP(C)
rm -f conftest conftest_c.$ac_ext

$4=$libnl_sane

OPAL_VAR_SCOPE_POP([ldd_output libnl_sane this_requires_v1 this_requires_v3 result_msg])
Expand Down

0 comments on commit dd8fa8f

Please sign in to comment.