[U-Boot] [PATCH v2 03/15] kbuild: move asm-offsets.h rules to ./Kbuild

Tom Rini trini at ti.com
Tue Feb 25 17:38:55 CET 2014


On Mon, Feb 24, 2014 at 06:36:07AM +0100, Wolfgang Denk wrote:
> Dear Masahiro,
> 
> In message <1393207943-3725-4-git-send-email-yamada.m at jp.panasonic.com> you wrote:
> >
> > +define cmd_generic-offsets
> > +	(set -e; \
> > +	 echo "#ifndef __GENERIC_ASM_OFFSETS_H__"; \
> > +	 echo "#define __GENERIC_ASM_OFFSETS_H__"; \
> > +	 echo "/*"; \
> > +	 echo " * DO NOT MODIFY."; \
> > +	 echo " *"; \
> > +	 echo " * This file was generated by Kbuild"; \
> > +	 echo " *"; \
> > +	 echo " */"; \
> > +	 echo ""; \
> > +	 sed -ne $(sed-y) $<; \
> > +	 echo ""; \
> > +	 echo "#endif" ) > $@
> > +endef
> 
> Can we use here documents in cases like this, so the number of
> shell command executions could be greatly reduced?
> 
> Does something like this work?
> 
> define cmd_generic-offsets		\
> 	cat <<_END_ > $@		\
> #ifndef __GENERIC_ASM_OFFSETS_H__	\
> #define __GENERIC_ASM_OFFSETS_H__	\
> /*					\
>  * DO NOT MODIFY			\
>  *					\
>  * This file was generated by Kbuild	\
>  */					\
> $$(sed -ne $(sed-y) $<)			\
> #endif					\

We can use printf(1) to split this up into 3 parts, but it honestly
reads worse:
diff --git a/Kbuild b/Kbuild
index 1d89761..b8d747f 100644
--- a/Kbuild
+++ b/Kbuild
@@ -15,15 +15,14 @@ targets := $(generic-offsets-file) lib/asm-offsets.s
 quiet_cmd_generic-offsets = GEN     $@
 define cmd_generic-offsets
 	(set -e; \
-	 echo "#ifndef __GENERIC_ASM_OFFSETS_H__"; \
-	 echo "#define __GENERIC_ASM_OFFSETS_H__"; \
-	 echo "/*"; \
-	 echo " * DO NOT MODIFY."; \
-	 echo " *"; \
-	 echo " * This file was generated by Kbuild"; \
-	 echo " *"; \
-	 echo " */"; \
-	 echo ""; \
+	 printf "#ifndef __GENERIC_ASM_OFFSETS_H__\n\
+#define __GENERIC_ASM_OFFSETS_H__\n\
+/*\n\
+ * DO NOT MODIFY.\n\
+ *\n\
+ * This file was generated by Kbuild\n\
+ *\n\
+ */\n\n"; \
 	 sed -ne $(sed-y) $<; \
 	 echo ""; \
 	 echo "#endif" ) > $@

(And it doesn't quite look right in the file, but that's just a matter
of massaging things.  It also didn't seem to matter to overall build
time since it's a one-off generation, not a many-off generation.  I'm OK
with this as-is.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140225/7e1407f1/attachment.pgp>


More information about the U-Boot mailing list