From: Jeremy Sowden Date: Wed, 28 Jan 2026 18:31:05 +0000 (+0000) Subject: build: simplify the instantation of nftversion.h X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a0ec8a7246e5c5eb85270e3d4de43e20a00c577;p=thirdparty%2Fnftables.git build: simplify the instantation of nftversion.h Add an nftversion.h.in autoconf input file which configure uses to instantiate nftversion.h in the usual way. Signed-off-by: Jeremy Sowden Signed-off-by: Phil Sutter --- diff --git a/configure.ac b/configure.ac index dd172e88..2c61072e 100644 --- a/configure.ac +++ b/configure.ac @@ -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 index 00000000..6f897719 --- /dev/null +++ b/nftversion.h.in @@ -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) */