Message ID | 20210111123626.28932-1-pvorel@suse.cz |
---|---|
State | Changes Requested |
Headers | show |
Series | [1/1] autoconf: Use pkg-config for keyutils detection | expand |
On Mon, Jan 11, 2021 at 8:36 PM Petr Vorel <pvorel@suse.cz> wrote: > Using pkg-config is less error prone during cross compilation. > > Signed-off-by: Petr Vorel <pvorel@suse.cz> > --- > Hi, > > if you agree with this, I'll replace (probably after release) ACL_LIBS, > CAP_LIBS, CRYPTO_LIBS, SELINUX_LIBS (to follow libmnl and libtirpc). > +1 > > libaio and libnuma does not support pkg-config. > > Tested: https://travis-ci.org/github/pevik/ltp/builds/753925166 > > [...] > diff --git a/m4/ltp-keyutils.m4 b/m4/ltp-keyutils.m4 > deleted file mode 100644 > index 451c549f3..000000000 > --- a/m4/ltp-keyutils.m4 > +++ /dev/null > @@ -1,10 +0,0 @@ > -dnl SPDX-License-Identifier: GPL-2.0-or-later > -dnl Copyright (c) 2016 Fujitsu Ltd. > -dnl Copyright (c) 2017 Petr Vorel <pvorel@suse.cz> > -dnl Author: Xiao Yang <yangx.jy@cn.fujitsu.com> > - > -AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT], [ > - AC_CHECK_LIB([keyutils], [add_key], > - [AC_DEFINE(HAVE_LIBKEYUTILS, 1, [Define to 1 if you have > libkeyutils installed.]) > - AC_SUBST(KEYUTILS_LIBS, "-lkeyutils")]) > -]) > diff --git a/m4/ltp-libkeyutils.m4 b/m4/ltp-libkeyutils.m4 > new file mode 100644 > index 000000000..f5d128969 > --- /dev/null > +++ b/m4/ltp-libkeyutils.m4 > @@ -0,0 +1,8 @@ > +dnl SPDX-License-Identifier: GPL-2.0-or-later > +dnl Copyright (c) 2020 Petr Vorel <pvorel@suse.cz> > + > +AC_DEFUN([LTP_CHECK_LIBKEYUTILS], [ > + PKG_CHECK_MODULES([LIBKEYUTILS], [libkeyutils], [ > I guess the list-of-modules should be [keyutils-libs] but not [libkeyutils]?
Hi Li, > > diff --git a/m4/ltp-keyutils.m4 b/m4/ltp-keyutils.m4 > > deleted file mode 100644 > > index 451c549f3..000000000 > > --- a/m4/ltp-keyutils.m4 > > +++ /dev/null > > @@ -1,10 +0,0 @@ > > -dnl SPDX-License-Identifier: GPL-2.0-or-later > > -dnl Copyright (c) 2016 Fujitsu Ltd. > > -dnl Copyright (c) 2017 Petr Vorel <pvorel@suse.cz> > > -dnl Author: Xiao Yang <yangx.jy@cn.fujitsu.com> > > - > > -AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT], [ > > - AC_CHECK_LIB([keyutils], [add_key], > > - [AC_DEFINE(HAVE_LIBKEYUTILS, 1, [Define to 1 if you have > > libkeyutils installed.]) > > - AC_SUBST(KEYUTILS_LIBS, "-lkeyutils")]) > > -]) > > diff --git a/m4/ltp-libkeyutils.m4 b/m4/ltp-libkeyutils.m4 > > new file mode 100644 > > index 000000000..f5d128969 > > --- /dev/null > > +++ b/m4/ltp-libkeyutils.m4 > > @@ -0,0 +1,8 @@ > > +dnl SPDX-License-Identifier: GPL-2.0-or-later > > +dnl Copyright (c) 2020 Petr Vorel <pvorel@suse.cz> > > + > > +AC_DEFUN([LTP_CHECK_LIBKEYUTILS], [ > > + PKG_CHECK_MODULES([LIBKEYUTILS], [libkeyutils], [ > I guess the list-of-modules should be [keyutils-libs] but not [libkeyutils]? No problem to change that, but can you explain why? Thanks for your review. Kind regards, Petr
Hi Petr, Petr Vorel <pvorel@suse.cz> wrote: > > + > > > +AC_DEFUN([LTP_CHECK_LIBKEYUTILS], [ > > > + PKG_CHECK_MODULES([LIBKEYUTILS], [libkeyutils], [ > > > > I guess the list-of-modules should be [keyutils-libs] but not > [libkeyutils]? > No problem to change that, but can you explain why? > From what I understanding, this macro runs the pkg-config tool to check for the presence of packages against keyutils-libs and sets two variables: LIBKEYUTILS_CFLAGS, LIBKEYUTILS_LIBS accordingly. So the list-of-modules should be the precise name(or version) of the library, am I right? See: https://autotools.io/pkgconfig/pkg_check_modules.html > Tested: https://travis-ci.org/github/pevik/ltp/builds/753925166 The reason for test all get passed is the "include/lapi/keyctl.h" has the second choice to include <linux/keyctl.h> I guess. #if defined(HAVE_KEYUTILS_H) && defined(HAVE_LIBKEYUTILS) # include <keyutils.h> #else # ifdef HAVE_LINUX_KEYCTL_H # include <linux/keyctl.h> # endif /* HAVE_LINUX_KEYCTL_H */
Hi Li, > Hi Petr, > Petr Vorel <pvorel@suse.cz> wrote: > > > + > > > > +AC_DEFUN([LTP_CHECK_LIBKEYUTILS], [ > > > > + PKG_CHECK_MODULES([LIBKEYUTILS], [libkeyutils], [ > > > I guess the list-of-modules should be [keyutils-libs] but not > > [libkeyutils]? > > No problem to change that, but can you explain why? > From what I understanding, this macro runs the pkg-config tool to check > for the presence of packages against keyutils-libs and sets two variables: > LIBKEYUTILS_CFLAGS, LIBKEYUTILS_LIBS accordingly. > So the list-of-modules should be the precise name(or version) of the > library, am I right? > See: https://autotools.io/pkgconfig/pkg_check_modules.html Thanks for an explanation, but I'm still missing something. In openSUSE: $ pkg-config --libs --cflags libkeyutils -lkeyutils $ pkg-config --libs --cflags keyutils-libs Package keyutils-libs was not found in the pkg-config search path. Perhaps you should add the directory containing `keyutils-libs.pc' to the PKG_CONFIG_PATH environment variable Package 'keyutils-libs', required by 'virtual:world', not found That's correct, because keyutils-devel package has file: /usr/lib64/pkgconfig/libkeyutils.pc The same is for Debian, which has /usr/lib/x86_64-linux-gnu/pkgconfig/libkeyutils.pc Looking at Fedora: keyutils-libs-devel [1] has /usr/lib64/pkgconfig/libkeyutils.pc. Download and unpack the package and run: $ PKG_CONFIG_LIBDIR="$PWD/usr/lib64/pkgconfig/" pkg-config --libs --cflags libkeyutils -lkeyutils > > Tested: https://travis-ci.org/github/pevik/ltp/builds/753925166 > The reason for test all get passed is the "include/lapi/keyctl.h" has the > second choice to include <linux/keyctl.h> I guess. > #if defined(HAVE_KEYUTILS_H) && defined(HAVE_LIBKEYUTILS) > # include <keyutils.h> In my case (openSUSE) I have HAVE_LIBKEYUTILS defined. > #else > # ifdef HAVE_LINUX_KEYCTL_H > # include <linux/keyctl.h> > # endif /* HAVE_LINUX_KEYCTL_H */ Kind regards, Petr [1] https://download-ib01.fedoraproject.org/pub/fedora/linux/updates/33/Everything/x86_64/Packages/k/keyutils-libs-devel-1.6.1-1.fc33.x86_64.rpm
Hi Li, ... > > From what I understanding, this macro runs the pkg-config tool to check > > for the presence of packages against keyutils-libs and sets two variables: > > LIBKEYUTILS_CFLAGS, LIBKEYUTILS_LIBS accordingly. > > So the list-of-modules should be the precise name(or version) of the > > library, am I right? > > See: https://autotools.io/pkgconfig/pkg_check_modules.html > Thanks for an explanation, but I'm still missing something. > In openSUSE: > $ pkg-config --libs --cflags libkeyutils > -lkeyutils > $ pkg-config --libs --cflags keyutils-libs > Package keyutils-libs was not found in the pkg-config search path. > Perhaps you should add the directory containing `keyutils-libs.pc' > to the PKG_CONFIG_PATH environment variable > Package 'keyutils-libs', required by 'virtual:world', not found > That's correct, because keyutils-devel package has file: > /usr/lib64/pkgconfig/libkeyutils.pc > The same is for Debian, which has > /usr/lib/x86_64-linux-gnu/pkgconfig/libkeyutils.pc > Looking at Fedora: > keyutils-libs-devel [1] has /usr/lib64/pkgconfig/libkeyutils.pc. > Download and unpack the package and run: > $ PKG_CONFIG_LIBDIR="$PWD/usr/lib64/pkgconfig/" pkg-config --libs --cflags libkeyutils > -lkeyutils And more importantly upstream has libkeyutils.pc.in [1] (not keyutils-libs.pc). Kind regards, Petr [1] https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/tree/libkeyutils.pc.in
Hi Petr, On Wed, Jan 13, 2021 at 6:47 AM Petr Vorel <pvorel@suse.cz> wrote: > Hi Li, > > ... > > > From what I understanding, this macro runs the pkg-config tool to check > > > for the presence of packages against keyutils-libs and sets two > variables: > > > LIBKEYUTILS_CFLAGS, LIBKEYUTILS_LIBS accordingly. > > > > So the list-of-modules should be the precise name(or version) of the > > > library, am I right? > > > See: https://autotools.io/pkgconfig/pkg_check_modules.html > > > Thanks for an explanation, but I'm still missing something. > > In openSUSE: > > > $ pkg-config --libs --cflags libkeyutils > > -lkeyutils > > > $ pkg-config --libs --cflags keyutils-libs > > Package keyutils-libs was not found in the pkg-config search path. > > Perhaps you should add the directory containing `keyutils-libs.pc' > > to the PKG_CONFIG_PATH environment variable > > Package 'keyutils-libs', required by 'virtual:world', not found > > > That's correct, because keyutils-devel package has file: > > /usr/lib64/pkgconfig/libkeyutils.pc > > > The same is for Debian, which has > > /usr/lib/x86_64-linux-gnu/pkgconfig/libkeyutils.pc > > > Looking at Fedora: > > keyutils-libs-devel [1] has /usr/lib64/pkgconfig/libkeyutils.pc. > > > Download and unpack the package and run: > > $ PKG_CONFIG_LIBDIR="$PWD/usr/lib64/pkgconfig/" pkg-config --libs > --cflags libkeyutils > > -lkeyutils > > And more importantly upstream has libkeyutils.pc.in [1] (not > keyutils-libs.pc). > Thanks for the detailed demo, it seems things not like what I assumed, and I misunderstood on something about libkeyutils. Your patch looks correct, and no need to modify it.
On 2021/1/11 20:36, Petr Vorel wrote: > Using pkg-config is less error prone during cross compilation. Hi Petr, Is there any detailed example about the above point? > Signed-off-by: Petr Vorel <pvorel@suse.cz> > --- > Hi, > > if you agree with this, I'll replace (probably after release) ACL_LIBS, > CAP_LIBS, CRYPTO_LIBS, SELINUX_LIBS (to follow libmnl and libtirpc). It is OK for me. Best Regards, Xiao Yang > libaio and libnuma does not support pkg-config. > > Tested: https://travis-ci.org/github/pevik/ltp/builds/753925166 > > Kind regards, > Petr > > configure.ac | 2 +- > include/mk/config.mk.in | 6 +++--- > m4/ltp-keyutils.m4 | 10 ---------- > m4/ltp-libkeyutils.m4 | 8 ++++++++ > testcases/cve/Makefile | 2 +- > testcases/kernel/syscalls/add_key/Makefile | 2 +- > testcases/kernel/syscalls/keyctl/Makefile | 2 +- > testcases/kernel/syscalls/request_key/Makefile | 2 +- > 8 files changed, 16 insertions(+), 18 deletions(-) > delete mode 100644 m4/ltp-keyutils.m4 > create mode 100644 m4/ltp-libkeyutils.m4 > > diff --git a/configure.ac b/configure.ac > index 06be1c094..8d667eb1e 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -328,7 +328,7 @@ LTP_CHECK_CLONE_SUPPORTS_7_ARGS > LTP_CHECK_CRYPTO > LTP_CHECK_FORTIFY_SOURCE > LTP_CHECK_KERNEL_DEVEL > -LTP_CHECK_KEYUTILS_SUPPORT > +LTP_CHECK_LIBKEYUTILS > LTP_CHECK_LIBMNL > LTP_CHECK_LINUX_PTRACE > LTP_CHECK_LINUXRANDOM > diff --git a/include/mk/config.mk.in b/include/mk/config.mk.in > index 218447ef3..382b7fda2 100644 > --- a/include/mk/config.mk.in > +++ b/include/mk/config.mk.in > @@ -52,12 +52,12 @@ LEXLIB := @LEXLIB@ > NUMA_LIBS := @NUMA_LIBS@ > SELINUX_LIBS := @SELINUX_LIBS@ > HAVE_RPC := @HAVE_RPC@ > -LIBTIRPC_CFLAGS := @LIBTIRPC_CFLAGS@ > -LIBTIRPC_LIBS := @LIBTIRPC_LIBS@ > -KEYUTILS_LIBS := @KEYUTILS_LIBS@ > HAVE_FTS_H := @HAVE_FTS_H@ > +LIBKEYUTILS_LIBS := @LIBKEYUTILS_LIBS@ > LIBMNL_LIBS := @LIBMNL_LIBS@ > LIBMNL_CFLAGS := @LIBMNL_CFLAGS@ > +LIBTIRPC_CFLAGS := @LIBTIRPC_CFLAGS@ > +LIBTIRPC_LIBS := @LIBTIRPC_LIBS@ > > prefix := @prefix@ > > diff --git a/m4/ltp-keyutils.m4 b/m4/ltp-keyutils.m4 > deleted file mode 100644 > index 451c549f3..000000000 > --- a/m4/ltp-keyutils.m4 > +++ /dev/null > @@ -1,10 +0,0 @@ > -dnl SPDX-License-Identifier: GPL-2.0-or-later > -dnl Copyright (c) 2016 Fujitsu Ltd. > -dnl Copyright (c) 2017 Petr Vorel <pvorel@suse.cz> > -dnl Author: Xiao Yang <yangx.jy@cn.fujitsu.com> > - > -AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT], [ > - AC_CHECK_LIB([keyutils], [add_key], > - [AC_DEFINE(HAVE_LIBKEYUTILS, 1, [Define to 1 if you have libkeyutils installed.]) > - AC_SUBST(KEYUTILS_LIBS, "-lkeyutils")]) > -]) > diff --git a/m4/ltp-libkeyutils.m4 b/m4/ltp-libkeyutils.m4 > new file mode 100644 > index 000000000..f5d128969 > --- /dev/null > +++ b/m4/ltp-libkeyutils.m4 > @@ -0,0 +1,8 @@ > +dnl SPDX-License-Identifier: GPL-2.0-or-later > +dnl Copyright (c) 2020 Petr Vorel <pvorel@suse.cz> > + > +AC_DEFUN([LTP_CHECK_LIBKEYUTILS], [ > + PKG_CHECK_MODULES([LIBKEYUTILS], [libkeyutils], [ > + AC_DEFINE([HAVE_LIBKEYUTILS], [1], [Define to 1 if you have libkeyutils library and headers]) > + ], [have_libkeyutils=no]) > +]) > diff --git a/testcases/cve/Makefile b/testcases/cve/Makefile > index da44fff60..90921dd85 100644 > --- a/testcases/cve/Makefile > +++ b/testcases/cve/Makefile > @@ -21,7 +21,7 @@ CFLAGS += -D_GNU_SOURCE > > stack_clash: CFLAGS += -fno-optimize-sibling-calls > > -cve-2016-7042: LDLIBS += $(KEYUTILS_LIBS) > +cve-2016-7042: LDLIBS += $(LIBKEYUTILS_LIBS) > > cve-2016-7117: CFLAGS += -pthread > cve-2016-7117: LDLIBS += -lrt > diff --git a/testcases/kernel/syscalls/add_key/Makefile b/testcases/kernel/syscalls/add_key/Makefile > index 0f51e0bc2..6c2102247 100644 > --- a/testcases/kernel/syscalls/add_key/Makefile > +++ b/testcases/kernel/syscalls/add_key/Makefile > @@ -5,6 +5,6 @@ top_srcdir ?= ../../../.. > > include $(top_srcdir)/include/mk/testcases.mk > > -LDLIBS += $(KEYUTILS_LIBS) > +LDLIBS += $(LIBKEYUTILS_LIBS) > > include $(top_srcdir)/include/mk/generic_leaf_target.mk > diff --git a/testcases/kernel/syscalls/keyctl/Makefile b/testcases/kernel/syscalls/keyctl/Makefile > index 180ece25a..343c5e359 100644 > --- a/testcases/kernel/syscalls/keyctl/Makefile > +++ b/testcases/kernel/syscalls/keyctl/Makefile > @@ -5,7 +5,7 @@ top_srcdir ?= ../../../.. > > include $(top_srcdir)/include/mk/testcases.mk > > -LDLIBS += $(KEYUTILS_LIBS) > +LDLIBS += $(LIBKEYUTILS_LIBS) > keyctl02: LDLIBS += -lpthread > > include $(top_srcdir)/include/mk/generic_leaf_target.mk > diff --git a/testcases/kernel/syscalls/request_key/Makefile b/testcases/kernel/syscalls/request_key/Makefile > index 58a99875e..e69774b96 100644 > --- a/testcases/kernel/syscalls/request_key/Makefile > +++ b/testcases/kernel/syscalls/request_key/Makefile > @@ -6,6 +6,6 @@ top_srcdir ?= ../../../.. > > include $(top_srcdir)/include/mk/testcases.mk > > -LDLIBS += $(KEYUTILS_LIBS) > +LDLIBS += $(LIBKEYUTILS_LIBS) > > include $(top_srcdir)/include/mk/generic_leaf_target.mk
Hi Yang, > On 2021/1/11 20:36, Petr Vorel wrote: > > Using pkg-config is less error prone during cross compilation. > Hi Petr, > Is there any detailed example about the above point? Sometimes I experienced problems during cross compilation with installed library for build architecture but missing library for host architecture build failed during linking because library was expected but missing. But I it turned out to be when using our CROSS_COMPILE implementation (without specifying --host). When configuring with just --host libraries are properly detected with AC_CHECK_LIB(). pkg-config has some pros and cons. Pros: * easily require specific library version * getting CFLAGS from *.pc file * IMHO it's a standard way nowadays Cons: * For cross compilation it's reuired to set correctly PKG_CONFIG_LIBDIR. I brought pkg-config as dependency to LTP due checking libtirpc >= 0.2.4. But this version is already 7 years old so we might not need this version check now. (and one day it'd be best to fix (or rewrite from scratch) rpc/tirpc tests and move them to libtirpc upstream as Sun-RPC was removed from glibc in 2.32). Thus we can safely reconsider if we want pkg-config or not. Kind regards, Petr
On 2021/1/13 18:39, Petr Vorel wrote: > Hi Yang, > >> On 2021/1/11 20:36, Petr Vorel wrote: >>> Using pkg-config is less error prone during cross compilation. >> Hi Petr, >> Is there any detailed example about the above point? > Sometimes I experienced problems during cross compilation with installed library > for build architecture but missing library for host architecture build failed > during linking because library was expected but missing. > > But I it turned out to be when using our CROSS_COMPILE implementation (without > specifying --host). When configuring with just --host libraries are properly > detected with AC_CHECK_LIB(). Hi Petr, Does the issue only happened when we use ./configure without --host? In an other word, AC_CHECK_LIB() can detect proper installed libraries for build architecture by './configure --host', right? > pkg-config has some pros and cons. > Pros: > * easily require specific library version > * getting CFLAGS from *.pc file > * IMHO it's a standard way nowadays > Cons: > * For cross compilation it's reuired to set correctly PKG_CONFIG_LIBDIR. Current ltp mixes pkg-config and AC_CHECK_LIB() so I want to unify them. We cannot use pkg-config for all libraries because some packages don't provide *.pc files. Best Regards, Xiao Yang > I brought pkg-config as dependency to LTP due checking libtirpc>= 0.2.4. > But this version is already 7 years old so we might not need this version check now. > (and one day it'd be best to fix (or rewrite from scratch) rpc/tirpc tests and > move them to libtirpc upstream as Sun-RPC was removed from glibc in 2.32). > > Thus we can safely reconsider if we want pkg-config or not. > > Kind regards, > Petr > > > . >
> On 2021/1/13 18:39, Petr Vorel wrote: > > Hi Yang, > > > On 2021/1/11 20:36, Petr Vorel wrote: > > > > Using pkg-config is less error prone during cross compilation. > > > Hi Petr, > > > Is there any detailed example about the above point? > > Sometimes I experienced problems during cross compilation with installed library > > for build architecture but missing library for host architecture build failed > > during linking because library was expected but missing. > > But I it turned out to be when using our CROSS_COMPILE implementation (without > > specifying --host). When configuring with just --host libraries are properly > > detected with AC_CHECK_LIB(). > Hi Petr, > Does the issue only happened when we use ./configure without --host? > In an other word, AC_CHECK_LIB() can detect proper installed libraries for > build architecture by './configure --host', right? Yes (but it cannot detect library version). > > pkg-config has some pros and cons. > > Pros: > > * easily require specific library version > > * getting CFLAGS from *.pc file > > * IMHO it's a standard way nowadays > > Cons: > > * For cross compilation it's reuired to set correctly PKG_CONFIG_LIBDIR. > Current ltp mixes pkg-config and AC_CHECK_LIB() so I want to unify them. > We cannot use pkg-config for all libraries because some packages don't > provide *.pc files. Yes. But if you want to remove pkg-config, I'd wait for others opinions about it :). Kind regards, Petr > Best Regards, > Xiao Yang > > I brought pkg-config as dependency to LTP due checking libtirpc>= 0.2.4. > > But this version is already 7 years old so we might not need this version check now. > > (and one day it'd be best to fix (or rewrite from scratch) rpc/tirpc tests and > > move them to libtirpc upstream as Sun-RPC was removed from glibc in 2.32). > > Thus we can safely reconsider if we want pkg-config or not. > > Kind regards, > > Petr > > .
diff --git a/configure.ac b/configure.ac index 06be1c094..8d667eb1e 100644 --- a/configure.ac +++ b/configure.ac @@ -328,7 +328,7 @@ LTP_CHECK_CLONE_SUPPORTS_7_ARGS LTP_CHECK_CRYPTO LTP_CHECK_FORTIFY_SOURCE LTP_CHECK_KERNEL_DEVEL -LTP_CHECK_KEYUTILS_SUPPORT +LTP_CHECK_LIBKEYUTILS LTP_CHECK_LIBMNL LTP_CHECK_LINUX_PTRACE LTP_CHECK_LINUXRANDOM diff --git a/include/mk/config.mk.in b/include/mk/config.mk.in index 218447ef3..382b7fda2 100644 --- a/include/mk/config.mk.in +++ b/include/mk/config.mk.in @@ -52,12 +52,12 @@ LEXLIB := @LEXLIB@ NUMA_LIBS := @NUMA_LIBS@ SELINUX_LIBS := @SELINUX_LIBS@ HAVE_RPC := @HAVE_RPC@ -LIBTIRPC_CFLAGS := @LIBTIRPC_CFLAGS@ -LIBTIRPC_LIBS := @LIBTIRPC_LIBS@ -KEYUTILS_LIBS := @KEYUTILS_LIBS@ HAVE_FTS_H := @HAVE_FTS_H@ +LIBKEYUTILS_LIBS := @LIBKEYUTILS_LIBS@ LIBMNL_LIBS := @LIBMNL_LIBS@ LIBMNL_CFLAGS := @LIBMNL_CFLAGS@ +LIBTIRPC_CFLAGS := @LIBTIRPC_CFLAGS@ +LIBTIRPC_LIBS := @LIBTIRPC_LIBS@ prefix := @prefix@ diff --git a/m4/ltp-keyutils.m4 b/m4/ltp-keyutils.m4 deleted file mode 100644 index 451c549f3..000000000 --- a/m4/ltp-keyutils.m4 +++ /dev/null @@ -1,10 +0,0 @@ -dnl SPDX-License-Identifier: GPL-2.0-or-later -dnl Copyright (c) 2016 Fujitsu Ltd. -dnl Copyright (c) 2017 Petr Vorel <pvorel@suse.cz> -dnl Author: Xiao Yang <yangx.jy@cn.fujitsu.com> - -AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT], [ - AC_CHECK_LIB([keyutils], [add_key], - [AC_DEFINE(HAVE_LIBKEYUTILS, 1, [Define to 1 if you have libkeyutils installed.]) - AC_SUBST(KEYUTILS_LIBS, "-lkeyutils")]) -]) diff --git a/m4/ltp-libkeyutils.m4 b/m4/ltp-libkeyutils.m4 new file mode 100644 index 000000000..f5d128969 --- /dev/null +++ b/m4/ltp-libkeyutils.m4 @@ -0,0 +1,8 @@ +dnl SPDX-License-Identifier: GPL-2.0-or-later +dnl Copyright (c) 2020 Petr Vorel <pvorel@suse.cz> + +AC_DEFUN([LTP_CHECK_LIBKEYUTILS], [ + PKG_CHECK_MODULES([LIBKEYUTILS], [libkeyutils], [ + AC_DEFINE([HAVE_LIBKEYUTILS], [1], [Define to 1 if you have libkeyutils library and headers]) + ], [have_libkeyutils=no]) +]) diff --git a/testcases/cve/Makefile b/testcases/cve/Makefile index da44fff60..90921dd85 100644 --- a/testcases/cve/Makefile +++ b/testcases/cve/Makefile @@ -21,7 +21,7 @@ CFLAGS += -D_GNU_SOURCE stack_clash: CFLAGS += -fno-optimize-sibling-calls -cve-2016-7042: LDLIBS += $(KEYUTILS_LIBS) +cve-2016-7042: LDLIBS += $(LIBKEYUTILS_LIBS) cve-2016-7117: CFLAGS += -pthread cve-2016-7117: LDLIBS += -lrt diff --git a/testcases/kernel/syscalls/add_key/Makefile b/testcases/kernel/syscalls/add_key/Makefile index 0f51e0bc2..6c2102247 100644 --- a/testcases/kernel/syscalls/add_key/Makefile +++ b/testcases/kernel/syscalls/add_key/Makefile @@ -5,6 +5,6 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -LDLIBS += $(KEYUTILS_LIBS) +LDLIBS += $(LIBKEYUTILS_LIBS) include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/keyctl/Makefile b/testcases/kernel/syscalls/keyctl/Makefile index 180ece25a..343c5e359 100644 --- a/testcases/kernel/syscalls/keyctl/Makefile +++ b/testcases/kernel/syscalls/keyctl/Makefile @@ -5,7 +5,7 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -LDLIBS += $(KEYUTILS_LIBS) +LDLIBS += $(LIBKEYUTILS_LIBS) keyctl02: LDLIBS += -lpthread include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/request_key/Makefile b/testcases/kernel/syscalls/request_key/Makefile index 58a99875e..e69774b96 100644 --- a/testcases/kernel/syscalls/request_key/Makefile +++ b/testcases/kernel/syscalls/request_key/Makefile @@ -6,6 +6,6 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -LDLIBS += $(KEYUTILS_LIBS) +LDLIBS += $(LIBKEYUTILS_LIBS) include $(top_srcdir)/include/mk/generic_leaf_target.mk
Using pkg-config is less error prone during cross compilation. Signed-off-by: Petr Vorel <pvorel@suse.cz> --- Hi, if you agree with this, I'll replace (probably after release) ACL_LIBS, CAP_LIBS, CRYPTO_LIBS, SELINUX_LIBS (to follow libmnl and libtirpc). libaio and libnuma does not support pkg-config. Tested: https://travis-ci.org/github/pevik/ltp/builds/753925166 Kind regards, Petr configure.ac | 2 +- include/mk/config.mk.in | 6 +++--- m4/ltp-keyutils.m4 | 10 ---------- m4/ltp-libkeyutils.m4 | 8 ++++++++ testcases/cve/Makefile | 2 +- testcases/kernel/syscalls/add_key/Makefile | 2 +- testcases/kernel/syscalls/keyctl/Makefile | 2 +- testcases/kernel/syscalls/request_key/Makefile | 2 +- 8 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 m4/ltp-keyutils.m4 create mode 100644 m4/ltp-libkeyutils.m4