]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
build: generate build time-stamp once at configure
authorJeremy Sowden <jeremy@azazel.net>
Wed, 28 Jan 2026 18:31:06 +0000 (18:31 +0000)
committerPhil Sutter <phil@nwl.cc>
Wed, 28 Jan 2026 19:00:49 +0000 (20:00 +0100)
The existing implementation tries to generate a time-stamp once when make is
run.  However, it doesn't work and generates one for every compilation.  Getting
this right portably in automake is not straightforward.  Instead, do it when
configure is run.

Rename the time-stamp variable since it is no longer generated by make.

Fixes: 64c07e38f049 ("table: Embed creating nft version into userdata")
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Makefile.am
configure.ac
nftversion.h.in

index 5c7c197f43ca70e0db66df97b7e465e4249b122f..c60c2e63d5aff2c0f2040cd591cb5af2f00fd439 100644 (file)
@@ -159,8 +159,6 @@ AM_CFLAGS = \
        \
        $(GCC_FVISIBILITY_HIDDEN) \
        \
-       -DMAKE_STAMP=$(MAKE_STAMP) \
-       \
        $(NULL)
 
 AM_YFLAGS = -d -Wno-yacc
index 2c61072e06820e4a828d28a85d63f938a9f4984c..9859072e9ae5c7bbe6490ab957e2502792ca5649 100644 (file)
@@ -149,9 +149,7 @@ AC_ARG_WITH([stable-release], [AS_HELP_STRING([--with-stable-release],
             [], [with_stable_release=0])
 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)"])
+AC_SUBST([BUILD_STAMP], [$(date +%s)])
 
 AC_ARG_ENABLE([distcheck],
              AS_HELP_STRING([--enable-distcheck], [Build for distcheck]),
index 6f897719d0059465a598d14e8023d3f5cf2ad019..325b9dcca2d87201ab539a41212394b7cbba6c12 100644 (file)
@@ -1,19 +1,21 @@
 #ifndef NFTABLES_NFTVERSION_H
 #define NFTABLES_NFTVERSION_H
 
+#define BUILD_STAMP @BUILD_STAMP@
+
 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,
+       ((uint64_t)BUILD_STAMP >> 56) & 0xff,
+       ((uint64_t)BUILD_STAMP >> 48) & 0xff,
+       ((uint64_t)BUILD_STAMP >> 40) & 0xff,
+       ((uint64_t)BUILD_STAMP >> 32) & 0xff,
+       ((uint64_t)BUILD_STAMP >> 24) & 0xff,
+       ((uint64_t)BUILD_STAMP >> 16) & 0xff,
+       ((uint64_t)BUILD_STAMP >> 8) & 0xff,
+       ((uint64_t)BUILD_STAMP >> 0) & 0xff,
 };
 
 #endif /* !defined(NFTABLES_NFTVERSION_H) */