• Masahiro Yamada's avatar
    kbuild: make -r/-R effective in top Makefile for old Make versions · 3812b8c5
    Masahiro Yamada authored
    Adding -rR to MAKEFLAGS is important because we do not want to
    be bothered by built-in implicit rules or variables.
    
    One problem that used to exist in older GNU Make versions is
    
      MAKEFLAGS += -rR
    
    ... does not become effective in the current Makefile. When you are
    building with O= option, it becomes effective in the top Makefile
    since it recurses via 'sub-make' target. Otherwise, the top Makefile
    tries implicit rules. That is why we explicitly add empty rules for
    Makefiles, but we often miss to do that.
    
    In fact, adding -d option to older GNU Make versions shows it is
    trying a bunch of implicit pattern rules.
    
     Considering target file `scripts/Makefile.kcov'.
      Looking for an implicit rule for `scripts/Makefile.kcov'.
      Trying pattern rule with stem `Makefile.kcov'.
      Trying implicit prerequisite `scripts/Makefile.kcov.o'.
      Trying pattern rule with stem `Makefile.kcov'.
      Trying implicit prerequisite `scripts/Makefile.kcov.c'.
      Trying pattern rule with stem `Makefile.kcov'.
      Trying implicit prerequisite `scripts/Makefile.kcov.cc'.
      Trying pattern rule with stem `Makefile.kcov'.
      Trying implicit prerequisite `scripts/Makefile.kcov.C'.
      ...
    
    This issue was fixed by GNU Make commit 58dae243526b ("[Savannah #20501]
    Handle adding -r/-R to MAKEFLAGS in the makefile"). So, it is no longer
    a problem if you use GNU Make 4.0 or later. However, older versions are
    still widely used.
    
    So, I decided to patch the kernel Makefile to invoke sub-make regardless
    of O= option. This will allow further cleanups.
    Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
    3812b8c5
Makefile 59 KB