[PATCH v3] nfsrahead: fix linking while static linking

Giulio Benetti
2022-08-10T21:46:05Z

-lmount must preceed -lblkid and to obtain this let's add in configure.ac:
PKG_CHECK_MODULES([LIBMOUNT], [mount])
and in tools/nfsrahead/Makefile.am let's substitute explicit `-lmount`
with:
$(LIBMOUNT_LIBS)
This way all the required libraries will be present and in the right order
when static linking.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
V1->V2:
* modify pkg-conf to pkg-config
V2->V3:
* use the correct way for using pkg-config with Autotools
---
configure.ac | 3 +++
tools/nfsrahead/Makefile.am | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f1c46c5c..ff85200b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,6 +273,9 @@ AC_LIBCAP
dnl Check for -lxml2
AC_LIBXML2

+dnl Check for -lmount
+PKG_CHECK_MODULES([LIBMOUNT], [mount])
+
# Check whether user wants TCP wrappers support
AC_TCP_WRAPPERS

diff --git a/tools/nfsrahead/Makefile.am b/tools/nfsrahead/Makefile.am
index 845ea0d5..7e08233a 100644
--- a/tools/nfsrahead/Makefile.am
+++ b/tools/nfsrahead/Makefile.am
@@ -1,6 +1,6 @@
libexec_PROGRAMS = nfsrahead
nfsrahead_SOURCES = main.c
-nfsrahead_LDFLAGS= -lmount
+nfsrahead_LDFLAGS= $(LIBMOUNT_LIBS)
nfsrahead_LDADD = ../../support/nfs/libnfsconf.la

man5_MANS = nfsrahead.man
--
2.34.1