From 0200baa675d3b51c0f021da7728353ee7ceedba4 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 16 Feb 2024 12:06:15 +0000 Subject: build system: avoid full rebuild when EXTRAVERSION changes The last two commits allow EXTRAVERSION to track the current state of a git repository. The build system was unable to determine which files were affected by changes to EXTRAVERSION and caused a full rebuild when it changed. Alter how the version information is passed to the code so only a handful of files need to be rebuilt when it changes. --- Makefile | 10 +++++++++- Makefile.flags | 2 +- archival/tar.c | 3 +++ editors/vi.c | 3 +++ libbb/messages.c | 3 +++ miscutils/bc.c | 3 +++ networking/httpd.c | 3 +++ 7 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c12b7791f..30a24f68e 100644 --- a/Makefile +++ b/Makefile @@ -892,7 +892,7 @@ endif # prepare2 creates a makefile if using a separate output directory prepare2: prepare3 outputmakefile -prepare1: prepare2 include/config/MARKER +prepare1: prepare2 include/config/MARKER include/BB_VER.h ifneq ($(KBUILD_MODULES),) $(Q)mkdir -p $(MODVERDIR) $(Q)rm -f $(MODVERDIR)/* @@ -956,6 +956,13 @@ define filechk_version.h ) endef +define filechk_BB_VER.h + (echo \#define BB_VER \"$(KERNELRELEASE)\";) +endef + +include/BB_VER.h: $(srctree)/Makefile .config .kernelrelease FORCE + $(call filechk,BB_VER.h) + # --------------------------------------------------------------------------- PHONY += depend dep @@ -1051,6 +1058,7 @@ CLEAN_FILES += busybox$(EXEEXT) busybox_unstripped* busybox.links \ MRPROPER_DIRS += include/config include2 MRPROPER_FILES += .config .config.old include/asm .version .old_version \ include/NUM_APPLETS.h \ + include/BB_VER.h \ include/common_bufsiz.h \ include/autoconf.h \ include/bbconfigopts.h \ diff --git a/Makefile.flags b/Makefile.flags index 8be999cb2..f24fd9475 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -17,7 +17,7 @@ CPPFLAGS += \ $(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \ $(if $(CONFIG_TIME64),-D_TIME_BITS=64) \ -DMINGW_VER=$(squote)$(quote)$(MINGW_VER)$(quote)$(squote) \ - -DBB_VER=$(squote)$(quote)$(BB_VER)$(quote)$(squote) + $(if $(CONFIG_PLATFORM_MINGW32),,-DBB_VER=$(squote)$(quote)$(BB_VER)$(quote)$(squote)) CFLAGS += $(call cc-option,-Wall,) CFLAGS += $(call cc-option,-Wshadow,) diff --git a/archival/tar.c b/archival/tar.c index bb82560b8..23ea02b5d 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -119,6 +119,9 @@ #include "libbb.h" #include "common_bufsiz.h" #include "bb_archive.h" +#if ENABLE_PLATFORM_MINGW32 +# include "BB_VER.h" +#endif /* FIXME: Stop using this non-standard feature */ #ifndef FNM_LEADING_DIR # define FNM_LEADING_DIR 0 diff --git a/editors/vi.c b/editors/vi.c index b49d5454d..7ad8412a2 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -214,6 +214,9 @@ #if ENABLE_FEATURE_VI_REGEX_SEARCH # include #endif +#if ENABLE_PLATFORM_MINGW32 +# include "BB_VER.h" +#endif // the CRASHME code is unmaintained, and doesn't currently build #define ENABLE_FEATURE_VI_CRASHME 0 diff --git a/libbb/messages.c b/libbb/messages.c index 3c9d8683a..12079a2e0 100644 --- a/libbb/messages.c +++ b/libbb/messages.c @@ -5,6 +5,9 @@ * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ #include "libbb.h" +#if ENABLE_PLATFORM_MINGW32 +# include "BB_VER.h" +#endif /* allow version to be extended, via CFLAGS */ #ifndef BB_EXTRA_VERSION diff --git a/miscutils/bc.c b/miscutils/bc.c index a82646674..31485ae9c 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -203,6 +203,9 @@ #include "libbb.h" #include "common_bufsiz.h" +#if ENABLE_PLATFORM_MINGW32 +# include "BB_VER.h" +#endif #if !ENABLE_BC && !ENABLE_FEATURE_DC_BIG # include "dc.c" diff --git a/networking/httpd.c b/networking/httpd.c index c76ce3658..bd3a5a097 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -299,6 +299,9 @@ #include "libbb.h" #include "common_bufsiz.h" +#if ENABLE_PLATFORM_MINGW32 +# include "BB_VER.h" +#endif #if ENABLE_PAM /* PAM may include . We may need to undefine bbox's stub define: */ # undef setlocale -- cgit v1.2.3-55-g6feb