kbuild: move extra gcc checks to scripts/Makefile.extrawarn

This commit was imported from Linux Kernel:
commit a86fe353 written by me.

W=... provides extra gcc checks.

Having such code in scripts/Makefile.build results in the same flags
being added to KBUILD_CFLAGS multiple times becuase
scripts/Makefile.build is invoked every time Kbuild descends into
the subdirectories.

Since the top Makefile is already too cluttered, this commit moves
all of extra gcc check stuff to a new file scripts/Makefile.extrawarn,
which is included from the top Makefile.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Series-to: uboot
Cover-letter:
Kbuild: sync with Linux 3.16-rc1

Kbuild-related update for Linux 3.16 was merge into the upstream:
Some improvements, refactoring, coding-style fixes, etc.

This series import them to U-Boot.

Sync with commit 6d87c225f5

END
kbuild: sync mixed targets handling with Linux 3.16-rc1

"make %_config all" was supported for the first time in U-Boot:
  commit 53bca5ab
  kbuild: support simultaneous board configuration and "make all"

Surprisingly it had not been working in Linux Kernel for a long time.

So I sent back the patch to the Linux Kbuild community and it was
accepted with a little code improvement, at commit 9319f453.

Now, you can do "make defconfig all" or "make %_defconfig all"
in Linux too.

This commit updates some scripts to fill the code-diff
between Linux and U-Boot.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
cosmetic: kbuild: clean-up coding style (sync with Linux 3.16-rc1)

Import the following trivial commits from Linux v3.16-rc1:

 bb66fc6 kbuild: trivial - use tabs for code indent where possible
 7eb6e34 kbuild: trivial - remove trailing empty lines
 3fbb43d kbuild: trivial - fix comment block indent
 38385f8 kbuild: trivial - remove trailing spaces

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
kbuild: Use relative path when possible

Import 3 useful commits by Michal Marek <mmarek@suse.cz>
from Linux 3.16-rc1.

  commit 9da0763bdd82572be243fcf5161734f11568960f
  kbuild: Use relative path when building in a subdir of the source tree

  commit 890676c65d699db3ad82e7dddd0cf8fb449031af
  kbuild: Use relative path when building in the source tree

  commit 7e1c04779efd51154baf652e653ceb24ce68939b
  kbuild: Use relative path for $(objtree)

mkconfig and tools/Makefile must be adjusted to use relative path
for srctree.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
scripts: objdiff: sync with Linux 3.16-rc1

Import scripts/objdiff improvement from Linux v3.16-rc1, which
consists of 6 commits written by me.

  commit 7fa0e6db3cedc9b70d68a4170f1352e2b1aa0f90
  scripts: objdiff: support directories for the augument of record command

  commit 8ac28bee76eec006aac5ba5c418878a607d53a9b
  scripts: objdiff: fix a comment

  commit 8b5d0f20d64f00ffd5685879f8eb3659379f5aaa
  scripts: objdiff: change the extension of disassembly from .o to .dis

  commit 18165efa8203a34d82f60a1831ea290e7304c654
  scripts: objdiff: improve path flexibility for record command

  commit 1ecc8e489abfdaa6d8d1689f7ff62fdf1adda30c
  scripts: objdiff: remove unnecessary code

  commit 5ab370e91af70d5f1b1dbaec78798a2ff236a2d5
  scripts: objdiff: direct error messages to stderr

  commit fd6e12423311697860f30d10398a0f9eb91977d2
  scripts: objdiff: get the path to .tmp_objdiff more simply

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
kconfig: import Kconfig files from Linux commit 6d87c225f

Import
  - scripts/kconfig/*
  - include/linux/kconfig.h
from Linux Kernel v3.16-rc1.

Series-to: u-boot@lists.denx.de
Series-cc: Simon Glass <sjg@chromium.org>
Series-cc: Tom Rini <trini@ti.com>
Series-cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Series-cc: Wolfgang Denk <wd@denx.de>
Series-version: 3
Series-changes: 3
 - Fetch source files from the latest Linux tag
Series-changes: 2
 - Fetch source files from the latest Linux tag

Cover-letter:
Kconfig for U-Boot
This series introduces Kconfig.

Besides Linux Kernel, Kconfig is used in some projects,
such as, BusyBox, Buildroot.

But our situation is a little more complicated.
For one board, we need to generate 3 images at most:
Full image, SPL and TPL.

Each image needs its own configuration input.

 How does Kconfig in U-Boot work?
 --------------------------------

For boards without SPL support, it works as in Linux Kernel.
"make <board>_defconfig" creates .config for you.
You can use "make config", "make menuconfig" etc. to create a new .config
from scratch or update the existing one.

"make silentoldconfig", if it is necessary, is automatically invoked,
creating or updating include/config/auto.conf and
include/generated/autoconf.h.

For boards with SPL/TPL support, another .config file is created
under spl/tpl directory.

To sum up, the location of Kconfig related files is as follows:

  [1] Full U-boot
    - configs/<board>_defconfig        (default configuration)
    - .config                          (saved config list)
    - include/config/auto.conf         (for use in makefiles)
    - include/generated/autoconf.h     (for use in C sources)
    - include/config/*                 (for if_changed_dep)

  [2] SPL
    - configs/spl/<board>_defconfig    (default configuration)
    - spl/.config                      (saved config list)
    - spl/include/config/auto.conf     (for use in makefiles)
    - spl/include/generated/autoconf.h (for use in C sources)
    - spl/include/config/*             (for if_changed_dep)

  [3] TPL
    - configs/tpl/<board>_defconfig    (default configuration)
    - tpl/.config                      (saved config list)
    - tpl/include/config/auto.conf     (for use in makefiles)
    - tpl/include/generated/autoconf.h (for use in C sources)
    - tpl/include/config/*             (for if_changed_dep)

 How to configure and build?
 ---------------------------

For board configuration, "make <board>_defconfig" is used instead of
"make <board>_config". The other things are the same as before.

 Coexistence of Kconfig and board header
 ---------------------------------------

For a long time, we have used C header files to define the set of CONFIGs.

It would take really long term (one year? two year? I don't know)
to migrate from board headers to Kconfig.

So, two different infractructure must coexist in the interim.

CONFIG macros defined in C headers are collected into
include/autoconf.mk, spl/include/autoconf.mk, tpl/include/autoconf.mk
for use in makefiles.

 Build Test
 ----------

I built all boards excepts some already broken ones.
I also checked MD5SUM of output binaries for all of them.

I believe this series should not break any boards.
But if you notice something got broken, please let me know.

Besides, I confirmed out-of-tree build, parallel build (-j make option)
works correctly.

 How to apply this series
 ------------------------

I confirmed this series can be applied on commit f23adc9f.

 Known Problems
 --------------

[1] MAKEALL and buildman have not been not adjusted yet

boards.cfg is not necessary for Kconfig. I want to delete it.

But before that, we must rework MAKEALL and buildman to search defconfig
files instead of boards.cfg.

[2] Many targets in one choice

Especially in ARM and PowerPC, there are too many target boards
in one choice.

This should be refactored in follow-up patches
by increasing the hierarchy and grouping the similar boards family.

END
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Do not apply: tools: add genkconfig

 ========================================
 Do not apply this patch to the main line
 ========================================

 What is this tool?
 ------------------

This tool converts boards.cfg to defconfig and Kconfig files.

It automatically generates
 - arch/${ARCH}/Kconfig
 - board/${VENDOR}/${BOARD}/Kconfig
 - board/${BOARD}/Kconfig
 - configs/${TARGET_BOARD}_defconfig

 How to use?
 -----------

Open tools/print_allconfigs with an editor.

Adjust cross compilers part for your environment.

  # Specify your favoriate cross tools
  CROSS_COMPILE_ARC=arc-linux-
  CROSS_COMPILE_AARCH64=aarch64-linux-gnu-
  CROSS_COMPILE_ARM=arm-unknown-linux-gnueabi-
   [snip]
  CROSS_COMPILE_X86=i386-linux-

And then, run "tools/genkconfig".

 Why is this patch here?
 -----------------------

The file boards.cfg is touched very frequently.
All the time, new/old boards are being added/removed.

The next commit was generated based on the u-boot/master at the time
I posted it.
It will become out-dated soon.

You can update it with this tool.

Series-changes: 2
 - Do not output CONFIG_BOARD_MAINTAINERS and CONFIG_BOARD_STATUS
 - Delete board/Kconfig and move "source board/*/*/Kconfig"
   statements to arch/*/Kconfig.
kconfig: add board Kconfig and defconfig files

This commit adds:
 - arch/${ARCH}/Kconfig
    provide a menu to select target boards
 - board/${VENDOR}/${BOARD}/Kconfig or board/${BOARD}/Kconfig
    set CONFIG macros to the appropriate values for each board
 - configs/${TARGET_BOARD}_defconfig
    default setting of each board

(This commit was automatically generated by a conversion script
based on boards.cfg)

In Linux Kernel, defconfig files are located under
arch/${ARCH}/configs/ directory.
It works in Linux Kernel since ARCH is always given from the
command line for cross compile.

But in U-Boot, ARCH is not given from the command line.
Which means we cannot know ARCH until the board configuration is done.
That is why all the "*_defconfig" files should be gathered into a
single directory ./configs/.
(The problem is configs/ directory contains about 1200 files!)

Besides, we must have separate defconfig for SPL and TPL too,
if they are supported.
SPL, TPL has its defconfig files under configs/spl/, configs/tpl/,
respectively.

Series-changes: 2
  - Re-generate based on the latest boards.cfg
kconfig: add basic Kconfig files

This commit adds more Kconfig files, which were written by hand.

Series-changes: 2
  - Do not include "board/Kconfig"
  - Drop CONFIG_BUILD_MODE
include: define CONFIG_SPL and CONFIG_TPL as 1

We are about to switch to Kconfig in the next commit.
But there are something to get done beforehand.

In Kconfig, include/generated/autoconf.h defines boolean
CONFIG macros as 1.

CONFIG_SPL and CONFIG_TPL, if defined, must be set to 1.
Otherwise, when switching to Kconfig, the build log
would be sprinkled with warning messages like this:
  warning: "CONFIG_SPL" redefined [enabled by default]

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Series-changes: 2
  - Rebase on the current u-boot/master
kconfig: switch to Kconfig

This commit enables Kconfig.
Going forward, we use Kconfig for board configuration.
mkconfig will never be used. Nor will include/config.mk be generated.

Kconfig must be adjusted for U-Boot because our situation is
a little more complicated than Linux Kernel.
We have to generate multiple binary images (Full U-Boot, SPL, TPL)
from one source tree.
Each image needs its own configuration input.

In order to keep this scheme in Kconfig, some files must be modified.
But the modification should be minimum.

The location of Kconfig related files is as follows:

 [1] Full U-Boot image
   - configs/<board>_defconfig        (default configuration)
   - .config                          (saved config list)
   - include/config/auto.conf         (for use in makefiles)
   - include/generated/autoconf.h     (for use in C sources)
   - include/config/*                 (for if_changed_dep)

 [2] SPL
   - configs/spl/<board>_defconfig    (default configuration)
   - spl/.config                      (saved config list)
   - spl/include/config/auto.conf     (for use in makefiles)
   - spl/include/generated/autoconf.h (for use in C sources)
   - spl/include/config/*             (for if_changed_dep)

 [3] TPL
   - configs/tpl/<board>_defconfig    (default configuration)
   - tpl/.config                      (saved config list)
   - tpl/include/config/auto.conf     (for use in makefiles)
   - tpl/include/generated/autoconf.h (for use in C sources)
   - tpl/include/config/*             (for if_changed_dep)

Usage:

Execute "make <board>_defconfig" to configure board and then run "make".
Or "make <board>_defconfig all" to configure and build in one time.

You can use "make config", "make menuconfig" etc. to create
a new .config or modify the existing one.

In Kconfig for U-boot, the configuration is done on three levels at most.

By the way, there is another item worth remarking here:
coexistence of Kconfig and board herder files.

Prior to Kconfig, we used C headers to define a set of configs.

We expect a very long term to migrate from C headers to Kconfig.
Two different infractructure must coexist in the interim.

In our former configuration scheme, include/autoconf.mk was generated
for use in makefiles.
It is still generated under include/, spl/include/, tpl/include/ directory
for the full, SPL, TPL image, respectively.

Series-changes: 2
  - Put dirty build rule into scripts/multiple_config.sh and
    scripts/Makefile.autoconf
  - Fix dependency tracking.
    In v1, any change to Kconfig triggered re-complile of all objects.
    In this version, re-compile is kept at a minimum.
  - Fix a clean-source check
    In v1, clean source tree check did not work correctly for
    out-of-tree build.
aaaaa
Don't send: do not clean scripts/kconfig/* by make mrproper
MAKEALL: adjust for Kconfig

Use "make <board>_defconfig" instead of "make <board>_config".

FIXME!
This fixup is bad because it still depends on boards.cfg
to support options such as -a <ARCH>, -c <CPU> etc.
We want to delete it when switching to Kconfig.

We have to invent another method without using boards.cfg.
buildman: adjust for Kconfig

Use "make <board>_defconfig" instead of "make <board>_config".

FIXME!
This fixup is bad because it still depends on boards.cfg
to support options such as -a <ARCH>, -c <CPU> etc.
We want to delete it when switching to Kconfig.

We have to invent another method without using boards.cfg.
MAKEALL: Show configuration
kconfig: delete redundant CONFIG_${ARCH} definition

CONFIG_${ARCH} is defined by Kconfig.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
kbuild: remove CONFIG_SPL/CONFIG_TPL definition in config headers

Now CONFIG_SPL and CONFIG_TPL are defined in Kconfig.

Remove the redundant definition in config headers.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Series-changes: 2
  - Rebase on the current u-boot/master
kconfig: remove old script

mkconfig is no longer used in Kconfig.
kconfig: add CONFIG_CROSS_COMPILE

Copy from Linux Kernel (with a few adjustments in comments).