Skip to content

Commit d424a8c

Browse files
committed
build: Make libnl check work with check_package
Update the libnl version compatibility checks to work with OAC_CHECK_PACKAGE. There's some duplicate code to support both OAC_CHECK_PACKAGE and OPAL_CHECK_PACKAGE that can be removed when OPAL_CHECK_PACKAGE is retired. Signed-off-by: Brian Barrett <[email protected]>
1 parent ba96e4a commit d424a8c

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

config/opal_check_libnl.m4

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dnl
33
dnl Copyright (c) 2015-2017 Research Organization for Information Science
44
dnl and Technology (RIST). All rights reserved.
55
dnl Copyright (c) 2017 Cisco Systems, Inc. All rights reserved.
6+
dnl Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
67
dnl $COPYRIGHT$
78
dnl
89
dnl Additional copyrights may follow
@@ -66,6 +67,8 @@ AC_DEFUN([OPAL_LIBNL_SANITY_INIT], [
6667
opal_libnl_location=$with_libnl
6768
;;
6869
esac
70+
71+
OAC_CHECK_PACKAGE_VERIFY_COMMANDS([[OPAL_LIBNL_CHECK_PACKAGE_CALLBACK]])
6972
])
7073

7174
dnl OPAL_LIBNL_SANITY_FAIL_MSG(lib)
@@ -79,6 +82,28 @@ AC_DEFUN([OPAL_LIBNL_SANITY_FAIL_MSG], [
7982
AC_MSG_WARN([Open MPI will therefore skip using lib$1.])
8083
])
8184

85+
dnl OPAL_LIBNL_CHECK_PACKAGE_CALLBACK(package name, prefix,
86+
dnl headers, function name,
87+
dnl action if happy, action if not happy)
88+
dnl
89+
dnl Callback from OAC_CHECK_PACKAGE to verify that there is
90+
dnl not a conflict. Note that CPPFLAGS, LDFLAGS, and LIBS
91+
dnl are setup to compile/link package.
92+
AC_DEFUN([OPAL_LIBNL_CHECK_PACKAGE_CALLBACK], [
93+
OPAL_VAR_SCOPE_PUSH([opal_libnl_sane])
94+
opal_libnl_sane=1
95+
case $host in
96+
*linux*)
97+
OPAL_LIBNL_SANITY_CHECK_LINUX([$1], [$4], [], [opal_libnl_sane])
98+
;;
99+
esac
100+
101+
AS_IF([test ${opal_libnl_sane} -eq 1],
102+
[$5], [$6])
103+
104+
OPAL_VAR_SCOPE_POP([opal_libnl_sane])
105+
])
106+
82107
dnl OPAL_LIBNL_SANITY_CHECK(lib, function, LIBS, libnl_check_ok)
83108
dnl
84109
dnl This macro is invoked from OPAL_CHECK_PACKAGE to make sure that
@@ -101,7 +126,7 @@ AC_DEFUN([OPAL_LIBNL_SANITY_CHECK], [
101126
opal_libnl_sane=1
102127
case $host in
103128
*linux*)
104-
OPAL_LIBNL_SANITY_CHECK_LINUX($1, $2, $3, opal_libnl_sane)
129+
OPAL_LIBNL_SANITY_CHECK_LINUX([$1], [$2], [-l$1 $3], [opal_libnl_sane])
105130
;;
106131
esac
107132

@@ -111,7 +136,7 @@ AC_DEFUN([OPAL_LIBNL_SANITY_CHECK], [
111136

112137
dnl
113138
dnl Simple helper for OPAL_LIBNL_SANITY_CHECK
114-
dnl $1: library name
139+
dnl $1: package name
115140
dnl $2: function
116141
dnl $3: LIBS
117142
dnl $4: output variable (1=ok, 0=not ok)
@@ -121,7 +146,7 @@ AC_DEFUN([OPAL_LIBNL_SANITY_CHECK_LINUX], [
121146

122147
AC_LANG_PUSH(C)
123148

124-
AC_MSG_CHECKING([if lib$1 requires libnl v1 or v3])
149+
AC_MSG_CHECKING([if $1 requires libnl v1 or v3])
125150
cat > conftest_c.$ac_ext << EOF
126151
extern void $2 (void);
127152
int main(int argc, char *argv[[]]) {
@@ -133,14 +158,15 @@ EOF
133158
this_requires_v1=0
134159
this_requires_v3=0
135160
result_msg=
136-
OPAL_LOG_COMMAND([$CC -o conftest $CFLAGS $CPPFLAGS conftest_c.$ac_ext $LDFLAGS -l$1 $LIBS $3],
161+
OPAL_LOG_COMMAND([$CC -o conftest $CFLAGS $CPPFLAGS conftest_c.$ac_ext $LDFLAGS $LIBS $3],
137162
[ldd_output=`ldd conftest`
138163
AS_IF([echo $ldd_output | grep -q libnl-3.so],
139164
[this_requires_v3=1
140165
result_msg="v3"])
141166
AS_IF([echo $ldd_output | grep -q libnl.so],
142167
[this_requires_v1=1
143168
result_msg="v1 $result_msg"])
169+
AS_IF([test -z "${result_msg}"], [result_msg="none"])
144170
AC_MSG_RESULT([$result_msg])
145171
],
146172
[AC_MSG_WARN([Could not link a simple program with lib $1])
@@ -156,7 +182,7 @@ EOF
156182

157183
# Does this library require both v1 and v3? If so, fail.
158184
AS_IF([test $this_requires_v1 -eq 1 && test $this_requires_v3 -eq 1],
159-
[AC_MSG_WARN([Unfortunately, lib$1 links to both libnl and libnl-3.])
185+
[AC_MSG_WARN([Unfortunately, $1 links to both libnl and libnl-3.])
160186
OPAL_LIBNL_SANITY_FAIL_MSG($1)
161187
libnl_sane=0])
162188

@@ -176,7 +202,7 @@ EOF
176202
# v1? If so, fail.
177203
AS_IF([test $libnl_sane -eq 1 && test $this_requires_v3 -eq 1],
178204
[AS_IF([test $opal_libnl_version -eq 1],
179-
[AC_MSG_WARN([libnl version conflict: $opal_libnlv1_libs requires libnl whereas lib$1 requires libnl-3])
205+
[AC_MSG_WARN([libnl version conflict: $opal_libnlv1_libs requires libnl whereas 1 requires libnl-3])
180206
OPAL_LIBNL_SANITY_FAIL_MSG($1)
181207
libnl_sane=0],
182208
[opal_libnlv3_libs="$opal_libnlv3_libs $1"

0 commit comments

Comments
 (0)