Skip to contentSkip to conversation

usr: shorten cmd_initfs in Makefile

PATCH In review Masahiro Yamada 2 participants 3 messages May 31, 2024 – Jul 16, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usr: shorten cmd_initfs in Makefile

Avoid repetition of long variables.

No functional change intended.

---

 usr/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
usr/Makefile +3 -3
index 132ef7e96e6d..75224d927025 100644
@@ -62,9 +62,9 @@ $(deps_initramfs): ;
 quiet_cmd_initfs = GEN     $@
       cmd_initfs = \
 	$(CONFIG_SHELL) $< -o $@ -l $(obj)/.initramfs_data.cpio.d \
-	$(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
-	$(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \
-	$(if $(KBUILD_BUILD_TIMESTAMP), -d "$(KBUILD_BUILD_TIMESTAMP)") \
+	$(addprefix -u , $(CONFIG_INITRAMFS_ROOT_UID)) \
+	$(addprefix -g , $(CONFIG_INITRAMFS_ROOT_GID)) \
+	$(patsubst %,-d "%", $(KBUILD_BUILD_TIMESTAMP)) \
 	$(ramfs-input)
 
 # We rebuild initramfs_data.cpio if:
Signature · 1 line
2.40.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Masahiro Yamada

Avoid repetition of long variables.

No functional change intended.

Quoted 25 lines

---

 usr/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
usr/Makefile +3 -3
index 132ef7e96e6d..75224d927025 100644
@@ -62,9 +62,9 @@ $(deps_initramfs): ;
 quiet_cmd_initfs = GEN     $@
       cmd_initfs = \
 	$(CONFIG_SHELL) $< -o $@ -l $(obj)/.initramfs_data.cpio.d \
-	$(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
-	$(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \
-	$(if $(KBUILD_BUILD_TIMESTAMP), -d "$(KBUILD_BUILD_TIMESTAMP)") \
+	$(addprefix -u , $(CONFIG_INITRAMFS_ROOT_UID)) \
+	$(addprefix -g , $(CONFIG_INITRAMFS_ROOT_GID)) \
+	$(patsubst %,-d "%", $(KBUILD_BUILD_TIMESTAMP)) \
 	$(ramfs-input)
 
 # We rebuild initramfs_data.cpio if:
Signature · 1 line
2.40.1
#2 lore raw
In reply to Masahiro Yamada
Quoted 16 lines · Masahiro Yamada

Avoid repetition of long variables.

No functional change intended.

---

 usr/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
usr/Makefile +0 -0
index 132ef7e96e6d..75224d927025 100644

usr/Makefile $(deps_initramfs): ; · line 67

Quoted 9 lines
usr/Makefile +3 -3
@@ -62,9 +62,9 @@ $(deps_initramfs): ;
 quiet_cmd_initfs = GEN     $@
       cmd_initfs = \
        $(CONFIG_SHELL) $< -o $@ -l $(obj)/.initramfs_data.cpio.d \
-       $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
-       $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \
-       $(if $(KBUILD_BUILD_TIMESTAMP), -d "$(KBUILD_BUILD_TIMESTAMP)") \
+       $(addprefix -u , $(CONFIG_INITRAMFS_ROOT_UID)) \
+       $(addprefix -g , $(CONFIG_INITRAMFS_ROOT_GID)) \
+       $(patsubst %,-d "%", $(KBUILD_BUILD_TIMESTAMP)) \

I dropped the last line because it will not work
when $(KBUILD_BUILD_TIMESTAMP) contains a space.

Quoted 6 lines
usr/Makefile +0 -1
        $(ramfs-input)
 
 # We rebuild initramfs_data.cpio if:
--

2.40.1

Signature · 2 lines
Best Regards
Masahiro Yamada