]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
build-sys: use PKG_CHECK_VAR()
authorKarel Zak <kzak@redhat.com>
Tue, 14 Jun 2022 13:47:05 +0000 (15:47 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 14 Jun 2022 13:47:05 +0000 (15:47 +0200)
Do not call 'PKG_CONFIG --exists' and '$PKG_CONFIG --variable' if
there is a much more robust PKG_CHECK_VAR() macro.

It's also not necessary to check for the dirs if all the feature
(systemd or bashcompletiondir) is disabled.

Reported-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac

index f6ce2d12b4b98a35607677f0399280008eab3f66..83c49d94443a5cbc97dd095d00e530eff919237a 100644 (file)
@@ -2442,13 +2442,11 @@ AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$have_systemd" = xyes])
 
 AC_ARG_WITH([systemdsystemunitdir],
   AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [directory for systemd unit files (requires systemd support)]),
-  [], [with_systemdsystemunitdir=check]
-)
-AS_IF([test "x$with_systemdsystemunitdir" = xcheck], [
+  [], [
   AS_IF([test "x$have_systemd" = xyes], [
-    with_systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
-  ],[
-    with_systemdsystemunitdir=no
+    PKG_CHECK_VAR([with_systemdsystemunitdir], [systemd], [systemdsystemunitdir],
+      [],
+      [with_systemdsystemunitdir=no])
   ])
 ])
 AS_IF([test "x$with_systemdsystemunitdir" != "xno"], [
@@ -2492,17 +2490,6 @@ AS_IF([test "x$with_vendordir" != x], [
 ])
 
 
-AC_ARG_WITH([bashcompletiondir],
-  AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
-  [],
-  [AS_IF([`$PKG_CONFIG --exists bash-completion`], [
-    with_bashcompletiondir=`$PKG_CONFIG --variable=completionsdir bash-completion`
-  ], [
-    with_bashcompletiondir=${datadir}/bash-completion/completions
-  ])
-])
-AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
-
 AC_ARG_ENABLE([bash-completion],
   AS_HELP_STRING([--disable-bash-completion], [do not install bash completion files]),
   [], [enable_bash_completion=yes]
@@ -2510,6 +2497,18 @@ AC_ARG_ENABLE([bash-completion],
 
 AM_CONDITIONAL([BUILD_BASH_COMPLETION], [test "x$enable_bash_completion" = xyes])
 
+AC_ARG_WITH([bashcompletiondir],
+  AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
+  [], [
+  AS_IF([test "x$enable_bash_completion" = xyes], [
+    PKG_CHECK_VAR([with_bashcompletiondir], [bash-completion], [completionsdir],
+      [],
+      [with_bashcompletiondir=${datadir}/bash-completion/completions])
+  ])
+])
+AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
+
+
 
 AC_ARG_WITH([python],
   AS_HELP_STRING([--without-python], [do not build python bindings, use --with-python={2,3} to force version]),