* [PATCH v2 2/3] ARM: i.MX: introduce imx_image_rule variable for code deduplication
2019-12-09 14:11 [PATCH v2 1/3] images: i.MX: rearrange image rules in preparation for boilerplate removal Ahmad Fatoum
@ 2019-12-09 14:11 ` Ahmad Fatoum
2019-12-09 14:11 ` [PATCH v2 3/3] ARM: i.MX: rebuild .imximg if DCD table in .imxcfg changes Ahmad Fatoum
2019-12-11 8:27 ` [PATCH v2 1/3] images: i.MX: rearrange image rules in preparation for boilerplate removal Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2019-12-09 14:11 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The next patch will add the .imxcfg file as a rule prerequisite, so the
target is rebuilt if it changes. Instead of duplicating it in all rules,
factor out the common parts into a imx_image_rule variable.
As the arguments are now going through an eval, any use of $ must be
escaped with another $ to become $$.
No functional change.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
* escaped PBL_MEMORY_SIZE dollars to fix imx_v8_defconfig pimximg build
* moved eval into define, so it doesn't need replication for each
extension
---
images/Makefile.imx | 36 ++++++++++++++----------------------
1 file changed, 14 insertions(+), 22 deletions(-)
diff --git a/images/Makefile.imx b/images/Makefile.imx
index daf0cf1fcfaa..80e1acf941c5 100644
--- a/images/Makefile.imx
+++ b/images/Makefile.imx
@@ -5,28 +5,20 @@
# %.imximg - convert into i.MX image
# ----------------------------------------------------------------
-$(obj)/%.imximg: $(obj)/% FORCE
- $(call if_changed,imx_image,$(CFG_$(@F)),)
-
-$(obj)/%.pimximg: $(obj)/% FORCE
- $(call if_changed,imx_image,$(CFG_$(patsubst %.pimximg,%.imximg,$(@F))),\
- -p $($(patsubst $(obj)/%.pblb,PBL_MEMORY_SIZE_%,$<)))
-
-$(obj)/%.psimximg: $(obj)/% FORCE
- $(call if_changed,imx_image,$(CFG_$(patsubst %.psimximg,%.imximg,$(@F))),\
- -p $($(patsubst $(obj)/%.pblb,PBL_MEMORY_SIZE_%,$<)) -s)
-
-$(obj)/%.simximg: $(obj)/% FORCE
- $(call if_changed,imx_image,$(CFG_$(patsubst %.simximg,%.imximg,$(@F))),-s)
-
-$(obj)/%.usimximg: $(obj)/% FORCE
- $(call if_changed,imx_image,$(CFG_$(patsubst %.usimximg,%.imximg,$(@F))),-u -s)
-
-$(obj)/%.esimximg: $(obj)/% FORCE
- $(call if_changed,imx_image,$(CFG_$(patsubst %.esimximg,%.imximg,$(@F))),-e -s)
-
-$(obj)/%.esimximg.dek: $(obj)/% FORCE
- $(call if_changed,imx_image,$(CFG_$(patsubst %.esimximg,%.imximg,$(@F))),-e -s)
+define imx_image_rule
+$(eval
+$$(obj)/%.$(strip $(1)): $$(obj)/% FORCE
+ $$(call if_changed,imx_image,$$(CFG_$$(patsubst %.$(strip $(1)),%.imximg,$$(@F))),$(strip $(2)))
+)
+endef
+
+$(call imx_image_rule,imximg)
+$(call imx_image_rule,pimximg, -p $$($$(patsubst $$(obj)/%.pblb,PBL_MEMORY_SIZE_%,$$<)))
+$(call imx_image_rule,psimximg, -p $$($$(patsubst $$(obj)/%.pblb,PBL_MEMORY_SIZE_%,$$<)) -s)
+$(call imx_image_rule,simximg, -s)
+$(call imx_image_rule,usimximg, -u -s)
+$(call imx_image_rule,esimximg, -e -s)
+$(call imx_image_rule,esimximg.dek, -e -s)
.SECONDEXPANSION:
$(obj)/%.img.dek: $(obj)/$$(FILE_$$(@F))
--
2.24.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] ARM: i.MX: rebuild .imximg if DCD table in .imxcfg changes
2019-12-09 14:11 [PATCH v2 1/3] images: i.MX: rearrange image rules in preparation for boilerplate removal Ahmad Fatoum
2019-12-09 14:11 ` [PATCH v2 2/3] ARM: i.MX: introduce imx_image_rule variable for code deduplication Ahmad Fatoum
@ 2019-12-09 14:11 ` Ahmad Fatoum
2019-12-11 8:27 ` [PATCH v2 1/3] images: i.MX: rearrange image rules in preparation for boilerplate removal Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2019-12-09 14:11 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
So far changing the DCD table didn't trigger a rerun of the i.MX
image utility. To fix this, we need to have the DCD table as prerequisite
to the .imximg rule. The file name is contained in $(CFG_$(@F)), but
can't be used directly because $@ (and by extension @F) has no value
when first expanded in the read-in phase. If we expand a second time
during the target-update phase however, we would get the correct value.
GNU make provides .SECONDEXPANSION to expand all following prerequisites
a second time. Use it to have changes to the DCD table rebuild the
image.
Because we are now using imx_image_rule to generate the target, we must
escape each $ one more time to arrive at $$$$(CFG_$$$$(@F)).
In the final step, we replace $$$$(@F) with %.imximg, so we support the
rules not ending in .imximg as well.
Dependency file generation is still broken however and changed to headers
included in DCD tables won't be caught, but this functionality can be
fixed in a separate patch.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
No changes in v2.
---
images/Makefile.imx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/images/Makefile.imx b/images/Makefile.imx
index 80e1acf941c5..c4b1bfb35e9f 100644
--- a/images/Makefile.imx
+++ b/images/Makefile.imx
@@ -5,9 +5,10 @@
# %.imximg - convert into i.MX image
# ----------------------------------------------------------------
+.SECONDEXPANSION:
define imx_image_rule
$(eval
-$$(obj)/%.$(strip $(1)): $$(obj)/% FORCE
+$$(obj)/%.$(strip $(1)): $$(obj)/% $$$$(CFG_%.imximg) FORCE
$$(call if_changed,imx_image,$$(CFG_$$(patsubst %.$(strip $(1)),%.imximg,$$(@F))),$(strip $(2)))
)
endef
@@ -20,7 +21,6 @@ $(call imx_image_rule,usimximg, -u -s)
$(call imx_image_rule,esimximg, -e -s)
$(call imx_image_rule,esimximg.dek, -e -s)
-.SECONDEXPANSION:
$(obj)/%.img.dek: $(obj)/$$(FILE_$$(@F))
$(Q)if [ -z $(FILE_$(@F)) ]; then echo "FILE_$(@F) empty!"; false; fi
$(call if_changed,shipped)
--
2.24.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread