[U-Boot] [PATCH 0/34] Switch over to real Kbuild

Masahiro Yamada yamada.m at jp.panasonic.com
Wed Dec 11 12:01:22 CET 2013


We switched to Kbuild style makefiles at v2014.01-rc1 release.
With that modification, we can write makefiles simpler.
But it is NOT real Kbuild.

As the next step, this series imports (+ adjusts) build scripts
from Linux Kernel under scripts/ directory.
By applying this series, we can get more advantages:
  - short log
  - perfect dependency tracking
  - preparation to the next step: Kconfig
  - other things...

 Kbuild without Kconfig
 ----------------------

At first, to make things clearer, let me explain
the difference between "Kbuild" and "Kconfig".
They are, I think, sometimes confusing.

 Kbuild - build system used for Linux Kernel.
    Some features of Kbuild are:

       (a) We can describe makefiles simple.
          Just addi objects to "obj-y" like this:
          obj-$(CONFIG_FOO) += foo.o

       (b) We can describe directory descending nicely
          Add a directory name to "obj-y" like this:
          obj-$(CONFIG_BAR) += bar/

       (c) Short log like follows:
          CC      common/foo.o
          CC      common/bar.o
          LD      common/built-in.o

       (d) Perfect dependency tracking
          I think this is the biggest advantage.
          To be honest, the dependency tracing of U-Boot build system
          was not reliable.

 Kconfig - A tool to manage CONFIG macros.
          We can handle the dependency among CONFIG macros.
          Kconfig allows us to modify CONFIG settings easily
          by "make config".
          GUI interface are also available by "make menuconfig"
          All defined CONFIG macros are stored into ".config" file

I think most of you are already familiar with above.
I definitely want to port both of these, but I want to do one by one: Kbuild first.
(If we do Kbuild and Kconfig at the same time, it might be messed up.)

So, I want to do "Kbuild without Kconfig" in this series.
The conventional tool (mkconfig + boards.cfg file)
is used for board configuration.

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

Before importing new features, I wanted to clean up some parts of makefiles.
I posted many trivial patches to refactor makefiles.

This series uses the followings as prerequisites:

[1] blackfin: Do not generate unused header bootrom-asm-offsets.h
http://patchwork.ozlabs.org/patch/295141/

[2] sandbox: Use system headers first for sandbox's os.c in a different way
http://patchwork.ozlabs.org/patch/294233/

[3] .gitignore: ignore spl/ and tpl/ directories except spl/Makefile
http://patchwork.ozlabs.org/patch/294271/

[4] Makefile: delete a make rule of $(LDSCRIPT)
http://patchwork.ozlabs.org/patch/294717/

[5] post: descend only when CONFIG_HAS_POST is defined
http://patchwork.ozlabs.org/patch/294741/

[6] Makefile: Select objects by CONFIG_ rather than $(ARCH) or $(CPU)
http://patchwork.ozlabs.org/patch/294742/

[7] drivers/usb/gadget: select objects by obj-$(CONFIG-...)
http://patchwork.ozlabs.org/patch/294745/

[8] drivers/mtd: descend into sub directories only when it is necessary
http://patchwork.ozlabs.org/patch/294746/

[9] Makefile: Move some scripts imported from Linux
http://patchwork.ozlabs.org/patch/294780/

[10] Makefile: delete unnecessary CPPFLAGS settings
http://patchwork.ozlabs.org/patch/294829/

[11] Makefile: delete unnecessary lines
http://patchwork.ozlabs.org/patch/295052/

[12] Makefile: Do not create empty autoconf.mk on error
http://patchwork.ozlabs.org/patch/295779/

[13] Makefile: use two double-quotations as a pair
http://patchwork.ozlabs.org/patch/296718/

[14] Makefile: correct dependencies of asm-offsets.[hs]
http://patchwork.ozlabs.org/patch/296722/

[15] examples: x86: delete 82559_eeprom
http://patchwork.ozlabs.org/patch/297608/

[16] Makefile, .gitignore: Cleanup non-existing binaries
http://patchwork.ozlabs.org/patch/297609/

[17] spl/Makefile: merge LIBS-y += arch/$(ARCH)/imx-common
http://patchwork.ozlabs.org/patch/299660/

You need to apply above patches beforehand to use this series.
They are simple patches, so I hope they will be reviewed and applied first.

 How to Build ?
 --------------

We can build the same as before.
Do board configuraton and then run "make".

  $ make  omap4_panda_config
  Configuring for omap4_panda board...
  $ make  CROSS_COMPILE=arm-linux-gnueabi-
  GEN     include/autoconf.mk.dep
  GEN     include/autoconf.mk
  CC      lib/asm-offsets.s
  GEN     include/generated/generic-asm-offsets.h
  CC      arch/arm/cpu/armv7/omap4/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  HOSTCC  scripts/basic/fixdep
   ...

You will find a difference at a glance, short log
If you need detail log message, please add "V=1".
(You can also use "V=2")

Please note we can not use any more
  $ make omap4_panda CROSS_COMPILE=arm-linux-gnueabi-
to do board configuration and "make" at the same time.

Instead, we can use Kbuild-ish way for that purpose:
  $ make omap4_panda_config all CROSS_COMPILE=arm-linux-gnuabi-

This series keeps the other features:

  - Support out-of-tree build
     You can use "O=<dir_name>" like this
     $ mkdir build_dir
     $ make omap4_panda_config all O=build_dir CROSS_COMPILE=arm-linux-gnueabi-

  - Works with parallel make option
     Add "-j" option for this. Compiling will get faster.

  - Of cource, SPL, TPL build are supported
    (nand_spl also works. But "nand_spl" is obsolete and we should switch to "spl".
     Until when should we continue to maintain nand_spl?)

  - Breaks no boards (except some boards which are already broken)
     I built all target boards to prove correctness of this series
     at least for compile test.

 My Next Plan
 ------------

  - Import Kconfig
      Use "make config", "make menuconfig", "make defconfig", etc. in U-Boot.

  - More refactoring
      Some parts of makefiles are still dirty.
      I want to refactor more makefiles in follow-up patches.

  - Use "obj-m" for standalone program?? Loadable module??
      I have not deceided about this yet.



Masahiro Yamada (34):
  .gitignore: ingore files generated by Kbuild
  Makefile.host.tmp: add a new script to refactor tools
  tools: convert makefiles to kbuild style
  board: samsung: refactor host programs
  examples: Use scripts/Makefile.build
  nand-spl: Use scripts/Makefile.build
  Makfile: move suffix rules to Makefile.build
  Makefile: move some variable definitions to the top Makefile
  Makefile: move BFD_ROOT_DIR to tools/gdb/Makefile
  Kbuild: import Kbuild.include from linux v3.12 tag
  Kbuild: Use Kbuild.include
  Makefile: move more flags to the top Makefile
  Makefile: refactor include path settings
  Makefile: move more stuff to top Makefile
  Makefile: move some flags to spl/Makefile
  Makefile: move some flags to examples makefiles
  Kbuild: change out-of-tree building
  Kbuild: add dummy obj-y to create built-in.o
  Makefile: rename scripts/Makefile.build to scripts/Makefile.build.tmp
  Kbuild: import more build scripts from Linux v3.12 tag
  Kbuild: use Linux Kernel build scripts
  Kbuild: delete temporary build scripts
  Kbuild: move some lines to more suitable place
  Kbuild: convert some make rules to Kbuild style
  Kbuild: move include directives of board configuration files
  Kbuild: generate {spl,tpl}-autoconf.mk only when it is necessary
  Makefile: remove a cleaning target "tidy"
  Kbuild: change the top Makefile to more Kbuild-ish structure
  examples: move api/ and standalone/ to examples/Makefile
  Kbuild: refactor Makefile and spl/Makefile more
  Makefile: Do not pass MTD_VERSION from the top Makefile
  Makefile: refactor tools-all targets
  Kbuild: use scripts/Makefile.clean
  Kbuild: support simultaneous board configuration and "make all"

 .gitignore                                         |   21 +-
 MAKEALL                                            |    6 +-
 Makefile                                           | 1240 +++++++++++++-------
 arch/arm/cpu/arm1136/config.mk                     |    2 +-
 arch/arm/cpu/arm926ejs/config.mk                   |    2 +-
 arch/arm/cpu/arm926ejs/davinci/config.mk           |    2 +-
 arch/arm/cpu/armv7/am33xx/config.mk                |    2 +-
 arch/arm/cpu/armv7/config.mk                       |    2 +-
 arch/arm/cpu/armv7/omap3/config.mk                 |    2 +-
 arch/arm/cpu/armv7/omap4/config.mk                 |    2 +-
 arch/arm/cpu/armv7/omap5/config.mk                 |    2 +-
 arch/arm/cpu/armv7/socfpga/config.mk               |    2 +-
 arch/arm/cpu/armv7/tegra114/Makefile               |    3 +-
 arch/arm/cpu/armv7/tegra30/Makefile                |    3 +-
 arch/arm/imx-common/Makefile                       |    2 +-
 arch/blackfin/config.mk                            |   10 +-
 arch/blackfin/cpu/Makefile                         |   10 +-
 arch/blackfin/lib/Makefile                         |    5 +-
 arch/m68k/cpu/mcf5227x/Makefile                    |    2 +-
 arch/m68k/cpu/mcf523x/Makefile                     |    2 +-
 arch/m68k/cpu/mcf52x2/Makefile                     |    2 +-
 arch/m68k/cpu/mcf532x/Makefile                     |    2 +-
 arch/m68k/cpu/mcf5445x/Makefile                    |    2 +-
 arch/m68k/cpu/mcf547x_8x/Makefile                  |    2 +-
 arch/mips/cpu/mips32/config.mk                     |    2 +-
 arch/mips/cpu/mips64/config.mk                     |    2 +-
 arch/mips/cpu/xburst/config.mk                     |    2 +-
 arch/nds32/config.mk                               |    2 +-
 arch/nds32/cpu/n1213/Makefile                      |    3 +
 arch/powerpc/cpu/mpc8xx/Makefile                   |    2 +-
 arch/powerpc/lib/Makefile                          |    4 +-
 arch/sandbox/cpu/Makefile                          |   11 +-
 arch/sparc/config.mk                               |    3 +-
 arch/x86/lib/Makefile                              |    2 +-
 board/ait/cam_enc_4xx/config.mk                    |    2 +-
 board/avionic-design/medcom-wide/Makefile          |    2 +-
 board/avionic-design/plutux/Makefile               |    2 +-
 board/avionic-design/tec/Makefile                  |    2 +-
 board/bct-brettl2/config.mk                        |    7 +-
 board/bf518f-ezbrd/config.mk                       |    7 +-
 board/bf526-ezbrd/config.mk                        |    7 +-
 board/bf527-ad7160-eval/config.mk                  |    7 +-
 board/bf527-ezkit/config.mk                        |    7 +-
 board/bf527-sdp/config.mk                          |    7 +-
 board/bf533-ezkit/config.mk                        |    7 +-
 board/bf533-stamp/config.mk                        |    7 +-
 board/bf537-stamp/config.mk                        |    7 +-
 board/bf538f-ezkit/config.mk                       |    7 +-
 board/bf548-ezkit/config.mk                        |    7 +-
 board/bf561-acvilon/config.mk                      |    7 +-
 board/bf561-ezkit/config.mk                        |    7 +-
 board/br4/config.mk                                |    7 +-
 board/cm-bf527/config.mk                           |    7 +-
 board/cm-bf533/config.mk                           |    7 +-
 board/cm-bf537e/config.mk                          |    7 +-
 board/cm-bf537u/config.mk                          |    7 +-
 board/cm-bf548/config.mk                           |    7 +-
 board/cm-bf561/config.mk                           |    7 +-
 board/compal/paz00/Makefile                        |    2 +-
 board/compulab/trimslice/Makefile                  |    2 +-
 board/cray/L1/Makefile                             |   10 +-
 board/freescale/common/Makefile                    |    5 +-
 board/h2200/Makefile                               |    2 +-
 board/ip04/config.mk                               |    7 +-
 board/matrix_vision/mvblm7/Makefile                |    4 +-
 board/matrix_vision/mvblx/Makefile                 |    2 +-
 board/matrix_vision/mvsmr/Makefile                 |    2 +-
 board/nvidia/common/Makefile                       |    2 +-
 board/pcs440ep/config.mk                           |    2 +-
 board/pr1/config.mk                                |    7 +-
 board/samsung/origen/Makefile                      |   23 +-
 .../origen/tools/{mkv310_image.c => mkorigenspl.c} |    0
 board/samsung/smdkv310/Makefile                    |   16 +-
 .../tools/{mkv310_image.c => mksmdkv310spl.c}      |    0
 board/sandburst/karef/Makefile                     |    2 +-
 board/sandburst/metrobox/Makefile                  |    2 +-
 board/spear/common/Makefile                        |    5 +-
 board/spear/x600/Makefile                          |    5 +-
 board/st-ericsson/snowball/Makefile                |    2 +-
 board/st-ericsson/u8500/Makefile                   |    2 +-
 board/tcm-bf518/config.mk                          |    7 +-
 board/tcm-bf537/config.mk                          |    7 +-
 common/Makefile                                    |   11 +-
 config.mk                                          |  333 +-----
 disk/Makefile                                      |    2 +-
 doc/DocBook/Makefile                               |   17 -
 drivers/bios_emulator/Makefile                     |    5 +-
 drivers/hwmon/Makefile                             |    2 +-
 drivers/net/npe/Makefile                           |    4 +-
 drivers/rtc/Makefile                               |    2 +-
 drivers/usb/musb-new/Makefile                      |    7 +-
 dts/Makefile                                       |   20 +-
 examples/Makefile                                  |    9 +
 examples/api/Makefile                              |   44 +-
 examples/standalone/Makefile                       |   71 +-
 fs/ubifs/Makefile                                  |    2 +-
 fs/yaffs2/Makefile                                 |    9 +-
 lib/Makefile                                       |    2 +-
 lib/lzma/Makefile                                  |    2 +-
 mkconfig                                           |    2 +-
 nand_spl/board/amcc/acadia/Makefile                |   45 +-
 nand_spl/board/amcc/bamboo/Makefile                |   45 +-
 nand_spl/board/amcc/canyonlands/Makefile           |   45 +-
 nand_spl/board/amcc/kilauea/Makefile               |   43 +-
 nand_spl/board/amcc/sequoia/Makefile               |   47 +-
 nand_spl/board/freescale/mpc8315erdb/Makefile      |   47 +-
 nand_spl/board/freescale/mpc8536ds/Makefile        |   59 +-
 nand_spl/board/freescale/mpc8569mds/Makefile       |   59 +-
 nand_spl/board/freescale/mpc8572ds/Makefile        |   59 +-
 nand_spl/board/freescale/p1023rds/Makefile         |   60 +-
 nand_spl/board/freescale/p1_p2_rdb/Makefile        |   59 +-
 nand_spl/board/sheldon/simpc8313/Makefile          |   48 +-
 net/Makefile                                       |    2 +-
 post/lib_powerpc/fpu/Makefile                      |   30 +-
 rules.mk                                           |   51 -
 scripts/Kbuild.include                             |  282 +++++
 scripts/Makefile                                   |    2 +
 scripts/Makefile.build                             |  519 +++++++-
 scripts/Makefile.clean                             |  108 ++
 scripts/Makefile.host                              |  170 +++
 scripts/Makefile.lib                               |  375 ++++++
 scripts/basic/.gitignore                           |    1 +
 scripts/basic/Makefile                             |   15 +
 scripts/basic/fixdep.c                             |  462 ++++++++
 scripts/mkmakefile                                 |   59 +
 spl/Makefile                                       |  185 +--
 tools/.gitignore                                   |    2 +-
 tools/Makefile                                     |  330 ++----
 tools/crc32.c                                      |    1 +
 tools/easylogo/Makefile                            |   12 +-
 tools/env/Makefile                                 |   34 +-
 tools/env/crc32.c                                  |    1 +
 tools/env/ctype.c                                  |    1 +
 tools/env/env_attr.c                               |    1 +
 tools/env/env_flags.c                              |    1 +
 tools/env/linux_string.c                           |    1 +
 tools/env_embedded.c                               |    1 +
 tools/fdt.c                                        |    1 +
 tools/fdt_ro.c                                     |    1 +
 tools/fdt_rw.c                                     |    1 +
 tools/fdt_strerror.c                               |    1 +
 tools/fdt_wip.c                                    |    1 +
 tools/gdb/Makefile                                 |   64 +-
 tools/image-fit.c                                  |    1 +
 tools/image-sig.c                                  |    1 +
 tools/image.c                                      |    1 +
 tools/kernel-doc/Makefile                          |   21 +-
 tools/md5.c                                        |    1 +
 tools/rsa-sign.c                                   |    1 +
 tools/sha1.c                                       |    1 +
 150 files changed, 3537 insertions(+), 1994 deletions(-)
 rename board/samsung/origen/tools/{mkv310_image.c => mkorigenspl.c} (100%)
 rename board/samsung/smdkv310/tools/{mkv310_image.c => mksmdkv310spl.c} (100%)
 create mode 100644 examples/Makefile
 delete mode 100644 rules.mk
 create mode 100644 scripts/Kbuild.include
 create mode 100644 scripts/Makefile
 create mode 100644 scripts/Makefile.clean
 create mode 100644 scripts/Makefile.host
 create mode 100644 scripts/Makefile.lib
 create mode 100644 scripts/basic/.gitignore
 create mode 100644 scripts/basic/Makefile
 create mode 100644 scripts/basic/fixdep.c
 create mode 100644 scripts/mkmakefile
 create mode 100644 tools/crc32.c
 create mode 100644 tools/env/crc32.c
 create mode 100644 tools/env/ctype.c
 create mode 100644 tools/env/env_attr.c
 create mode 100644 tools/env/env_flags.c
 create mode 100644 tools/env/linux_string.c
 create mode 100644 tools/env_embedded.c
 create mode 100644 tools/fdt.c
 create mode 100644 tools/fdt_ro.c
 create mode 100644 tools/fdt_rw.c
 create mode 100644 tools/fdt_strerror.c
 create mode 100644 tools/fdt_wip.c
 create mode 100644 tools/image-fit.c
 create mode 100644 tools/image-sig.c
 create mode 100644 tools/image.c
 create mode 100644 tools/md5.c
 create mode 100644 tools/rsa-sign.c
 create mode 100644 tools/sha1.c

-- 
1.8.3.2



More information about the U-Boot mailing list