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

Masahiro Yamada yamada.m at jp.panasonic.com
Wed Dec 18 07:17:18 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
 ----------------------

First of all, 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 U-boot developers are already familiar with above.
(In most cases, they are Linux Kernel developers too.)

I definitely want to port both of these, but I want to do them separately: 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.

 Prerequisite
 ------------

You need to apply some patches beforehand to use this series.
This series uses the followings as prerequisites:

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

[2] Makefile: fix the typo error for mrproper (posted by Bo Shen)
http://patchwork.ozlabs.org/patch/301493/

[3] nand_util.c: Use '%zd' for length in nand_unlock debug print (posted by Tom Rini)
http://patchwork.ozlabs.org/patch/301740/
This is not mandatory, but recommended.
It fixes some warnings, so you can get cleaner buildman log.

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

We can build the same as before.
Do board configuraton first 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 no longer use
  $ 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.

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

 - ".*.su" files at the top directory
  After build, you will notice ".*.su" files at the top directory.
   $ ls -a
   .          .20193.su         CREDITS     api         disk      include   scripts          u-boot-nand.bin  u-boot.srec
   ..         .20198.su         Licenses    arch        doc       lib       snapshot.commit  u-boot-pad.img
   .18993.su  .20203.su         MAKEALL     board       drivers   mkconfig  spl              u-boot.bin
   .18998.su  .checkpatch.conf  Makefile    boards.cfg  dts       nand_spl  test             u-boot.ldr
   .19037.su  .git              README      common      examples  net       tools            u-boot.lds
   .19042.su  .gitignore        System.map  config.mk   fs        post      u-boot           u-boot.map

   These files ".<process_number>.su" are created when -fstack-usage is given to $(call cc-option, ...)

   I will fix this problem correctly lator.

 - I marked dirty parts with "FIX ME".

   In some board-specific config.mk files.
     # FIX ME
     ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
     ccflags-y := -O2
     endif

   In the top Makefile
     # FIX ME
     cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
     c_flags := $(KBUILD_CFLAGS) $(cpp_flags)

   I will re-write them more nicely after other parts are prepared.

Changes for v2:
   - At version 1, nand_spl boards got broken at 12 and fixed at 14.
     Fix this problem
   - At version 1, sandbox got broken at 17 and fixed at 21.
     Fix this problem
   - Add a new patch at the tail:
     35/35 "Kbuild: chech clean source and generate Makefile for out-of-tree build"
   - Rebase on v2014.01-rc2 tag

Masahiro Yamada (35):
  .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"
  Kbuild: check clean source and generate Makefile for out-of-tree build

 .gitignore                                         |   28 +-
 MAKEALL                                            |    8 +-
 Makefile                                           | 1300 +++++++++++++-------
 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                                     |  364 ++----
 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, 3608 insertions(+), 2026 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