]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
build: Fix rule that copies `.config` to `build/config`
authorSimon Kuenzer <simon@unikraft.io>
Fri, 29 Sep 2023 14:51:35 +0000 (16:51 +0200)
committerRazvan Deaconescu <razvand@unikraft.io>
Fri, 20 Oct 2023 16:35:55 +0000 (19:35 +0300)
The rule that copies the current `.config` to the build directory was
intended, among other things, to detect configuration changes. However, the
corresponding rule always copies the file, causing to update the timestamp
on every make call. This commit fixes that rule by only copying the file
when there have been configuration updates.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1119

Makefile

index 071c84a6f65e027897f59ce5d9cfe21b884b9bff..23d5da3c8dbaa80c3ffb1c7b64cf94eefbd9cfa2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -778,9 +778,8 @@ fetch: $(UK_FETCH) $(UK_FETCH-y)
 
 # Copy current configuration in order to detect changes
 $(UK_CONFIG_OUT): $(UK_CONFIG)
-       $(call verbose_cmd,CP,config,$(CP) \
-               $(UK_CONFIG) \
-               $(UK_CONFIG_OUT))
+       $(call verbose_cmd,CP,config, \
+               cmp -s $^ $@; if [ $$? -ne 0 ]; then cp $^ $@; fi)
 
 prepare: $(KCONFIG_AUTOHEADER) $(UK_CONFIG_OUT) $(UK_PREPARE) $(UK_PREPARE-y)
 prepare: $(UK_FIXDEP) | fetch
@@ -983,8 +982,10 @@ oldconfig:
        @$(COMMON_CONFIG_ENV) $(SCRIPTS_DIR)/configupdate $(UK_CONFIG) $(UK_CONFIG_OUT)
 
 # Regenerate $(KCONFIG_AUTOHEADER) whenever $(UK_CONFIG) changed
-$(KCONFIG_AUTOHEADER): $(UK_CONFIG)
-       @$(COMMON_CONFIG_ENV) $(KPYTHON) $(CONFIGLIB)/genconfig.py --header-path $(KCONFIG_AUTOHEADER) $(CONFIG_CONFIG_IN)
+$(KCONFIG_AUTOHEADER): $(UK_CONFIG_OUT)
+       $(call verbose_cmd,GEN,config.h, \
+               $(COMMON_CONFIG_ENV) $(KPYTHON) $(CONFIGLIB)/genconfig.py \
+                       --header-path $(KCONFIG_AUTOHEADER) $(CONFIG_CONFIG_IN))
 else
 # Use traditional KConfig system on Linux
 xconfig: $(KCONFIG_DIR)/qconf
@@ -1062,8 +1063,10 @@ endif
 .PHONY: defconfig savedefconfig silentoldconfig
 
 # Regenerate $(KCONFIG_AUTOHEADER) whenever $(UK_CONFIG) changed
-$(KCONFIG_AUTOHEADER): $(UK_CONFIG) $(KCONFIG_DIR)/conf
-       @$(COMMON_CONFIG_ENV) $(KCONFIG_DIR)/conf --syncconfig $(CONFIG_CONFIG_IN)
+$(KCONFIG_AUTOHEADER): $(UK_CONFIG_OUT) $(KCONFIG_DIR)/conf
+       $(call verbose_cmd,GEN,config.h, \
+               $(COMMON_CONFIG_ENV) $(KCONFIG_DIR)/conf \
+                       --syncconfig $(CONFIG_CONFIG_IN))
 endif