script/checkpatch.pl: warn about deprecated use of EXTRA_{A,C,CPP,LD}FLAGS
authorArnaud Lacombe <lacombar@gmail.com>
Mon, 15 Aug 2011 05:07:14 +0000 (01:07 -0400)
committerMichal Marek <mmarek@suse.cz>
Wed, 31 Aug 2011 14:43:44 +0000 (16:43 +0200)
Usage of these flags has been deprecated for nearly 4 years by:

    commit f77bf01425b11947eeb3b5b54685212c302741b8
    Author: Sam Ravnborg <sam@neptun.(none)>
    Date:   Mon Oct 15 22:25:06 2007 +0200

        kbuild: introduce ccflags-y, asflags-y and ldflags-y

Moreover, these flags (at least EXTRA_CFLAGS) have been documented for command
line use. By default, gmake(1) do not override command line setting, so this is
likely to result in build failure or unexpected behavior.

Warn about their introduction in Makefile or Kbuild files.

Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
scripts/checkpatch.pl

index 9d761c95eca2988e0ff227baa8619b684d6eb33a..955183ada37acdd4258ca12431b3eac3946f4f23 100755 (executable)
@@ -1661,6 +1661,20 @@ sub process {
                        #print "is_end<$is_end> length<$length>\n";
                }
 
+               if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
+                   ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
+                       my $flag = $1;
+                       my $replacement = {
+                               'EXTRA_AFLAGS' =>   'asflags-y',
+                               'EXTRA_CFLAGS' =>   'ccflags-y',
+                               'EXTRA_CPPFLAGS' => 'cppflags-y',
+                               'EXTRA_LDFLAGS' =>  'ldflags-y',
+                       };
+
+                       WARN("DEPRECATED_VARIABLE",
+                            "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
+               }
+
 # check we are in a valid source file if not then ignore this hunk
                next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);