On 01.07.2021 16:10, Anthony PERARD wrote:
> This will always try regenerate the content of compile.h, but if it
> didn't change the file isn't updated.
> 
> Also, as it's currently the case, the file isn't regenerated during
> `sudo make install` if it exist and does belong to a different user.
> 
> Thus, we can remove the target "delete-unfresh-files".
> Target $(TARGET) still need a phony dependency, so add FORCE.
> 
> This patch imports the macro 'filechk' from Linux v5.12.

Would you mind clarifying why $(if_changed ...) cannot be used here
(unlike for .banner in the earlier patch)?

> @@ -413,22 +405,29 @@ endef
>       $(call if_changed,banner)
>  targets += .banner
>  
> -# compile.h contains dynamic build info. Rebuilt on every 'make' invocation.
> -include/xen/compile.h: include/xen/compile.h.in .banner
> -     @sed -e 's/@@date@@/$(XEN_BUILD_DATE)/g' \
> -         -e 's/@@time@@/$(XEN_BUILD_TIME)/g' \
> -         -e 's/@@whoami@@/$(XEN_WHOAMI)/g' \
> -         -e 's/@@domain@@/$(XEN_DOMAIN)/g' \
> -         -e 's/@@hostname@@/$(XEN_BUILD_HOST)/g' \
> -         -e 's!@@compiler@@!$(shell $(CC) $(CFLAGS) --version 2>&1 | head 
> -1)!g' \
> -         -e 's/@@version@@/$(XEN_VERSION)/g' \
> -         -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \
> -         -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
> -         -e 's!@@changeset@@!$(shell tools/scmversion $(XEN_ROOT) || echo 
> "unavailable")!g' \
> -         < include/xen/compile.h.in > $@.new
> +# Don't refresh this files during e.g., 'sudo make install'
> +define filechk_compile.h
> +    if [ ! -r $@ -o -O $@ ]; then \
> +    sed -e 's/@@date@@/$(XEN_BUILD_DATE)/g' \
> +        -e 's/@@time@@/$(XEN_BUILD_TIME)/g' \
> +        -e 's/@@whoami@@/$(XEN_WHOAMI)/g' \
> +        -e 's/@@domain@@/$(XEN_DOMAIN)/g' \
> +        -e 's/@@hostname@@/$(XEN_BUILD_HOST)/g' \
> +        -e 's!@@compiler@@!$(shell $(CC) $(CFLAGS) --version 2>&1 | head 
> -1)!g' \
> +        -e 's/@@version@@/$(XEN_VERSION)/g' \
> +        -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \
> +        -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
> +        -e 's!@@changeset@@!$(shell tools/scmversion $(XEN_ROOT) || echo 
> "unavailable")!g' \
> +     < $<; \
> +    sed -rf tools/process-banner.sed < .banner; \
> +    else \
> +     cat $@; \
> +    fi

Just like "cat" I think the "sed" invocations should be indented deeper
than if/else/fi.

Jan


Reply via email to