On Mon, Feb 24, 2014 at 06:36:07AM +0100, Wolfgang Denk wrote:
> Dear Masahiro,
> 
> In message <1393207943-3725-4-git-send-email-yamad...@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

Attachment: signature.asc
Description: Digital signature

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to