On Mon, 2018-07-16 at 14:39 +0200, Dirk Gouders wrote:
> Because the kbuild function if_changed writes the command line to a
> .cmd file for later tests, multiple calls of that function within a
> target would result in overwrites of previous values and effectively
> render the command line test meaningless, resulting in flip-flop
> behaviour.
> 
> Produce an error for targets with multiple calls to if_changed.

Hi.  Some questions:

How is the existing use in arch/microblaze/boot/Makefile incorrect?

$(obj)/simpleImage.%: vmlinux FORCE
        $(call if_changed,cp,.unstrip)
        $(call if_changed,objcopy)
        $(call if_changed,uimage)
        $(call if_changed,strip,.strip)
        @echo 'Kernel: $(UIMAGE_OUT) is ready' ' (#'`cat .version`')'

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2911,6 +2911,14 @@ sub process {
>                            "Use of $flag is deprecated, please use 
> \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
>               }
>  i
> +             # Check for multiple calls of if_changed within a target in 
> Makefiles
> +             if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&

Why is any Kbuild file check useful?

> +                 ($prevline =~ /^[ +]\t\$\(call if_changed,/) &&
> +                 ($line =~ /^[ +]\t\$\(call if_changed,/)) {

What about if_changed_dep and if_changed_rule?

> +                             ERROR("MULTIPLE_IF_CHANGED",
> +                                   "Multiple calls of if_changed within a 
> target.\n" . $herecurr);
> +             }

And some more style things:

There are instances with multiple tabs so probably
these should use '\t*' or '\s*' and not '\t'.

This should probably not require a single space after
if_changed so likely:

        'call\s+if_changed'

Reply via email to