Skip to contentSkip to conversation

kbuild: dtc: use env to resolve echo

PATCH Applied Rouven Czerwinski 4 participants 6 messages Jan 20, 2022 – Feb 21, 2022 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: dtc: use env to resolve echo

Posix does not mandate to have binaries within a certain path, but rather that the utilities may be available. Use env to resolve and call echo from PATH.

Fixes 2ae7ac7ab2f1 ("kbuild: dtc: Allow adding device tree fragments via config")
---
 scripts/Makefile.lib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.lib +1 -1
index 13b1789c01..94ca1b771b 100644
@@ -340,7 +340,7 @@ dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS))
 quiet_cmd_dtc = DTC     $@
 # For compatibility between make 4.2 and 4.3
 H := \#
-cmd_dtc = /bin/echo -e '$(H)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(dts-frags),'$(H)include "$(f)"\n') | \
+cmd_dtc = /usr/bin/env echo -e '$(H)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(dts-frags),'$(H)include "$(f)"') | \
 	$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
 	$(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
 		-i $(srctree)/arch/$(SRCARCH)/dts $(DTC_FLAGS) \
Signature · 7 lines
2.34.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

There's another in scripts/Kbuild.include

Quoted 29 lines · Rouven Czerwinski

Posix does not mandate to have binaries within a certain path, but rather that the utilities may be available. Use env to resolve and call echo from PATH.

Fixes 2ae7ac7ab2f1 ("kbuild: dtc: Allow adding device tree fragments via config")
---
 scripts/Makefile.lib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.lib +1 -2
index 13b1789c01..94ca1b771b 100644
@@ -340,7 +340,7 @@ dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS))
 quiet_cmd_dtc = DTC     $@
 # For compatibility between make 4.2 and 4.3
 H := \#
-cmd_dtc = /bin/echo -e '$(H)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(dts-frags),'$(H)include "$(f)"\n') | \
+cmd_dtc = /usr/bin/env echo -e '$(H)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(dts-frags),'$(H)include "$(f)"') | \
        $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
        $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
                -i $(srctree)/arch/$(SRCARCH)/dts $(DTC_FLAGS) \
--

2.34.1

Quoted 4 lines

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw
In reply to Rouven Czerwinski
Quoted 16 lines · Rouven Czerwinski

Posix does not mandate to have binaries within a certain path, but rather that the utilities may be available. Use env to resolve and call echo from PATH.

Fixes 2ae7ac7ab2f1 ("kbuild: dtc: Allow adding device tree fragments via config")
---
 scripts/Makefile.lib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.lib +0 -0
index 13b1789c01..94ca1b771b 100644

scripts/Makefile.lib dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS)) · line 343

Quoted 4 lines
scripts/Makefile.lib +0 -1
@@ -340,7 +340,7 @@ dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS))
 quiet_cmd_dtc = DTC     $@
 # For compatibility between make 4.2 and 4.3
 H := \#
-cmd_dtc = /bin/echo -e '$(H)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(dts-frags),'$(H)include "$(f)"\n') | \

Why hardcode /bin/echo anyway and not use plain 'echo' instead. I assume because echo can be a shell builtin, but are there shells out there where the builtin is not enough?

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw
Quoted 12 lines · Sascha Hauer
Quoted 11 lines · Rouven Czerwinski

Posix does not mandate to have binaries within a certain path, but rather that the utilities may be available. Use env to resolve and call echo from PATH.

Fixes 2ae7ac7ab2f1 ("kbuild: dtc: Allow adding device tree fragments via config")
---
 scripts/Makefile.lib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

scripts/Makefile.lib dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS)) · line 343

Quoted 9 lines
scripts/Makefile.lib +0 -1
index 13b1789c01..94ca1b771b 100644
@@ -340,7 +340,7 @@ dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS))
 quiet_cmd_dtc = DTC     $@
 # For compatibility between make 4.2 and 4.3
 H := \#
-cmd_dtc = /bin/echo -e '$(H)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< $(dts-frags),'$(H)include "$(f)"\n') | \

Why hardcode /bin/echo anyway and not use plain 'echo' instead. I assume because echo can be a shell builtin, but are there shells out there where the builtin is not enough?

The builtin echo implementations are not very compatible. Better use printf instead. For example, echo from dash (the default /bin/sh in Debian) does not support '-e'.

Michael

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#5 lore raw
In reply to Rouven Czerwinski
Quoted 10 lines · Rouven Czerwinski

Posix does not mandate to have binaries within a certain path, but rather that the utilities may be available. Use env to resolve and call echo from PATH.

Fixes 2ae7ac7ab2f1 ("kbuild: dtc: Allow adding device tree fragments via config")
---
 scripts/Makefile.lib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox