]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
build: disable --with-unitdir by default
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 27 Aug 2025 13:51:10 +0000 (15:51 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 27 Aug 2025 14:56:04 +0000 (16:56 +0200)
Same behaviour as in the original patch:

  --with-unitdir auto-detects the systemd unit path.
  --with-unitdir=PATH uses the PATH

no --with-unitdir means this does not install the systemd unit file.

INSTALL file description looks fine for what this does after this
patch.

While at this, extend tests/build/ to cover for this new option.

Fixes: c4b17cf830510 ("tools: add a systemd unit for static rulesets")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
configure.ac
tests/build/run-tests.sh

index 626c641b006a28d5532d7a6597f9ca463b8c448d..670b4f0fbdf794334a2daec3ac7f4ea199207900 100644 (file)
@@ -115,15 +115,22 @@ AC_CHECK_DECLS([getprotobyname_r, getprotobynumber_r, getservbyport_r], [], [],
 ]])
 
 AC_ARG_WITH([unitdir],
-       [AS_HELP_STRING([--with-unitdir=PATH], [Path to systemd service unit directory])],
-       [unitdir="$withval"],
+       [AS_HELP_STRING([--with-unitdir[=PATH]],
+       [Path to systemd service unit directory, or omit PATH to auto-detect])],
        [
-               unitdir=$("$PKG_CONFIG" systemd --variable systemdsystemunitdir 2>/dev/null)
-               AS_IF([test -z "$unitdir"], [unitdir='${prefix}/lib/systemd/system'])
-       ])
+               if test "x$withval" = "xyes"; then
+                       unitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd 2>/dev/null)
+                       AS_IF([test -z "$unitdir"], [unitdir='${prefix}/lib/systemd/system'])
+               elif test "x$withval" = "xno"; then
+                       unitdir=""
+               else
+                       unitdir="$withval"
+               fi
+       ],
+       [unitdir=""]
+)
 AC_SUBST([unitdir])
 
-
 AC_CONFIG_FILES([                                      \
                Makefile                                \
                libnftables.pc                          \
@@ -137,5 +144,11 @@ nft configuration:
   use mini-gmp:                        ${with_mini_gmp}
   enable man page:              ${enable_man_doc}
   libxtables support:          ${with_xtables}
-  json output support:          ${with_json}
-  systemd unit:                        ${unitdir}"
+  json output support:          ${with_json}"
+
+if test "x$unitdir" != "x"; then
+AC_SUBST([unitdir])
+echo "  systemd unit:                 ${unitdir}"
+else
+echo "  systemd unit:                 no"
+fi
index 916df2e2fa8e06a741533a77e363fe42c5d07256..674383cb6cc7414c10c0d67fd7dc302391ece148 100755 (executable)
@@ -3,7 +3,7 @@
 log_file="$(pwd)/tests.log"
 dir=../..
 argument=( --without-cli --with-cli=linenoise --with-cli=editline --enable-debug --with-mini-gmp
-          --enable-man-doc --with-xtables --with-json)
+          --enable-man-doc --with-xtables --with-json --with-unitdir --with-unitdir=/lib/systemd/system)
 ok=0
 failed=0