On 05.06.2025 01:09, Stefano Stabellini wrote:
> --- a/xen/scripts/Makefile.asm-generic
> +++ b/xen/scripts/Makefile.asm-generic
> @@ -32,7 +32,12 @@ old-headers := $(wildcard $(obj)/*.h)
>  unwanted    := $(filter-out $(generic-y) $(generated-y),$(old-headers))
>  
>  quiet_cmd_wrap = WRAP    $@
> -      cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@
> +      cmd_wrap = \
> +     upper=$$(echo $*.h | tr a-z A-Z | tr '/.' '__'); \
> +     printf "\#ifndef ASM_GENERIC_$${upper}\n" > $@; \
> +     printf "\#define ASM_GENERIC_$${upper}\n" >> $@; \
> +     printf "\#include <asm-generic/$*.h>\n" >> $@; \
> +     printf "\#endif /* ASM_GENERIC_$${upper} */\n" >> $@

I'm curious: In what is now a0f56da94c3e I had to resort to "define" to
get the rule to work (including a correct .*.cmd being generated). I
can't claim I actually understood why things didn't work the "simple
macro" way, and hence it's unclear to me whether the way it's done here
will work with all make versions.

One further difference to that other commit: If make is interrupted in
the middle of any of these printf-s, an incomplete file may remain. The
cmd_xlat_h rule specifically uses "mv -f $@.new $@" to cover that corner
case.

Finally - is ASM_GENERIC_$${upper} actually correct? Isn't that the
guard that ought to be used _in_ asm-generic/$*.h?

Jan

Reply via email to