]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
build: simplify the instantation of nftversion.h
authorJeremy Sowden <jeremy@azazel.net>
Wed, 28 Jan 2026 18:31:05 +0000 (18:31 +0000)
committerPhil Sutter <phil@nwl.cc>
Wed, 28 Jan 2026 19:00:49 +0000 (20:00 +0100)
Add an nftversion.h.in autoconf input file which configure uses to instantiate
nftversion.h in the usual way.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Phil Sutter <phil@nwl.cc>
configure.ac
nftversion.h.in [new file with mode: 0644]

index dd172e88ca581d8da25396559ed2e1cb8229d217..2c61072e06820e4a828d28a85d63f938a9f4984c 100644 (file)
@@ -147,22 +147,8 @@ AM_CONDITIONAL([BUILD_SERVICE], [test "x$unitdir" != x])
 AC_ARG_WITH([stable-release], [AS_HELP_STRING([--with-stable-release],
             [Stable release number])],
             [], [with_stable_release=0])
-AC_CONFIG_COMMANDS([stable_release],
-                   [STABLE_RELEASE=$stable_release],
-                   [stable_release=$with_stable_release])
-AC_CONFIG_COMMANDS([nftversion.h], [
-(
-       echo "static char nftversion[[]] = {"
-       echo "  ${VERSION}," | tr '.' ','
-       echo "  ${STABLE_RELEASE}"
-       echo "};"
-       echo "static char nftbuildstamp[[]] = {"
-       for i in `seq 56 -8 0`; do
-               echo "  ((uint64_t)MAKE_STAMP >> $i) & 0xff,"
-       done
-       echo "};"
-) >nftversion.h
-])
+AC_SUBST([STABLE_RELEASE],[$with_stable_release])
+AC_SUBST([NFT_VERSION], [$(echo "${VERSION}" | tr '.' ',')])
 # Current date should be fetched exactly once per build,
 # so have 'make' call date and pass the value to every 'gcc' call
 AC_SUBST([MAKE_STAMP], ["\$(shell date +%s)"])
@@ -175,6 +161,7 @@ AM_CONDITIONAL([BUILD_DISTCHECK], [test "x$enable_distcheck" = "xyes"])
 AC_CONFIG_FILES([                                      \
                Makefile                                \
                libnftables.pc                          \
+               nftversion.h                            \
                ])
 AC_OUTPUT
 
diff --git a/nftversion.h.in b/nftversion.h.in
new file mode 100644 (file)
index 0000000..6f89771
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef NFTABLES_NFTVERSION_H
+#define NFTABLES_NFTVERSION_H
+
+static char nftversion[] = {
+       @NFT_VERSION@,
+       @STABLE_RELEASE@
+};
+static char nftbuildstamp[] = {
+       ((uint64_t)MAKE_STAMP >> 56) & 0xff,
+       ((uint64_t)MAKE_STAMP >> 48) & 0xff,
+       ((uint64_t)MAKE_STAMP >> 40) & 0xff,
+       ((uint64_t)MAKE_STAMP >> 32) & 0xff,
+       ((uint64_t)MAKE_STAMP >> 24) & 0xff,
+       ((uint64_t)MAKE_STAMP >> 16) & 0xff,
+       ((uint64_t)MAKE_STAMP >> 8) & 0xff,
+       ((uint64_t)MAKE_STAMP >> 0) & 0xff,
+};
+
+#endif /* !defined(NFTABLES_NFTVERSION_H) */