[PATCH 1/3] Makefile: Fix incorrect FORCE deps on env rules

These rules run on every build even if nothing has changed. The FORCE dependency is only needed for if_changed, not for cmd. Drop it.
Signed-off-by: Simon Glass sjg@chromium.org ---
Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index 166acba27032..19503d013ab6 100644 --- a/Makefile +++ b/Makefile @@ -1808,7 +1808,7 @@ quiet_cmd_gen_envp = ENVP $@ rm -f $@; \ touch $@ ; \ fi -include/generated/env.in: include/generated/env.txt FORCE +include/generated/env.in: include/generated/env.txt $(call cmd,gen_envp)
# Regenerate the environment if it changes @@ -1826,7 +1826,7 @@ quiet_cmd_envc = ENVC $@ touch $@ ; \ fi
-include/generated/env.txt: $(wildcard $(ENV_FILE)) FORCE +include/generated/env.txt: $(wildcard $(ENV_FILE)) $(call cmd,envc)
# Write out the resulting environment, converted to a C string

At present two acpi files are built every time since they use a version number from version.h
This is not necessary. Make use of the same technique as for the version string, so that they are build only when they change.
Signed-off-by: Simon Glass sjg@chromium.org ---
cmd/version.c | 2 ++ include/version_string.h | 2 ++ lib/acpi/acpi_table.c | 15 +++++++-------- test/dm/acpi.c | 16 +++++++--------- 4 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/cmd/version.c b/cmd/version.c index 190ef6a9061a..87e1fa4159c1 100644 --- a/cmd/version.c +++ b/cmd/version.c @@ -19,6 +19,8 @@ U_BOOT_TIME " " U_BOOT_TZ ")" CONFIG_IDENT_STRING
const char version_string[] = U_BOOT_VERSION_STRING; +const unsigned short version_num = U_BOOT_VERSION_NUM; +const unsigned char version_num_patch = U_BOOT_VERSION_NUM_PATCH;
static int do_version(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) diff --git a/include/version_string.h b/include/version_string.h index a89a6e43705e..a7d07e4cc7ca 100644 --- a/include/version_string.h +++ b/include/version_string.h @@ -4,5 +4,7 @@ #define __VERSION_STRING_H__
extern const char version_string[]; +extern const unsigned short version_num; +extern const unsigned char version_num_patch;
#endif /* __VERSION_STRING_H__ */ diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index 7c4189e2434b..a8d4b470001d 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -11,8 +11,7 @@ #include <log.h> #include <mapmem.h> #include <tables_csum.h> -#include <timestamp.h> -#include <version.h> +#include <version_string.h> #include <acpi/acpi_table.h> #include <asm/global_data.h> #include <dm/acpi.h> @@ -25,12 +24,12 @@ * to have valid date. So for U-Boot version 2021.04 OEM_REVISION is set to * value 0x20210401. */ -#define OEM_REVISION ((((U_BOOT_VERSION_NUM / 1000) % 10) << 28) | \ - (((U_BOOT_VERSION_NUM / 100) % 10) << 24) | \ - (((U_BOOT_VERSION_NUM / 10) % 10) << 20) | \ - ((U_BOOT_VERSION_NUM % 10) << 16) | \ - (((U_BOOT_VERSION_NUM_PATCH / 10) % 10) << 12) | \ - ((U_BOOT_VERSION_NUM_PATCH % 10) << 8) | \ +#define OEM_REVISION ((((version_num / 1000) % 10) << 28) | \ + (((version_num / 100) % 10) << 24) | \ + (((version_num / 10) % 10) << 20) | \ + ((version_num % 10) << 16) | \ + (((version_num_patch / 10) % 10) << 12) | \ + ((version_num_patch % 10) << 8) | \ 0x01)
int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags) diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 9634fc2e9002..818f71572c7c 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -11,10 +11,8 @@ #include <dm.h> #include <malloc.h> #include <mapmem.h> -#include <timestamp.h> -#include <version.h> #include <tables_csum.h> -#include <version.h> +#include <version_string.h> #include <acpi/acpigen.h> #include <acpi/acpi_device.h> #include <acpi/acpi_table.h> @@ -26,12 +24,12 @@
#define BUF_SIZE 4096
-#define OEM_REVISION ((((U_BOOT_VERSION_NUM / 1000) % 10) << 28) | \ - (((U_BOOT_VERSION_NUM / 100) % 10) << 24) | \ - (((U_BOOT_VERSION_NUM / 10) % 10) << 20) | \ - ((U_BOOT_VERSION_NUM % 10) << 16) | \ - (((U_BOOT_VERSION_NUM_PATCH / 10) % 10) << 12) | \ - ((U_BOOT_VERSION_NUM_PATCH % 10) << 8) | \ +#define OEM_REVISION ((((version_num / 1000) % 10) << 28) | \ + (((version_num / 100) % 10) << 24) | \ + (((version_num / 10) % 10) << 20) | \ + ((version_num % 10) << 16) | \ + (((version_num_patch / 10) % 10) << 12) | \ + ((version_num_patch % 10) << 8) | \ 0x01)
/**

On Sat, Apr 29, 2023 at 07:21:46PM -0600, Simon Glass wrote:
At present two acpi files are built every time since they use a version number from version.h
This is not necessary. Make use of the same technique as for the version string, so that they are build only when they change.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/next, thanks!

These files should have both 'always' and 'targets' so that dependencies are detected correctly.
When only 'always' is used, the target is built every time, although I am not quite sure why.
Make sure each has both 'always' and 'targets' to avoid this problem.
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/efi_loader/Makefile | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 13a35eae6c06..1a8c8d7cab5c 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -23,6 +23,7 @@ CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI)
ifdef CONFIG_RISCV always += boothart.efi +targets += boothart.o endif
ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) @@ -32,10 +33,12 @@ endif
ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) always += dtbdump.efi +targets += dtbdump.o endif
ifdef CONFIG_EFI_LOAD_FILE2_INITRD always += initrddump.efi +targets += initrddump.o endif
obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o

Am 30. April 2023 03:21:47 MESZ schrieb Simon Glass sjg@chromium.org:
These files should have both 'always' and 'targets' so that dependencies are detected correctly.
When only 'always' is used, the target is built every time, although I am not quite sure why.
Make sure each has both 'always' and 'targets' to avoid this problem.
Signed-off-by: Simon Glass sjg@chromium.org
lib/efi_loader/Makefile | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 13a35eae6c06..1a8c8d7cab5c 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile
How about lib/efi_selftest/Makefile? Any changes needed there too?
Best regards
Heinrich
@@ -23,6 +23,7 @@ CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI)
ifdef CONFIG_RISCV always += boothart.efi +targets += boothart.o endif
ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) @@ -32,10 +33,12 @@ endif
ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) always += dtbdump.efi +targets += dtbdump.o endif
ifdef CONFIG_EFI_LOAD_FILE2_INITRD always += initrddump.efi +targets += initrddump.o endif
obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o

Hi Heinrich,
On Sun, 30 Apr 2023 at 09:00, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Am 30. April 2023 03:21:47 MESZ schrieb Simon Glass sjg@chromium.org:
These files should have both 'always' and 'targets' so that dependencies are detected correctly.
When only 'always' is used, the target is built every time, although I am not quite sure why.
Make sure each has both 'always' and 'targets' to avoid this problem.
Signed-off-by: Simon Glass sjg@chromium.org
lib/efi_loader/Makefile | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 13a35eae6c06..1a8c8d7cab5c 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile
How about lib/efi_selftest/Makefile? Any changes needed there too?
Not that I can see.
Regards, Simon

On Sat, Apr 29, 2023 at 07:21:47PM -0600, Simon Glass wrote:
These files should have both 'always' and 'targets' so that dependencies are detected correctly.
When only 'always' is used, the target is built every time, although I am not quite sure why.
Make sure each has both 'always' and 'targets' to avoid this problem.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/next, thanks!

On Sat, Apr 29, 2023 at 07:21:45PM -0600, Simon Glass wrote:
These rules run on every build even if nothing has changed. The FORCE dependency is only needed for if_changed, not for cmd. Drop it.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/next, thanks!
participants (3)
-
Heinrich Schuchardt
-
Simon Glass
-
Tom Rini