kconfig: import Kconfig files from Linux 3.16-rc6

Import
  - scripts/kconfig/*
  - include/linux/kconfig.h
from Linux 3.16-rc6.

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: 5
Series-changes: 4
 - Fetch source files from the latest Linux tag

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:
Normal 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
updating include/generated/autoconf.h and files under include/config/
directory.

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

Use "make spl:config", "make spl:menuconfig" etc. to modify spl/.config
and "make tpl:config", "make tpl:menuconfig" etc. for tpl/.config.

 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.

 What is new in v5 ?
 -------------------

[1] Add CPU selection layer to PowerPC

  ARCH select
    |--- CPU select
          |--- board select

In v4, there were too many boards in the menu of
PowerPC board select.
In v5, CPU select has benn added between ARCH select
and board select.

[2] Improve the tool to generate boards.cfg

 What is new in v4 ?
 -------------------

[1] Single defconfig per board
In v3, one board can have multiple defconfigs.
For example, "omap3_beagle" board had
configs/omap3_beagle_defconfig and configs/omap3_beagle_spl_defconfig.

One problem of this approach is that some configs such as
CONFIG_ARM=y are duplicated between the omap3_beagle_defconfig and
omap3_beagle_spl_defconfig.

In v4, defconfigs for Normal, SPL, TPL images are coalesced together
into a single file by adding special syntaxes to support conditional
definition.

[2] Add MAINTAINERS files

[3] Add a tool to generate boards.cfg and drop it from the git repository

 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 fbe79a17f
+ the following prerequisites.

http://patchwork.ozlabs.org/patch/372339/
http://patchwork.ozlabs.org/patch/372337/
http://patchwork.ozlabs.org/patch/372338/
http://patchwork.ozlabs.org/patch/372347/

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: 5
 - Add CPU select menu for PowerPC

Series-changes: 4
 - Remove debug code
 - Do not specify CONFIG_SYS_CPU if the cpu field of boards.cfg is '-'
 - Adjust to the current boards.cfg fields spec.
 - Add "select CPU" to PowerPC Kconfig
 - Generate only one defconfig per board

Series-changes: 3
 - Create SPL defconfig into configs/<board>_spl_defconfig
   instead of conigs/spl/<board>_defconfig. Like the same for TPL.
   Because I want to handle Falcon boot more genericlly.
   If you build only configs/<board>_spl_defconfig, it is Falcon boot.
 - Create board select menu based on the 8th field of boards.cfg.
   It is common that many entries (= 7th field) share the same
   config header. So this change help to reduce the code redandancy.

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/.

Series-changes: 4
  - Re-generate based on the latest boards.cfg
  - Have only one defconfig per board

Series-changes: 3
  - Re-generate based on the latest boards.cfg
  - Change the location of SPL/TPL defconfig files
    SPL: configs/spl/<board>_defconfig -> configs/<board>_spl_defconfig
    TPL: configs/tpl/<board>_defconfig -> configs/<board>_tpl_defconfig

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: 4
  - Abolish CONFIG_SUBIMAGES
  - Add CONFIG_DEFCONFIG_LIST

Series-changes: 3
  - Add CONFIG_SUBIMAGES for generic sub-image framework.
  - Move CONFIG_SYS_EXTRA_OPTIONS to the top Kconfig.
  - Add more help messages to each config.

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: 3
  - Rebase on the current u-boot/master

Series-changes: 2
  - Rebase on the current u-boot/master
kconfig: switch to Kconfig

This commit enables Kconfig.
Going forward, we use Kconfig for the 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 boot images (Normal, SPL, TPL)
from one source tree.
Each image needs its own configuration input.

Usage:

Run "make <board>_defconfig" to do the board configuration.

It will create .config file and additionally spl/.config, tpl/.config
if SPL, TPL is enabled respectively.

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

Use "make spl:config", "make spl:menuconfig" etc. for spl/.config
and do likewise for tpl/.config file.

The generic syntax of configuration targets for SPL, TPL is:

  <target_image>:<config_command>

When the configuration is done, run "make".
(Or "make <board>_defconfig all" will do the configuration and build
in one time.)

For futher information of how Kconfig in U-Boot works,
please read the comment block of scripts/multiconfig.py.

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 Normal, SPL, TPL image, respectively.

Series-changes: 5
  - Rebase on commit fbe79a17fd

Series-changes: 4
  - Have one defconfig file for each board by supporting conditional
    definition in defconfig
  - Put adjustment code into scripts/multiconfig.py

Series-changes: 3
  - Invoke SPL/TPL configuration only for defconfig and silentoldconfig

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.
Don't send: do not clean scripts/kconfig/* by make mrproper
Do not apply: tools: add gen_maintainers.py

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

This tool generates MAINTAINERS files based on boards.cfg file.

Because it is used only once, it should not be applied.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Series-changes: 4
  - Newly added
Add MAINTAINERS files

We have switched to Kconfig and the boards.cfg file is going to
be removed. We have to retrieve the board status and maintainers
information from it.

The MAINTAINERS format as in Linux Kernel would be nice
because we can crib the scripts/get_maintainer.pl for our use.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Series-changes: 4
  - Newly added
tools: add genboardscfg.py

Now the primary data for each board is in Kconfig, defconfig and
MAINTAINERS.

It is true boards.cfg is needed for MAKEALL and buildman and
might be useful to brouse boards in a single database.
But it would be painful to maintain the boards.cfg in sync.

So, this is the solution.
Add a tool to generate the equivalent boards.cfg file based on
the latest Kconfig, defconfig and MAINTAINERS.

We can keep all the functions of MAKEALL and buildman with it.

The best thing would be to change MAKEALL and buildman for not
depending on boards.cfg in future, but it would take some time.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Series-changes: 5
  - Support wildcard pattern like 'F:  configs/foo_*_defconfig'
  - Rename genboardscfg to genboardscfg.py
  - Use assert statement for sanity check
  - Do not run if imported from another script
    if __name__ == '__main__':
         main()
  - Check if we are at the top of source directory

Series-changes: 4
  - Newly added
kconfig: remove mkconfig and boards.cfg

The old configuration script is no longer necessary.

And boards.cfg is not a primary database, but derived from
Kconfig, defconfig and MAINTAINERS files.

We can generate the latest boards.cfg with the genboardscfg.py tool.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Series-changes: 4
  - Remove boards.cfg
  - Update .gitignore
MAKEALL: adjust for Kconfig

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

Invoke tools/genboardscfg.py to generate boards.cfg when it is missing.

Series-changes: 4
  - Generate boards.cfg automatically if it is missing
buildman: adjust for Kconfig

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

Invoke tools/genboardscfg.py to generate boards.cfg when it is missing.

Series-changes: 4
  - Generate boards.cfg automatically if it is missing
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>
Series-changes: 4
  - Rebase on the current u-boot/master
powerpc: remove redundant CPU definition

CONFIG_${CPU} is defined by Kconfig.

Series-changes: 4
  - Newly added
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: 4
  - Rebase on the current u-boot/master

Series-changes: 3
  - Rebase on the current u-boot/master

Series-changes: 2
  - Rebase on the current u-boot/master
kconfig: add CONFIG_CROSS_COMPILE

Copy from Linux Kernel (with a few adjustments in comments).
kconfig: add CONFIG_CC_OPTIMIZE_FOR_SIZE
kconfig: zynq: refactor Zynq Kconfig and defconfig

Move Zynq board select menu to arch/arm/cpu/armv7/Kconfig.

Move common setting (CONFIG_SYS_SOC="zynq" etc.)
to arch/arm/cpu/armv7/Kconfig.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>