All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
@ 2014-01-29 12:25 Masahiro Yamada
  2014-01-29 12:25 ` [U-Boot] [PATCH v8 01/38] .gitignore: ingore files generated by Kbuild Masahiro Yamada
                   ` (40 more replies)
  0 siblings, 41 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:25 UTC (permalink / raw)
  To: u-boot


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. We need more progress.

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 simply.
          Just add objects to "obj-y" like this:
          obj-$(CONFIG_FOO) += foo.o

       (b) We can describe directory descending nicely.
          Add directories with a slash 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 the followings beforehand to use this series.

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

I confirmed this series can apply on:
Commit 0876703cf + prerequisite[1].

 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.

 Note
 ----

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

 Run Test
 --------

 - Tested for MPC5121 on an ifm AC14xx board,
     Beagle (C4) board and Wand (quad) board by Gerhard Sittig

 - Tested for Zynq ZC706 board by me

Run test report for your board is welcome!

Changes for v8:
  - Rebase on commit 0876703c.
  - Fix a typo in comment in 38/38

Changes for v7:
  - Fix a bug in spl build:
    In v6, build failed if we try to build another SPL board
    without doing "make clobber".
    For example,
      $ make omap3_beagle_config
      $ make CROSS_COMPILE=<your_gcc_prefix>
      $ make am335x_evm_config
      $ make CROSS_COMPILE=<your_gcc_prefix>
    This failed in v6. We needed either "make clobber" or "make mrproper"
    before switching to another board.
    Now, we can two or more boards continuously.

Changes for v6:
  - Rebase on the current u-boot/master
  - Linux Kernel 3.13 was released on Jan. 20, so import build scripts
    from v3.13 to be breeding edge.
  - Minor change in post/lib_powerpc/fpu/Makefile
  - Include cmd_files under nand_spl/board/*/*/Makefile

Changes for v5:
  - Fix a bug reported by Gerhard Sittig:
        "make tools" before running "make" failed at v4.
  - Revive "env" target so that we can build only under tools/env/.
  - Add a new patch at the tail:
      38/38 "tools/env: cross-compile fw_printenv without setting HOSTCC"
  - Describe "clobber" target shortly by deleteing "*.imx" and "*.map"
     with wildcard matching.
  - Rebase on the current u-boot/master

Changes for v4:
  - Add a new patch at the tail:
      37/37 "kbuild: Do not generate .*.su files at the top directory"
  - Change "checkstack" target to Kbuild style
  - Move the line where U_BOOT_VERSION is defined

Changes for v3:
  - Rebase on the current u-boot/master
  - Add a new patch at the tail:
      36/36 "board: sandburst: delete FORCEBUILD"

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 (38):
  .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.13 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 build
  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.13 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/ entry 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
  board: sandburst: delete FORCEBUILD
  kbuild: Do not generate .*.su files at the top directory
  tools/env: cross-compile fw_printenv without setting HOSTCC

 .gitignore                                         |   30 +-
 MAKEALL                                            |    8 +-
 Makefile                                           | 1310 +++++++++++++-------
 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-ng/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                     |    6 +-
 board/sandburst/metrobox/Makefile                  |    6 +-
 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                               |   73 +-
 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                       |   74 +-
 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                      |   29 +-
 rules.mk                                           |   51 -
 scripts/Kbuild.include                             |  284 +++++
 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                                       |  197 +--
 tools/.gitignore                                   |    3 +-
 tools/Makefile                                     |  373 ++----
 tools/crc32.c                                      |    1 +
 tools/easylogo/Makefile                            |   12 +-
 tools/env/.gitignore                               |    2 +
 tools/env/Makefile                                 |   39 +-
 tools/env/README                                   |    5 +-
 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 +
 153 files changed, 3693 insertions(+), 2057 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/.gitignore
 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

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 01/38] .gitignore: ingore files generated by Kbuild
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
@ 2014-01-29 12:25 ` Masahiro Yamada
  2014-01-29 12:25 ` [U-Boot] [PATCH v8 02/38] Makefile.host.tmp: add a new script to refactor tools Masahiro Yamada
                   ` (39 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:25 UTC (permalink / raw)
  To: u-boot

Ignore generated files by Kbuild such as .*.cmd, *.order, etc.

Besides above,
 - Ignore *.s files
   We do not need to ignore with file name, asm-offsets.s
 - Do not ignore *.rej (for quilt)
 - Ignore backup files, \#*#

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

Changes in v8: None
Changes in v7: None
Changes in v6:
 - ignore *.elf

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
 - Do not double "*~"
 - Ignore more patterns

 .gitignore | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/.gitignore b/.gitignore
index d7d5538..b613586 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,16 +5,20 @@
 #
 # Normal rules
 #
-
-*.rej
-*.orig
-*.a
+.*
 *.o
+*.o.*
+*.a
+*.s
 *.su
-*~
+*.mod.c
+*.i
+*.lst
+*.order
+*.elf
 *.swp
-*.patch
 *.bin
+*.patch
 *.cfgtmp
 *.dts.tmp
 
@@ -24,12 +28,10 @@
 #
 # Top-level generic files
 #
-
 /MLO*
 /SPL
 /System.map
 /u-boot
-/u-boot.elf
 /u-boot.hex
 /u-boot.imx
 /u-boot-with-spl.imx
@@ -50,6 +52,12 @@
 /u-boot.sb
 
 #
+# git files that we don't want to ignore even it they are dot-files
+#
+!.gitignore
+!.mailmap
+
+#
 # Generated files
 #
 
@@ -65,7 +73,6 @@
 /include/generated/
 /include/spl-autoconf.mk
 /include/tpl-autoconf.mk
-asm-offsets.s
 
 # stgit generated dirs
 patches-*
@@ -91,3 +98,7 @@ GPATH
 GRTAGS
 GSYMS
 GTAGS
+
+*.orig
+*~
+\#*#
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 02/38] Makefile.host.tmp: add a new script to refactor tools
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
  2014-01-29 12:25 ` [U-Boot] [PATCH v8 01/38] .gitignore: ingore files generated by Kbuild Masahiro Yamada
@ 2014-01-29 12:25 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 03/38] tools: convert makefiles to kbuild style Masahiro Yamada
                   ` (38 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:25 UTC (permalink / raw)
  To: u-boot

This commit adds scripts/Makefile.host.tmp which will
be used in the next commit to convert makefiles
under tools/ directory to Kbuild style.

Notice this script, scripts/Makefile.host.tmp
is temporary.

When switching over to real Kbuild,
it will be replaced with scripts/Makefile.host of Linux Kernel.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 scripts/Makefile.build    | 17 ++++++++++---
 scripts/Makefile.host.tmp | 61 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 3 deletions(-)
 create mode 100644 scripts/Makefile.host.tmp

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index e3354aa..c451fbf 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -7,15 +7,23 @@ include $(TOPDIR)/config.mk
 LIB := $(obj)built-in.o
 LIBGCC = $(obj)libgcc.o
 SRCS :=
+subdir-y :=
+obj-dirs :=
 
 include Makefile
 
+# Do not include host rules unless needed
+ifneq ($(hostprogs-y)$(hostprogs-m),)
+include $(SRCTREE)/scripts/Makefile.host.tmp
+endif
+
 # Going forward use the following
 obj-y := $(sort $(obj-y))
 extra-y := $(sort $(extra-y))
+always := $(sort $(always))
 lib-y := $(sort $(lib-y))
 
-subdir-y 	:= $(patsubst %/,%,$(filter %/, $(obj-y)))
+subdir-y 	+= $(patsubst %/,%,$(filter %/, $(obj-y)))
 obj-y		:= $(patsubst %/, %/built-in.o, $(obj-y))
 subdir-obj-y	:= $(filter %/built-in.o, $(obj-y))
 subdir-obj-y	:= $(addprefix $(obj),$(subdir-obj-y))
@@ -25,7 +33,8 @@ SRCS	+= $(wildcard $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) \
 OBJS	:= $(addprefix $(obj),$(obj-y))
 
 # $(obj-dirs) is a list of directories that contain object files
-obj-dirs := $(dir $(OBJS))
+
+obj-dirs += $(dir $(OBJS))
 
 # Create directories for object files if directory does not exist
 # Needed when obj-y := dir/file.o syntax is used
@@ -33,7 +42,7 @@ _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
 
 LGOBJS := $(addprefix $(obj),$(sort $(lib-y)))
 
-all: $(LIB) $(addprefix $(obj),$(extra-y))
+all: $(LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
 
 $(LIB):	$(obj).depend $(OBJS)
 	$(call cmd_link_o_target, $(OBJS))
@@ -48,7 +57,9 @@ endif
 ifneq ($(subdir-obj-y),)
 # Descending
 $(subdir-obj-y): $(subdir-y)
+endif
 
+ifneq ($(subdir-y),)
 $(subdir-y): FORCE
 	$(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build
 endif
diff --git a/scripts/Makefile.host.tmp b/scripts/Makefile.host.tmp
new file mode 100644
index 0000000..4b57846
--- /dev/null
+++ b/scripts/Makefile.host.tmp
@@ -0,0 +1,61 @@
+
+__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
+
+# C code
+# Executables compiled from a single .c file
+host-csingle	:= $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
+
+# C executables linked based on several .o files
+host-cmulti	:= $(foreach m,$(__hostprogs),$(if $($(m)-objs),$(m)))
+
+# Object (.o) files compiled from .c files
+host-cobjs	:= $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
+
+# output directory for programs/.o files
+# hostprogs-y := tools/build may have been specified. Retrieve directory
+host-objdirs := $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f))))
+# directory of .o files from prog-objs notation
+host-objdirs += $(foreach f,$(host-cmulti),                  \
+                    $(foreach m,$($(f)-objs),                \
+                        $(if $(dir $(m)),$(dir $(m)))))
+
+host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs))))
+
+__hostprogs     := $(addprefix $(obj),$(__hostprogs))
+host-csingle	:= $(addprefix $(obj),$(host-csingle))
+host-cmulti	:= $(addprefix $(obj),$(host-cmulti))
+host-cobjs	:= $(addprefix $(obj),$(host-cobjs))
+host-objdirs    := $(addprefix $(obj),$(host-objdirs))
+
+obj-dirs += $(host-objdirs)
+
+#####
+# Handle options to gcc. Support building with separate output directory
+
+_hostc_flags   = $(HOSTCFLAGS)   $(HOST_EXTRACFLAGS)   \
+                 $(HOSTCFLAGS_$(basetarget).o)
+
+# Find all -I options and call addtree
+flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
+
+ifeq ($(OBJTREE),$(SRCTREE))
+__hostc_flags	= $(_hostc_flags)
+else
+__hostc_flags	= -I$(obj) $(call flags,_hostc_flags)
+endif
+
+hostc_flags    = $(__hostc_flags)
+
+#####
+# Compile programs on the host
+
+$(host-csingle): $(obj)%: %.c
+	$(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTLDFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $<
+
+$(host-cmulti): $(obj)%: $(host-cobjs)
+	$(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj),$($(@F)-objs)) $(HOSTLOADLIBES_$(@F))
+
+$(host-cobjs): $(obj)%.o: %.c
+	$(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
+
+targets += $(host-csingle)  $(host-cmulti) $(host-cobjs)
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 03/38] tools: convert makefiles to kbuild style
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
  2014-01-29 12:25 ` [U-Boot] [PATCH v8 01/38] .gitignore: ingore files generated by Kbuild Masahiro Yamada
  2014-01-29 12:25 ` [U-Boot] [PATCH v8 02/38] Makefile.host.tmp: add a new script to refactor tools Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 04/38] board: samsung: refactor host programs Masahiro Yamada
                   ` (37 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

Before this commit, makefiles under tools/ directory
were implemented with their own way.

This commit refactors them by using "hostprogs-y" variable.

Several C sources have been added to wrap other C sources
to simplify Makefile.
For example, tools/crc32.c includes lib/crc32.c

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
  - Rebase on the current u-boot/master

Changes in v4: None
Changes in v3: None
Changes in v2:
  - Rebase on v2014.01-rc2 tag

 Makefile                  |  18 ++-
 config.mk                 |  28 +---
 rules.mk                  |   5 -
 spl/Makefile              |   4 +-
 tools/.gitignore          |   2 +-
 tools/Makefile            | 338 ++++++++++++++--------------------------------
 tools/crc32.c             |   1 +
 tools/easylogo/Makefile   |  12 +-
 tools/env/Makefile        |  32 +----
 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        |  43 +-----
 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 +
 28 files changed, 156 insertions(+), 365 deletions(-)
 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

diff --git a/Makefile b/Makefile
index 1687e2e..a1e2810 100644
--- a/Makefile
+++ b/Makefile
@@ -126,6 +126,8 @@ unexport CDPATH
 
 #########################################################################
 
+build := -f $(TOPDIR)/scripts/Makefile.build -C
+
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
 # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
@@ -362,8 +364,6 @@ endif
 endif
 endif
 
-build := -f $(TOPDIR)/scripts/Makefile.build -C
-
 all:		$(ALL-y) $(SUBDIR_EXAMPLES-y)
 
 $(obj)u-boot.dtb:	checkdtc $(obj)u-boot
@@ -558,7 +558,10 @@ $(OBJS):
 $(LIBS):	depend $(SUBDIR_TOOLS)
 		$(MAKE) $(build) $(dir $(subst $(obj),,$@))
 
-$(SUBDIRS):	depend
+tools:	depend
+		$(MAKE) $(build) $@ all
+
+$(filter-out tools,$(SUBDIRS)):	depend
 		$(MAKE) -C $@ all
 
 $(SUBDIR_EXAMPLES-y): $(obj)u-boot
@@ -711,7 +714,7 @@ depend dep tags ctags etags cscope $(obj)System.map:
 	@ exit 1
 
 tools: $(VERSION_FILE) $(TIMESTAMP_FILE)
-	$(MAKE) -C $@ all
+	$(MAKE) $(build) $@ all
 endif	# config.mk
 
 # ARM relocations should all be R_ARM_RELATIVE (32-bit) or
@@ -746,14 +749,15 @@ $(TIMESTAMP_FILE):
 		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
 
 easylogo env gdb:
-	$(MAKE) -C tools/$@ all MTD_VERSION=${MTD_VERSION}
+	$(MAKE) $(build) tools/$@ MTD_VERSION=${MTD_VERSION}
+
 gdbtools: gdb
 
 xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc
 	$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) -C doc/DocBook/ $@
 
 tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
-	$(MAKE) -C tools HOST_TOOLS_ALL=y
+	$(MAKE) $(build) tools HOST_TOOLS_ALL=y
 
 .PHONY : CHANGELOG
 CHANGELOG:
@@ -798,7 +802,7 @@ clean:
 	       $(obj)tools/gen_eth_addr    $(obj)tools/img2srec		  \
 	       $(obj)tools/dump{env,}image		  \
 	       $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk	  \
-	       $(obj)tools/mk{$(BOARD),}spl				  \
+	       $(obj)tools/mk{$(BOARD),exynos}spl			  \
 	       $(obj)tools/mxsboot					  \
 	       $(obj)tools/ncb		   $(obj)tools/ubsha1		  \
 	       $(obj)tools/kernel-doc/docproc				  \
diff --git a/config.mk b/config.mk
index 60e297a..07afb35 100644
--- a/config.mk
+++ b/config.mk
@@ -58,7 +58,6 @@ PLATFORM_LDFLAGS =
 
 HOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
 		  $(HOSTCPPFLAGS)
-HOSTSTRIP	= strip
 
 #
 # Mac OS X / Darwin's C preprocessor is Apple specific.  It
@@ -93,13 +92,6 @@ ifeq ($(HOSTOS),cygwin)
 HOSTCFLAGS	+= -ansi
 endif
 
-# We build some files with extra pedantic flags to try to minimize things
-# that won't build on some weird host compiler -- though there are lots of
-# exceptions for files that aren't complaint.
-
-HOSTCFLAGS_NOPED = $(filter-out -pedantic,$(HOSTCFLAGS))
-HOSTCFLAGS	+= -pedantic
-
 #########################################################################
 #
 # Option checker, gcc version (courtesy linux kernel) to ensure
@@ -213,24 +205,6 @@ CPPFLAGS += -ffunction-sections -fdata-sections
 LDFLAGS_FINAL += --gc-sections
 endif
 
-# TODO(sjg at chromium.org): Is this correct on Mac OS?
-
-# MXSImage needs LibSSL
-ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)
-HOSTLIBS	+= -lssl -lcrypto
-# Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
-# the mxsimage support within tools/mxsimage.c .
-HOSTCFLAGS	+= -DCONFIG_MXS
-endif
-
-ifdef CONFIG_FIT_SIGNATURE
-HOSTLIBS	+= -lssl -lcrypto
-
-# This affects include/image.h, but including the board config file
-# is tricky, so manually define this options here.
-HOSTCFLAGS	+= -DCONFIG_FIT_SIGNATURE
-endif
-
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
 CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
 endif
@@ -341,7 +315,7 @@ endif
 
 #########################################################################
 
-export	HOSTCC HOSTCFLAGS HOSTLDFLAGS PEDCFLAGS HOSTSTRIP CROSS_COMPILE \
+export	HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE \
 	AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
 export	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
 
diff --git a/rules.mk b/rules.mk
index f4510b7..b36de4d 100644
--- a/rules.mk
+++ b/rules.mk
@@ -43,9 +43,4 @@ $(obj).depend.%:	%.c
 $(obj).depend.%:	%.S
 	$(MAKE_DEPEND)
 
-$(HOSTOBJS): $(obj)%.o: %.c
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
-$(NOPEDOBJS): $(obj)%.o: %.c
-	$(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
-
 #########################################################################
diff --git a/spl/Makefile b/spl/Makefile
index 4143e38..d5164e0 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -164,7 +164,9 @@ else
 VAR_SIZE_PARAM =
 endif
 $(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
-	$(OBJTREE)/tools/mk$(BOARD)spl $(VAR_SIZE_PARAM) $< $@
+	$(if $(wildcard $(OBJTREE)/tools/mk$(BOARD)spl),\
+	$(OBJTREE)/tools/mk$(BOARD)spl,\
+	$(OBJTREE)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
 endif
 
 $(obj)$(SPL_BIN).bin:	$(obj)$(SPL_BIN)
diff --git a/tools/.gitignore b/tools/.gitignore
index cd2f041..13283b7 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -6,6 +6,7 @@
 /dumpimage
 /mkenvimage
 /mkimage
+/mkexynosspl
 /mpc86x_clk
 /mxsboot
 /ncb
@@ -15,7 +16,6 @@
 /xway-swap-bytes
 /*.exe
 /easylogo/easylogo
-/env/crc32.c
 /env/fw_printenv
 /gdb/gdbcont
 /gdb/gdbsend
diff --git a/tools/Makefile b/tools/Makefile
index 328cea3..c3cdaf0 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -5,14 +5,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-TOOLSUBDIRS = kernel-doc
-
-#
-# Include this after HOSTOS HOSTARCH check
-# so that we can act intelligently.
-#
-include $(TOPDIR)/config.mk
-
 #
 # toolchains targeting win32 generate .exe files
 #
@@ -43,82 +35,111 @@ ENVCRC-$(CONFIG_ENV_IS_IN_NVRAM) = y
 ENVCRC-$(CONFIG_ENV_IS_IN_SPI_FLASH) = y
 CONFIG_BUILD_ENVCRC ?= $(ENVCRC-y)
 
-# Generated executable files
-BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
-BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
-BIN_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
-BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
-BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
-BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
-BIN_FILES-y += dumpimage$(SFX)
-BIN_FILES-y += mkenvimage$(SFX)
-BIN_FILES-y += mkimage$(SFX)
-BIN_FILES-$(CONFIG_EXYNOS5250) += mk$(BOARD)spl$(SFX)
-BIN_FILES-$(CONFIG_EXYNOS5420) += mk$(BOARD)spl$(SFX)
-BIN_FILES-$(CONFIG_MX23) += mxsboot$(SFX)
-BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX)
-BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
-BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
-BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX)
-BIN_FILES-y += proftool(SFX)
-BIN_FILES-$(CONFIG_STATIC_RELA) += relocate-rela$(SFX)
-
-# Source files which exist outside the tools directory
-EXT_OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += common/env_embedded.o
-EXT_OBJ_FILES-y += common/image.o
-EXT_OBJ_FILES-$(CONFIG_FIT) += common/image-fit.o
-EXT_OBJ_FILES-y += common/image-sig.o
-EXT_OBJ_FILES-y += lib/crc32.o
-EXT_OBJ_FILES-y += lib/md5.o
-EXT_OBJ_FILES-y += lib/sha1.o
-
-# Source files located in the tools directory
-NOPED_OBJ_FILES-y += aisimage.o
-NOPED_OBJ_FILES-y += default_image.o
-NOPED_OBJ_FILES-y += dumpimage.o
-NOPED_OBJ_FILES-y += fit_image.o
-NOPED_OBJ_FILES-y += image-host.o
-NOPED_OBJ_FILES-y += imximage.o
-NOPED_OBJ_FILES-y += kwbimage.o
-NOPED_OBJ_FILES-y += imagetool.o
-NOPED_OBJ_FILES-y += mkenvimage.o
-NOPED_OBJ_FILES-y += mkimage.o
-NOPED_OBJ_FILES-y += mxsimage.o
-NOPED_OBJ_FILES-y += omapimage.o
-NOPED_OBJ_FILES-y += os_support.o
-NOPED_OBJ_FILES-y += pblimage.o
-NOPED_OBJ_FILES-y += proftool.o
-NOPED_OBJ_FILES-y += ublimage.o
-NOPED_OBJ_FILES-y += relocate-rela.o
-OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc.o
-OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
-OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
-OBJ_FILES-$(CONFIG_EXYNOS_SPL) += mkexynosspl.o
-OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o
-OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
-OBJ_FILES-$(CONFIG_MX23) += mxsboot.o
-OBJ_FILES-$(CONFIG_MX28) += mxsboot.o
-OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
-OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
-OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o
-OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
-OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o
+# TODO: CONFIG_CMD_LICENSE does not work
+hostprogs-$(CONFIG_CMD_LICENSE) += bin2header$(SFX)
 
-# Don't build by default
-#ifeq ($(ARCH),ppc)
-#BIN_FILES-y += mpc86x_clk$(SFX)
-#OBJ_FILES-y += mpc86x_clk.o
-#endif
+hostprogs-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
+hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
+HOSTCFLAGS_bmp_logo$(SFX) := -pedantic
+
+hostprogs-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
+envcrc$(SFX)-objs := crc32.o env_embedded.o envcrc.o sha1.o
+
+hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
+HOSTCFLAGS_gen_eth_addr$(SFX) := -pedantic
 
+hostprogs-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
+HOSTCFLAGS_img2srec$(SFX) := -pedantic
+
+hostprogs-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
+HOSTCFLAGS_xway-swap-bytes$(SFX) := -pedantic
+
+hostprogs-y += mkenvimage$(SFX)
+mkenvimage$(SFX)-objs := crc32.o mkenvimage.o os_support.o
+
+hostprogs-y += dumpimage$(SFX) mkimage$(SFX)
+
+FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := image-sig.o
 # Flattened device tree objects
-LIBFDT_OBJ_FILES-y += fdt.o
-LIBFDT_OBJ_FILES-y += fdt_ro.o
-LIBFDT_OBJ_FILES-y += fdt_rw.o
-LIBFDT_OBJ_FILES-y += fdt_strerror.o
-LIBFDT_OBJ_FILES-y += fdt_wip.o
+LIBFDT_OBJS := fdt.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_wip.o
+RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := rsa-sign.o
+
+# common objs for dumpimage and mkimage
+dumpimage-mkimage-objs := aisimage.o \
+			$(FIT_SIG_OBJS-y) \
+			crc32.o \
+			default_image.o \
+			fit_image.o \
+			image-fit.o \
+			image-host.o \
+			image.o \
+			imagetool.o \
+			imximage.o \
+			kwbimage.o \
+			md5.o \
+			mxsimage.o \
+			omapimage.o \
+			os_support.o \
+			pblimage.o \
+			sha1.o \
+			ublimage.o \
+			$(LIBFDT_OBJS) \
+			$(RSA_OBJS-y)
+
+dumpimage$(SFX)-objs := $(dumpimage-mkimage-objs) dumpimage.o
+mkimage$(SFX)-objs   := $(dumpimage-mkimage-objs) mkimage.o
+
+# TODO(sjg@chromium.org): Is this correct on Mac OS?
+
+# MXSImage needs LibSSL
+ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)
+HOSTLOADLIBES_dumpimage$(SFX) := -lssl -lcrypto
+HOSTLOADLIBES_mkimage$(SFX) := -lssl -lcrypto
+# Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
+# the mxsimage support within tools/mxsimage.c .
+HOSTCFLAGS	+= -DCONFIG_MXS
+endif
+
+ifdef CONFIG_FIT_SIGNATURE
+HOSTLOADLIBES_dumpimage$(SFX) := -lssl -lcrypto
+HOSTLOADLIBES_mkimage$(SFX) := -lssl -lcrypto
+
+# This affects include/image.h, but including the board config file
+# is tricky, so manually define this options here.
+HOST_EXTRACFLAGS	+= -DCONFIG_FIT_SIGNATURE
+endif
+
+hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl$(SFX)
+hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl$(SFX)
+HOSTCFLAGS_mkexynosspl$(SFX) := -pedantic
+
+hostprogs-$(CONFIG_MX23) += mxsboot$(SFX)
+hostprogs-$(CONFIG_MX28) += mxsboot$(SFX)
+HOSTCFLAGS_mxsboot$(SFX) := -pedantic
+
+hostprogs-$(CONFIG_NETCONSOLE) += ncb$(SFX)
+hostprogs-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
+
+ubsha1$(SFX)-objs := os_support.o sha1.o ubsha1.o
+
+HOSTCFLAGS_ubsha1.o := -pedantic
+
+hostprogs-$(CONFIG_KIRKWOOD) += kwboot$(SFX)
+hostprogs-y += proftool$(SFX)
+hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela$(SFX)
 
-# RSA objects
-RSA_OBJ_FILES-$(CONFIG_FIT_SIGNATURE) += rsa-sign.o
+# We build some files with extra pedantic flags to try to minimize things
+# that won't build on some weird host compiler -- though there are lots of
+# exceptions for files that aren't complaint.
+HOSTCFLAGS_crc32.o := -pedantic
+HOSTCFLAGS_md5.o := -pedantic
+HOSTCFLAGS_sha1.o := -pedantic
+
+# Don't build by default
+#hostprogs-$(CONFIG_PPC) += mpc86x_clk$(SFX)
+#HOSTCFLAGS_mpc86x_clk$(SFX) := -pedantic
+
+always := $(hostprogs-y)
 
 # Generated LCD/video logo
 LOGO_H = $(OBJTREE)/include/bmp_logo.h
@@ -147,24 +168,13 @@ endif # !LOGO_BMP
 HOSTSRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
 HOSTSRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
 HOSTSRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
-HOSTSRCS += $(addprefix $(SRCTREE)/lib/rsa/,$(RSA_OBJ_FILES-y:.o=.c))
-BINS	:= $(addprefix $(obj),$(sort $(BIN_FILES-y)))
-LIBFDT_OBJS	:= $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
-RSA_OBJS	:= $(addprefix $(obj),$(RSA_OBJ_FILES-y))
-
-# We cannot check CONFIG_FIT_SIGNATURE here since it is not set on the host
-FIT_SIG_OBJ_FILES	:= image-sig.o
-FIT_SIG_OBJS		:= $(addprefix $(obj),$(FIT_SIG_OBJ_FILES))
-
-HOSTOBJS := $(addprefix $(obj),$(OBJ_FILES-y))
-NOPEDOBJS := $(addprefix $(obj),$(NOPED_OBJ_FILES-y))
 
 #
 # Use native tools and options
 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
 #
-HOSTCPPFLAGS =	-include $(SRCTREE)/include/libfdt_env.h \
+HOST_EXTRACFLAGS += -include $(SRCTREE)/include/libfdt_env.h \
 		-idirafter $(SRCTREE)/include \
 		-idirafter $(SRCTREE)/arch/$(ARCH)/include \
 		-idirafter $(OBJTREE)/include \
@@ -175,152 +185,12 @@ HOSTCPPFLAGS =	-include $(SRCTREE)/include/libfdt_env.h \
 		-D__KERNEL_STRICT_NAMES \
 		-D_GNU_SOURCE
 
+all:	$(LOGO-y)
 
-all:	$(obj).depend $(BINS) $(LOGO-y) subdirs
-
-$(obj)bin2header$(SFX): $(obj)bin2header.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)bmp_logo$(SFX):	$(obj)bmp_logo.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)proftool(SFX):	$(obj)proftool.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)envcrc$(SFX):	$(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-
-$(obj)gen_eth_addr$(SFX):	$(obj)gen_eth_addr.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)img2srec$(SFX):	$(obj)img2srec.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)xway-swap-bytes$(SFX):	$(obj)xway-swap-bytes.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)dumpimage$(SFX):	$(obj)aisimage.o \
-			$(FIT_SIG_OBJS) \
-			$(obj)crc32.o \
-			$(obj)default_image.o \
-			$(obj)fit_image.o \
-			$(obj)image-fit.o \
-			$(obj)image.o \
-			$(obj)image-host.o \
-			$(obj)imagetool.o \
-			$(obj)imximage.o \
-			$(obj)kwbimage.o \
-			$(obj)dumpimage.o \
-			$(obj)md5.o \
-			$(obj)mxsimage.o \
-			$(obj)omapimage.o \
-			$(obj)os_support.o \
-			$(obj)pblimage.o \
-			$(obj)sha1.o \
-			$(obj)ublimage.o \
-			$(LIBFDT_OBJS) \
-			$(RSA_OBJS)
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
-	$(HOSTSTRIP) $@
-
-$(obj)mkenvimage$(SFX):	$(obj)crc32.o $(obj)mkenvimage.o \
-	$(obj)os_support.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)mkimage$(SFX):	$(obj)aisimage.o \
-			$(FIT_SIG_OBJS) \
-			$(obj)crc32.o \
-			$(obj)default_image.o \
-			$(obj)fit_image.o \
-			$(obj)image-fit.o \
-			$(obj)image-host.o \
-			$(obj)image.o \
-			$(obj)imagetool.o \
-			$(obj)imximage.o \
-			$(obj)kwbimage.o \
-			$(obj)md5.o \
-			$(obj)mkimage.o \
-			$(obj)mxsimage.o \
-			$(obj)omapimage.o \
-			$(obj)os_support.o \
-			$(obj)pblimage.o \
-			$(obj)sha1.o \
-			$(obj)ublimage.o \
-			$(LIBFDT_OBJS) \
-			$(RSA_OBJS)
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
-	$(HOSTSTRIP) $@
-
-$(obj)mk$(BOARD)spl$(SFX):	$(obj)mkexynosspl.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)mpc86x_clk$(SFX):	$(obj)mpc86x_clk.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)mxsboot$(SFX):	$(obj)mxsboot.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)ncb$(SFX):	$(obj)ncb.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)ubsha1$(SFX):	$(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-
-$(obj)kwboot$(SFX): $(obj)kwboot.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-$(obj)relocate-rela$(SFX): $(obj)relocate-rela.o
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-# Some of the tool objects need to be accessed from outside the tools directory
-$(obj)%.o: $(SRCTREE)/common/%.c
-	$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
-
-$(obj)%.o: $(SRCTREE)/lib/%.c
-	$(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $<
-
-$(obj)%.o: $(SRCTREE)/lib/libfdt/%.c
-	$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
-
-$(obj)%.o: $(SRCTREE)/lib/rsa/%.c
-	$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
-
-subdirs:
-ifeq ($(TOOLSUBDIRS),)
-	@:
-else
-	@for dir in $(TOOLSUBDIRS) ; do \
-	    $(MAKE) \
-		HOSTOS=$(HOSTOS) \
-		HOSTARCH=$(HOSTARCH) \
-		-C $$dir || exit 1 ; \
-	done
-endif
+subdir-y := kernel-doc
 
 $(LOGO_H):	$(obj)bmp_logo $(LOGO_BMP)
 	$(obj)./bmp_logo --gen-info $(LOGO_BMP) > $@
 
 $(LOGO_DATA_H):	$(obj)bmp_logo $(LOGO_BMP)
 	$(obj)./bmp_logo --gen-data $(LOGO_BMP) > $@
-
-#########################################################################
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/tools/crc32.c b/tools/crc32.c
new file mode 100644
index 0000000..aed7112
--- /dev/null
+++ b/tools/crc32.c
@@ -0,0 +1 @@
+#include "../lib/crc32.c"
diff --git a/tools/easylogo/Makefile b/tools/easylogo/Makefile
index d8e28b0..10aba2b 100644
--- a/tools/easylogo/Makefile
+++ b/tools/easylogo/Makefile
@@ -1,11 +1,3 @@
-include $(TOPDIR)/config.mk
+hostprogs-y := easylogo
 
-all: $(obj)easylogo
-
-$(obj)easylogo: $(SRCTREE)/tools/easylogo/easylogo.c
-	$(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $^
-
-clean:
-	rm -f $(obj)easylogo
-
-.PHONY: all clean
+always := $(hostprogs-y)
diff --git a/tools/env/Makefile b/tools/env/Makefile
index 27892f7..c303815 100644
--- a/tools/env/Makefile
+++ b/tools/env/Makefile
@@ -5,15 +5,8 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
-
-HOSTSRCS := $(SRCTREE)/lib/crc32.c  fw_env.c  fw_env_main.c
-HOSTSRCS += $(SRCTREE)/lib/ctype.c $(SRCTREE)/lib/linux_string.c
-HOSTSRCS += $(SRCTREE)/common/env_attr.c $(SRCTREE)/common/env_flags.c
-HEADERS	:= fw_env.h $(OBJTREE)/include/config.h
-
 # Compile for a hosted environment on the target
-HOSTCPPFLAGS  = -idirafter $(SRCTREE)/include \
+HOST_EXTRACFLAGS  = -idirafter $(SRCTREE)/include \
 		-idirafter $(SRCTREE)/arch/$(ARCH)/include \
 		-idirafter $(OBJTREE)/include \
 		-idirafter $(SRCTREE)/tools/env \
@@ -21,23 +14,12 @@ HOSTCPPFLAGS  = -idirafter $(SRCTREE)/include \
 		-DTEXT_BASE=$(TEXT_BASE)
 
 ifeq ($(MTD_VERSION),old)
-HOSTCPPFLAGS += -DMTD_OLD
+HOST_EXTRACFLAGS += -DMTD_OLD
 endif
 
-all:	$(obj)fw_printenv
-
-# Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
-$(obj)fw_printenv:	$(HOSTSRCS) $(HEADERS)
-	$(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS)
-	$(HOSTSTRIP) $@
-
-clean:
-	rm -f $(obj)fw_printenv
-
-#########################################################################
-
-include $(TOPDIR)/rules.mk
-
-sinclude $(obj).depend
+hostprogs-y := fw_printenv
+always := $(hostprogs-y)
 
-#########################################################################
+fw_printenv-objs := fw_env.o fw_env_main.o \
+	crc32.o ctype.o linux_string.o \
+	env_attr.o env_flags.o
diff --git a/tools/env/crc32.c b/tools/env/crc32.c
new file mode 100644
index 0000000..34f8178
--- /dev/null
+++ b/tools/env/crc32.c
@@ -0,0 +1 @@
+#include "../../lib/crc32.c"
diff --git a/tools/env/ctype.c b/tools/env/ctype.c
new file mode 100644
index 0000000..21050e9
--- /dev/null
+++ b/tools/env/ctype.c
@@ -0,0 +1 @@
+#include "../../lib/ctype.c"
diff --git a/tools/env/env_attr.c b/tools/env/env_attr.c
new file mode 100644
index 0000000..502d4c9
--- /dev/null
+++ b/tools/env/env_attr.c
@@ -0,0 +1 @@
+#include "../../common/env_attr.c"
diff --git a/tools/env/env_flags.c b/tools/env/env_flags.c
new file mode 100644
index 0000000..b261cb8
--- /dev/null
+++ b/tools/env/env_flags.c
@@ -0,0 +1 @@
+#include "../../common/env_flags.c"
diff --git a/tools/env/linux_string.c b/tools/env/linux_string.c
new file mode 100644
index 0000000..6c01add
--- /dev/null
+++ b/tools/env/linux_string.c
@@ -0,0 +1 @@
+#include "../../lib/linux_string.c"
diff --git a/tools/env_embedded.c b/tools/env_embedded.c
new file mode 100644
index 0000000..59a6357
--- /dev/null
+++ b/tools/env_embedded.c
@@ -0,0 +1 @@
+#include "../common/env_embedded.c"
diff --git a/tools/fdt.c b/tools/fdt.c
new file mode 100644
index 0000000..1eafc56
--- /dev/null
+++ b/tools/fdt.c
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt.c"
diff --git a/tools/fdt_ro.c b/tools/fdt_ro.c
new file mode 100644
index 0000000..9005fe3
--- /dev/null
+++ b/tools/fdt_ro.c
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_ro.c"
diff --git a/tools/fdt_rw.c b/tools/fdt_rw.c
new file mode 100644
index 0000000..adc3fdf
--- /dev/null
+++ b/tools/fdt_rw.c
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_rw.c"
diff --git a/tools/fdt_strerror.c b/tools/fdt_strerror.c
new file mode 100644
index 0000000..d0b5822
--- /dev/null
+++ b/tools/fdt_strerror.c
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_strerror.c"
diff --git a/tools/fdt_wip.c b/tools/fdt_wip.c
new file mode 100644
index 0000000..7810f07
--- /dev/null
+++ b/tools/fdt_wip.c
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_wip.c"
diff --git a/tools/gdb/Makefile b/tools/gdb/Makefile
index dd98fb6..850bb9b 100644
--- a/tools/gdb/Makefile
+++ b/tools/gdb/Makefile
@@ -8,49 +8,18 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
-
-BINS	= gdbsend gdbcont
-
-COBJS	= gdbsend.o gdbcont.o error.o remote.o serial.o
-
-HOSTOBJS := $(addprefix $(obj),$(COBJS))
-HOSTSRCS := $(COBJS:.o=.c)
-BINS	:= $(addprefix $(obj),$(BINS))
+ifneq ($(HOSTOS),cygwin)
 
 #
 # Use native tools and options
 #
-HOSTCPPFLAGS = -I$(BFD_ROOT_DIR)/include
-
-ifeq ($(HOSTOS),cygwin)
-
-all:
-$(obj).depend:
-
-else	# ! CYGWIN
-
-all:	$(obj).depend $(BINS)
-
-$(obj)gdbsend:	$(obj)gdbsend.o $(obj)error.o $(obj)remote.o $(obj)serial.o
-		$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-
-$(obj)gdbcont:	$(obj)gdbcont.o $(obj)error.o $(obj)remote.o $(obj)serial.o
-		$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-
-clean:
-	rm -f $(HOSTOBJS)
-
-distclean:	clean
-	rm -f $(BINS) $(obj)core $(obj)*.bak $(obj).depend
-
-#########################################################################
+HOST_EXTRACFLAGS := -I$(BFD_ROOT_DIR)/include -pedantic
 
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
+hostprogs-y := gdbsend gdbcont
 
-sinclude $(obj).depend
+gdbsend-objs := gdbsend.o error.o remote.o serial.o
+gdbcont-objs := gdbcont.o error.o remote.o serial.o
 
-#########################################################################
+always := $(hostprogs-y)
 
 endif	# cygwin
diff --git a/tools/image-fit.c b/tools/image-fit.c
new file mode 100644
index 0000000..037e5cc
--- /dev/null
+++ b/tools/image-fit.c
@@ -0,0 +1 @@
+#include "../common/image-fit.c"
diff --git a/tools/image-sig.c b/tools/image-sig.c
new file mode 100644
index 0000000..e45419f
--- /dev/null
+++ b/tools/image-sig.c
@@ -0,0 +1 @@
+#include "../common/image-sig.c"
diff --git a/tools/image.c b/tools/image.c
new file mode 100644
index 0000000..0f9bacc
--- /dev/null
+++ b/tools/image.c
@@ -0,0 +1 @@
+#include "../common/image.c"
diff --git a/tools/kernel-doc/Makefile b/tools/kernel-doc/Makefile
index eb56e2e..f15a4b7 100644
--- a/tools/kernel-doc/Makefile
+++ b/tools/kernel-doc/Makefile
@@ -4,22 +4,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
+hostprogs-y := docproc
+always := $(hostprogs-y)
 
-all:	$(obj)docproc
-
-$(obj)docproc:	docproc.c
-	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
-	$(HOSTSTRIP) $@
-
-clean:
-	rm -rf docproc
-
-#########################################################################
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
+HOST_EXTRACFLAGS := -pedantic
diff --git a/tools/md5.c b/tools/md5.c
new file mode 100644
index 0000000..befaa32
--- /dev/null
+++ b/tools/md5.c
@@ -0,0 +1 @@
+#include "../lib/md5.c"
diff --git a/tools/rsa-sign.c b/tools/rsa-sign.c
new file mode 100644
index 0000000..150bbe1
--- /dev/null
+++ b/tools/rsa-sign.c
@@ -0,0 +1 @@
+#include "../lib/rsa/rsa-sign.c"
diff --git a/tools/sha1.c b/tools/sha1.c
new file mode 100644
index 0000000..0d717df
--- /dev/null
+++ b/tools/sha1.c
@@ -0,0 +1 @@
+#include "../lib/sha1.c"
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 04/38] board: samsung: refactor host programs
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (2 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 03/38] tools: convert makefiles to kbuild style Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 05/38] examples: Use scripts/Makefile.build Masahiro Yamada
                   ` (36 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

Some Samsung boards have their own tools under board/samsung/<board>/tools/.
This commit refactor more makefiles with "hostprogs-y".

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

Note1:
Samsung boards have tools under board/samsung/<board>/tools/
and have tools/mkexynosspl.c too.
It is inconsistent, so we should choose the appropriate
directory in which Samsung-specific tools are stored.

Note2:

I marded TODO item in board/samsung/origen/Makefile.

Samsung engineers, I hope you will fix the root cause of the warning.

 # omit -O2 option to suppress
 #   warning: dereferencing type-punned pointer will break strict-aliasing rules
 #
 # TODO:
 # Fix the root cause in tools/mkorigenspl.c and delete the following work-around
 $(obj)/tools/mkorigenspl: HOSTCFLAGS:=$(filter-out -O2,$(HOSTCFLAGS))


Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
  - Rebase on the current u-boot/master

Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile                                             |  1 +
 board/samsung/origen/Makefile                        | 20 ++++++++++----------
 .../origen/tools/{mkv310_image.c => mkorigenspl.c}   |  0
 board/samsung/smdkv310/Makefile                      | 15 ++++-----------
 .../tools/{mkv310_image.c => mksmdkv310spl.c}        |  0
 spl/Makefile                                         |  4 ++--
 6 files changed, 17 insertions(+), 23 deletions(-)
 rename board/samsung/origen/tools/{mkv310_image.c => mkorigenspl.c} (100%)
 rename board/samsung/smdkv310/tools/{mkv310_image.c => mksmdkv310spl.c} (100%)

diff --git a/Makefile b/Makefile
index a1e2810..8c585b6 100644
--- a/Makefile
+++ b/Makefile
@@ -809,6 +809,7 @@ clean:
 	       $(obj)tools/proftool
 	@rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image}	  \
 	       $(obj)board/matrix_vision/*/bootscript.img		  \
+	       $(obj)spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl	  \
 	       $(obj)u-boot.lds						  \
 	       $(obj)arch/blackfin/cpu/init.{lds,elf}
 	@rm -f $(obj)include/bmp_logo.h
diff --git a/board/samsung/origen/Makefile b/board/samsung/origen/Makefile
index e8818bf..31e88f4 100644
--- a/board/samsung/origen/Makefile
+++ b/board/samsung/origen/Makefile
@@ -4,16 +4,16 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-ifndef CONFIG_SPL_BUILD
-obj-y	+= origen.o
-endif
-
 ifdef CONFIG_SPL_BUILD
-all: $(OBJTREE)/tools/mk$(BOARD)spl
-endif
+hostprogs-y := tools/mkorigenspl
+always := $(hostprogs-y)
 
-# Fix ME after we implement hostprogs-y.
-ifdef CONFIG_SPL_BUILD
-$(OBJTREE)/tools/mk$(BOARD)spl:	tools/mkv310_image.c
-	$(HOSTCC) tools/mkv310_image.c -o $(OBJTREE)/tools/mk$(BOARD)spl
+# omit -O2 option to suppress
+#   warning: dereferencing type-punned pointer will break strict-aliasing rules
+#
+# TODO:
+# Fix the root cause in tools/mkorigenspl.c and delete the following work-around
+$(obj)tools/mkorigenspl: HOSTCFLAGS:=$(filter-out -O2,$(HOSTCFLAGS))
+else
+obj-y	+= origen.o
 endif
diff --git a/board/samsung/origen/tools/mkv310_image.c b/board/samsung/origen/tools/mkorigenspl.c
similarity index 100%
rename from board/samsung/origen/tools/mkv310_image.c
rename to board/samsung/origen/tools/mkorigenspl.c
diff --git a/board/samsung/smdkv310/Makefile b/board/samsung/smdkv310/Makefile
index dbc621b..9e37b4e 100644
--- a/board/samsung/smdkv310/Makefile
+++ b/board/samsung/smdkv310/Makefile
@@ -4,16 +4,9 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-ifndef CONFIG_SPL_BUILD
-obj-y	+= smdkv310.o
-endif
-
 ifdef CONFIG_SPL_BUILD
-all: $(OBJTREE)/tools/mk$(BOARD)spl
-endif
-
-# Fix ME after we implement hostprogs-y.
-ifdef CONFIG_SPL_BUILD
-$(OBJTREE)/tools/mk$(BOARD)spl:	tools/mkv310_image.c
-	$(HOSTCC) tools/mkv310_image.c -o $(OBJTREE)/tools/mk$(BOARD)spl
+hostprogs-y := tools/mksmdkv310spl
+always := $(hostprogs-y)
+else
+obj-y	+= smdkv310.o
 endif
diff --git a/board/samsung/smdkv310/tools/mkv310_image.c b/board/samsung/smdkv310/tools/mksmdkv310spl.c
similarity index 100%
rename from board/samsung/smdkv310/tools/mkv310_image.c
rename to board/samsung/smdkv310/tools/mksmdkv310spl.c
diff --git a/spl/Makefile b/spl/Makefile
index d5164e0..e76b2b4 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -164,8 +164,8 @@ else
 VAR_SIZE_PARAM =
 endif
 $(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
-	$(if $(wildcard $(OBJTREE)/tools/mk$(BOARD)spl),\
-	$(OBJTREE)/tools/mk$(BOARD)spl,\
+	$(if $(wildcard $(OBJTREE)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\
+	$(OBJTREE)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\
 	$(OBJTREE)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
 endif
 
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 05/38] examples: Use scripts/Makefile.build
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (3 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 04/38] board: samsung: refactor host programs Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 06/38] nand-spl: " Masahiro Yamada
                   ` (35 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile                     |  5 +----
 examples/api/Makefile        | 21 +++++---------------
 examples/standalone/Makefile | 46 ++++++++++++++------------------------------
 scripts/Makefile.build       |  7 ++++---
 4 files changed, 24 insertions(+), 55 deletions(-)

diff --git a/Makefile b/Makefile
index 8c585b6..b10d3b1 100644
--- a/Makefile
+++ b/Makefile
@@ -558,12 +558,9 @@ $(OBJS):
 $(LIBS):	depend $(SUBDIR_TOOLS)
 		$(MAKE) $(build) $(dir $(subst $(obj),,$@))
 
-tools:	depend
+$(SUBDIRS):	depend
 		$(MAKE) $(build) $@ all
 
-$(filter-out tools,$(SUBDIRS)):	depend
-		$(MAKE) -C $@ all
-
 $(SUBDIR_EXAMPLES-y): $(obj)u-boot
 
 $(obj)u-boot.lds: $(LDSCRIPT) depend
diff --git a/examples/api/Makefile b/examples/api/Makefile
index cad10a3..f770859 100644
--- a/examples/api/Makefile
+++ b/examples/api/Makefile
@@ -11,10 +11,8 @@ ifeq ($(ARCH),arm)
 LOAD_ADDR = 0x1000000
 endif
 
-include $(TOPDIR)/config.mk
-
 # Resulting ELF and binary exectuables will be named demo and demo.bin
-OUTPUT = $(obj)demo
+extra-y = demo
 
 # Source files located in the examples/api directory
 SOBJ_FILES-y += crt0.o
@@ -43,13 +41,13 @@ OBJS	+= $(addprefix $(obj),$(COBJ_FILES-y))
 OBJS	+= $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
 OBJS	+= $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
 
-all:	$(obj).depend $(OUTPUT)
-
 #########################################################################
 
-$(OUTPUT):	$(OBJS)
+$(obj)demo:	$(OBJS)
 		$(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
-		$(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
+
+$(obj)demo.bin: $(obj)demo
+		$(OBJCOPY) -O binary $< $@ 2>/dev/null
 
 # Rule to build generic library C files
 $(obj)%.o: $(SRCTREE)/lib/%.c
@@ -58,12 +56,3 @@ $(obj)%.o: $(SRCTREE)/lib/%.c
 # Rule to build architecture-specific library assembly files
 $(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
 	$(CC) -g $(CFLAGS) -c -o $@ $<
-
-#########################################################################
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index 0841c75..cad4409 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -5,27 +5,25 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
-
-ELF-y        := hello_world
-
-ELF-$(CONFIG_SMC91111)           += smc91111_eeprom
-ELF-$(CONFIG_SMC911X)            += smc911x_eeprom
-ELF-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
-ELF-$(CONFIG_MPC5xxx)            += interrupt
-ELF-$(CONFIG_8xx)                += test_burst timer
-ELF-$(CONFIG_8260)               += mem_to_mem_idma2intr
-ELF-$(CONFIG_PPC)                += sched
+extra-y        := hello_world
+extra-$(CONFIG_SMC91111)           += smc91111_eeprom
+extra-$(CONFIG_SMC911X)            += smc911x_eeprom
+extra-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
+extra-$(CONFIG_MPC5xxx)            += interrupt
+extra-$(CONFIG_8xx)                += test_burst timer
+extra-$(CONFIG_8260)               += mem_to_mem_idma2intr
+extra-$(CONFIG_PPC)                += sched
 
 #
 # Some versions of make do not handle trailing white spaces properly;
 # leading to build failures. The problem was found with GNU Make 3.80.
 # Using 'strip' as a workaround for the problem.
 #
-ELF := $(strip $(ELF-y))
+ELF := $(strip $(extra-y))
+
+extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
+clean-files  := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-))
 
-SREC := $(addsuffix .srec,$(ELF))
-BIN  := $(addsuffix .bin,$(ELF))
 
 COBJS	:= $(ELF:=.o)
 
@@ -42,8 +40,6 @@ LIBOBJS	= $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
 SRCS	:= $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
 OBJS	:= $(addprefix $(obj),$(COBJS))
 ELF	:= $(addprefix $(obj),$(ELF))
-BIN	:= $(addprefix $(obj),$(BIN))
-SREC	:= $(addprefix $(obj),$(SREC))
 
 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
 
@@ -60,13 +56,10 @@ endif
 # We don't want gcc reordering functions if possible.  This ensures that an
 # application's entry point will be the first function in the application's
 # source file.
-CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder)
-CFLAGS += $(CFLAGS_NTR)
-
-all:	$(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
+CFLAGS += $(call cc-option,-fno-toplevel-reorder)
 
 #########################################################################
-$(LIB):	$(obj).depend $(LIBOBJS)
+$(LIB):	$(LIBOBJS)
 	$(call cmd_link_o_target, $(LIBOBJS))
 
 $(ELF):
@@ -75,19 +68,8 @@ $(obj)%:	$(obj)%.o $(LIB)
 			-o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
 			-L$(gcclibdir) -lgcc
 
-$(SREC):
 $(obj)%.srec:	$(obj)%
 		$(OBJCOPY) -O srec $< $@ 2>/dev/null
 
-$(BIN):
 $(obj)%.bin:	$(obj)%
 		$(OBJCOPY) -O binary $< $@ 2>/dev/null
-
-#########################################################################
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index c451fbf..50c0394 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -4,7 +4,8 @@ all:
 
 include $(TOPDIR)/config.mk
 
-LIB := $(obj)built-in.o
+# variable LIB is used in examples/standalone/Makefile
+__LIB := $(obj)built-in.o
 LIBGCC = $(obj)libgcc.o
 SRCS :=
 subdir-y :=
@@ -42,9 +43,9 @@ _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
 
 LGOBJS := $(addprefix $(obj),$(sort $(lib-y)))
 
-all: $(LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
+all: $(__LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
 
-$(LIB):	$(obj).depend $(OBJS)
+$(__LIB):	$(obj).depend $(OBJS)
 	$(call cmd_link_o_target, $(OBJS))
 
 ifneq ($(strip $(lib-y)),)
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 06/38] nand-spl: Use scripts/Makefile.build
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (4 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 05/38] examples: Use scripts/Makefile.build Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 07/38] Makfile: move suffix rules to Makefile.build Masahiro Yamada
                   ` (34 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile                                      |  2 +-
 nand_spl/board/amcc/acadia/Makefile           |  8 --------
 nand_spl/board/amcc/bamboo/Makefile           |  8 --------
 nand_spl/board/amcc/canyonlands/Makefile      |  8 --------
 nand_spl/board/amcc/kilauea/Makefile          |  8 --------
 nand_spl/board/amcc/sequoia/Makefile          |  8 --------
 nand_spl/board/freescale/mpc8315erdb/Makefile | 10 ----------
 nand_spl/board/freescale/mpc8536ds/Makefile   | 10 ----------
 nand_spl/board/freescale/mpc8569mds/Makefile  | 10 ----------
 nand_spl/board/freescale/mpc8572ds/Makefile   | 10 ----------
 nand_spl/board/freescale/p1023rds/Makefile    | 11 +----------
 nand_spl/board/freescale/p1_p2_rdb/Makefile   | 10 ----------
 nand_spl/board/sheldon/simpc8313/Makefile     | 11 -----------
 13 files changed, 2 insertions(+), 112 deletions(-)

diff --git a/Makefile b/Makefile
index b10d3b1..5204ab4 100644
--- a/Makefile
+++ b/Makefile
@@ -567,7 +567,7 @@ $(obj)u-boot.lds: $(LDSCRIPT) depend
 		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 nand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
-		$(MAKE) -C nand_spl/board/$(BOARDDIR) all
+		$(MAKE) $(build) nand_spl/board/$(BOARDDIR) all
 
 $(obj)u-boot-nand.bin:	nand_spl $(obj)u-boot.bin
 		cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
diff --git a/nand_spl/board/amcc/acadia/Makefile b/nand_spl/board/amcc/acadia/Makefile
index 022a205..3b00d49 100644
--- a/nand_spl/board/amcc/acadia/Makefile
+++ b/nand_spl/board/amcc/acadia/Makefile
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
 include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 
 nandobj	:= $(OBJTREE)/nand_spl/
@@ -94,10 +93,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/amcc/bamboo/Makefile b/nand_spl/board/amcc/bamboo/Makefile
index d413a48..4063274 100644
--- a/nand_spl/board/amcc/bamboo/Makefile
+++ b/nand_spl/board/amcc/bamboo/Makefile
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
 include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 
 nandobj	:= $(OBJTREE)/nand_spl/
@@ -82,10 +81,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/amcc/canyonlands/Makefile b/nand_spl/board/amcc/canyonlands/Makefile
index b2ef03f..13c8b36 100644
--- a/nand_spl/board/amcc/canyonlands/Makefile
+++ b/nand_spl/board/amcc/canyonlands/Makefile
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
 include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 
 nandobj	:= $(OBJTREE)/nand_spl/
@@ -87,10 +86,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/amcc/kilauea/Makefile b/nand_spl/board/amcc/kilauea/Makefile
index 5899b9e..9d07147 100644
--- a/nand_spl/board/amcc/kilauea/Makefile
+++ b/nand_spl/board/amcc/kilauea/Makefile
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
 include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 
 nandobj	:= $(OBJTREE)/nand_spl/
@@ -83,10 +82,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/amcc/sequoia/Makefile b/nand_spl/board/amcc/sequoia/Makefile
index fea6c4e..111bb0d 100644
--- a/nand_spl/board/amcc/sequoia/Makefile
+++ b/nand_spl/board/amcc/sequoia/Makefile
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-include $(TOPDIR)/config.mk
 include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk
 
 nandobj	:= $(OBJTREE)/nand_spl/
@@ -86,10 +85,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/freescale/mpc8315erdb/Makefile b/nand_spl/board/freescale/mpc8315erdb/Makefile
index c49a6e0..7813823 100644
--- a/nand_spl/board/freescale/mpc8315erdb/Makefile
+++ b/nand_spl/board/freescale/mpc8315erdb/Makefile
@@ -6,11 +6,8 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-NAND_SPL := y
 PAD_TO := 0xfff04000
 
-include $(TOPDIR)/config.mk
-
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
@@ -79,10 +76,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/freescale/mpc8536ds/Makefile b/nand_spl/board/freescale/mpc8536ds/Makefile
index 6233081..5d9953b 100644
--- a/nand_spl/board/freescale/mpc8536ds/Makefile
+++ b/nand_spl/board/freescale/mpc8536ds/Makefile
@@ -7,12 +7,9 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-NAND_SPL := y
 CONFIG_SYS_TEXT_BASE_SPL := 0xfff00000
 PAD_TO := 0xfff01000
 
-include $(TOPDIR)/config.mk
-
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
@@ -109,10 +106,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/freescale/mpc8569mds/Makefile b/nand_spl/board/freescale/mpc8569mds/Makefile
index 6233081..5d9953b 100644
--- a/nand_spl/board/freescale/mpc8569mds/Makefile
+++ b/nand_spl/board/freescale/mpc8569mds/Makefile
@@ -7,12 +7,9 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-NAND_SPL := y
 CONFIG_SYS_TEXT_BASE_SPL := 0xfff00000
 PAD_TO := 0xfff01000
 
-include $(TOPDIR)/config.mk
-
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
@@ -109,10 +106,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/freescale/mpc8572ds/Makefile b/nand_spl/board/freescale/mpc8572ds/Makefile
index 6233081..5d9953b 100644
--- a/nand_spl/board/freescale/mpc8572ds/Makefile
+++ b/nand_spl/board/freescale/mpc8572ds/Makefile
@@ -7,12 +7,9 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-NAND_SPL := y
 CONFIG_SYS_TEXT_BASE_SPL := 0xfff00000
 PAD_TO := 0xfff01000
 
-include $(TOPDIR)/config.mk
-
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
@@ -109,10 +106,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/freescale/p1023rds/Makefile b/nand_spl/board/freescale/p1023rds/Makefile
index dbdfa19..652590d 100644
--- a/nand_spl/board/freescale/p1023rds/Makefile
+++ b/nand_spl/board/freescale/p1023rds/Makefile
@@ -3,10 +3,8 @@
 #
 # SPDX-License-Identifier:	GPL-2.0+
 #
-NAND_SPL := y
-PAD_TO := 0xfff01000
 
-include $(TOPDIR)/config.mk
+PAD_TO := 0xfff01000
 
 nandobj	:= $(OBJTREE)/nand_spl/
 
@@ -104,10 +102,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/freescale/p1_p2_rdb/Makefile b/nand_spl/board/freescale/p1_p2_rdb/Makefile
index 6233081..5d9953b 100644
--- a/nand_spl/board/freescale/p1_p2_rdb/Makefile
+++ b/nand_spl/board/freescale/p1_p2_rdb/Makefile
@@ -7,12 +7,9 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-NAND_SPL := y
 CONFIG_SYS_TEXT_BASE_SPL := 0xfff00000
 PAD_TO := 0xfff01000
 
-include $(TOPDIR)/config.mk
-
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
@@ -109,10 +106,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/nand_spl/board/sheldon/simpc8313/Makefile b/nand_spl/board/sheldon/simpc8313/Makefile
index 90f132c..5e83abc 100644
--- a/nand_spl/board/sheldon/simpc8313/Makefile
+++ b/nand_spl/board/sheldon/simpc8313/Makefile
@@ -7,10 +7,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-NAND_SPL := y
-
-include $(TOPDIR)/config.mk
-
 nandobj	:= $(OBJTREE)/nand_spl/
 
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
@@ -88,10 +84,3 @@ $(obj)%.o:	$(obj)%.S
 
 $(obj)%.o:	$(obj)%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 07/38] Makfile: move suffix rules to Makefile.build
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (5 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 06/38] nand-spl: " Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 08/38] Makefile: move some variable definitions to the top Makefile Masahiro Yamada
                   ` (33 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit moves suffix rules from config.mk
to scripts/Makefile.build, which will allow us
to switch smoothly to real Kbuild.

Note1:
post/lib_powerpc/fpu/Makefile has
its own rule to compile C sources.
We need to tweak it to keep the same behavior.

Note2:
There are two file2 with the same name:
arch/arm/lib/crt0.S and eamples/api/crt0.S.
To keep the same build behavior,
examples/api/Makefile also has to be treaked.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 config.mk                     | 35 -----------------------------------
 examples/api/Makefile         |  4 ++--
 post/lib_powerpc/fpu/Makefile |  2 +-
 scripts/Makefile.build        | 31 +++++++++++++++++++++++++++++++
 4 files changed, 34 insertions(+), 38 deletions(-)

diff --git a/config.mk b/config.mk
index 07afb35..b08be7a 100644
--- a/config.mk
+++ b/config.mk
@@ -318,38 +318,3 @@ endif
 export	HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE \
 	AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
 export	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
-
-#########################################################################
-
-# Allow boards to use custom optimize flags on a per dir/file basis
-ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
-ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
-EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR))
-ALL_CFLAGS += $(EXTRA_CPPFLAGS)
-
-# The _DEP version uses the $< file target (for dependency generation)
-# See rules.mk
-EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \
-		$(CPPFLAGS_$(BCURDIR))
-$(obj)%.s:	%.S
-	$(CPP) $(ALL_AFLAGS) -o $@ $<
-$(obj)%.o:	%.S
-	$(CC)  $(ALL_AFLAGS) -o $@ $< -c
-$(obj)%.o:	%.c
-ifneq ($(CHECKSRC),0)
-	$(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $<
-endif
-	$(CC)  $(ALL_CFLAGS) -o $@ $< -c
-$(obj)%.i:	%.c
-	$(CPP) $(ALL_CFLAGS) -o $@ $< -c
-$(obj)%.s:	%.c
-	$(CC)  $(ALL_CFLAGS) -o $@ $< -c -S
-
-#########################################################################
-
-# If the list of objects to link is empty, just create an empty built-in.o
-cmd_link_o_target = $(if $(strip $1),\
-		      $(LD) $(LDFLAGS) -r -o $@ $1,\
-		      rm -f $@; $(AR) rcs $@ )
-
-#########################################################################
diff --git a/examples/api/Makefile b/examples/api/Makefile
index f770859..52f4368 100644
--- a/examples/api/Makefile
+++ b/examples/api/Makefile
@@ -50,9 +50,9 @@ $(obj)demo.bin: $(obj)demo
 		$(OBJCOPY) -O binary $< $@ 2>/dev/null
 
 # Rule to build generic library C files
-$(obj)%.o: $(SRCTREE)/lib/%.c
+$(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y))): $(obj)%.o: $(SRCTREE)/lib/%.c
 	$(CC) -g $(CFLAGS) -c -o $@ $<
 
 # Rule to build architecture-specific library assembly files
-$(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
+$(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y))): $(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
 	$(CC) -g $(CFLAGS) -c -o $@ $<
diff --git a/post/lib_powerpc/fpu/Makefile b/post/lib_powerpc/fpu/Makefile
index ae56a82..a7aa5bc 100644
--- a/post/lib_powerpc/fpu/Makefile
+++ b/post/lib_powerpc/fpu/Makefile
@@ -18,7 +18,7 @@ obj-y	+= darwin-ldouble.o
 CFLAGS := $(shell echo $(CFLAGS) | sed s/-msoft-float//)
 CFLAGS += -mhard-float -fkeep-inline-functions
 
-$(obj)%.o:	%.c
+$(addprefix $(obj),$(obj-y)): $(obj)%.o:	%.c
 	$(CC)  $(ALL_CFLAGS) -o $@.fp $< -c
 	$(OBJCOPY) -R .gnu.attributes $@.fp $@
 	rm -f $@.fp
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 50c0394..1b3d77f 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -67,6 +67,37 @@ endif
 
 #########################################################################
 
+# Allow boards to use custom optimize flags on a per dir/file basis
+ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
+ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
+EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR))
+ALL_CFLAGS += $(EXTRA_CPPFLAGS)
+
+# The _DEP version uses the $< file target (for dependency generation)
+# See rules.mk
+EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \
+		$(CPPFLAGS_$(BCURDIR))
+$(obj)%.s:	%.S
+	$(CPP) $(ALL_AFLAGS) -o $@ $<
+$(obj)%.o:	%.S
+	$(CC)  $(ALL_AFLAGS) -o $@ $< -c
+$(obj)%.o:	%.c
+ifneq ($(CHECKSRC),0)
+	$(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $<
+endif
+	$(CC)  $(ALL_CFLAGS) -o $@ $< -c
+$(obj)%.i:	%.c
+	$(CPP) $(ALL_CFLAGS) -o $@ $< -c
+$(obj)%.s:	%.c
+	$(CC)  $(ALL_CFLAGS) -o $@ $< -c -S
+
+# If the list of objects to link is empty, just create an empty built-in.o
+cmd_link_o_target = $(if $(strip $1),\
+		      $(LD) $(LDFLAGS) -r -o $@ $1,\
+		      rm -f $@; $(AR) rcs $@ )
+
+#########################################################################
+
 # defines $(obj).depend target
 
 include $(TOPDIR)/rules.mk
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 08/38] Makefile: move some variable definitions to the top Makefile
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (6 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 07/38] Makfile: move suffix rules to Makefile.build Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 09/38] Makefile: move BFD_ROOT_DIR to tools/gdb/Makefile Masahiro Yamada
                   ` (32 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit moves some variable definitions from config.mk
to the top Makefile:

  - HOSTCC, HOSTCFLAGS, HOSTLDFLAGS
  - AS, LD, CC, CPP, etc.
  - SHELL (renamed to CONFIG_SHELL)

I'd like to slim down config.mk file
because it is included from all recursive make.
It is redundant to re-define the variables
every time descending into sub directories.
We should rather define them at the top Makefile
and export them.

U-Boot makefiles has been used "SHELL" variable to store shell
chosen for the user, whereas Linux Kernel uses "CONFIG_SHELL".

We should never use "SHELL" variable because it is
a special variable for GNU Make.
Changing SHELL may cause unpredictable side effects
whose root cause is usually difficult to find.
We should use a generic variable name "CONFIG_SHELL".

We should not use the syntax as follows either:

    rm -f $(obj)tools/env/{fw_printenv,fw_setenv}

This depends on "bash" although GNU Make generally
invokes "sh" to run the each rule.

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

O'REILLY GNU Make says like follows about SHELL variable:

By default, /bin/sh is used for the shell.
This shell is controlled by the make variable SHELL
but it is not inherited from the environment.
When make starts, it imports all the variables
from the user?s environment as make variables, except SHELL.
This is because the user?s choice of shell should not cause a
makefile (possibly included in some downloaded software package) to fail.
If a user really wants to change the default shell used by make,
he can set the SHELL variable explicitly in the makefile.

Please refer to the first page of the following PDF file:
http://oreilly.com/catalog/make3/book/ch05.pdf


Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
  - Do not use bash-dependent clean rules:
     For example,
         rm -f $(obj)tools/env/{fw_printenv,fw_setenv}
       should be converted to
         rm -f $(addprefix $(obj)tools/env/, fw_printenv fw_setenv)
  - Add more comments in commit log
  - Rebase on v2014.01-rc2 tag

 Makefile  | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
 config.mk | 78 ++--------------------------------------------------
 2 files changed, 84 insertions(+), 88 deletions(-)

diff --git a/Makefile b/Makefile
index 5204ab4..0c1eef3 100644
--- a/Makefile
+++ b/Makefile
@@ -161,6 +161,73 @@ ifeq ($(HOSTARCH),$(ARCH))
 CROSS_COMPILE ?=
 endif
 
+# SHELL used by kbuild
+CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
+	  else if [ -x /bin/bash ]; then echo /bin/bash; \
+	  else echo sh; fi ; fi)
+
+HOSTCC       = gcc
+HOSTCFLAGS   = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
+
+ifeq ($(HOSTOS),cygwin)
+HOSTCFLAGS	+= -ansi
+endif
+
+# Mac OS X / Darwin's C preprocessor is Apple specific.  It
+# generates numerous errors and warnings.  We want to bypass it
+# and use GNU C's cpp.	To do this we pass the -traditional-cpp
+# option to the compiler.  Note that the -traditional-cpp flag
+# DOES NOT have the same semantics as GNU C's flag, all it does
+# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
+#
+# Apple's linker is similar, thanks to the new 2 stage linking
+# multiple symbol definitions are treated as errors, hence the
+# -multiply_defined suppress option to turn off this error.
+#
+ifeq ($(HOSTOS),darwin)
+# get major and minor product version (e.g. '10' and '6' for Snow Leopard)
+DARWIN_MAJOR_VERSION	= $(shell sw_vers -productVersion | cut -f 1 -d '.')
+DARWIN_MINOR_VERSION	= $(shell sw_vers -productVersion | cut -f 2 -d '.')
+
+os_x_before	= $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
+	$(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
+
+# Snow Leopards build environment has no longer restrictions as described above
+HOSTCC       = $(call os_x_before, 10, 5, "cc", "gcc")
+HOSTCFLAGS  += $(call os_x_before, 10, 4, "-traditional-cpp")
+HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
+endif
+
+# Make variables (CC, etc...)
+
+AS		= $(CROSS_COMPILE)as
+# Always use GNU ld
+ifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),)
+LD		= $(CROSS_COMPILE)ld.bfd
+else
+LD		= $(CROSS_COMPILE)ld
+endif
+CC		= $(CROSS_COMPILE)gcc
+CPP		= $(CC) -E
+AR		= $(CROSS_COMPILE)ar
+NM		= $(CROSS_COMPILE)nm
+LDR		= $(CROSS_COMPILE)ldr
+STRIP		= $(CROSS_COMPILE)strip
+OBJCOPY		= $(CROSS_COMPILE)objcopy
+OBJDUMP		= $(CROSS_COMPILE)objdump
+AWK		= awk
+RANLIB		= $(CROSS_COMPILE)RANLIB
+DTC		= dtc
+CHECK		= sparse
+
+CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
+		  -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
+
+export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
+export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
+export MAKE AWK
+export DTC CHECK CHECKFLAGS
+
 # load other configuration
 include $(TOPDIR)/config.mk
 
@@ -788,27 +855,28 @@ clean:
 	       $(obj)examples/standalone/interrupt			  \
 	       $(obj)examples/standalone/mem_to_mem_idma2intr		  \
 	       $(obj)examples/standalone/sched				  \
-	       $(obj)examples/standalone/smc911{11,x}_eeprom		  \
+	       $(addprefix $(obj)examples/standalone/, smc91111_eeprom smc911x_eeprom) \
 	       $(obj)examples/standalone/test_burst			  \
 	       $(obj)examples/standalone/timer
-	@rm -f $(obj)examples/api/demo{,.bin}
+	@rm -f $(addprefix $(obj)examples/api/, demo demo.bin)
 	@rm -f $(obj)tools/bmp_logo	   $(obj)tools/easylogo/easylogo  \
 	       $(obj)tools/env/fw_printenv				  \
 	       $(obj)tools/envcrc					  \
-	       $(obj)tools/gdb/{gdbcont,gdbsend}			  \
+	       $(addprefix $(obj)tools/gdb/, gdbcont gdbsend)		  \
 	       $(obj)tools/gen_eth_addr    $(obj)tools/img2srec		  \
-	       $(obj)tools/dump{env,}image		  \
-	       $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk	  \
-	       $(obj)tools/mk{$(BOARD),exynos}spl			  \
+	       $(obj)tools/dumpimage					  \
+	       $(addprefix $(obj)tools/, mkenvimage mkimage)		  \
+	       $(obj)tools/mpc86x_clk					  \
+	       $(addprefix $(obj)tools/, mk$(BOARD)spl mkexynosspl)	  \
 	       $(obj)tools/mxsboot					  \
 	       $(obj)tools/ncb		   $(obj)tools/ubsha1		  \
 	       $(obj)tools/kernel-doc/docproc				  \
 	       $(obj)tools/proftool
-	@rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image}	  \
+	@rm -f $(addprefix $(obj)board/cray/L1/, bootscript.c bootscript.image) \
 	       $(obj)board/matrix_vision/*/bootscript.img		  \
 	       $(obj)spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl	  \
 	       $(obj)u-boot.lds						  \
-	       $(obj)arch/blackfin/cpu/init.{lds,elf}
+	       $(addprefix $(obj)arch/blackfin/cpu/, init.lds init.elf)
 	@rm -f $(obj)include/bmp_logo.h
 	@rm -f $(obj)include/bmp_logo_data.h
 	@rm -f $(obj)lib/asm-offsets.s
@@ -843,11 +911,11 @@ clobber:	tidy
 	@rm -f $(obj)u-boot.dtb
 	@rm -f $(obj)u-boot.sb
 	@rm -f $(obj)u-boot.spr
-	@rm -f $(obj)nand_spl/{u-boot.{lds,lst},System.map}
-	@rm -f $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map}
-	@rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.map}
+	@rm -f $(addprefix $(obj)nand_spl/, u-boot.lds u-boot.lst System.map)
+	@rm -f $(addprefix $(obj)nand_spl/, u-boot-nand_spl.lds u-boot-spl u-boot-spl.map)
+	@rm -f $(addprefix $(obj)spl/, u-boot-spl u-boot-spl.bin u-boot-spl.map)
 	@rm -f $(obj)spl/u-boot-spl.lds
-	@rm -f $(obj)tpl/{u-boot-tpl,u-boot-tpl.bin,u-boot-tpl.map}
+	@rm -f $(addprefix $(obj)tpl/, u-boot-tpl u-boot-tpl.bin u-boot-tpl.map)
 	@rm -f $(obj)tpl/u-boot-spl.lds
 	@rm -f $(obj)MLO MLO.byteswap
 	@rm -f $(obj)SPL
@@ -856,7 +924,7 @@ clobber:	tidy
 	@rm -fr $(obj)include/generated
 	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
 	@rm -f $(obj)dts/*.tmp
-	@rm -f $(obj)spl/u-boot-spl{,-pad}.ais
+	@rm -f $(addprefix $(obj)spl/, u-boot-spl.ais, u-boot-spl-pad.ais)
 
 mrproper \
 distclean:	clobber unconfig
diff --git a/config.mk b/config.mk
index b08be7a..74617d3 100644
--- a/config.mk
+++ b/config.mk
@@ -6,13 +6,6 @@
 #
 #########################################################################
 
-# Set shell to bash if possible, otherwise fall back to sh
-SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
-	else if [ -x /bin/bash ]; then echo /bin/bash; \
-	else echo sh; fi; fi)
-
-export	SHELL
-
 ifeq ($(CURDIR),$(SRCTREE))
 dir :=
 else
@@ -55,44 +48,6 @@ PLATFORM_CPPFLAGS =
 PLATFORM_LDFLAGS =
 
 #########################################################################
-
-HOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
-		  $(HOSTCPPFLAGS)
-
-#
-# Mac OS X / Darwin's C preprocessor is Apple specific.  It
-# generates numerous errors and warnings.  We want to bypass it
-# and use GNU C's cpp.	To do this we pass the -traditional-cpp
-# option to the compiler.  Note that the -traditional-cpp flag
-# DOES NOT have the same semantics as GNU C's flag, all it does
-# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
-#
-# Apple's linker is similar, thanks to the new 2 stage linking
-# multiple symbol definitions are treated as errors, hence the
-# -multiply_defined suppress option to turn off this error.
-#
-
-ifeq ($(HOSTOS),darwin)
-# get major and minor product version (e.g. '10' and '6' for Snow Leopard)
-DARWIN_MAJOR_VERSION	= $(shell sw_vers -productVersion | cut -f 1 -d '.')
-DARWIN_MINOR_VERSION	= $(shell sw_vers -productVersion | cut -f 2 -d '.')
-
-os_x_before	= $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
-	$(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
-
-# Snow Leopards build environment has no longer restrictions as described above
-HOSTCC		 = $(call os_x_before, 10, 5, "cc", "gcc")
-HOSTCFLAGS	+= $(call os_x_before, 10, 4, "-traditional-cpp")
-HOSTLDFLAGS	+= $(call os_x_before, 10, 5, "-multiply_defined suppress")
-else
-HOSTCC		= gcc
-endif
-
-ifeq ($(HOSTOS),cygwin)
-HOSTCFLAGS	+= -ansi
-endif
-
-#########################################################################
 #
 # Option checker, gcc version (courtesy linux kernel) to ensure
 # only supported compiler options are used
@@ -117,30 +72,9 @@ endif
 
 # cc-version
 # Usage gcc-ver := $(call cc-version)
-cc-version = $(shell $(SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC))
-binutils-version = $(shell $(SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS))
-dtc-version = $(shell $(SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC))
-
-#
-# Include the make variables (CC, etc...)
-#
-AS	= $(CROSS_COMPILE)as
-
-# Always use GNU ld
-LD	= $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \
-		then echo "$(CROSS_COMPILE)ld.bfd"; else echo "$(CROSS_COMPILE)ld"; fi;)
-
-CC	= $(CROSS_COMPILE)gcc
-CPP	= $(CC) -E
-AR	= $(CROSS_COMPILE)ar
-NM	= $(CROSS_COMPILE)nm
-LDR	= $(CROSS_COMPILE)ldr
-STRIP	= $(CROSS_COMPILE)strip
-OBJCOPY = $(CROSS_COMPILE)objcopy
-OBJDUMP = $(CROSS_COMPILE)objdump
-RANLIB	= $(CROSS_COMPILE)RANLIB
-DTC	= dtc
-CHECK	= sparse
+cc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC))
+binutils-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS))
+dtc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC))
 
 #########################################################################
 
@@ -286,10 +220,6 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),)
 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
 endif
 
-# Linus' kernel sanity checking tool
-CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
-		  -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
-
 # Location of a usable BFD library, where we define "usable" as
 # "built for ${HOST}, supports ${TARGET}".  Sensible values are
 # - When cross-compiling: the root of the cross-environment
@@ -315,6 +245,4 @@ endif
 
 #########################################################################
 
-export	HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE \
-	AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
 export	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 09/38] Makefile: move BFD_ROOT_DIR to tools/gdb/Makefile
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (7 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 08/38] Makefile: move some variable definitions to the top Makefile Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 10/38] kbuild: import Kbuild.include from linux v3.13 tag Masahiro Yamada
                   ` (31 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

BFD_ROOT_DIR is used only in tools/gdb/Makefile

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 config.mk          | 23 -----------------------
 tools/gdb/Makefile | 21 +++++++++++++++++++++
 2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/config.mk b/config.mk
index 74617d3..dfe81fa 100644
--- a/config.mk
+++ b/config.mk
@@ -220,29 +220,6 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),)
 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
 endif
 
-# Location of a usable BFD library, where we define "usable" as
-# "built for ${HOST}, supports ${TARGET}".  Sensible values are
-# - When cross-compiling: the root of the cross-environment
-# - Linux/ppc (native): /usr
-# - NetBSD/ppc (native): you lose ... (must extract these from the
-#   binutils build directory, plus the native and U-Boot include
-#   files don't like each other)
-#
-# So far, this is used only by tools/gdb/Makefile.
-
-ifeq ($(HOSTOS),darwin)
-BFD_ROOT_DIR =		/usr/local/tools
-else
-ifeq ($(HOSTARCH),$(ARCH))
-# native
-BFD_ROOT_DIR =		/usr
-else
-#BFD_ROOT_DIR =		/LinuxPPC/CDK		# Linux/i386
-#BFD_ROOT_DIR =		/usr/pkg/cross		# NetBSD/i386
-BFD_ROOT_DIR =		/opt/powerpc
-endif
-endif
-
 #########################################################################
 
 export	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
diff --git a/tools/gdb/Makefile b/tools/gdb/Makefile
index 850bb9b..4513320 100644
--- a/tools/gdb/Makefile
+++ b/tools/gdb/Makefile
@@ -10,6 +10,27 @@
 
 ifneq ($(HOSTOS),cygwin)
 
+# Location of a usable BFD library, where we define "usable" as
+# "built for ${HOST}, supports ${TARGET}".  Sensible values are
+# - When cross-compiling: the root of the cross-environment
+# - Linux/ppc (native): /usr
+# - NetBSD/ppc (native): you lose ... (must extract these from the
+#   binutils build directory, plus the native and U-Boot include
+#   files don't like each other)
+
+ifeq ($(HOSTOS),darwin)
+BFD_ROOT_DIR =		/usr/local/tools
+else
+ifeq ($(HOSTARCH),$(ARCH))
+# native
+BFD_ROOT_DIR =		/usr
+else
+#BFD_ROOT_DIR =		/LinuxPPC/CDK		# Linux/i386
+#BFD_ROOT_DIR =		/usr/pkg/cross		# NetBSD/i386
+BFD_ROOT_DIR =		/opt/powerpc
+endif
+endif
+
 #
 # Use native tools and options
 #
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 10/38] kbuild: import Kbuild.include from linux v3.13 tag
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (8 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 09/38] Makefile: move BFD_ROOT_DIR to tools/gdb/Makefile Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 11/38] kbuild: Use Kbuild.include Masahiro Yamada
                   ` (30 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

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

Changes in v8: None
Changes in v7: None
Changes in v6:
  - Import from linux v3.13

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 scripts/Kbuild.include | 278 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 278 insertions(+)
 create mode 100644 scripts/Kbuild.include

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
new file mode 100644
index 0000000..547e15d
--- /dev/null
+++ b/scripts/Kbuild.include
@@ -0,0 +1,278 @@
+####
+# kbuild: Generic definitions
+
+# Convenient variables
+comma   := ,
+squote  := '
+empty   :=
+space   := $(empty) $(empty)
+
+###
+# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
+dot-target = $(dir $@).$(notdir $@)
+
+###
+# The temporary file to save gcc -MD generated dependencies must not
+# contain a comma
+depfile = $(subst $(comma),_,$(dot-target).d)
+
+###
+# filename of target with directory and extension stripped
+basetarget = $(basename $(notdir $@))
+
+###
+# filename of first prerequisite with directory and extension stripped
+baseprereq = $(basename $(notdir $<))
+
+###
+# Escape single quote for use in echo statements
+escsq = $(subst $(squote),'\$(squote)',$1)
+
+###
+# Easy method for doing a status message
+       kecho := :
+ quiet_kecho := echo
+silent_kecho := :
+kecho := $($(quiet)kecho)
+
+###
+# filechk is used to check if the content of a generated file is updated.
+# Sample usage:
+# define filechk_sample
+#	echo $KERNELRELEASE
+# endef
+# version.h : Makefile
+#	$(call filechk,sample)
+# The rule defined shall write to stdout the content of the new file.
+# The existing file will be compared with the new one.
+# - If no file exist it is created
+# - If the content differ the new file is used
+# - If they are equal no change, and no timestamp update
+# - stdin is piped in from the first prerequisite ($<) so one has
+#   to specify a valid file as first prerequisite (often the kbuild file)
+define filechk
+	$(Q)set -e;				\
+	$(kecho) '  CHK     $@';		\
+	mkdir -p $(dir $@);			\
+	$(filechk_$(1)) < $< > $@.tmp;		\
+	if [ -r $@ ] && cmp -s $@ $@.tmp; then	\
+		rm -f $@.tmp;			\
+	else					\
+		$(kecho) '  UPD     $@';	\
+		mv -f $@.tmp $@;		\
+	fi
+endef
+
+######
+# gcc support functions
+# See documentation in Documentation/kbuild/makefiles.txt
+
+# cc-cross-prefix
+# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
+# Return first prefix where a prefix$(CC) is found in PATH.
+# If no $(CC) found in PATH with listed prefixes return nothing
+cc-cross-prefix =  \
+	$(word 1, $(foreach c,$(1),                                   \
+		$(shell set -e;                                       \
+		if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \
+			echo $(c);                                    \
+		fi)))
+
+# output directory for tests below
+TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
+
+# try-run
+# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
+# Exit code chooses option. "$$TMP" is can be used as temporary file and
+# is automatically cleaned up.
+try-run = $(shell set -e;		\
+	TMP="$(TMPOUT).$$$$.tmp";	\
+	TMPO="$(TMPOUT).$$$$.o";	\
+	if ($(1)) >/dev/null 2>&1;	\
+	then echo "$(2)";		\
+	else echo "$(3)";		\
+	fi;				\
+	rm -f "$$TMP" "$$TMPO")
+
+# as-option
+# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
+
+as-option = $(call try-run,\
+	$(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
+
+# as-instr
+# Usage: cflags-y += $(call as-instr,instr,option1,option2)
+
+as-instr = $(call try-run,\
+	printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
+
+# cc-option
+# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
+
+cc-option = $(call try-run,\
+	$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
+
+# cc-option-yn
+# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
+cc-option-yn = $(call try-run,\
+	$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
+
+# cc-option-align
+# Prefix align with either -falign or -malign
+cc-option-align = $(subst -functions=0,,\
+	$(call cc-option,-falign-functions=0,-malign-functions=0))
+
+# cc-disable-warning
+# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
+cc-disable-warning = $(call try-run,\
+	$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
+
+# cc-version
+# Usage gcc-ver := $(call cc-version)
+cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
+
+# cc-fullversion
+# Usage gcc-ver := $(call cc-fullversion)
+cc-fullversion = $(shell $(CONFIG_SHELL) \
+	$(srctree)/scripts/gcc-version.sh -p $(CC))
+
+# cc-ifversion
+# Usage:  EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
+cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3))
+
+# cc-ldoption
+# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
+cc-ldoption = $(call try-run,\
+	$(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
+
+# ld-option
+# Usage: LDFLAGS += $(call ld-option, -X)
+ld-option = $(call try-run,\
+	$(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
+
+# ar-option
+# Usage: KBUILD_ARFLAGS := $(call ar-option,D)
+# Important: no spaces around options
+ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
+
+######
+
+###
+# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
+# Usage:
+# $(Q)$(MAKE) $(build)=dir
+build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+
+###
+# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
+# Usage:
+# $(Q)$(MAKE) $(modbuiltin)=dir
+modbuiltin := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.modbuiltin obj
+
+# Prefix -I with $(srctree) if it is not an absolute path.
+# skip if -I has no parameter
+addtree = $(if $(patsubst -I%,%,$(1)), \
+$(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1))
+
+# Find all -I options and call addtree
+flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
+
+# echo command.
+# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
+echo-cmd = $(if $($(quiet)cmd_$(1)),\
+	echo '  $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
+
+# printing commands
+cmd = @$(echo-cmd) $(cmd_$(1))
+
+# Add $(obj)/ for paths that are not absolute
+objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
+
+###
+# if_changed      - execute command if any prerequisite is newer than
+#                   target, or command line has changed
+# if_changed_dep  - as if_changed, but uses fixdep to reveal dependencies
+#                   including used config symbols
+# if_changed_rule - as if_changed but execute rule instead
+# See Documentation/kbuild/makefiles.txt for more info
+
+ifneq ($(KBUILD_NOCMDDEP),1)
+# Check if both arguments has same arguments. Result is empty string if equal.
+# User may override this check using make KBUILD_NOCMDDEP=1
+arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
+                    $(filter-out $(cmd_$@),   $(cmd_$(1))) )
+else
+arg-check = $(if $(strip $(cmd_$@)),,1)
+endif
+
+# >'< substitution is for echo to work,
+# >$< substitution to preserve $ when reloading .cmd file
+# note: when using inline perl scripts [perl -e '...$$t=1;...']
+# in $(cmd_xxx) double $$ your perl vars
+make-cmd = $(subst \\,\\\\,$(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))))
+
+# Find any prerequisites that is newer than target or that does not exist.
+# PHONY targets skipped in both cases.
+any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
+
+# Execute command if command has changed or prerequisite(s) are updated.
+#
+if_changed = $(if $(strip $(any-prereq) $(arg-check)),                       \
+	@set -e;                                                             \
+	$(echo-cmd) $(cmd_$(1));                                             \
+	echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
+
+# Execute the command and also postprocess generated .d dependencies file.
+if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ),                  \
+	@set -e;                                                             \
+	$(echo-cmd) $(cmd_$(1));                                             \
+	scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
+	rm -f $(depfile);                                                    \
+	mv -f $(dot-target).tmp $(dot-target).cmd)
+
+# Usage: $(call if_changed_rule,foo)
+# Will check if $(cmd_foo) or any of the prerequisites changed,
+# and if so will execute $(rule_foo).
+if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ),                 \
+	@set -e;                                                             \
+	$(rule_$(1)))
+
+###
+# why - tell why a a target got build
+#       enabled by make V=2
+#       Output (listed in the order they are checked):
+#          (1) - due to target is PHONY
+#          (2) - due to target missing
+#          (3) - due to: file1.h file2.h
+#          (4) - due to command line change
+#          (5) - due to missing .cmd file
+#          (6) - due to target not in $(targets)
+# (1) PHONY targets are always build
+# (2) No target, so we better build it
+# (3) Prerequisite is newer than target
+# (4) The command line stored in the file named dir/.target.cmd
+#     differed from actual command line. This happens when compiler
+#     options changes
+# (5) No dir/.target.cmd file (used to store command line)
+# (6) No dir/.target.cmd file and target not listed in $(targets)
+#     This is a good hint that there is a bug in the kbuild file
+ifeq ($(KBUILD_VERBOSE),2)
+why =                                                                        \
+    $(if $(filter $@, $(PHONY)),- due to target is PHONY,                    \
+        $(if $(wildcard $@),                                                 \
+            $(if $(strip $(any-prereq)),- due to: $(any-prereq),             \
+                $(if $(arg-check),                                           \
+                    $(if $(cmd_$@),- due to command line change,             \
+                        $(if $(filter $@, $(targets)),                       \
+                            - due to missing .cmd file,                      \
+                            - due to $(notdir $@) not in $$(targets)         \
+                         )                                                   \
+                     )                                                       \
+                 )                                                           \
+             ),                                                              \
+             - due to target missing                                         \
+         )                                                                   \
+     )
+
+echo-why = $(call escsq, $(strip $(why)))
+endif
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 11/38] kbuild: Use Kbuild.include
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (9 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 10/38] kbuild: import Kbuild.include from linux v3.13 tag Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 12/38] Makefile: move more flags to the top Makefile Masahiro Yamada
                   ` (29 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit adjusts some files to use Kbuild.include.

 - Use cc-option defined in Kbuild.include
    (Delete cc-option in config.mk)
 - Use cc-version defined in
    (Delete cc-version in config.mk)
 - Move binutils-version and dtc-version to Kbuild.include
     by analogy to cc-version

This commit also adds srctree (same as SRCTREE)
to use Kbuild scripts.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile               |  9 ++++++---
 config.mk              | 29 -----------------------------
 scripts/Kbuild.include |  8 +++++++-
 scripts/Makefile.build |  1 +
 spl/Makefile           |  4 ++--
 5 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/Makefile b/Makefile
index 0c1eef3..e4045bc 100644
--- a/Makefile
+++ b/Makefile
@@ -102,9 +102,10 @@ OBJTREE		:= $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
 SPLTREE		:= $(OBJTREE)/spl
 TPLTREE		:= $(OBJTREE)/tpl
 SRCTREE		:= $(CURDIR)
+srctree		:= $(SRCTREE)
 TOPDIR		:= $(SRCTREE)
 LNDIR		:= $(OBJTREE)
-export	TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE
+export	TOPDIR SRCTREE srctree OBJTREE SPLTREE TPLTREE
 
 MKCONFIG	:= $(SRCTREE)/mkconfig
 export MKCONFIG
@@ -126,8 +127,6 @@ unexport CDPATH
 
 #########################################################################
 
-build := -f $(TOPDIR)/scripts/Makefile.build -C
-
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
 # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
@@ -198,6 +197,10 @@ HOSTCFLAGS  += $(call os_x_before, 10, 4, "-traditional-cpp")
 HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
 endif
 
+# We need some generic definitions (do not try to remake the file).
+$(srctree)/scripts/Kbuild.include: ;
+include $(srctree)/scripts/Kbuild.include
+
 # Make variables (CC, etc...)
 
 AS		= $(CROSS_COMPILE)as
diff --git a/config.mk b/config.mk
index dfe81fa..ba42641 100644
--- a/config.mk
+++ b/config.mk
@@ -48,35 +48,6 @@ PLATFORM_CPPFLAGS =
 PLATFORM_LDFLAGS =
 
 #########################################################################
-#
-# Option checker, gcc version (courtesy linux kernel) to ensure
-# only supported compiler options are used
-#
-CC_OPTIONS_CACHE_FILE := $(OBJTREE)/include/generated/cc_options.mk
-CC_TEST_OFILE := $(OBJTREE)/include/generated/cc_test_file.o
-
--include $(CC_OPTIONS_CACHE_FILE)
-
-cc-option-sys = $(shell mkdir -p $(dir $(CC_TEST_OFILE)); \
-		if $(CC) $(CFLAGS) $(1) -S -xc /dev/null -o $(CC_TEST_OFILE) \
-		> /dev/null 2>&1; then \
-		echo 'CC_OPTIONS += $(strip $1)' >> $(CC_OPTIONS_CACHE_FILE); \
-		echo "$(1)"; fi)
-
-ifeq ($(CONFIG_CC_OPT_CACHE_DISABLE),y)
-cc-option = $(strip $(if $(call cc-option-sys,$1),$1,$2))
-else
-cc-option = $(strip $(if $(findstring $1,$(CC_OPTIONS)),$1,\
-		$(if $(call cc-option-sys,$1),$1,$2)))
-endif
-
-# cc-version
-# Usage gcc-ver := $(call cc-version)
-cc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC))
-binutils-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS))
-dtc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC))
-
-#########################################################################
 
 # Load generated board configuration
 ifeq ($(CONFIG_TPL_BUILD),y)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 547e15d..ca5fd56 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -140,6 +140,10 @@ cc-fullversion = $(shell $(CONFIG_SHELL) \
 # Usage:  EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
 cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3))
 
+# added for U-Boot
+binutils-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/binutils-version.sh $(AS))
+dtc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/dtc-version.sh $(DTC))
+
 # cc-ldoption
 # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
 cc-ldoption = $(call try-run,\
@@ -161,7 +165,9 @@ ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
 # Usage:
 # $(Q)$(MAKE) $(build)=dir
-build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+#build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+# temporary
+build := -f $(srctree)/scripts/Makefile.build -C
 
 ###
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 1b3d77f..7789efa 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -2,6 +2,7 @@
 .PHONY: all
 all:
 
+include $(srctree)/scripts/Kbuild.include
 include $(TOPDIR)/config.mk
 
 # variable LIB is used in examples/standalone/Makefile
diff --git a/spl/Makefile b/spl/Makefile
index e76b2b4..736acd7 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -24,6 +24,8 @@ else
 SPL_BIN := u-boot-spl
 endif
 
+include $(srctree)/scripts/Kbuild.include
+
 include $(TOPDIR)/config.mk
 
 # We want the final binaries in this directory
@@ -126,8 +128,6 @@ ifeq ($(wildcard $(LDSCRIPT)),)
 $(error could not find linker script)
 endif
 
-build := -f $(TOPDIR)/scripts/Makefile.build -C
-
 # Special flags for CPP when processing the linker script.
 # Pass the version down so we can handle backwards compatibility
 # on the fly.
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 12/38] Makefile: move more flags to the top Makefile
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (10 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 11/38] kbuild: Use Kbuild.include Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 13/38] Makefile: refactor include path settings Masahiro Yamada
                   ` (28 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

Before this commit, most of compiler flags were defined in config.mk.
But it is redundant because config.mk is included from all recursive make.

This commit moves many complier flags to the top Makefile
and export them.
And we use new vaiarables to store them:
KBUILD_CPPFLAGS, KBUILD_CFLAGS, KBUILD_AFLAGS.
This will allow us to switch more smoothly to Kbuild.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
  - At version 1, nand_spl boards got broken by this commit
    (and fixed again in the lator commit.)
    Fix this problem

 Makefile  | 35 +++++++++++++++++++++++++++++++++++
 config.mk | 41 ++++-------------------------------------
 2 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/Makefile b/Makefile
index e4045bc..3a97483 100644
--- a/Makefile
+++ b/Makefile
@@ -226,11 +226,46 @@ CHECK		= sparse
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
 
+KBUILD_CPPFLAGS := -D__KERNEL__
+
+KBUILD_CFLAGS   := -Wall -Wstrict-prototypes \
+		   -Wno-format-security \
+		   -fno-builtin -ffreestanding
+KBUILD_AFLAGS   := -D__ASSEMBLY__
+
 export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
 export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
 export MAKE AWK
 export DTC CHECK CHECKFLAGS
 
+export KBUILD_CPPFLAGS
+export KBUILD_CFLAGS KBUILD_AFLAGS
+
+KBUILD_CFLAGS += -Os #-fomit-frame-pointer
+
+ifdef BUILD_TAG
+KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
+endif
+
+KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
+
+KBUILD_CFLAGS	+= -g
+# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
+# option to the assembler.
+KBUILD_AFLAGS	+= -g
+
+# Report stack usage if supported
+KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
+
+KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
+
+# turn jbsr into jsr for m68k
+ifeq ($(ARCH),m68k)
+ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
+KBUILD_AFLAGS += -Wa,-gstabs,-S
+endif
+endif
+
 # load other configuration
 include $(TOPDIR)/config.mk
 
diff --git a/config.mk b/config.mk
index ba42641..04b63f6 100644
--- a/config.mk
+++ b/config.mk
@@ -90,19 +90,13 @@ endif
 
 #########################################################################
 
-# We don't actually use $(ARFLAGS) anywhere anymore, so catch people
-# who are porting old code to latest mainline but not updating $(AR).
-ARFLAGS = $(error update your Makefile to use cmd_link_o_target and not AR)
 RELFLAGS= $(PLATFORM_RELFLAGS)
-DBGFLAGS= -g # -DDEBUG
-OPTFLAGS= -Os #-fomit-frame-pointer
 
 OBJCFLAGS += --gap-fill=0xff
 
 gccincdir := $(shell $(CC) -print-file-name=include)
 
-CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)		\
-	-D__KERNEL__
+CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
 
 # Enable garbage collection of un-used sections for SPL
 ifeq ($(CONFIG_SPL_BUILD),y)
@@ -134,26 +128,10 @@ CPPFLAGS += -I$(OBJTREE)/include
 endif
 
 CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include
-CPPFLAGS += -fno-builtin -ffreestanding -nostdinc	\
+CPPFLAGS += -nostdinc	\
 	-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
 
-CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
-
-ifdef BUILD_TAG
-CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
-endif
-
-CFLAGS_SSP := $(call cc-option,-fno-stack-protector)
-CFLAGS += $(CFLAGS_SSP)
-# Some toolchains enable security related warning flags by default,
-# but they don't make much sense in the u-boot world, so disable them.
-CFLAGS_WARN := $(call cc-option,-Wno-format-nonliteral) \
-	       $(call cc-option,-Wno-format-security)
-CFLAGS += $(CFLAGS_WARN)
-
-# Report stack usage if supported
-CFLAGS_STACK := $(call cc-option,-fstack-usage)
-CFLAGS += $(CFLAGS_STACK)
+CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
 
 BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
 
@@ -165,18 +143,7 @@ endif
 endif
 endif
 
-# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
-# option to the assembler.
-AFLAGS_DEBUG :=
-
-# turn jbsr into jsr for m68k
-ifeq ($(ARCH),m68k)
-ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
-AFLAGS_DEBUG := -Wa,-gstabs,-S
-endif
-endif
-
-AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
+AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
 
 LDFLAGS += $(PLATFORM_LDFLAGS)
 LDFLAGS_FINAL += -Bstatic
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 13/38] Makefile: refactor include path settings
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (11 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 12/38] Makefile: move more flags to the top Makefile Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 14/38] Makefile: move more stuff to top Makefile Masahiro Yamada
                   ` (27 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit merges commonly-used header include paths
to UBOOTINCLUDE and NOSTDINC_FLAGS variables, which are placed
at the top Makefile.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile           | 14 +++++++++++++-
 config.mk          | 11 ++---------
 tools/Makefile     |  8 +++-----
 tools/env/Makefile |  4 +---
 4 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/Makefile b/Makefile
index 3a97483..9c39022 100644
--- a/Makefile
+++ b/Makefile
@@ -226,6 +226,15 @@ CHECK		= sparse
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
 
+# Use UBOOTINCLUDE when you must reference the include/ directory.
+# Needed to be compatible with the O= option
+UBOOTINCLUDE    :=
+ifneq ($(OBJTREE),$(SRCTREE))
+UBOOTINCLUDE	+= -I$(OBJTREE)/include
+endif
+UBOOTINCLUDE	+= -I$(srctree)/include \
+		-I$(srctree)/arch/$(ARCH)/include
+
 KBUILD_CPPFLAGS := -D__KERNEL__
 
 KBUILD_CFLAGS   := -Wall -Wstrict-prototypes \
@@ -238,7 +247,7 @@ export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
 export MAKE AWK
 export DTC CHECK CHECKFLAGS
 
-export KBUILD_CPPFLAGS
+export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE
 export KBUILD_CFLAGS KBUILD_AFLAGS
 
 KBUILD_CFLAGS += -Os #-fomit-frame-pointer
@@ -254,6 +263,9 @@ KBUILD_CFLAGS	+= -g
 # option to the assembler.
 KBUILD_AFLAGS	+= -g
 
+NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
+CHECKFLAGS     += $(NOSTDINC_FLAGS)
+
 # Report stack usage if supported
 KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
 
diff --git a/config.mk b/config.mk
index 04b63f6..f700ee1 100644
--- a/config.mk
+++ b/config.mk
@@ -94,8 +94,6 @@ RELFLAGS= $(PLATFORM_RELFLAGS)
 
 OBJCFLAGS += --gap-fill=0xff
 
-gccincdir := $(shell $(CC) -print-file-name=include)
-
 CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
 
 # Enable garbage collection of un-used sections for SPL
@@ -123,13 +121,8 @@ Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
 endif
 endif
 
-ifneq ($(OBJTREE),$(SRCTREE))
-CPPFLAGS += -I$(OBJTREE)/include
-endif
-
-CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include
-CPPFLAGS += -nostdinc	\
-	-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
+CPPFLAGS += $(UBOOTINCLUDE)
+CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
 
 CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
 
diff --git a/tools/Makefile b/tools/Makefile
index c3cdaf0..21341b7 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -175,11 +175,9 @@ HOSTSRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
 #
 HOST_EXTRACFLAGS += -include $(SRCTREE)/include/libfdt_env.h \
-		-idirafter $(SRCTREE)/include \
-		-idirafter $(SRCTREE)/arch/$(ARCH)/include \
-		-idirafter $(OBJTREE)/include \
-		-I $(SRCTREE)/lib/libfdt \
-		-I $(SRCTREE)/tools \
+		$(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
+		-I$(SRCTREE)/lib/libfdt \
+		-I$(SRCTREE)/tools \
 		-DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
 		-DUSE_HOSTCC \
 		-D__KERNEL_STRICT_NAMES \
diff --git a/tools/env/Makefile b/tools/env/Makefile
index c303815..d47fe16 100644
--- a/tools/env/Makefile
+++ b/tools/env/Makefile
@@ -6,9 +6,7 @@
 #
 
 # Compile for a hosted environment on the target
-HOST_EXTRACFLAGS  = -idirafter $(SRCTREE)/include \
-		-idirafter $(SRCTREE)/arch/$(ARCH)/include \
-		-idirafter $(OBJTREE)/include \
+HOST_EXTRACFLAGS  = $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
 		-idirafter $(SRCTREE)/tools/env \
 		-DUSE_HOSTCC \
 		-DTEXT_BASE=$(TEXT_BASE)
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 14/38] Makefile: move more stuff to top Makefile
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (12 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 13/38] Makefile: refactor include path settings Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 15/38] Makefile: move some flags to spl/Makefile Masahiro Yamada
                   ` (26 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile  | 20 +++++++++++++++++---
 config.mk | 19 +------------------
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/Makefile b/Makefile
index 9c39022..b24b425 100644
--- a/Makefile
+++ b/Makefile
@@ -281,13 +281,27 @@ endif
 # load other configuration
 include $(TOPDIR)/config.mk
 
+ifneq ($(CONFIG_SYS_TEXT_BASE),)
+KBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
+endif
+
+export CONFIG_SYS_TEXT_BASE
+
+LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
+ifneq ($(CONFIG_SYS_TEXT_BASE),)
+LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
+endif
+
 # Targets which don't build the source code
-NON_BUILD_TARGETS = backup clean clobber distclean mrproper tidy unconfig
+NON_BUILD_TARGETS = backup clean clobber distclean mrproper tidy unconfig %_config
 
 # Only do the generic board check when actually building, not configuring
 ifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),)
-ifeq ($(findstring _config,$(MAKECMDGOALS)),)
-$(CHECK_GENERIC_BOARD)
+ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
+ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
+CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \
+Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
+endif
 endif
 endif
 
diff --git a/config.mk b/config.mk
index f700ee1..54d1d8b 100644
--- a/config.mk
+++ b/config.mk
@@ -102,10 +102,6 @@ CPPFLAGS += -ffunction-sections -fdata-sections
 LDFLAGS_FINAL += --gc-sections
 endif
 
-ifneq ($(CONFIG_SYS_TEXT_BASE),)
-CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
-endif
-
 ifeq ($(CONFIG_SPL_BUILD),y)
 CPPFLAGS += -DCONFIG_SPL_BUILD
 ifeq ($(CONFIG_TPL_BUILD),y)
@@ -113,14 +109,6 @@ CPPFLAGS += -DCONFIG_TPL_BUILD
 endif
 endif
 
-# Does this architecture support generic board init?
-ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
-ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
-CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \
-Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
-endif
-endif
-
 CPPFLAGS += $(UBOOTINCLUDE)
 CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
 
@@ -141,11 +129,6 @@ AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
 LDFLAGS += $(PLATFORM_LDFLAGS)
 LDFLAGS_FINAL += -Bstatic
 
-LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
-ifneq ($(CONFIG_SYS_TEXT_BASE),)
-LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
-endif
-
 LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SPL_TEXT_BASE),)
 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
@@ -153,4 +136,4 @@ endif
 
 #########################################################################
 
-export	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
+export PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 15/38] Makefile: move some flags to spl/Makefile
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (13 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 14/38] Makefile: move more stuff to top Makefile Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 16/38] Makefile: move some flags to examples makefiles Masahiro Yamada
                   ` (25 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

Some flags are used for SPL (and TPL) build only.
This commit moves them from config.mk to spl/Makefile.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 config.mk    | 19 -------------------
 spl/Makefile | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/config.mk b/config.mk
index 54d1d8b..597a566 100644
--- a/config.mk
+++ b/config.mk
@@ -95,20 +95,6 @@ RELFLAGS= $(PLATFORM_RELFLAGS)
 OBJCFLAGS += --gap-fill=0xff
 
 CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
-
-# Enable garbage collection of un-used sections for SPL
-ifeq ($(CONFIG_SPL_BUILD),y)
-CPPFLAGS += -ffunction-sections -fdata-sections
-LDFLAGS_FINAL += --gc-sections
-endif
-
-ifeq ($(CONFIG_SPL_BUILD),y)
-CPPFLAGS += -DCONFIG_SPL_BUILD
-ifeq ($(CONFIG_TPL_BUILD),y)
-CPPFLAGS += -DCONFIG_TPL_BUILD
-endif
-endif
-
 CPPFLAGS += $(UBOOTINCLUDE)
 CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
 
@@ -129,11 +115,6 @@ AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
 LDFLAGS += $(PLATFORM_LDFLAGS)
 LDFLAGS_FINAL += -Bstatic
 
-LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
-ifneq ($(CONFIG_SPL_TEXT_BASE),)
-LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
-endif
-
 #########################################################################
 
 export PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
diff --git a/spl/Makefile b/spl/Makefile
index 736acd7..001205b 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -17,6 +17,15 @@
 CONFIG_SPL_BUILD := y
 export CONFIG_SPL_BUILD
 
+KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
+ifeq ($(CONFIG_TPL_BUILD),y)
+KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
+endif
+
+# Enable garbage collection of un-used sections for SPL
+KBUILD_CFLAGS += -ffunction-sections -fdata-sections
+LDFLAGS_FINAL += --gc-sections
+
 ifeq ($(CONFIG_TPL_BUILD),y)
 export CONFIG_TPL_BUILD
 SPL_BIN := u-boot-tpl
@@ -172,6 +181,11 @@ endif
 $(obj)$(SPL_BIN).bin:	$(obj)$(SPL_BIN)
 	$(OBJCOPY) $(OBJCFLAGS) $(SPL_OBJCFLAGS) -O binary $< $@
 
+LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
+ifneq ($(CONFIG_SPL_TEXT_BASE),)
+LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
+endif
+
 GEN_UBOOT = \
 	cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $(__START) \
 		--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 16/38] Makefile: move some flags to examples makefiles
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (14 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 15/38] Makefile: move some flags to spl/Makefile Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 17/38] kbuild: change out-of-tree build Masahiro Yamada
                   ` (24 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit moves some flags which are used
under examples/ directory only.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 config.mk                    | 8 --------
 examples/api/Makefile        | 4 ++++
 examples/standalone/Makefile | 4 ++++
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/config.mk b/config.mk
index 597a566..ed1a519 100644
--- a/config.mk
+++ b/config.mk
@@ -102,14 +102,6 @@ CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
 
 BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
 
-ifeq ($(findstring examples/,$(BCURDIR)),)
-ifeq ($(CONFIG_SPL_BUILD),)
-ifdef FTRACE
-CFLAGS += -finstrument-functions -DFTRACE
-endif
-endif
-endif
-
 AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
 
 LDFLAGS += $(PLATFORM_LDFLAGS)
diff --git a/examples/api/Makefile b/examples/api/Makefile
index 52f4368..ee3c487 100644
--- a/examples/api/Makefile
+++ b/examples/api/Makefile
@@ -4,6 +4,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+ifdef FTRACE
+CFLAGS += -finstrument-functions -DFTRACE
+endif
+
 ifeq ($(ARCH),powerpc)
 LOAD_ADDR = 0x40000
 endif
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index cad4409..1f8d70c 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -5,6 +5,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+ifdef FTRACE
+CFLAGS += -finstrument-functions -DFTRACE
+endif
+
 extra-y        := hello_world
 extra-$(CONFIG_SMC91111)           += smc91111_eeprom
 extra-$(CONFIG_SMC911X)            += smc911x_eeprom
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 17/38] kbuild: change out-of-tree build
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (15 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 16/38] Makefile: move some flags to examples makefiles Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 18/38] kbuild: add dummy obj-y to create built-in.o Masahiro Yamada
                   ` (23 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit changes the working directory
where the build process occurs.

Before this commit, build process occurred under the source
tree for both in-tree and out-of-tree build.

That's why we needed to add $(obj) prefix to all generated
files in makefiles like follows:
  $(obj)u-boot.bin:  $(obj)u-boot

Here, $(obj) is empty for in-tree build, whereas it points
to the output directory for out-of-tree build.

And our old build system changes the current working directory
with "make -C <sub-dir>" syntax when descending into the
sub-directories.

On the other hand, Kbuild uses a different idea
to handle out-of-tree build and directory descending.

The build process of Kbuild always occurs under the output tree.
When "O=dir/to/store/output/files" is given, the build system
changes the current working directory to that directory and
restarts the make.

Kbuild uses "make -f $(srctree)/scripts/Makefile.build obj=<sub-dir>"
syntax for descending into sub-directories.
(We can write it like "make $(obj)=<sub-dir>" with a shorthand.)
This means the current working directory is always the top
of the output directory.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Gerhard Sittig <gsi@denx.de>
---

This patch seems a big change at a glance.
But the idea is pretty simple.

The major change in the top Makefile is imported
from Linux Kernel from Linux Kernel.

The rest parts are for adjusting prefixes.

  - omit $(obj) prefixes for files which are generated in
     the top directory
  - change $(obj)foo to $(obj)/foo for files which are generated
     under sub directories.
  - add $(srctree)/ or $(src)/ prefixes when we need to point
     to the source files.
  - The environmanet BUILD_DIR has been renamed to KBUILD_OUTPUT.
    So, this commit modifies MAKEALL too.

FYI:
Basic structure of the top Makefile is as follows:

ifeq ($(KBUILD_SRC),)

ifeq ("$(origin O)", "command line")
  KBUILD_OUTPUT := $(O)
endif

ifneq ($(KBUILD_OUTPUT),)

   << define KBUILD_SRC and change directory and restart make >>

skip-makefile := 1
endif
endif

ifeq ($(skip-makefile),)

  <<Main part of Makefile>>

endif


Changes in v8: None
Changes in v7: None
Changes in v6:
  - Fix doc/DocBook/Makefile
  - Rebase on the current u-boot/master

Changes in v5:
  - Rebase on the current u-boot/master

Changes in v4:
  - Change a little checkstack target:
      Use $(src) rather than $(srctree) where Linux Kernel does so.

Changes in v3:
  - Rebase on the current u-boot/master

Changes in v2:
  - Rebase on v2014.01-rc2 tag
  - At version 1, sandbox got broken by this commit
    (and fixed again in the lator commit.)
    Fix this problem
  - Change a little MAKEALL
     Do not add "O=<dir>" if objtree is the same as srctree.
     This will be helpful at 35/35.

 MAKEALL                                       |   6 +-
 Makefile                                      | 569 ++++++++++++++------------
 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/blackfin/config.mk                       |  10 +-
 arch/blackfin/cpu/Makefile                    |   8 +-
 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/powerpc/lib/Makefile                     |   4 +-
 arch/sandbox/cpu/Makefile                     |   4 +-
 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-ng/Makefile          |   2 +-
 board/avionic-design/tec/Makefile             |   2 +-
 board/compal/paz00/Makefile                   |   2 +-
 board/compulab/trimslice/Makefile             |   2 +-
 board/cray/L1/Makefile                        |   8 +-
 board/h2200/Makefile                          |   2 +-
 board/matrix_vision/mvblm7/Makefile           |   4 +-
 board/matrix_vision/mvsmr/Makefile            |   2 +-
 board/nvidia/common/Makefile                  |   2 +-
 board/pcs440ep/config.mk                      |   2 +-
 board/samsung/origen/Makefile                 |   2 +-
 common/Makefile                               |   9 +-
 config.mk                                     |  42 +-
 doc/DocBook/Makefile                          |   6 +-
 drivers/bios_emulator/Makefile                |   2 +-
 dts/Makefile                                  |   6 +-
 examples/api/Makefile                         |  16 +-
 examples/standalone/Makefile                  |  14 +-
 fs/ubifs/Makefile                             |   2 +-
 lib/Makefile                                  |   2 +-
 mkconfig                                      |   2 +-
 nand_spl/board/amcc/acadia/Makefile           |  30 +-
 nand_spl/board/amcc/bamboo/Makefile           |  30 +-
 nand_spl/board/amcc/canyonlands/Makefile      |  30 +-
 nand_spl/board/amcc/kilauea/Makefile          |  28 +-
 nand_spl/board/amcc/sequoia/Makefile          |  32 +-
 nand_spl/board/freescale/mpc8315erdb/Makefile |  30 +-
 nand_spl/board/freescale/mpc8536ds/Makefile   |  42 +-
 nand_spl/board/freescale/mpc8569mds/Makefile  |  42 +-
 nand_spl/board/freescale/mpc8572ds/Makefile   |  42 +-
 nand_spl/board/freescale/p1023rds/Makefile    |  42 +-
 nand_spl/board/freescale/p1_p2_rdb/Makefile   |  42 +-
 nand_spl/board/sheldon/simpc8313/Makefile     |  30 +-
 post/lib_powerpc/fpu/Makefile                 |   2 +-
 rules.mk                                      |  19 +-
 scripts/Kbuild.include                        |   4 +-
 scripts/Makefile.build                        |  57 ++-
 scripts/Makefile.host.tmp                     |  18 +-
 spl/Makefile                                  |  49 ++-
 tools/Makefile                                |  18 +-
 64 files changed, 612 insertions(+), 744 deletions(-)

diff --git a/MAKEALL b/MAKEALL
index 562071a..01d0598 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -668,8 +668,6 @@ build_target() {
 		output_dir="${OUTPUT_PREFIX}"
 	fi
 
-	export BUILD_DIR="${output_dir}"
-
 	target_arch=$(get_target_arch ${target})
 	eval cross_toolchain=\$CROSS_COMPILE_`echo $target_arch | tr '[:lower:]' '[:upper:]'`
 	if [ "${cross_toolchain}" ] ; then
@@ -680,6 +678,10 @@ build_target() {
 	    MAKE=make
 	fi
 
+	if [  "${output_dir}" != "." ] ; then
+		MAKE="${MAKE} O=${output_dir}"
+	fi
+
 	${MAKE} distclean >/dev/null
 	${MAKE} -s ${target}_config
 
diff --git a/Makefile b/Makefile
index b24b425..1409c8b 100644
--- a/Makefile
+++ b/Makefile
@@ -14,8 +14,8 @@ U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 else
 U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION)
 endif
-TIMESTAMP_FILE = $(obj)include/generated/timestamp_autogenerated.h
-VERSION_FILE = $(obj)include/generated/version_autogenerated.h
+TIMESTAMP_FILE = include/generated/timestamp_autogenerated.h
+VERSION_FILE = include/generated/version_autogenerated.h
 
 HOSTARCH := $(shell uname -m | \
 	sed -e s/i.86/x86/ \
@@ -43,32 +43,82 @@ else
 XECHO = :
 endif
 
-#########################################################################
-#
-# U-boot build supports generating object files in a separate external
-# directory. Two use cases are supported:
-#
-# 1) Add O= to the make command line
-# 'make O=/tmp/build all'
-#
-# 2) Set environment variable BUILD_DIR to point to the desired location
-# 'export BUILD_DIR=/tmp/build'
-# 'make'
-#
-# The second approach can also be used with a MAKEALL script
-# 'export BUILD_DIR=/tmp/build'
-# './MAKEALL'
+# kbuild supports saving output files in a separate directory.
+# To locate output files in a separate directory two syntaxes are supported.
+# In both cases the working directory must be the root of the kernel src.
+# 1) O=
+# Use "make O=dir/to/store/output/files/"
 #
-# Command line 'O=' setting overrides BUILD_DIR environment variable.
-#
-# When none of the above methods is used the local build is performed and
-# the object files are placed in the source directory.
+# 2) Set KBUILD_OUTPUT
+# Set the environment variable KBUILD_OUTPUT to point to the directory
+# where the output files shall be placed.
+# export KBUILD_OUTPUT=dir/to/store/output/files/
+# make
 #
+# The O= assignment takes precedence over the KBUILD_OUTPUT environment
+# variable.
+
+
+# KBUILD_SRC is set on invocation of make in OBJ directory
+# KBUILD_SRC is not intended to be used by the regular user (for now)
+ifeq ($(KBUILD_SRC),)
 
+# OK, Make called in directory where kernel src resides
+# Do we want to locate output files in a separate directory?
 ifeq ("$(origin O)", "command line")
-BUILD_DIR := $(O)
+  KBUILD_OUTPUT := $(O)
+endif
+
+ifeq ("$(origin W)", "command line")
+  export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
 endif
 
+# That's our default target when none is given on the command line
+PHONY := _all
+_all:
+
+# Cancel implicit rules on top Makefile
+$(CURDIR)/Makefile Makefile: ;
+
+ifneq ($(KBUILD_OUTPUT),)
+# Invoke a second make in the output directory, passing relevant variables
+# check that the output directory actually exists
+saved-output := $(KBUILD_OUTPUT)
+KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
+$(if $(KBUILD_OUTPUT),, \
+     $(error output directory "$(saved-output)" does not exist))
+
+PHONY += $(MAKECMDGOALS) sub-make
+
+$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
+	@:
+
+sub-make: FORCE
+	$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
+	KBUILD_SRC=$(CURDIR) \
+	KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
+	$(filter-out _all sub-make,$(MAKECMDGOALS))
+
+# Leave processing to above invocation of make
+skip-makefile := 1
+endif # ifneq ($(KBUILD_OUTPUT),)
+endif # ifeq ($(KBUILD_SRC),)
+
+# We process the rest of the Makefile if this is the final invocation of make
+ifeq ($(skip-makefile),)
+
+PHONY += all
+_all: all
+
+srctree		:= $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
+objtree		:= $(CURDIR)
+src		:= $(srctree)
+obj		:= $(objtree)
+
+VPATH		:= $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
+
+export srctree objtree VPATH
+
 # Call a source code checker (by default, "sparse") as part of the
 # C compilation.
 #
@@ -87,41 +137,16 @@ ifndef CHECKSRC
 endif
 export CHECKSRC
 
-ifneq ($(BUILD_DIR),)
-saved-output := $(BUILD_DIR)
-
-# Attempt to create a output directory.
-$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
-
-# Verify if it was successful.
-BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
-$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
-endif # ifneq ($(BUILD_DIR),)
-
-OBJTREE		:= $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
+OBJTREE		:= $(objtree)
 SPLTREE		:= $(OBJTREE)/spl
 TPLTREE		:= $(OBJTREE)/tpl
-SRCTREE		:= $(CURDIR)
-srctree		:= $(SRCTREE)
+SRCTREE		:= $(srctree)
 TOPDIR		:= $(SRCTREE)
-LNDIR		:= $(OBJTREE)
-export	TOPDIR SRCTREE srctree OBJTREE SPLTREE TPLTREE
+export	TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE
 
 MKCONFIG	:= $(SRCTREE)/mkconfig
 export MKCONFIG
 
-# $(obj) and (src) are defined in config.mk but here in main Makefile
-# we also need them before config.mk is included which is the case for
-# some targets like unconfig, clean, clobber, distclean, etc.
-ifneq ($(OBJTREE),$(SRCTREE))
-obj := $(OBJTREE)/
-src := $(SRCTREE)/
-else
-obj :=
-src :=
-endif
-export obj src
-
 # Make sure CDPATH settings don't interfere
 unexport CDPATH
 
@@ -136,14 +161,14 @@ SUBDIRS = $(SUBDIR_TOOLS)
 
 .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
 
-ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))
+ifeq (include/config.mk,$(wildcard include/config.mk))
 
 # Include autoconf.mk before config.mk so that the config options are available
 # to all top level build files.  We need the dummy all: target to prevent the
 # dependency target in autoconf.mk.dep from being the default.
 all:
-sinclude $(obj)include/autoconf.mk.dep
-sinclude $(obj)include/autoconf.mk
+sinclude include/autoconf.mk.dep
+sinclude include/autoconf.mk
 
 SUBDIR_EXAMPLES-y := examples/standalone
 SUBDIR_EXAMPLES-$(CONFIG_API) += examples/api
@@ -152,7 +177,7 @@ SUBDIRS += $(SUBDIR_EXAMPLES-y)
 endif
 
 # load ARCH, BOARD, and CPU configuration
-include $(obj)include/config.mk
+include include/config.mk
 export	ARCH CPU BOARD VENDOR SOC
 
 # set default to nothing for native builds
@@ -197,6 +222,9 @@ HOSTCFLAGS  += $(call os_x_before, 10, 4, "-traditional-cpp")
 HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
 endif
 
+# Look for make include files relative to root of kernel src
+MAKEFLAGS += --include-dir=$(srctree)
+
 # We need some generic definitions (do not try to remake the file).
 $(srctree)/scripts/Kbuild.include: ;
 include $(srctree)/scripts/Kbuild.include
@@ -287,7 +315,7 @@ endif
 
 export CONFIG_SYS_TEXT_BASE
 
-LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
+LDFLAGS_u-boot += -T u-boot.lds $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
 LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
 endif
@@ -350,9 +378,9 @@ head-y := $(CPUDIR)/start.o
 head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
 head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
 
-OBJS := $(addprefix $(obj),$(head-y))
+OBJS := $(head-y)
 
-HAVE_VENDOR_COMMON_LIB = $(if $(wildcard board/$(VENDOR)/common/Makefile),y,n)
+HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
 
 LIBS-y += lib/
 LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
@@ -412,7 +440,7 @@ LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/
 LIBS-y += board/$(BOARDDIR)/
 
 LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y))
-LIBS := $(addprefix $(obj),$(sort $(LIBS-y)))
+LIBS := $(sort $(LIBS-y))
 .PHONY : $(LIBS)
 
 # Add GCC lib
@@ -437,9 +465,6 @@ LDPPFLAGS += \
 	$(shell $(LD) --version | \
 	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
 
-__OBJS := $(subst $(obj),,$(OBJS))
-__LIBS := $(subst $(obj),,$(LIBS))
-
 #########################################################################
 #########################################################################
 
@@ -464,66 +489,66 @@ ifneq ($(CONFIG_STATIC_RELA),)
 DO_STATIC_RELA = \
 	start=$$($(NM) $(1) | grep __rel_dyn_start | cut -f 1 -d ' '); \
 	end=$$($(NM) $(1) | grep __rel_dyn_end | cut -f 1 -d ' '); \
-	$(obj)tools/relocate-rela $(2) $(3) $$start $$end
+	tools/relocate-rela $(2) $(3) $$start $$end
 else
 DO_STATIC_RELA =
 endif
 
 # Always append ALL so that arch config.mk's can add custom ones
-ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
-
-ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin
-ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin
-ALL-$(CONFIG_RAMBOOT_PBL) += $(obj)u-boot.pbl
-ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
-ALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.img
-ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin
-ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
+ALL-y += u-boot.srec u-boot.bin System.map
+
+ALL-$(CONFIG_NAND_U_BOOT) += u-boot-nand.bin
+ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin
+ALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl
+ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin
+ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
+ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
+ALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb u-boot-dtb.bin
 ifneq ($(CONFIG_SPL_TARGET),)
-ALL-$(CONFIG_SPL) += $(obj)$(CONFIG_SPL_TARGET:"%"=%)
+ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
 endif
-ALL-$(CONFIG_REMAKE_ELF) += $(obj)u-boot.elf
+ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
 
 # enable combined SPL/u-boot/dtb rules for tegra
 ifneq ($(CONFIG_TEGRA),)
 ifeq ($(CONFIG_SPL),y)
 ifeq ($(CONFIG_OF_SEPARATE),y)
-ALL-y += $(obj)u-boot-dtb-tegra.bin
+ALL-y += u-boot-dtb-tegra.bin
 else
-ALL-y += $(obj)u-boot-nodtb-tegra.bin
+ALL-y += u-boot-nodtb-tegra.bin
 endif
 endif
 endif
 
 all:		$(ALL-y) $(SUBDIR_EXAMPLES-y)
 
-$(obj)u-boot.dtb:	checkdtc $(obj)u-boot
-		$(MAKE) $(build) dts binary
-		mv $(obj)dts/dt.dtb $@
+u-boot.dtb:	checkdtc u-boot
+		$(MAKE) $(build)=dts binary
+		mv dts/dt.dtb $@
 
-$(obj)u-boot-dtb.bin:	$(obj)u-boot.bin $(obj)u-boot.dtb
+u-boot-dtb.bin:	u-boot.bin u-boot.dtb
 		cat $^ >$@
 
-$(obj)u-boot.hex:	$(obj)u-boot
+u-boot.hex:	u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
 
-$(obj)u-boot.srec:	$(obj)u-boot
+u-boot.srec:	u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
 
-$(obj)u-boot.bin:	$(obj)u-boot
+u-boot.bin:	u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
 		$(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE))
 		$(BOARD_SIZE_CHECK)
 
-$(obj)u-boot.ldr:	$(obj)u-boot
+u-boot.ldr:	u-boot
 		$(CREATE_LDR_ENV)
 		$(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
 		$(BOARD_SIZE_CHECK)
 
-$(obj)u-boot.ldr.hex:	$(obj)u-boot.ldr
+u-boot.ldr.hex:	u-boot.ldr
 		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
 
-$(obj)u-boot.ldr.srec:	$(obj)u-boot.ldr
+u-boot.ldr.srec:	u-boot.ldr
 		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
 
 #
@@ -534,79 +559,78 @@ ifndef CONFIG_SYS_UBOOT_START
 CONFIG_SYS_UBOOT_START := 0
 endif
 
-$(obj)u-boot.img:	$(obj)u-boot.bin
-		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
+u-boot.img:	u-boot.bin
+		tools/mkimage -A $(ARCH) -T firmware -C none \
 		-O u-boot -a $(CONFIG_SYS_TEXT_BASE) \
 		-e $(CONFIG_SYS_UBOOT_START) \
 		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
 
-$(obj)u-boot.imx: $(obj)u-boot.bin depend
-		$(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common $(OBJTREE)/u-boot.imx
+u-boot.imx: u-boot.bin depend
+		$(MAKE) $(build)=arch/arm/imx-common $(objtree)/u-boot.imx
 
-$(obj)u-boot.kwb:       $(obj)u-boot.bin
-		$(obj)tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
+u-boot.kwb:       u-boot.bin
+		tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
 		-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
 
-$(obj)u-boot.pbl:	$(obj)u-boot.bin
-		$(obj)tools/mkimage -n $(CONFIG_SYS_FSL_PBL_RCW) \
+u-boot.pbl:	u-boot.bin
+		tools/mkimage -n $(CONFIG_SYS_FSL_PBL_RCW) \
 		-R $(CONFIG_SYS_FSL_PBL_PBI) -T pblimage \
 		-d $< $@
 
-$(obj)u-boot.sha1:	$(obj)u-boot.bin
-		$(obj)tools/ubsha1 $(obj)u-boot.bin
+u-boot.sha1:	u-boot.bin
+		tools/ubsha1 u-boot.bin
 
-$(obj)u-boot.dis:	$(obj)u-boot
+u-boot.dis:	u-boot
 		$(OBJDUMP) -d $< > $@
 
 # $@ is output, $(1) and $(2) are inputs, $(3) is padded intermediate,
 # $(4) is pad-to
 SPL_PAD_APPEND = \
 		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(4) -I binary -O binary \
-		$(1) $(obj)$(3); \
-		cat $(obj)$(3) $(2) > $@; \
-		rm $(obj)$(3)
+		$(1) $(3); \
+		cat $(3) $(2) > $@; \
+		rm $(3)
 
 ifdef CONFIG_TPL
-SPL_PAYLOAD := $(obj)tpl/u-boot-with-tpl.bin
+SPL_PAYLOAD := tpl/u-boot-with-tpl.bin
 else
-SPL_PAYLOAD := $(obj)u-boot.bin
+SPL_PAYLOAD := u-boot.bin
 endif
 
-$(obj)u-boot-with-spl.bin: $(obj)spl/u-boot-spl.bin $(SPL_PAYLOAD)
+u-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD)
 		$(call SPL_PAD_APPEND,$<,$(SPL_PAYLOAD),spl/u-boot-spl-pad.bin,$(CONFIG_SPL_PAD_TO))
 
-$(obj)tpl/u-boot-with-tpl.bin: $(obj)tpl/u-boot-tpl.bin $(obj)u-boot.bin
-		$(call SPL_PAD_APPEND,$<,$(obj)u-boot.bin,tpl/u-boot-tpl-pad.bin,$(CONFIG_TPL_PAD_TO))
+tpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin
+		$(call SPL_PAD_APPEND,$<,u-boot.bin,tpl/u-boot-tpl-pad.bin,$(CONFIG_TPL_PAD_TO))
 
-$(obj)u-boot-with-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
-		$(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common \
+u-boot-with-spl.imx: spl/u-boot-spl.bin u-boot.bin
+		$(MAKE) $(build)=arch/arm/imx-common \
 			$(OBJTREE)/u-boot-with-spl.imx
 
-$(obj)u-boot-with-nand-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
-		$(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common \
+u-boot-with-nand-spl.imx: spl/u-boot-spl.bin u-boot.bin
+		$(MAKE) $(build)=arch/arm/imx-common \
 			$(OBJTREE)/u-boot-with-nand-spl.imx
 
-$(obj)u-boot.ubl:       $(obj)u-boot-with-spl.bin
-		$(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
-		-e $(CONFIG_SYS_TEXT_BASE) -d $< $(obj)u-boot.ubl
+u-boot.ubl:       u-boot-with-spl.bin
+		tools/mkimage -n $(UBL_CONFIG) -T ublimage \
+		-e $(CONFIG_SYS_TEXT_BASE) -d $< u-boot.ubl
 
-$(obj)u-boot.ais:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
-		$(obj)tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(CONFIG_AIS_CONFIG_FILE),"/dev/null") \
+u-boot.ais:       spl/u-boot-spl.bin u-boot.img
+		tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \
 			-T aisimage \
 			-e $(CONFIG_SPL_TEXT_BASE) \
-			-d $(obj)spl/u-boot-spl.bin \
-			$(obj)spl/u-boot-spl.ais
+			-d spl/u-boot-spl.bin \
+			spl/u-boot-spl.ais
 		$(OBJCOPY) ${OBJCFLAGS} -I binary \
 			--pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
-			$(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais
-		cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.img > \
-			$(obj)u-boot.ais
+			spl/u-boot-spl.ais spl/u-boot-spl-pad.ais
+		cat spl/u-boot-spl-pad.ais u-boot.img > u-boot.ais
 
 
-$(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
-		$(MAKE) $(build) $(SRCTREE)/$(CPUDIR)/$(SOC)/ $(OBJTREE)/u-boot.sb
+u-boot.sb:       u-boot.bin spl/u-boot-spl.bin
+		$(MAKE) $(build)=$(CPUDIR)/$(SOC)/ $(OBJTREE)/u-boot.sb
 
 # On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
 # Both images are created using mkimage (crc etc), so that the ROM
@@ -614,124 +638,123 @@ $(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
 # SPL image (with mkimage header) and not the binary. Otherwise the resulting image
 # which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
 # The resulting image containing both U-Boot images is called u-boot.spr
-$(obj)u-boot.spr:	$(obj)u-boot.img $(obj)spl/u-boot-spl.bin
-		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
+u-boot.spr:	u-boot.img spl/u-boot-spl.bin
+		tools/mkimage -A $(ARCH) -T firmware -C none \
 		-a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
-		-d $(obj)spl/u-boot-spl.bin $@
+		-d spl/u-boot-spl.bin $@
 		$(OBJCOPY) -I binary -O binary \
 			--pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff $@
-		cat $(obj)u-boot.img >> $@
+		cat u-boot.img >> $@
 
 ifneq ($(CONFIG_TEGRA),)
-$(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
-		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
-		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $@
-		rm $(obj)spl/u-boot-spl-pad.bin
+u-boot-nodtb-tegra.bin: spl/u-boot-spl.bin u-boot.bin
+		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary spl/u-boot-spl spl/u-boot-spl-pad.bin
+		cat spl/u-boot-spl-pad.bin u-boot.bin > $@
+		rm spl/u-boot-spl-pad.bin
 
 ifeq ($(CONFIG_OF_SEPARATE),y)
-$(obj)u-boot-dtb-tegra.bin: $(obj)u-boot-nodtb-tegra.bin $(obj)u-boot.dtb
-		cat $(obj)u-boot-nodtb-tegra.bin $(obj)u-boot.dtb > $@
+u-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin u-boot.dtb
+		cat u-boot-nodtb-tegra.bin u-boot.dtb > $@
 endif
 endif
 
-$(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
-		cat $(obj)spl/u-boot-spl.bin $(obj)u-boot.img > $@
+u-boot-img.bin: spl/u-boot-spl.bin u-boot.img
+		cat spl/u-boot-spl.bin u-boot.img > $@
 
 # PPC4xx needs the SPL at the end of the image, since the reset vector
 # is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target
 # and need to introduce a new build target with the full blown U-Boot
 # at the start padded up to the start of the SPL image. And then concat
 # the SPL image to the end.
-$(obj)u-boot-img-spl-at-end.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
+u-boot-img-spl-at-end.bin: spl/u-boot-spl.bin u-boot.img
 		$(OBJCOPY) -I binary -O binary --pad-to=$(CONFIG_UBOOT_PAD_TO) \
-			 --gap-fill=0xff $(obj)u-boot.img $@
-		cat $(obj)spl/u-boot-spl.bin >> $@
+			 --gap-fill=0xff u-boot.img $@
+		cat spl/u-boot-spl.bin >> $@
 
 # Create a new ELF from a raw binary file.  This is useful for arm64
 # where static relocation needs to be performed on the raw binary,
 # but certain simulators only accept an ELF file (but don't do the
 # relocation).
 # FIXME refactor dts/Makefile to share target/arch detection
-$(obj)u-boot.elf: $(obj)u-boot.bin
+u-boot.elf: u-boot.bin
 	@$(OBJCOPY)  -B aarch64 -I binary -O elf64-littleaarch64 \
-		$< $(obj)u-boot-elf.o
-	@$(LD) $(obj)u-boot-elf.o -o $@ \
+		$< u-boot-elf.o
+	@$(LD) u-boot-elf.o -o $@ \
 		--defsym=_start=$(CONFIG_SYS_TEXT_BASE) \
 		-Ttext=$(CONFIG_SYS_TEXT_BASE)
 
 ifeq ($(CONFIG_SANDBOX),y)
 GEN_UBOOT = \
-		cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
-			-Wl,--start-group $(__LIBS) -Wl,--end-group \
+		$(CC) $(SYMS) -T u-boot.lds \
+			-Wl,--start-group $(LIBS) -Wl,--end-group \
 			$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
 else
 GEN_UBOOT = \
-		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
-			$(__OBJS) \
-			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
+		$(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
+			$(OBJS) \
+			--start-group $(LIBS) --end-group $(PLATFORM_LIBS) \
 			-Map u-boot.map -o u-boot
 endif
 
-$(obj)u-boot:	depend \
-		$(SUBDIR_TOOLS) $(OBJS) $(LIBS) $(obj)u-boot.lds
+u-boot:	depend $(SUBDIR_TOOLS) $(OBJS) $(LIBS) u-boot.lds
 		$(GEN_UBOOT)
 ifeq ($(CONFIG_KALLSYMS),y)
-		smap=`$(call SYSTEM_MAP,$(obj)u-boot) | \
+		smap=`$(call SYSTEM_MAP,u-boot) | \
 			awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
 		$(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \
-			-c common/system_map.c -o $(obj)common/system_map.o
-		$(GEN_UBOOT) $(obj)common/system_map.o
+			-c $(srctree)/common/system_map.c -o common/system_map.o
+		$(GEN_UBOOT) common/system_map.o
 endif
 
 $(OBJS):
 	@:
 
 $(LIBS):	depend $(SUBDIR_TOOLS)
-		$(MAKE) $(build) $(dir $(subst $(obj),,$@))
+		$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
 
 $(SUBDIRS):	depend
-		$(MAKE) $(build) $@ all
+		$(MAKE) $(build)=$@ all
 
-$(SUBDIR_EXAMPLES-y): $(obj)u-boot
+$(SUBDIR_EXAMPLES-y): u-boot
 
-$(obj)u-boot.lds: $(LDSCRIPT) depend
+u-boot.lds: $(LDSCRIPT) depend
 		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 nand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
-		$(MAKE) $(build) nand_spl/board/$(BOARDDIR) all
+		$(MAKE) $(build)=nand_spl/board/$(BOARDDIR) all
 
-$(obj)u-boot-nand.bin:	nand_spl $(obj)u-boot.bin
-		cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
+u-boot-nand.bin:	nand_spl u-boot.bin
+		cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin
 
-$(obj)spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend
-		$(MAKE) -C spl all
+spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend
+		$(MAKE) obj=spl -f $(srctree)/spl/Makefile all
 
-$(obj)tpl/u-boot-tpl.bin:	$(SUBDIR_TOOLS) depend
-		$(MAKE) -C spl all CONFIG_TPL_BUILD=y
+tpl/u-boot-tpl.bin:	$(SUBDIR_TOOLS) depend
+		$(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y
 
 # Explicitly make _depend in subdirs containing multiple targets to prevent
 # parallel sub-makes creating .depend files simultaneously.
 depend dep:	$(TIMESTAMP_FILE) $(VERSION_FILE) \
-		$(obj)include/spl-autoconf.mk \
-		$(obj)include/tpl-autoconf.mk \
-		$(obj)include/autoconf.mk \
-		$(obj)include/generated/generic-asm-offsets.h \
-		$(obj)include/generated/asm-offsets.h
+		include/spl-autoconf.mk \
+		include/tpl-autoconf.mk \
+		include/autoconf.mk \
+		include/generated/generic-asm-offsets.h \
+		include/generated/asm-offsets.h
 
 TAG_SUBDIRS = $(SUBDIRS)
-TAG_SUBDIRS += $(dir $(__LIBS))
+TAG_SUBDIRS += $(dir $(LIBS))
 TAG_SUBDIRS += include
 
 FIND := find
 FINDFLAGS := -L
 
 checkstack:
-		$(CROSS_COMPILE)objdump -d $(obj)u-boot \
-			`$(FIND) $(obj) -name u-boot-spl -print` | \
-			perl $(src)scripts/checkstack.pl $(ARCH)
+		$(CROSS_COMPILE)objdump -d u-boot \
+			`$(FIND) . -name u-boot-spl -print` | \
+			perl $(src)/scripts/checkstack.pl $(ARCH)
 
 tags ctags:
-		ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
+		ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
 						-name '*.[chS]' -print`
 
 etags:
@@ -746,7 +769,7 @@ SYSTEM_MAP = \
 		$(NM) $1 | \
 		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
 		LC_ALL=C sort
-$(obj)System.map:	$(obj)u-boot
+System.map:	u-boot
 		@$(call SYSTEM_MAP,$<) > $@
 
 checkthumb:
@@ -778,76 +801,76 @@ checkdtc:
 # This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
 # the dep file is only include in this top level makefile to determine when
 # to regenerate the autoconf.mk file.
-$(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
+include/autoconf.mk.dep: include/config.h include/common.h
 	@$(XECHO) Generating $@ ; \
 	: Generate the dependancies ; \
 	$(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \
-		-MQ $(obj)include/autoconf.mk include/common.h > $@ || \
+		-MQ include/autoconf.mk $(srctree)/include/common.h > $@ || \
 		rm $@
 
-$(obj)include/autoconf.mk: $(obj)include/config.h
+include/autoconf.mk: include/config.h
 	@$(XECHO) Generating $@ ; \
 	: Extract the config macros ; \
-	$(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
-		sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
+	$(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
+		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
 	rm $@.tmp
 
 # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
-$(obj)include/tpl-autoconf.mk: $(obj)include/config.h
+include/tpl-autoconf.mk: include/config.h
 	@$(XECHO) Generating $@ ; \
 	: Extract the config macros ; \
 	$(CPP) $(CFLAGS) -DCONFIG_TPL_BUILD  -DCONFIG_SPL_BUILD\
-			-DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
-		sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
+			-DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
+		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
 	rm $@.tmp
 
-$(obj)include/spl-autoconf.mk: $(obj)include/config.h
+include/spl-autoconf.mk: include/config.h
 	@$(XECHO) Generating $@ ; \
 	: Extract the config macros ; \
-	$(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
-		sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
+	$(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
+		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
 	rm $@.tmp
 
-$(obj)include/generated/generic-asm-offsets.h: $(obj)lib/asm-offsets.s
+include/generated/generic-asm-offsets.h: lib/asm-offsets.s
 	@$(XECHO) Generating $@
-	tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@
+	$(srctree)/tools/scripts/make-asm-offsets lib/asm-offsets.s $@
 
-$(obj)lib/asm-offsets.s: $(obj)include/config.h $(src)lib/asm-offsets.c
-	@mkdir -p $(obj)lib
+lib/asm-offsets.s: include/config.h $(srctree)/lib/asm-offsets.c
+	@mkdir -p lib
 	$(CC) -DDO_DEPS_ONLY \
 		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
-		-o $@ $(src)lib/asm-offsets.c -c -S
+		-o $@ $(srctree)/lib/asm-offsets.c -c -S
 
-$(obj)include/generated/asm-offsets.h: $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
+include/generated/asm-offsets.h: $(CPUDIR)/$(SOC)/asm-offsets.s
 	@$(XECHO) Generating $@
-	tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@
+	$(srctree)/tools/scripts/make-asm-offsets $(CPUDIR)/$(SOC)/asm-offsets.s $@
 
-$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s: $(obj)include/config.h
-	@mkdir -p $(obj)$(CPUDIR)/$(SOC)
-	if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
+$(CPUDIR)/$(SOC)/asm-offsets.s:	include/config.h
+	@mkdir -p $(CPUDIR)/$(SOC)
+	if [ -f $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
 		$(CC) -DDO_DEPS_ONLY \
 		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
-			-o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
+			-o $@ $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
 	else \
 		touch $@; \
 	fi
 
 #########################################################################
 else	# !config.mk
-all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
-$(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \
+all u-boot.hex u-boot.srec u-boot.bin \
+u-boot.img u-boot.dis u-boot \
 $(filter-out tools,$(SUBDIRS)) \
-depend dep tags ctags etags cscope $(obj)System.map:
+depend dep tags ctags etags cscope System.map:
 	@echo "System not configured - see README" >&2
 	@ exit 1
 
 tools: $(VERSION_FILE) $(TIMESTAMP_FILE)
-	$(MAKE) $(build) $@ all
+	$(MAKE) $(build)=$@ all
 endif	# config.mk
 
 # ARM relocations should all be R_ARM_RELATIVE (32-bit) or
 # R_AARCH64_RELATIVE (64-bit).
-checkarmreloc: $(obj)u-boot
+checkarmreloc: u-boot
 	@RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \
 		grep R_A | sort -u`"; \
 	if test "$$RELOC" != "R_ARM_RELATIVE" -a \
@@ -877,15 +900,15 @@ $(TIMESTAMP_FILE):
 		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
 
 easylogo env gdb:
-	$(MAKE) $(build) tools/$@ MTD_VERSION=${MTD_VERSION}
+	$(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION}
 
 gdbtools: gdb
 
 xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc
-	$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) -C doc/DocBook/ $@
+	$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) $(build)=doc/DocBook $@
 
 tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
-	$(MAKE) $(build) tools HOST_TOOLS_ALL=y
+	$(MAKE) $(build)=tools HOST_TOOLS_ALL=y
 
 .PHONY : CHANGELOG
 CHANGELOG:
@@ -897,57 +920,52 @@ include/license.h: tools/bin2header COPYING
 #########################################################################
 
 unconfig:
-	@rm -f $(obj)include/config.h $(obj)include/config.mk \
-		$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
-		$(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep \
-		$(obj)include/spl-autoconf.mk \
-		$(obj)include/tpl-autoconf.mk
+	@rm -f include/config.h include/config.mk \
+		board/*/config.tmp board/*/*/config.tmp \
+		include/autoconf.mk include/autoconf.mk.dep \
+		include/spl-autoconf.mk \
+		include/tpl-autoconf.mk
 
 %_config::	unconfig
 	@$(MKCONFIG) -A $(@:_config=)
 
-sinclude $(obj).boards.depend
-$(obj).boards.depend:	boards.cfg
-	@awk '(NF && $$1 !~ /^#/) { print $$7 ": " $$7 "_config; $$(MAKE)" }' $< > $@
-
-#########################################################################
 #########################################################################
 
 clean:
-	@rm -f $(obj)examples/standalone/atmel_df_pow2			  \
-	       $(obj)examples/standalone/hello_world			  \
-	       $(obj)examples/standalone/interrupt			  \
-	       $(obj)examples/standalone/mem_to_mem_idma2intr		  \
-	       $(obj)examples/standalone/sched				  \
-	       $(addprefix $(obj)examples/standalone/, smc91111_eeprom smc911x_eeprom) \
-	       $(obj)examples/standalone/test_burst			  \
-	       $(obj)examples/standalone/timer
-	@rm -f $(addprefix $(obj)examples/api/, demo demo.bin)
-	@rm -f $(obj)tools/bmp_logo	   $(obj)tools/easylogo/easylogo  \
-	       $(obj)tools/env/fw_printenv				  \
-	       $(obj)tools/envcrc					  \
-	       $(addprefix $(obj)tools/gdb/, gdbcont gdbsend)		  \
-	       $(obj)tools/gen_eth_addr    $(obj)tools/img2srec		  \
-	       $(obj)tools/dumpimage					  \
-	       $(addprefix $(obj)tools/, mkenvimage mkimage)		  \
-	       $(obj)tools/mpc86x_clk					  \
-	       $(addprefix $(obj)tools/, mk$(BOARD)spl mkexynosspl)	  \
-	       $(obj)tools/mxsboot					  \
-	       $(obj)tools/ncb		   $(obj)tools/ubsha1		  \
-	       $(obj)tools/kernel-doc/docproc				  \
-	       $(obj)tools/proftool
-	@rm -f $(addprefix $(obj)board/cray/L1/, bootscript.c bootscript.image) \
-	       $(obj)board/matrix_vision/*/bootscript.img		  \
-	       $(obj)spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl	  \
-	       $(obj)u-boot.lds						  \
-	       $(addprefix $(obj)arch/blackfin/cpu/, init.lds init.elf)
-	@rm -f $(obj)include/bmp_logo.h
-	@rm -f $(obj)include/bmp_logo_data.h
-	@rm -f $(obj)lib/asm-offsets.s
-	@rm -f $(obj)include/generated/asm-offsets.h
-	@rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
+	@rm -f examples/standalone/atmel_df_pow2			  \
+	       examples/standalone/hello_world				  \
+	       examples/standalone/interrupt				  \
+	       examples/standalone/mem_to_mem_idma2intr			  \
+	       examples/standalone/sched				  \
+	       $(addprefix examples/standalone/, smc91111_eeprom smc911x_eeprom) \
+	       examples/standalone/test_burst				  \
+	       examples/standalone/timer
+	@rm -f $(addprefix examples/api/, demo demo.bin)
+	@rm -f tools/bmp_logo	   tools/easylogo/easylogo		  \
+	       tools/env/fw_printenv					  \
+	       tools/envcrc						  \
+	       $(addprefix tools/gdb/, gdbcont gdbsend)			  \
+	       tools/gen_eth_addr    tools/img2srec			  \
+	       tools/dumpimage						  \
+	       $(addprefix tools/, mkenvimage mkimage)			  \
+	       tools/mpc86x_clk						  \
+	       $(addprefix tools/, mk$(BOARD)spl mkexynosspl)		  \
+	       tools/mxsboot						  \
+	       tools/ncb		   tools/ubsha1			  \
+	       tools/kernel-doc/docproc					  \
+	       tools/proftool
+	@rm -f $(addprefix board/cray/L1/, bootscript.c bootscript.image) \
+	       board/matrix_vision/*/bootscript.img			  \
+	       spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl		  \
+	       u-boot.lds						  \
+	       $(addprefix arch/blackfin/cpu/, init.lds init.elf)
+	@rm -f include/bmp_logo.h
+	@rm -f include/bmp_logo_data.h
+	@rm -f lib/asm-offsets.s
+	@rm -f include/generated/asm-offsets.h
+	@rm -f $(CPUDIR)/$(SOC)/asm-offsets.s
 	@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
-	@$(MAKE) -s -C doc/DocBook/ cleandocs
+	@$(MAKE) -f $(srctree)/doc/DocBook/Makefile cleandocs
 	@find $(OBJTREE) -type f \
 		\( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
 		-o -name '*.o'	-o -name '*.a' -o -name '*.exe' \
@@ -962,38 +980,38 @@ clobber:	tidy
 	@find $(OBJTREE) -type f \( -name '*.srec' \
 		-o -name '*.bin' -o -name u-boot.img \) \
 		-print0 | xargs -0 rm -f
-	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
-		$(obj)cscope.* $(obj)*.*~
-	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y)
-	@rm -f $(obj)u-boot.kwb
-	@rm -f $(obj)u-boot.pbl
-	@rm -f $(obj)u-boot.imx
-	@rm -f $(obj)u-boot-with-spl.imx
-	@rm -f $(obj)u-boot-with-nand-spl.imx
-	@rm -f $(obj)u-boot.ubl
-	@rm -f $(obj)u-boot.ais
-	@rm -f $(obj)u-boot.dtb
-	@rm -f $(obj)u-boot.sb
-	@rm -f $(obj)u-boot.spr
-	@rm -f $(addprefix $(obj)nand_spl/, u-boot.lds u-boot.lst System.map)
-	@rm -f $(addprefix $(obj)nand_spl/, u-boot-nand_spl.lds u-boot-spl u-boot-spl.map)
-	@rm -f $(addprefix $(obj)spl/, u-boot-spl u-boot-spl.bin u-boot-spl.map)
-	@rm -f $(obj)spl/u-boot-spl.lds
-	@rm -f $(addprefix $(obj)tpl/, u-boot-tpl u-boot-tpl.bin u-boot-tpl.map)
-	@rm -f $(obj)tpl/u-boot-spl.lds
-	@rm -f $(obj)MLO MLO.byteswap
-	@rm -f $(obj)SPL
-	@rm -f $(obj)tools/xway-swap-bytes
-	@rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
-	@rm -fr $(obj)include/generated
-	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
-	@rm -f $(obj)dts/*.tmp
-	@rm -f $(addprefix $(obj)spl/, u-boot-spl.ais, u-boot-spl-pad.ais)
+	@rm -f $(OBJS) *.bak ctags etags TAGS \
+		cscope.* *.*~
+	@rm -f u-boot u-boot.map u-boot.hex $(ALL-y)
+	@rm -f u-boot.kwb
+	@rm -f u-boot.pbl
+	@rm -f u-boot.imx
+	@rm -f u-boot-with-spl.imx
+	@rm -f u-boot-with-nand-spl.imx
+	@rm -f u-boot.ubl
+	@rm -f u-boot.ais
+	@rm -f u-boot.dtb
+	@rm -f u-boot.sb
+	@rm -f u-boot.spr
+	@rm -f $(addprefix nand_spl/, u-boot.lds u-boot.lst System.map)
+	@rm -f $(addprefix nand_spl/, u-boot-nand_spl.lds u-boot-spl u-boot-spl.map)
+	@rm -f $(addprefix spl/, u-boot-spl u-boot-spl.bin u-boot-spl.map)
+	@rm -f spl/u-boot-spl.lds
+	@rm -f $(addprefix tpl/, u-boot-tpl u-boot-tpl.bin u-boot-tpl.map)
+	@rm -f tpl/u-boot-spl.lds
+	@rm -f MLO MLO.byteswap
+	@rm -f SPL
+	@rm -f tools/xway-swap-bytes
+	@rm -fr include/asm/proc include/asm/arch include/asm
+	@rm -fr include/generated
+	@[ ! -d nand_spl ] || find nand_spl -name "*" -type l -print | xargs rm -f
+	@rm -f dts/*.tmp
+	@rm -f $(addprefix spl/, u-boot-spl.ais, u-boot-spl-pad.ais)
 
 mrproper \
 distclean:	clobber unconfig
 ifneq ($(OBJTREE),$(SRCTREE))
-	rm -rf $(obj)*
+	rm -rf *
 endif
 
 backup:
@@ -1001,3 +1019,12 @@ backup:
 	gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
 
 #########################################################################
+
+endif	# skip-makefile
+
+PHONY += FORCE
+FORCE:
+
+# Declare the contents of the .PHONY variable as phony.  We keep that
+# information in a variable so we can use it in if_changed and friends.
+.PHONY: $(PHONY)
diff --git a/arch/arm/cpu/arm1136/config.mk b/arch/arm/cpu/arm1136/config.mk
index f74228c..ab1fc4a 100644
--- a/arch/arm/cpu/arm1136/config.mk
+++ b/arch/arm/cpu/arm1136/config.mk
@@ -14,6 +14,6 @@ ifdef CONFIG_SPL_BUILD
 ALL-y	+= $(OBJTREE)/SPL
 endif
 else
-ALL-y	+= $(obj)u-boot.imx
+ALL-y	+= u-boot.imx
 endif
 endif
diff --git a/arch/arm/cpu/arm926ejs/config.mk b/arch/arm/cpu/arm926ejs/config.mk
index 4d9895f..f27ca15 100644
--- a/arch/arm/cpu/arm926ejs/config.mk
+++ b/arch/arm/cpu/arm926ejs/config.mk
@@ -13,6 +13,6 @@ ifdef CONFIG_SPL_BUILD
 ALL-y	+= $(OBJTREE)/SPL
 endif
 else
-ALL-y	+= $(obj)u-boot.imx
+ALL-y	+= u-boot.imx
 endif
 endif
diff --git a/arch/arm/cpu/arm926ejs/davinci/config.mk b/arch/arm/cpu/arm926ejs/davinci/config.mk
index d5c978b..69e9d5a 100644
--- a/arch/arm/cpu/arm926ejs/davinci/config.mk
+++ b/arch/arm/cpu/arm926ejs/davinci/config.mk
@@ -4,5 +4,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 ifndef CONFIG_SPL_BUILD
-ALL-$(CONFIG_SPL_FRAMEWORK)	+= $(obj)u-boot.ais
+ALL-$(CONFIG_SPL_FRAMEWORK)	+= u-boot.ais
 endif
diff --git a/arch/arm/cpu/armv7/am33xx/config.mk b/arch/arm/cpu/armv7/am33xx/config.mk
index 8e3668f..1c06fb4 100644
--- a/arch/arm/cpu/armv7/am33xx/config.mk
+++ b/arch/arm/cpu/armv7/am33xx/config.mk
@@ -7,5 +7,5 @@ ifdef CONFIG_SPL_BUILD
 ALL-y	+= $(OBJTREE)/MLO
 ALL-$(CONFIG_SPL_SPI_SUPPORT) += $(OBJTREE)/MLO.byteswap
 else
-ALL-y	+= $(obj)u-boot.img
+ALL-y	+= u-boot.img
 endif
diff --git a/arch/arm/cpu/armv7/config.mk b/arch/arm/cpu/armv7/config.mk
index 38b7c40..d01f3d9 100644
--- a/arch/arm/cpu/armv7/config.mk
+++ b/arch/arm/cpu/armv7/config.mk
@@ -20,6 +20,6 @@ ifdef CONFIG_SPL_BUILD
 ALL-y	+= $(OBJTREE)/SPL
 endif
 else
-ALL-y	+= $(obj)u-boot.imx
+ALL-y	+= u-boot.imx
 endif
 endif
diff --git a/arch/arm/cpu/armv7/omap3/config.mk b/arch/arm/cpu/armv7/omap3/config.mk
index 1d6a57c..2a3d1c5 100644
--- a/arch/arm/cpu/armv7/omap3/config.mk
+++ b/arch/arm/cpu/armv7/omap3/config.mk
@@ -11,5 +11,5 @@
 ifdef CONFIG_SPL_BUILD
 ALL-y	+= $(OBJTREE)/MLO
 else
-ALL-y	+= $(obj)u-boot.img
+ALL-y	+= u-boot.img
 endif
diff --git a/arch/arm/cpu/armv7/omap4/config.mk b/arch/arm/cpu/armv7/omap4/config.mk
index 1d6a57c..2a3d1c5 100644
--- a/arch/arm/cpu/armv7/omap4/config.mk
+++ b/arch/arm/cpu/armv7/omap4/config.mk
@@ -11,5 +11,5 @@
 ifdef CONFIG_SPL_BUILD
 ALL-y	+= $(OBJTREE)/MLO
 else
-ALL-y	+= $(obj)u-boot.img
+ALL-y	+= u-boot.img
 endif
diff --git a/arch/arm/cpu/armv7/omap5/config.mk b/arch/arm/cpu/armv7/omap5/config.mk
index 2673af9..261b272 100644
--- a/arch/arm/cpu/armv7/omap5/config.mk
+++ b/arch/arm/cpu/armv7/omap5/config.mk
@@ -9,5 +9,5 @@
 ifdef CONFIG_SPL_BUILD
 ALL-y	+= $(OBJTREE)/MLO
 else
-ALL-y	+= $(obj)u-boot.img
+ALL-y	+= u-boot.img
 endif
diff --git a/arch/arm/cpu/armv7/socfpga/config.mk b/arch/arm/cpu/armv7/socfpga/config.mk
index d33ab7d..3d18491 100644
--- a/arch/arm/cpu/armv7/socfpga/config.mk
+++ b/arch/arm/cpu/armv7/socfpga/config.mk
@@ -4,5 +4,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 ifndef CONFIG_SPL_BUILD
-ALL-y	+= $(obj)u-boot.img
+ALL-y	+= u-boot.img
 endif
diff --git a/arch/blackfin/config.mk b/arch/blackfin/config.mk
index 73fa798..c752025 100644
--- a/arch/blackfin/config.mk
+++ b/arch/blackfin/config.mk
@@ -12,7 +12,7 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x1000 -m elf32bfin
 ifeq ($(CONFIG_BFIN_CPU),)
 CONFIG_BFIN_CPU := \
 	$(shell awk '$$2 == "CONFIG_BFIN_CPU" { print $$3 }' \
-		$(src)include/configs/$(BOARD).h)
+		$(srctree)/include/configs/$(BOARD).h)
 else
 CONFIG_BFIN_CPU := $(strip $(CONFIG_BFIN_CPU:"%"=%))
 endif
@@ -28,10 +28,10 @@ PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
 PLATFORM_RELFLAGS += -mcpu=$(CONFIG_BFIN_CPU)
 
 ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS)
-ALL-y += $(obj)u-boot.ldr
+ALL-y += u-boot.ldr
 endif
 ifeq ($(CONFIG_ENV_IS_EMBEDDED_IN_LDR),y)
-CREATE_LDR_ENV = $(obj)tools/envcrc --binary > $(obj)env-ldr.o
+CREATE_LDR_ENV = tools/envcrc --binary > env-ldr.o
 HOSTCFLAGS_NOPED_ADSP := \
 	$(shell $(CPP) -dD - -mcpu=$(CONFIG_BFIN_CPU) </dev/null \
 		| awk '$$2 ~ /ADSP/ { print "-D" $$2 }')
@@ -47,10 +47,10 @@ LDR_FLAGS-$(CONFIG_BFIN_BOOTROM_USES_EVT1) += -J
 
 LDR_FLAGS += --bmode $(subst BFIN_BOOT_,,$(CONFIG_BFIN_BOOT_MODE))
 LDR_FLAGS += --use-vmas
-LDR_FLAGS += --initcode $(obj)$(CPUDIR)/initcode.o
+LDR_FLAGS += --initcode $(CPUDIR)/initcode.o
 ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_UART)
 LDR_FLAGS-$(CONFIG_ENV_IS_EMBEDDED_IN_LDR) += \
-	--punchit $$(($(CONFIG_ENV_OFFSET))):$$(($(CONFIG_ENV_SIZE))):$(obj)env-ldr.o
+	--punchit $$(($(CONFIG_ENV_OFFSET))):$$(($(CONFIG_ENV_SIZE))):env-ldr.o
 endif
 ifneq (,$(findstring s,$(MAKEFLAGS)))
 LDR_FLAGS += --quiet
diff --git a/arch/blackfin/cpu/Makefile b/arch/blackfin/cpu/Makefile
index a61594a..369dc74 100644
--- a/arch/blackfin/cpu/Makefile
+++ b/arch/blackfin/cpu/Makefile
@@ -25,9 +25,9 @@ extra-y += check_initcode
 
 # make sure our initcode (which goes into LDR) does not
 # have relocs or external references
-$(obj)initcode.o: CFLAGS += -fno-function-sections -fno-data-sections
+$(obj)/initcode.o: CFLAGS += -fno-function-sections -fno-data-sections
 READINIT = env LC_ALL=C $(CROSS_COMPILE)readelf -s $<
-$(obj)check_initcode: $(obj)initcode.o
+$(obj)/check_initcode: $(obj)/initcode.o
 ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS)
 	@if $(READINIT) | grep '\<GLOBAL\>.*\<UND\>' ; then \
 		echo "$< contains external references!" 1>&2 ; \
@@ -35,7 +35,7 @@ ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS)
 	fi
 endif
 
-$(obj)init.lds: init.lds.S
+$(obj)/init.lds: $(src)/init.lds.S
 	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P $^ -o $@
-$(obj)init.elf: $(obj)init.lds $(obj)init.o $(obj)initcode.o
+$(obj)/init.elf: $(obj)/init.lds $(obj)/init.o $(obj)/initcode.o
 	$(LD) $(LDFLAGS) -T $^ -o $@
diff --git a/arch/mips/cpu/mips32/config.mk b/arch/mips/cpu/mips32/config.mk
index 067f871..7ee7faa 100644
--- a/arch/mips/cpu/mips32/config.mk
+++ b/arch/mips/cpu/mips32/config.mk
@@ -21,4 +21,4 @@ else
 PLATFORM_LDFLAGS  += -m elf32ltsmip
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 -T mips.lds
+CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 -T $(srctree)/$(src)/mips.lds
diff --git a/arch/mips/cpu/mips64/config.mk b/arch/mips/cpu/mips64/config.mk
index d1a8b2c..02113a1 100644
--- a/arch/mips/cpu/mips64/config.mk
+++ b/arch/mips/cpu/mips64/config.mk
@@ -21,4 +21,4 @@ else
 PLATFORM_LDFLAGS  += -m elf64ltsmip
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0xffffffff80200000 -T mips64.lds
+CONFIG_STANDALONE_LOAD_ADDR ?= 0xffffffff80200000 -T $(srctree)/$(src)/mips64.lds
diff --git a/arch/mips/cpu/xburst/config.mk b/arch/mips/cpu/xburst/config.mk
index d81da21..00b0fd9 100644
--- a/arch/mips/cpu/xburst/config.mk
+++ b/arch/mips/cpu/xburst/config.mk
@@ -12,4 +12,4 @@ else
 PLATFORM_LDFLAGS  += -m elf32ltsmip
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 -T mips.lds
+CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 -T $(srctree)/$(src)/mips.lds
diff --git a/arch/nds32/config.mk b/arch/nds32/config.mk
index e93e3a8..550f8a4 100644
--- a/arch/nds32/config.mk
+++ b/arch/nds32/config.mk
@@ -10,7 +10,7 @@
 
 CROSS_COMPILE ?= nds32le-linux-
 
-CONFIG_STANDALONE_LOAD_ADDR = 0x300000 -T nds32.lds
+CONFIG_STANDALONE_LOAD_ADDR = 0x300000 -T $(srctree)/$(src)/nds32.lds
 
 PLATFORM_RELFLAGS	+= -fno-strict-aliasing -fno-common -mrelax
 PLATFORM_RELFLAGS	+= -gdwarf-2
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index a706d3c..ac780d4 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -54,11 +54,11 @@ ifndef CONFIG_SPL_BUILD
 # Workaround for local bus unaligned access problems
 # on MPC512x and MPC5200
 ifdef CONFIG_MPC512X
-$(obj)ppcstring.o: AFLAGS += -Dmemcpy=__memcpy
+$(obj)/ppcstring.o: AFLAGS += -Dmemcpy=__memcpy
 obj-y += memcpy_mpc5200.o
 endif
 ifdef CONFIG_MPC5200
-$(obj)ppcstring.o: AFLAGS += -Dmemcpy=__memcpy
+$(obj)/ppcstring.o: AFLAGS += -Dmemcpy=__memcpy
 obj-y += memcpy_mpc5200.o
 endif
 endif
diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile
index b564294..c5f5426 100644
--- a/arch/sandbox/cpu/Makefile
+++ b/arch/sandbox/cpu/Makefile
@@ -10,7 +10,7 @@
 obj-y	:= cpu.o os.o start.o state.o
 
 # os.c is build in the system environment, so needs standard includes
-$(obj)os.o: CFLAGS := $(filter-out -nostdinc,\
+$(obj)/os.o: CFLAGS := $(filter-out -nostdinc,\
 	$(patsubst -I%,-idirafter%,$(CFLAGS)))
-$(obj).depend.os: CPPFLAGS := $(filter-out -nostdinc,\
+$(obj)/.depend.os: CPPFLAGS := $(filter-out -nostdinc,\
 	$(patsubst -I%,-idirafter%,$(CPPFLAGS)))
diff --git a/arch/sparc/config.mk b/arch/sparc/config.mk
index e94e7cb..9bb3724 100644
--- a/arch/sparc/config.mk
+++ b/arch/sparc/config.mk
@@ -7,6 +7,7 @@
 
 CROSS_COMPILE ?= sparc-elf-
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) -T sparc.lds
+CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) \
+			-T $(srctree)/$(src)/sparc.lds
 
 PLATFORM_CPPFLAGS += -DCONFIG_SPARC -D__sparc__
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 638f790..a35d062 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -23,5 +23,5 @@ obj-$(CONFIG_CMD_ZBOOT)	+= zimage.o
 LIBGCC := $(notdir $(NORMAL_LIBGCC))
 extra-y := $(LIBGCC)
 
-$(obj)$(LIBGCC): $(NORMAL_LIBGCC)
+$(obj)/$(LIBGCC): $(NORMAL_LIBGCC)
 	$(OBJCOPY) $< $@ --prefix-symbols=__normal_
diff --git a/board/ait/cam_enc_4xx/config.mk b/board/ait/cam_enc_4xx/config.mk
index d7e7894..c7cfaca 100644
--- a/board/ait/cam_enc_4xx/config.mk
+++ b/board/ait/cam_enc_4xx/config.mk
@@ -9,7 +9,7 @@
 
 UBL_CONFIG = $(SRCTREE)/board/$(BOARDDIR)/ublimage.cfg
 ifndef CONFIG_SPL_BUILD
-ALL-y += $(obj)u-boot.ubl
+ALL-y += u-boot.ubl
 else
 # as SPL_TEXT_BASE is not page-aligned, we need for some
 # linkers the -n flag (Do not page align data), to prevent
diff --git a/board/avionic-design/medcom-wide/Makefile b/board/avionic-design/medcom-wide/Makefile
index 87e1912..bcf7ccf 100644
--- a/board/avionic-design/medcom-wide/Makefile
+++ b/board/avionic-design/medcom-wide/Makefile
@@ -9,4 +9,4 @@
 
 obj-y	:= ../common/tamonten.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
diff --git a/board/avionic-design/plutux/Makefile b/board/avionic-design/plutux/Makefile
index 87e1912..bcf7ccf 100644
--- a/board/avionic-design/plutux/Makefile
+++ b/board/avionic-design/plutux/Makefile
@@ -9,4 +9,4 @@
 
 obj-y	:= ../common/tamonten.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
diff --git a/board/avionic-design/tec-ng/Makefile b/board/avionic-design/tec-ng/Makefile
index 79d8602..a556b92 100644
--- a/board/avionic-design/tec-ng/Makefile
+++ b/board/avionic-design/tec-ng/Makefile
@@ -7,4 +7,4 @@
 
 obj-y	:= ../common/tamonten-ng.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
diff --git a/board/avionic-design/tec/Makefile b/board/avionic-design/tec/Makefile
index 87e1912..bcf7ccf 100644
--- a/board/avionic-design/tec/Makefile
+++ b/board/avionic-design/tec/Makefile
@@ -9,4 +9,4 @@
 
 obj-y	:= ../common/tamonten.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
diff --git a/board/compal/paz00/Makefile b/board/compal/paz00/Makefile
index b2d3b6b..e6a0b29 100644
--- a/board/compal/paz00/Makefile
+++ b/board/compal/paz00/Makefile
@@ -16,4 +16,4 @@
 
 obj-y	:= paz00.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
diff --git a/board/compulab/trimslice/Makefile b/board/compulab/trimslice/Makefile
index f3bd00d..311eb92 100644
--- a/board/compulab/trimslice/Makefile
+++ b/board/compulab/trimslice/Makefile
@@ -7,4 +7,4 @@
 
 obj-y	:= trimslice.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
diff --git a/board/cray/L1/Makefile b/board/cray/L1/Makefile
index 5f6c690..6aae9fa 100644
--- a/board/cray/L1/Makefile
+++ b/board/cray/L1/Makefile
@@ -9,8 +9,8 @@ obj-y	= L1.o flash.o
 obj-y	+= init.o
 obj-y	+= bootscript.o
 
-$(obj)bootscript.c: $(obj)bootscript.image
-	od -t x1 -v -A x $^ | awk -f x2c.awk > $@
+$(obj)/bootscript.c: $(obj)/bootscript.image
+	od -t x1 -v -A x $^ | awk -f $(srctree)/$(src)/x2c.awk > $@
 
-$(obj)bootscript.image: $(src)bootscript.hush $(src)Makefile
-	-$(OBJTREE)/tools/mkimage -A ppc -O linux -T script -C none -a 0 -e 0 -n bootscript -d $(src)bootscript.hush $@
+$(obj)/bootscript.image: $(src)/bootscript.hush
+	-$(OBJTREE)/tools/mkimage -A ppc -O linux -T script -C none -a 0 -e 0 -n bootscript -d $< $@
diff --git a/board/h2200/Makefile b/board/h2200/Makefile
index d4fa153..e516e91 100644
--- a/board/h2200/Makefile
+++ b/board/h2200/Makefile
@@ -10,5 +10,5 @@ obj-y	:= h2200.o
 
 extra-y := h2200-header.bin
 
-$(obj)h2200-header.bin: $(obj)h2200-header.o
+$(obj)/h2200-header.bin: $(obj)/h2200-header.o
 	$(OBJCOPY) -O binary $< $@
diff --git a/board/matrix_vision/mvblm7/Makefile b/board/matrix_vision/mvblm7/Makefile
index 879d794..1bc1d61 100644
--- a/board/matrix_vision/mvblm7/Makefile
+++ b/board/matrix_vision/mvblm7/Makefile
@@ -8,5 +8,5 @@ obj-y	:= mvblm7.o pci.o fpga.o
 
 extra-y := bootscript.img
 
-$(obj)bootscript.img:
-	@mkimage -T script -C none -n M7_script -d bootscript $@
+$(obj)/bootscript.img: $(src)/bootscript
+	@mkimage -T script -C none -n M7_script -d $< $@
diff --git a/board/matrix_vision/mvsmr/Makefile b/board/matrix_vision/mvsmr/Makefile
index b6a4f67..9454259 100644
--- a/board/matrix_vision/mvsmr/Makefile
+++ b/board/matrix_vision/mvsmr/Makefile
@@ -12,5 +12,5 @@ obj-y	:= mvsmr.o fpga.o
 
 extra-y := bootscript.img
 
-$(obj)bootscript.img: bootscript
+$(obj)/bootscript.img: $(src)/bootscript
 	@mkimage -T script -C none -n mvSMR_Script -d $< $@
diff --git a/board/nvidia/common/Makefile b/board/nvidia/common/Makefile
index e3fcf2b..e3b2651 100644
--- a/board/nvidia/common/Makefile
+++ b/board/nvidia/common/Makefile
@@ -1,4 +1,4 @@
 # Copyright (c) 2011 The Chromium OS Authors.
 # SPDX-License-Identifier:	GPL-2.0+
 
-include common.mk
+include $(src)/common.mk
diff --git a/board/pcs440ep/config.mk b/board/pcs440ep/config.mk
index 1e76128..b90d5d0 100644
--- a/board/pcs440ep/config.mk
+++ b/board/pcs440ep/config.mk
@@ -10,7 +10,7 @@
 #
 
 # Check the U-Boot Image with a SHA1 checksum
-ALL-y += $(obj)u-boot.sha1
+ALL-y += u-boot.sha1
 
 PLATFORM_CPPFLAGS += -DCONFIG_440=1
 
diff --git a/board/samsung/origen/Makefile b/board/samsung/origen/Makefile
index 31e88f4..37acba7 100644
--- a/board/samsung/origen/Makefile
+++ b/board/samsung/origen/Makefile
@@ -13,7 +13,7 @@ always := $(hostprogs-y)
 #
 # TODO:
 # Fix the root cause in tools/mkorigenspl.c and delete the following work-around
-$(obj)tools/mkorigenspl: HOSTCFLAGS:=$(filter-out -O2,$(HOSTCFLAGS))
+$(obj)/tools/mkorigenspl: HOSTCFLAGS:=$(filter-out -O2,$(HOSTCFLAGS))
 else
 obj-y	+= origen.o
 endif
diff --git a/common/Makefile b/common/Makefile
index 4d99ecd..a292ee8 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -234,11 +234,10 @@ obj-$(CONFIG_FIT_SIGNATURE) += image-sig.o
 obj-y += memsize.o
 obj-y += stdio.o
 
-$(obj)env_embedded.o: $(src)env_embedded.c
+$(obj)/env_embedded.o: $(src)/env_embedded.c
 	$(CC) $(AFLAGS) -Wa,--no-warn \
-		-DENV_CRC=$(shell $(obj)../tools/envcrc) \
-		-c -o $@ $(src)env_embedded.c
+		-DENV_CRC=$(shell tools/envcrc) -c -o $@ $<
 
 # SEE README.arm-unaligned-accesses
-$(obj)hush.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
-$(obj)fdt_support.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
+$(obj)/hush.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
+$(obj)/fdt_support.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
diff --git a/config.mk b/config.mk
index ed1a519..0fa3167 100644
--- a/config.mk
+++ b/config.mk
@@ -6,42 +6,6 @@
 #
 #########################################################################
 
-ifeq ($(CURDIR),$(SRCTREE))
-dir :=
-else
-dir := $(subst $(SRCTREE)/,,$(CURDIR))
-endif
-
-ifneq ($(OBJTREE),$(SRCTREE))
-# Create object files for SPL in a separate directory
-ifeq ($(CONFIG_SPL_BUILD),y)
-ifeq ($(CONFIG_TPL_BUILD),y)
-obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
-else
-obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
-endif
-else
-obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
-endif
-src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
-
-$(shell mkdir -p $(obj))
-else
-# Create object files for SPL in a separate directory
-ifeq ($(CONFIG_SPL_BUILD),y)
-ifeq ($(CONFIG_TPL_BUILD),y)
-obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
-else
-obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
-
-endif
-$(shell mkdir -p $(obj))
-else
-obj :=
-endif
-src :=
-endif
-
 # clean the slate ...
 PLATFORM_RELFLAGS =
 PLATFORM_CPPFLAGS =
@@ -52,14 +16,14 @@ PLATFORM_LDFLAGS =
 # Load generated board configuration
 ifeq ($(CONFIG_TPL_BUILD),y)
 # Include TPL autoconf
-sinclude $(OBJTREE)/include/tpl-autoconf.mk
+sinclude include/tpl-autoconf.mk
 else
 ifeq ($(CONFIG_SPL_BUILD),y)
 # Include SPL autoconf
-sinclude $(OBJTREE)/include/spl-autoconf.mk
+sinclude include/spl-autoconf.mk
 else
 # Include normal autoconf
-sinclude $(OBJTREE)/include/autoconf.mk
+sinclude include/autoconf.mk
 endif
 endif
 sinclude $(OBJTREE)/include/config.mk
diff --git a/doc/DocBook/Makefile b/doc/DocBook/Makefile
index 29b79d7..aa7c44b 100644
--- a/doc/DocBook/Makefile
+++ b/doc/DocBook/Makefile
@@ -6,8 +6,6 @@
 # To add a new book the only step required is to add the book to the
 # list of DOCBOOKS.
 
-include $(TOPDIR)/config.mk
-
 DOCBOOKS := fs.xml linker_lists.xml stdio.xml
 
 ###
@@ -122,7 +120,7 @@ quiet_cmd_db2pdf = PDF     $@
 
 
 index = index.html
-main_idx = $(index)
+main_idx = doc/DocBook/$(index)
 build_main_index = rm -rf $(main_idx); \
 		   echo '<h1>U-Boot Bootloader HTML Documentation</h1>' >> $(main_idx) && \
 		   echo '<h2>U-Boot Version: $(U_BOOT_VERSION)</h2>' >> $(main_idx) && \
@@ -151,7 +149,7 @@ quiet_cmd_db2man = MAN     $@
 	@(which xmlto > /dev/null 2>&1) || \
 	 (echo "*** You need to install xmlto ***"; \
 	  exit 1)
-	$(Q)mkdir -p $(obj)man
+	$(Q)mkdir -p $(obj)/man
 	$(call cmd_db2man)
 	@touch $@
 
diff --git a/drivers/bios_emulator/Makefile b/drivers/bios_emulator/Makefile
index 52a2ceb..330f36f 100644
--- a/drivers/bios_emulator/Makefile
+++ b/drivers/bios_emulator/Makefile
@@ -8,7 +8,7 @@ obj-y = atibios.o biosemu.o besys.o bios.o \
 	$(X86DIR)/sys.o \
 	$(X86DIR)/debug.o
 
-EXTRA_CFLAGS += -I. -I./include \
+EXTRA_CFLAGS += -I$(srctree)/$(src) -I$(srctree)/$(src)/include \
 	-D__PPC__  -D__BIG_ENDIAN__
 
 CFLAGS += $(EXTRA_CFLAGS)
diff --git a/dts/Makefile b/dts/Makefile
index 6c7198f..d81f32d 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -26,7 +26,7 @@ DTC_FLAGS := -R 4 -p 0x1000 \
 # Use a constant name for this so we can access it from C code.
 # objcopy doesn't seem to allow us to set the symbol name independently of
 # the filename.
-DT_BIN	:= $(obj)dt.dtb
+DT_BIN	:= $(obj)/dt.dtb
 
 $(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts
 	$(CPP) $(DTS_CPPFLAGS) $< -o $(DT_BIN).dts.tmp
@@ -38,7 +38,7 @@ process_lds = \
 # Run the compiler and get the link script from the linker
 GET_LDS = $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--verbose 2>&1
 
-$(obj)dt.o: $(DT_BIN)
+$(obj)/dt.o: $(DT_BIN)
 	# We want the output format and arch.
 	# We also hope to win a prize for ugliest Makefile / shell interaction
 	# We look in the LDSCRIPT first.
@@ -62,7 +62,7 @@ $(obj)dt.o: $(DT_BIN)
 	\
 	cd $(dir ${DT_BIN}) && \
 	$(OBJCOPY) -I binary -O $${oformat} -B $${oarch} \
-		$(notdir ${DT_BIN}) $@
+		$(notdir ${DT_BIN}) $(notdir $@)
 	rm $(DT_BIN)
 
 obj-$(CONFIG_OF_EMBED)	:= dt.o
diff --git a/examples/api/Makefile b/examples/api/Makefile
index ee3c487..db0bb34 100644
--- a/examples/api/Makefile
+++ b/examples/api/Makefile
@@ -40,23 +40,23 @@ SRCS	+= $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
 SRCS	+= $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
 
 # Create a list of object files to be compiled
-OBJS	+= $(addprefix $(obj),$(SOBJ_FILES-y))
-OBJS	+= $(addprefix $(obj),$(COBJ_FILES-y))
-OBJS	+= $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
-OBJS	+= $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
+OBJS	+= $(addprefix $(obj)/,$(SOBJ_FILES-y))
+OBJS	+= $(addprefix $(obj)/,$(COBJ_FILES-y))
+OBJS	+= $(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y)))
+OBJS	+= $(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y)))
 
 #########################################################################
 
-$(obj)demo:	$(OBJS)
+$(obj)/demo:	$(OBJS)
 		$(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
 
-$(obj)demo.bin: $(obj)demo
+$(obj)/demo.bin: $(obj)/demo
 		$(OBJCOPY) -O binary $< $@ 2>/dev/null
 
 # Rule to build generic library C files
-$(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y))): $(obj)%.o: $(SRCTREE)/lib/%.c
+$(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c
 	$(CC) -g $(CFLAGS) -c -o $@ $<
 
 # Rule to build architecture-specific library assembly files
-$(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y))): $(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
+$(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
 	$(CC) -g $(CFLAGS) -c -o $@ $<
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index 1f8d70c..a6819f7 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -31,7 +31,7 @@ clean-files  := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-
 
 COBJS	:= $(ELF:=.o)
 
-LIB	= $(obj)libstubs.o
+LIB	= $(obj)/libstubs.o
 
 LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
 LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
@@ -39,11 +39,11 @@ LIBAOBJS := $(LIBAOBJS-y)
 
 LIBCOBJS = stubs.o
 
-LIBOBJS	= $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
+LIBOBJS	= $(addprefix $(obj)/,$(LIBAOBJS) $(LIBCOBJS))
 
 SRCS	:= $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
-OBJS	:= $(addprefix $(obj),$(COBJS))
-ELF	:= $(addprefix $(obj),$(ELF))
+OBJS	:= $(addprefix $(obj)/,$(COBJS))
+ELF	:= $(addprefix $(obj)/,$(ELF))
 
 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
 
@@ -67,13 +67,13 @@ $(LIB):	$(LIBOBJS)
 	$(call cmd_link_o_target, $(LIBOBJS))
 
 $(ELF):
-$(obj)%:	$(obj)%.o $(LIB)
+$(obj)/%:	$(obj)/%.o $(LIB)
 		$(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
 			-o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
 			-L$(gcclibdir) -lgcc
 
-$(obj)%.srec:	$(obj)%
+$(obj)/%.srec:	$(obj)/%
 		$(OBJCOPY) -O srec $< $@ 2>/dev/null
 
-$(obj)%.bin:	$(obj)%
+$(obj)/%.bin:	$(obj)/%
 		$(OBJCOPY) -O binary $< $@ 2>/dev/null
diff --git a/fs/ubifs/Makefile b/fs/ubifs/Makefile
index 389b0e3..5682b16 100644
--- a/fs/ubifs/Makefile
+++ b/fs/ubifs/Makefile
@@ -15,4 +15,4 @@ obj-y += tnc.o tnc_misc.o debug.o crc16.o budget.o
 obj-y += log.o orphan.o recovery.o replay.o
 
 # SEE README.arm-unaligned-accesses
-$(obj)super.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
+$(obj)/super.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
diff --git a/lib/Makefile b/lib/Makefile
index 760340f..43b13d0 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -67,4 +67,4 @@ obj-$(CONFIG_BOOTP_RANDOM_DELAY) += rand.o
 obj-$(CONFIG_CMD_LINK_LOCAL) += rand.o
 
 # SEE README.arm-unaligned-accesses
-$(obj)bzlib.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
+$(obj)/bzlib.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
diff --git a/mkconfig b/mkconfig
index b96c81f..5f516f2 100755
--- a/mkconfig
+++ b/mkconfig
@@ -23,7 +23,7 @@ options=""
 
 if [ \( $# -eq 2 \) -a \( "$1" = "-A" \) ] ; then
 	# Automatic mode
-	line=`awk '($0 !~ /^#/ && $7 ~ /^'"$2"'$/) { print $1, $2, $3, $4, $5, $6, $7, $8 }' boards.cfg`
+	line=`awk '($0 !~ /^#/ && $7 ~ /^'"$2"'$/) { print $1, $2, $3, $4, $5, $6, $7, $8 }' $srctree/boards.cfg`
 	if [ -z "$line" ] ; then
 		echo "make: *** No rule to make target \`$2_config'.  Stop." >&2
 		exit 1
diff --git a/nand_spl/board/amcc/acadia/Makefile b/nand_spl/board/amcc/acadia/Makefile
index 3b00d49..041213f 100644
--- a/nand_spl/board/amcc/acadia/Makefile
+++ b/nand_spl/board/amcc/acadia/Makefile
@@ -18,8 +18,8 @@ CFLAGS	+= -DCONFIG_NAND_SPL
 SOBJS	= start.o resetvec.o cache.o
 COBJS	= gpio.o nand_boot.o nand_ecc.o memory.o ndfc.o pll.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -47,49 +47,41 @@ $(nandobj)u-boot.lds: $(LDSCRIPT)
 # create symbolic links for common files
 
 # from cpu directory
-$(obj)cache.S:
+$(obj)/cache.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/cache.S $@
 
-$(obj)gpio.c:
+$(obj)/gpio.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/gpio.c $@
 
-$(obj)ndfc.c:
+$(obj)/ndfc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/mtd/nand/ndfc.c $@
 
-$(obj)resetvec.S:
+$(obj)/resetvec.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/resetvec.S $@
 
-$(obj)start.S:
+$(obj)/start.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/start.S $@
 
 # from board directory
-$(obj)memory.c:
+$(obj)/memory.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/board/amcc/acadia/memory.c $@
 
-$(obj)pll.c:
+$(obj)/pll.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/board/amcc/acadia/pll.c $@
 
 # from nand_spl directory
-$(obj)nand_boot.c:
+$(obj)/nand_boot.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/nand_spl/nand_boot.c $@
 
 # from drivers/mtd/nand directory
-$(obj)nand_ecc.c:
+$(obj)/nand_ecc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/mtd/nand/nand_ecc.c $@
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/amcc/bamboo/Makefile b/nand_spl/board/amcc/bamboo/Makefile
index 4063274..92b604e 100644
--- a/nand_spl/board/amcc/bamboo/Makefile
+++ b/nand_spl/board/amcc/bamboo/Makefile
@@ -18,8 +18,8 @@ CFLAGS	+= -DCONFIG_NAND_SPL
 SOBJS	= start.o init.o resetvec.o
 COBJS	= nand_boot.o nand_ecc.o ndfc.o sdram.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -41,43 +41,29 @@ $(nandobj)u-boot.lds: $(LDSCRIPT)
 # create symbolic links for common files
 
 # from cpu directory
-$(obj)ndfc.c:
+$(obj)/ndfc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/mtd/nand/ndfc.c $@
 
-$(obj)resetvec.S:
+$(obj)/resetvec.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/resetvec.S $@
 
-$(obj)start.S:
+$(obj)/start.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/start.S $@
 
 # from board directory
-$(obj)init.S:
+$(obj)/init.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/board/amcc/bamboo/init.S $@
 
 # from nand_spl directory
-$(obj)nand_boot.c:
+$(obj)/nand_boot.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/nand_spl/nand_boot.c $@
 
 # from drivers/mtd/nand directory
-$(obj)nand_ecc.c:
+$(obj)/nand_ecc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/mtd/nand/nand_ecc.c $@
-
-ifneq ($(OBJTREE), $(SRCTREE))
-$(obj)sdram.c:
-	@rm -f $@
-	ln -s $(SRCTREE)/nand_spl/board/$(BOARDDIR)/sdram.c $@
-endif
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/amcc/canyonlands/Makefile b/nand_spl/board/amcc/canyonlands/Makefile
index 13c8b36..9a730e9 100644
--- a/nand_spl/board/amcc/canyonlands/Makefile
+++ b/nand_spl/board/amcc/canyonlands/Makefile
@@ -23,8 +23,8 @@ COBJS	+= nand_boot.o
 COBJS	+= nand_ecc.o
 COBJS	+= ndfc.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -46,43 +46,29 @@ $(nandobj)u-boot.lds: $(LDSCRIPT)
 # create symbolic links for common files
 
 # from cpu directory
-$(obj)ndfc.c:
+$(obj)/ndfc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/mtd/nand/ndfc.c $@
 
-$(obj)resetvec.S:
+$(obj)/resetvec.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/resetvec.S $@
 
-$(obj)start.S:
+$(obj)/start.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/start.S $@
 
 # from board directory
-$(obj)init.S:
+$(obj)/init.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/board/amcc/canyonlands/init.S $@
 
 # from nand_spl directory
-$(obj)nand_boot.c:
+$(obj)/nand_boot.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/nand_spl/nand_boot.c $@
 
 # from drivers/mtd/nand directory
-$(obj)nand_ecc.c:
+$(obj)/nand_ecc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/mtd/nand/nand_ecc.c $@
-
-ifneq ($(OBJTREE), $(SRCTREE))
-$(obj)ddr2_fixed.c:
-	@rm -f $@
-	ln -s $(SRCTREE)/nand_spl/board/$(BOARDDIR)/ddr2_fixed.c $@
-endif
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/amcc/kilauea/Makefile b/nand_spl/board/amcc/kilauea/Makefile
index 9d07147..1c5498c 100644
--- a/nand_spl/board/amcc/kilauea/Makefile
+++ b/nand_spl/board/amcc/kilauea/Makefile
@@ -18,8 +18,8 @@ CFLAGS	+= -DCONFIG_NAND_SPL
 SOBJS	= start.o resetvec.o cache.o
 COBJS	= 44x_spd_ddr2.o nand_boot.o nand_ecc.o ndfc.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -41,44 +41,36 @@ $(nandobj)u-boot.lds: $(LDSCRIPT)
 # create symbolic links for common files
 
 # from cpu directory
-$(obj)44x_spd_ddr2.c: $(obj)ecc.h
+$(obj)/44x_spd_ddr2.c: $(obj)/ecc.h
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/44x_spd_ddr2.c $@
 
-$(obj)cache.S:
+$(obj)/cache.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/cache.S $@
 
-$(obj)ecc.h:
+$(obj)/ecc.h:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/ecc.h $@
 
-$(obj)ndfc.c:
+$(obj)/ndfc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/mtd/nand/ndfc.c $@
 
-$(obj)resetvec.S:
+$(obj)/resetvec.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/resetvec.S $@
 
-$(obj)start.S:
+$(obj)/start.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/start.S $@
 
 # from nand_spl directory
-$(obj)nand_boot.c:
+$(obj)/nand_boot.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/nand_spl/nand_boot.c $@
 
 # from drivers/nand directory
-$(obj)nand_ecc.c:
+$(obj)/nand_ecc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/mtd/nand/nand_ecc.c $@
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/amcc/sequoia/Makefile b/nand_spl/board/amcc/sequoia/Makefile
index 111bb0d..62131ab 100644
--- a/nand_spl/board/amcc/sequoia/Makefile
+++ b/nand_spl/board/amcc/sequoia/Makefile
@@ -18,8 +18,8 @@ CFLAGS	+= -DCONFIG_NAND_SPL
 SOBJS	= start.o init.o resetvec.o
 COBJS	= denali_data_eye.o nand_boot.o nand_ecc.o ndfc.o sdram.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -41,47 +41,39 @@ $(nandobj)u-boot.lds: $(LDSCRIPT)
 # create symbolic links for common files
 
 # from cpu directory
-$(obj)denali_data_eye.c:
+$(obj)/denali_data_eye.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/denali_data_eye.c $@
 
-$(obj)ndfc.c:
+$(obj)/ndfc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/mtd/nand/ndfc.c $@
 
-$(obj)resetvec.S:
+$(obj)/resetvec.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/resetvec.S $@
 
-$(obj)start.S:
+$(obj)/start.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/ppc4xx/start.S $@
 
 # from board directory
-$(obj)init.S:
+$(obj)/init.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/board/amcc/sequoia/init.S $@
 
-$(obj)sdram.c:
+$(obj)/sdram.c:
 	@rm -f $@
-	@rm -f $(obj)sdram.h
+	@rm -f $(obj)/sdram.h
 	ln -s $(SRCTREE)/board/amcc/sequoia/sdram.c $@
-	ln -s $(SRCTREE)/board/amcc/sequoia/sdram.h $(obj)sdram.h
+	ln -s $(SRCTREE)/board/amcc/sequoia/sdram.h $(obj)/sdram.h
 
 # from nand_spl directory
-$(obj)nand_boot.c:
+$(obj)/nand_boot.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/nand_spl/nand_boot.c $@
 
 # from drivers/mtd/nand directory
-$(obj)nand_ecc.c:
+$(obj)/nand_ecc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/mtd/nand/nand_ecc.c $@
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/freescale/mpc8315erdb/Makefile b/nand_spl/board/freescale/mpc8315erdb/Makefile
index 7813823..a2054ee 100644
--- a/nand_spl/board/freescale/mpc8315erdb/Makefile
+++ b/nand_spl/board/freescale/mpc8315erdb/Makefile
@@ -20,8 +20,8 @@ SOBJS	= start.o ticks.o
 COBJS	= nand_boot_fsl_elbc.o $(BOARD).o sdram.o ns16550.o spl_minimal.o \
 	  time.o cache.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -42,37 +42,29 @@ $(nandobj)u-boot.lds: $(LDSCRIPT)
 
 # create symbolic links for common files
 
-$(obj)start.S:
+$(obj)/start.S:
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc83xx/start.S $@
 
-$(obj)nand_boot_fsl_elbc.c:
+$(obj)/nand_boot_fsl_elbc.c:
 	ln -sf $(SRCTREE)/nand_spl/nand_boot_fsl_elbc.c $@
 
-$(obj)sdram.c:
+$(obj)/sdram.c:
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/sdram.c $@
 
-$(obj)$(BOARD).c:
+$(obj)/$(BOARD).c:
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/$(BOARD).c $@
 
-$(obj)ns16550.c:
+$(obj)/ns16550.c:
 	ln -sf $(SRCTREE)/drivers/serial/ns16550.c $@
 
-$(obj)spl_minimal.c:
+$(obj)/spl_minimal.c:
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc83xx/spl_minimal.c $@
 
-$(obj)cache.c:
+$(obj)/cache.c:
 	ln -sf $(SRCTREE)/arch/powerpc/lib/cache.c $@
 
-$(obj)time.c:
+$(obj)/time.c:
 	ln -sf $(SRCTREE)/arch/powerpc/lib/time.c $@
 
-$(obj)ticks.S:
+$(obj)/ticks.S:
 	ln -sf $(SRCTREE)/arch/powerpc/lib/ticks.S $@
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/freescale/mpc8536ds/Makefile b/nand_spl/board/freescale/mpc8536ds/Makefile
index 5d9953b..f711cf3 100644
--- a/nand_spl/board/freescale/mpc8536ds/Makefile
+++ b/nand_spl/board/freescale/mpc8536ds/Makefile
@@ -22,8 +22,8 @@ SOBJS	= start.o resetvec.o
 COBJS	= cache.o cpu_init_early.o spl_minimal.o fsl_law.o law.o \
 	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -45,64 +45,50 @@ $(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
 
 # create symbolic links for common files
 
-$(obj)cache.c:
+$(obj)/cache.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/lib/cache.c $@
 
-$(obj)cpu_init_early.c:
+$(obj)/cpu_init_early.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/cpu_init_early.c $@
 
-$(obj)spl_minimal.c:
+$(obj)/spl_minimal.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/spl_minimal.c $@
 
-$(obj)fsl_law.c:
+$(obj)/fsl_law.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc8xxx/law.c $@
 
-$(obj)law.c:
+$(obj)/law.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/law.c $@
 
-$(obj)nand_boot_fsl_elbc.c:
+$(obj)/nand_boot_fsl_elbc.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/nand_spl/nand_boot_fsl_elbc.c $@
 
-$(obj)ns16550.c:
+$(obj)/ns16550.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/drivers/serial/ns16550.c $@
 
-$(obj)resetvec.S:
+$(obj)/resetvec.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/$(CPUDIR)/resetvec.S $@
 
-$(obj)fixed_ivor.S:
+$(obj)/fixed_ivor.S:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/fixed_ivor.S $@
 
-$(obj)start.S: $(obj)fixed_ivor.S
+$(obj)/start.S: $(obj)/fixed_ivor.S
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/start.S $@
 
-$(obj)tlb.c:
+$(obj)/tlb.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/tlb.c $@
 
-$(obj)tlb_table.c:
+$(obj)/tlb_table.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/tlb.c $@
-
-ifneq ($(OBJTREE), $(SRCTREE))
-$(obj)nand_boot.c:
-	@rm -f $@
-	ln -s $(SRCTREE)/nand_spl/board/$(BOARDDIR)/nand_boot.c $@
-endif
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/freescale/mpc8569mds/Makefile b/nand_spl/board/freescale/mpc8569mds/Makefile
index 5d9953b..f711cf3 100644
--- a/nand_spl/board/freescale/mpc8569mds/Makefile
+++ b/nand_spl/board/freescale/mpc8569mds/Makefile
@@ -22,8 +22,8 @@ SOBJS	= start.o resetvec.o
 COBJS	= cache.o cpu_init_early.o spl_minimal.o fsl_law.o law.o \
 	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -45,64 +45,50 @@ $(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
 
 # create symbolic links for common files
 
-$(obj)cache.c:
+$(obj)/cache.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/lib/cache.c $@
 
-$(obj)cpu_init_early.c:
+$(obj)/cpu_init_early.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/cpu_init_early.c $@
 
-$(obj)spl_minimal.c:
+$(obj)/spl_minimal.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/spl_minimal.c $@
 
-$(obj)fsl_law.c:
+$(obj)/fsl_law.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc8xxx/law.c $@
 
-$(obj)law.c:
+$(obj)/law.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/law.c $@
 
-$(obj)nand_boot_fsl_elbc.c:
+$(obj)/nand_boot_fsl_elbc.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/nand_spl/nand_boot_fsl_elbc.c $@
 
-$(obj)ns16550.c:
+$(obj)/ns16550.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/drivers/serial/ns16550.c $@
 
-$(obj)resetvec.S:
+$(obj)/resetvec.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/$(CPUDIR)/resetvec.S $@
 
-$(obj)fixed_ivor.S:
+$(obj)/fixed_ivor.S:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/fixed_ivor.S $@
 
-$(obj)start.S: $(obj)fixed_ivor.S
+$(obj)/start.S: $(obj)/fixed_ivor.S
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/start.S $@
 
-$(obj)tlb.c:
+$(obj)/tlb.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/tlb.c $@
 
-$(obj)tlb_table.c:
+$(obj)/tlb_table.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/tlb.c $@
-
-ifneq ($(OBJTREE), $(SRCTREE))
-$(obj)nand_boot.c:
-	@rm -f $@
-	ln -s $(SRCTREE)/nand_spl/board/$(BOARDDIR)/nand_boot.c $@
-endif
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/freescale/mpc8572ds/Makefile b/nand_spl/board/freescale/mpc8572ds/Makefile
index 5d9953b..f711cf3 100644
--- a/nand_spl/board/freescale/mpc8572ds/Makefile
+++ b/nand_spl/board/freescale/mpc8572ds/Makefile
@@ -22,8 +22,8 @@ SOBJS	= start.o resetvec.o
 COBJS	= cache.o cpu_init_early.o spl_minimal.o fsl_law.o law.o \
 	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -45,64 +45,50 @@ $(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
 
 # create symbolic links for common files
 
-$(obj)cache.c:
+$(obj)/cache.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/lib/cache.c $@
 
-$(obj)cpu_init_early.c:
+$(obj)/cpu_init_early.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/cpu_init_early.c $@
 
-$(obj)spl_minimal.c:
+$(obj)/spl_minimal.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/spl_minimal.c $@
 
-$(obj)fsl_law.c:
+$(obj)/fsl_law.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc8xxx/law.c $@
 
-$(obj)law.c:
+$(obj)/law.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/law.c $@
 
-$(obj)nand_boot_fsl_elbc.c:
+$(obj)/nand_boot_fsl_elbc.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/nand_spl/nand_boot_fsl_elbc.c $@
 
-$(obj)ns16550.c:
+$(obj)/ns16550.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/drivers/serial/ns16550.c $@
 
-$(obj)resetvec.S:
+$(obj)/resetvec.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/$(CPUDIR)/resetvec.S $@
 
-$(obj)fixed_ivor.S:
+$(obj)/fixed_ivor.S:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/fixed_ivor.S $@
 
-$(obj)start.S: $(obj)fixed_ivor.S
+$(obj)/start.S: $(obj)/fixed_ivor.S
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/start.S $@
 
-$(obj)tlb.c:
+$(obj)/tlb.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/tlb.c $@
 
-$(obj)tlb_table.c:
+$(obj)/tlb_table.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/tlb.c $@
-
-ifneq ($(OBJTREE), $(SRCTREE))
-$(obj)nand_boot.c:
-	@rm -f $@
-	ln -s $(SRCTREE)/nand_spl/board/$(BOARDDIR)/nand_boot.c $@
-endif
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/freescale/p1023rds/Makefile b/nand_spl/board/freescale/p1023rds/Makefile
index 652590d..21a6920 100644
--- a/nand_spl/board/freescale/p1023rds/Makefile
+++ b/nand_spl/board/freescale/p1023rds/Makefile
@@ -18,8 +18,8 @@ SOBJS	= start.o resetvec.o
 COBJS	= cache.o cpu_init_early.o spl_minimal.o fsl_law.o law.o \
 	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -41,64 +41,50 @@ $(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
 
 # create symbolic links for common files
 
-$(obj)cache.c:
+$(obj)/cache.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/lib/cache.c $@
 
-$(obj)cpu_init_early.c:
+$(obj)/cpu_init_early.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/$(CPUDIR)/cpu_init_early.c $@
 
-$(obj)spl_minimal.c:
+$(obj)/spl_minimal.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/$(CPUDIR)/spl_minimal.c $@
 
-$(obj)fsl_law.c:
+$(obj)/fsl_law.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc8xxx/law.c $@
 
-$(obj)law.c:
+$(obj)/law.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/law.c $@
 
-$(obj)nand_boot_fsl_elbc.c:
+$(obj)/nand_boot_fsl_elbc.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/nand_spl/nand_boot_fsl_elbc.c $@
 
-$(obj)ns16550.c:
+$(obj)/ns16550.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/drivers/serial/ns16550.c $@
 
-$(obj)resetvec.S:
+$(obj)/resetvec.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/$(CPUDIR)/resetvec.S $@
 
-$(obj)fixed_ivor.S:
+$(obj)/fixed_ivor.S:
 	@rm -f $@
 	ln -sf $(SRCTREE)/$(CPUDIR)/fixed_ivor.S $@
 
-$(obj)start.S: $(obj)fixed_ivor.S
+$(obj)/start.S: $(obj)/fixed_ivor.S
 	@rm -f $@
 	ln -sf $(SRCTREE)/$(CPUDIR)/start.S $@
 
-$(obj)tlb.c:
+$(obj)/tlb.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/$(CPUDIR)/tlb.c $@
 
-$(obj)tlb_table.c:
+$(obj)/tlb_table.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/tlb.c $@
-
-ifneq ($(OBJTREE), $(SRCTREE))
-$(obj)nand_boot.c:
-	@rm -f $@
-	ln -s $(SRCTREE)/nand_spl/board/$(BOARDDIR)/nand_boot.c $@
-endif
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/freescale/p1_p2_rdb/Makefile b/nand_spl/board/freescale/p1_p2_rdb/Makefile
index 5d9953b..f711cf3 100644
--- a/nand_spl/board/freescale/p1_p2_rdb/Makefile
+++ b/nand_spl/board/freescale/p1_p2_rdb/Makefile
@@ -22,8 +22,8 @@ SOBJS	= start.o resetvec.o
 COBJS	= cache.o cpu_init_early.o spl_minimal.o fsl_law.o law.o \
 	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -45,64 +45,50 @@ $(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
 
 # create symbolic links for common files
 
-$(obj)cache.c:
+$(obj)/cache.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/lib/cache.c $@
 
-$(obj)cpu_init_early.c:
+$(obj)/cpu_init_early.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/cpu_init_early.c $@
 
-$(obj)spl_minimal.c:
+$(obj)/spl_minimal.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/spl_minimal.c $@
 
-$(obj)fsl_law.c:
+$(obj)/fsl_law.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc8xxx/law.c $@
 
-$(obj)law.c:
+$(obj)/law.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/law.c $@
 
-$(obj)nand_boot_fsl_elbc.c:
+$(obj)/nand_boot_fsl_elbc.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/nand_spl/nand_boot_fsl_elbc.c $@
 
-$(obj)ns16550.c:
+$(obj)/ns16550.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/drivers/serial/ns16550.c $@
 
-$(obj)resetvec.S:
+$(obj)/resetvec.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/$(CPUDIR)/resetvec.S $@
 
-$(obj)fixed_ivor.S:
+$(obj)/fixed_ivor.S:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/fixed_ivor.S $@
 
-$(obj)start.S: $(obj)fixed_ivor.S
+$(obj)/start.S: $(obj)/fixed_ivor.S
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/start.S $@
 
-$(obj)tlb.c:
+$(obj)/tlb.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/arch/powerpc/cpu/mpc85xx/tlb.c $@
 
-$(obj)tlb_table.c:
+$(obj)/tlb_table.c:
 	@rm -f $@
 	ln -sf $(SRCTREE)/board/$(BOARDDIR)/tlb.c $@
-
-ifneq ($(OBJTREE), $(SRCTREE))
-$(obj)nand_boot.c:
-	@rm -f $@
-	ln -s $(SRCTREE)/nand_spl/board/$(BOARDDIR)/nand_boot.c $@
-endif
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/nand_spl/board/sheldon/simpc8313/Makefile b/nand_spl/board/sheldon/simpc8313/Makefile
index 5e83abc..ca45ecd 100644
--- a/nand_spl/board/sheldon/simpc8313/Makefile
+++ b/nand_spl/board/sheldon/simpc8313/Makefile
@@ -19,8 +19,8 @@ SOBJS	= start.o ticks.o
 COBJS	= nand_boot_fsl_elbc.o $(BOARD).o sdram.o ns16550.o spl_minimal.o \
 	  time.o cache.o
 
-SRCS	:= $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c))
-OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
+SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
+OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
@@ -41,46 +41,38 @@ $(nandobj)u-boot.lds: $(LDSCRIPT)
 
 # create symbolic links for common files
 
-$(obj)start.S:
+$(obj)/start.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/mpc83xx/start.S $@
 
-$(obj)nand_boot_fsl_elbc.c:
+$(obj)/nand_boot_fsl_elbc.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/nand_spl/nand_boot_fsl_elbc.c $@
 
-$(obj)sdram.c:
+$(obj)/sdram.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/board/$(BOARDDIR)/sdram.c $@
 
-$(obj)$(BOARD).c:
+$(obj)/$(BOARD).c:
 	@rm -f $@
 	ln -s $(SRCTREE)/board/$(BOARDDIR)/$(BOARD).c $@
 
-$(obj)ns16550.c:
+$(obj)/ns16550.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/drivers/serial/ns16550.c $@
 
-$(obj)spl_minimal.c:
+$(obj)/spl_minimal.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/cpu/mpc83xx/spl_minimal.c $@
 
-$(obj)cache.c:
+$(obj)/cache.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/lib/cache.c $@
 
-$(obj)time.c:
+$(obj)/time.c:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/lib/time.c $@
 
-$(obj)ticks.S:
+$(obj)/ticks.S:
 	@rm -f $@
 	ln -s $(SRCTREE)/arch/powerpc/lib/ticks.S $@
-
-#########################################################################
-
-$(obj)%.o:	$(obj)%.S
-	$(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:	$(obj)%.c
-	$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/post/lib_powerpc/fpu/Makefile b/post/lib_powerpc/fpu/Makefile
index a7aa5bc..c720a26 100644
--- a/post/lib_powerpc/fpu/Makefile
+++ b/post/lib_powerpc/fpu/Makefile
@@ -18,7 +18,7 @@ obj-y	+= darwin-ldouble.o
 CFLAGS := $(shell echo $(CFLAGS) | sed s/-msoft-float//)
 CFLAGS += -mhard-float -fkeep-inline-functions
 
-$(addprefix $(obj),$(obj-y)): $(obj)%.o:	%.c
+$(addprefix $(obj)/,$(obj-y)): $(obj)/%.o: $(src)/%.c
 	$(CC)  $(ALL_CFLAGS) -o $@.fp $< -c
 	$(OBJCOPY) -R .gnu.attributes $@.fp $@
 	rm -f $@.fp
diff --git a/rules.mk b/rules.mk
index b36de4d..e4fd337 100644
--- a/rules.mk
+++ b/rules.mk
@@ -6,41 +6,42 @@
 #
 #########################################################################
 
-_depend:	$(obj).depend
+_depend:	$(obj)/.depend
 
 # Split the source files into two camps: those in the current directory, and
 # those somewhere else. For the first camp we want to support CPPFLAGS_<fname>
 # and for the second we don't / can't.
-PWD_SRCS := $(filter $(notdir $(SRCS)),$(SRCS))
-OTHER_SRCS := $(filter-out $(notdir $(SRCS)),$(SRCS))
+PWD_SRCS := $(foreach f,$(SRCS), $(if \
+	$(filter $(if $(KBUILD_SRC),$(srctree)/)$(src)/$(notdir $f),$f), $f))
+OTHER_SRCS := $(filter-out $(PWD_SRCS),$(SRCS))
 
 # This is a list of dependency files to generate
-DEPS := $(basename $(patsubst %,$(obj).depend.%,$(PWD_SRCS)))
+DEPS := $(basename $(addprefix $(obj)/.depend., $(notdir $(PWD_SRCS))))
 
 # Join all the dependencies into a single file, in three parts
 #	1 .Concatenate all the generated depend files together
 #	2. Add in the deps from OTHER_SRCS which we couldn't process
 #	3. Add in the HOSTSRCS
-$(obj).depend:	$(src)Makefile $(TOPDIR)/config.mk $(DEPS) $(OTHER_SRCS) \
+$(obj)/.depend:	$(TOPDIR)/config.mk $(DEPS) $(OTHER_SRCS) \
 		$(HOSTSRCS)
 	cat /dev/null $(DEPS) >$@
 	@for f in $(OTHER_SRCS); do \
 		g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
-		$(CC) -M $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
+		$(CC) -M $(CPPFLAGS) -MQ $(obj)/$$g $$f >> $@ ; \
 	done
 	@for f in $(HOSTSRCS); do \
 		g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
-		$(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
+		$(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)/$$g $$f >> $@ ; \
 	done
 
 MAKE_DEPEND = $(CC) -M $(CPPFLAGS) $(EXTRA_CPPFLAGS_DEP) \
 		-MQ $(addsuffix .o,$(obj)$(basename $<)) $< >$@
 
 
-$(obj).depend.%:	%.c
+$(obj)/.depend.%:	$(src)/%.c
 	$(MAKE_DEPEND)
 
-$(obj).depend.%:	%.S
+$(obj)/.depend.%:	$(src)/%.S
 	$(MAKE_DEPEND)
 
 #########################################################################
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index ca5fd56..6113c13 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -165,9 +165,7 @@ ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
 # Usage:
 # $(Q)$(MAKE) $(build)=dir
-#build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
-# temporary
-build := -f $(srctree)/scripts/Makefile.build -C
+build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
 
 ###
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 7789efa..52a44ff 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -2,17 +2,28 @@
 .PHONY: all
 all:
 
+ifeq ($(CONFIG_TPL_BUILD),y)
+  src := $(patsubst tpl/%,%,$(obj))
+else
+  ifeq ($(CONFIG_SPL_BUILD),y)
+    src := $(patsubst spl/%,%,$(obj))
+  else
+    src := $(obj)
+  endif
+endif
+
 include $(srctree)/scripts/Kbuild.include
-include $(TOPDIR)/config.mk
+include $(srctree)/config.mk
 
 # variable LIB is used in examples/standalone/Makefile
-__LIB := $(obj)built-in.o
-LIBGCC = $(obj)libgcc.o
+__LIB := $(obj)/built-in.o
+LIBGCC = $(obj)/libgcc.o
 SRCS :=
 subdir-y :=
 obj-dirs :=
 
-include Makefile
+kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
+include $(kbuild-dir)/Makefile
 
 # Do not include host rules unless needed
 ifneq ($(hostprogs-y)$(hostprogs-m),)
@@ -28,31 +39,37 @@ lib-y := $(sort $(lib-y))
 subdir-y 	+= $(patsubst %/,%,$(filter %/, $(obj-y)))
 obj-y		:= $(patsubst %/, %/built-in.o, $(obj-y))
 subdir-obj-y	:= $(filter %/built-in.o, $(obj-y))
-subdir-obj-y	:= $(addprefix $(obj),$(subdir-obj-y))
+subdir-obj-y	:= $(addprefix $(obj)/,$(subdir-obj-y))
+
+SRCS	+= $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) \
+	$(lib-y:.o=.S) $(extra-y:.o=.c) $(extra-y:.o=.S)
 
-SRCS	+= $(wildcard $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) \
-	$(lib-y:.o=.S) $(extra-y:.o=.c) $(extra-y:.o=.S))
-OBJS	:= $(addprefix $(obj),$(obj-y))
+SRCS := $(addprefix $(if $(KBUILD_SRC),$(srctree)/$(src)/,$(src)/),$(SRCS))
+SRCS := $(wildcard $(SRCS))
+
+OBJS	:= $(addprefix $(obj)/,$(obj-y))
 
 # $(obj-dirs) is a list of directories that contain object files
 
 obj-dirs += $(dir $(OBJS))
 
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+
 # Create directories for object files if directory does not exist
 # Needed when obj-y := dir/file.o syntax is used
 _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
 
-LGOBJS := $(addprefix $(obj),$(sort $(lib-y)))
+LGOBJS := $(addprefix $(obj)/,$(sort $(lib-y)))
 
-all: $(__LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
+all: $(__LIB) $(addprefix $(obj)/,$(extra-y) $(always)) $(subdir-y)
 
-$(__LIB):	$(obj).depend $(OBJS)
+$(__LIB):	$(obj)/.depend $(OBJS)
 	$(call cmd_link_o_target, $(OBJS))
 
 ifneq ($(strip $(lib-y)),)
 all: $(LIBGCC)
 
-$(LIBGCC): $(obj).depend $(LGOBJS)
+$(LIBGCC): $(obj)/.depend $(LGOBJS)
 	$(call cmd_link_o_target, $(LGOBJS))
 endif
 
@@ -63,7 +80,7 @@ endif
 
 ifneq ($(subdir-y),)
 $(subdir-y): FORCE
-	$(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build
+	$(MAKE) $(build)=$(obj)/$@
 endif
 
 #########################################################################
@@ -78,18 +95,18 @@ ALL_CFLAGS += $(EXTRA_CPPFLAGS)
 # See rules.mk
 EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \
 		$(CPPFLAGS_$(BCURDIR))
-$(obj)%.s:	%.S
+$(obj)/%.s:	$(src)/%.S
 	$(CPP) $(ALL_AFLAGS) -o $@ $<
-$(obj)%.o:	%.S
+$(obj)/%.o:	$(src)/%.S
 	$(CC)  $(ALL_AFLAGS) -o $@ $< -c
-$(obj)%.o:	%.c
+$(obj)/%.o:	$(src)/%.c
 ifneq ($(CHECKSRC),0)
 	$(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $<
 endif
 	$(CC)  $(ALL_CFLAGS) -o $@ $< -c
-$(obj)%.i:	%.c
+$(obj)/%.i:	$(src)/%.c
 	$(CPP) $(ALL_CFLAGS) -o $@ $< -c
-$(obj)%.s:	%.c
+$(obj)/%.s:	$(src)/%.c
 	$(CC)  $(ALL_CFLAGS) -o $@ $< -c -S
 
 # If the list of objects to link is empty, just create an empty built-in.o
@@ -99,11 +116,11 @@ cmd_link_o_target = $(if $(strip $1),\
 
 #########################################################################
 
-# defines $(obj).depend target
+# defines $(obj)/.depend target
 
 include $(TOPDIR)/rules.mk
 
-sinclude $(obj).depend
+sinclude $(obj)/.depend
 
 #########################################################################
 
diff --git a/scripts/Makefile.host.tmp b/scripts/Makefile.host.tmp
index 4b57846..53fe930 100644
--- a/scripts/Makefile.host.tmp
+++ b/scripts/Makefile.host.tmp
@@ -21,11 +21,11 @@ host-objdirs += $(foreach f,$(host-cmulti),                  \
 
 host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs))))
 
-__hostprogs     := $(addprefix $(obj),$(__hostprogs))
-host-csingle	:= $(addprefix $(obj),$(host-csingle))
-host-cmulti	:= $(addprefix $(obj),$(host-cmulti))
-host-cobjs	:= $(addprefix $(obj),$(host-cobjs))
-host-objdirs    := $(addprefix $(obj),$(host-objdirs))
+__hostprogs     := $(addprefix $(obj)/,$(__hostprogs))
+host-csingle	:= $(addprefix $(obj)/,$(host-csingle))
+host-cmulti	:= $(addprefix $(obj)/,$(host-cmulti))
+host-cobjs	:= $(addprefix $(obj)/,$(host-cobjs))
+host-objdirs    := $(addprefix $(obj)/,$(host-objdirs))
 
 obj-dirs += $(host-objdirs)
 
@@ -49,13 +49,13 @@ hostc_flags    = $(__hostc_flags)
 #####
 # Compile programs on the host
 
-$(host-csingle): $(obj)%: %.c
+$(host-csingle): $(obj)/%: $(src)/%.c
 	$(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTLDFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $<
 
-$(host-cmulti): $(obj)%: $(host-cobjs)
-	$(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj),$($(@F)-objs)) $(HOSTLOADLIBES_$(@F))
+$(host-cmulti): $(obj)/%: $(host-cobjs)
+	$(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj)/,$($(@F)-objs)) $(HOSTLOADLIBES_$(@F))
 
-$(host-cobjs): $(obj)%.o: %.c
+$(host-cobjs): $(obj)/%.o: $(src)/%.c
 	$(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
 
 targets += $(host-csingle)  $(host-cmulti) $(host-cobjs)
diff --git a/spl/Makefile b/spl/Makefile
index 001205b..3950df2 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -14,6 +14,11 @@
 # Based on top-level Makefile.
 #
 
+src := $(obj)
+
+# Create output directory if not already present
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+
 CONFIG_SPL_BUILD := y
 export CONFIG_SPL_BUILD
 
@@ -37,14 +42,6 @@ include $(srctree)/scripts/Kbuild.include
 
 include $(TOPDIR)/config.mk
 
-# We want the final binaries in this directory
-ifeq ($(CONFIG_TPL_BUILD),y)
-obj := $(OBJTREE)/tpl/
-SPLTREE := $(TPLTREE)
-else
-obj := $(OBJTREE)/spl/
-endif
-
 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(SRCTREE)/board/$(VENDOR)/common/Makefile),y,n)
 
 ifdef	CONFIG_SPL_START_S_PATH
@@ -112,11 +109,13 @@ PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
 PLATFORM_LIBS := $(filter-out %/libgcc.o, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
 endif
 
-START := $(addprefix $(SPLTREE)/,$(head-y))
-LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y)))
+LIBS-y := $(sort $(LIBS-y))
+
+__START := $(head-y)
+__LIBS := $(LIBS-y)
 
-__START := $(subst $(obj),,$(START))
-__LIBS := $(subst $(obj),,$(LIBS))
+START := $(addprefix $(obj)/,$(head-y))
+LIBS := $(addprefix $(obj)/,$(LIBS-y))
 
 # Linker Script
 ifdef CONFIG_SPL_LDSCRIPT
@@ -147,21 +146,21 @@ LDPPFLAGS += \
 	$(shell $(LD) --version | \
 	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
 
-$(OBJTREE)/MLO:	$(obj)u-boot-spl.bin
+$(OBJTREE)/MLO:	$(obj)/u-boot-spl.bin
 	$(OBJTREE)/tools/mkimage -T omapimage \
 		-a $(CONFIG_SPL_TEXT_BASE) -d $< $@
 
-$(OBJTREE)/MLO.byteswap: $(obj)u-boot-spl.bin
+$(OBJTREE)/MLO.byteswap: $(obj)/u-boot-spl.bin
 	$(OBJTREE)/tools/mkimage -T omapimage -n byteswap \
 		-a $(CONFIG_SPL_TEXT_BASE) -d $< $@
 
-$(OBJTREE)/SPL : $(obj)u-boot-spl.bin depend
-		$(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common $@
+$(objtree)/SPL : $(obj)/u-boot-spl.bin depend
+		$(MAKE) $(build)=spl/arch/arm/imx-common $@
 
-ALL-y	+= $(obj)$(SPL_BIN).bin
+ALL-y	+= $(obj)/$(SPL_BIN).bin
 
 ifdef CONFIG_SAMSUNG
-ALL-y	+= $(obj)$(BOARD)-spl.bin
+ALL-y	+= $(obj)/$(BOARD)-spl.bin
 endif
 
 all:	$(ALL-y)
@@ -172,16 +171,16 @@ VAR_SIZE_PARAM = --vs
 else
 VAR_SIZE_PARAM =
 endif
-$(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
+$(obj)/$(BOARD)-spl.bin: $(obj)/u-boot-spl.bin
 	$(if $(wildcard $(OBJTREE)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\
 	$(OBJTREE)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\
 	$(OBJTREE)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
 endif
 
-$(obj)$(SPL_BIN).bin:	$(obj)$(SPL_BIN)
+$(obj)/$(SPL_BIN).bin:	$(obj)/$(SPL_BIN)
 	$(OBJCOPY) $(OBJCFLAGS) $(SPL_OBJCFLAGS) -O binary $< $@
 
-LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
+LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SPL_TEXT_BASE),)
 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
 endif
@@ -191,19 +190,19 @@ GEN_UBOOT = \
 		--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
 		-Map $(SPL_BIN).map -o $(SPL_BIN)
 
-$(obj)$(SPL_BIN):	depend $(START) $(LIBS) $(obj)u-boot-spl.lds
+$(obj)/$(SPL_BIN):	depend $(START) $(LIBS) $(obj)/u-boot-spl.lds
 	$(GEN_UBOOT)
 
 $(START):
 	@:
 
 $(LIBS):	depend
-	$(MAKE) $(build) $(SRCTREE)$(dir $(subst $(SPLTREE),,$@))
+	$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
 
-$(obj)u-boot-spl.lds: $(LDSCRIPT) depend
+$(obj)/u-boot-spl.lds: $(LDSCRIPT) depend
 	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(obj). -ansi -D__ASSEMBLY__ -P - < $< > $@
 
-depend:	$(obj).depend
+depend:	$(obj)/.depend
 .PHONY: depend
 
 # defines $(obj).depend target
diff --git a/tools/Makefile b/tools/Makefile
index 21341b7..9b19dcb 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -142,8 +142,8 @@ HOSTCFLAGS_sha1.o := -pedantic
 always := $(hostprogs-y)
 
 # Generated LCD/video logo
-LOGO_H = $(OBJTREE)/include/bmp_logo.h
-LOGO_DATA_H = $(OBJTREE)/include/bmp_logo_data.h
+LOGO_H = $(objtree)/include/bmp_logo.h
+LOGO_DATA_H = $(objtree)/include/bmp_logo_data.h
 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H)
 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
@@ -151,14 +151,14 @@ LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
 
 # Generic logo
 ifeq ($(LOGO_BMP),)
-LOGO_BMP= logos/denx.bmp
+LOGO_BMP= $(srctree)/$(src)/logos/denx.bmp
 
 # Use board logo and fallback to vendor
 ifneq ($(wildcard logos/$(BOARD).bmp),)
-LOGO_BMP= logos/$(BOARD).bmp
+LOGO_BMP= $(srctree)/$(src)/logos/$(BOARD).bmp
 else
 ifneq ($(wildcard logos/$(VENDOR).bmp),)
-LOGO_BMP= logos/$(VENDOR).bmp
+LOGO_BMP= $(srctree)/$(src)/logos/$(VENDOR).bmp
 endif
 endif
 
@@ -187,8 +187,8 @@ all:	$(LOGO-y)
 
 subdir-y := kernel-doc
 
-$(LOGO_H):	$(obj)bmp_logo $(LOGO_BMP)
-	$(obj)./bmp_logo --gen-info $(LOGO_BMP) > $@
+$(LOGO_H):	$(obj)/bmp_logo $(LOGO_BMP)
+	$(obj)/bmp_logo --gen-info $(LOGO_BMP) > $@
 
-$(LOGO_DATA_H):	$(obj)bmp_logo $(LOGO_BMP)
-	$(obj)./bmp_logo --gen-data $(LOGO_BMP) > $@
+$(LOGO_DATA_H):	$(obj)/bmp_logo $(LOGO_BMP)
+	$(obj)/bmp_logo --gen-data $(LOGO_BMP) > $@
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 18/38] kbuild: add dummy obj-y to create built-in.o
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (16 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 17/38] kbuild: change out-of-tree build Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 19/38] Makefile: rename scripts/Makefile.build to scripts/Makefile.build.tmp Masahiro Yamada
                   ` (22 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

We are going to switch over to Kbuild in upcoming commits.

Each makefile must have non-empty obj- or obj-y
to generate built-in.o on Kbuild.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/tegra114/Makefile | 3 ++-
 arch/arm/cpu/armv7/tegra30/Makefile  | 3 ++-
 arch/nds32/cpu/n1213/Makefile        | 3 +++
 board/freescale/common/Makefile      | 5 ++++-
 board/samsung/origen/Makefile        | 3 +++
 board/samsung/smdkv310/Makefile      | 3 +++
 board/spear/common/Makefile          | 5 ++++-
 board/spear/x600/Makefile            | 5 ++++-
 8 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra114/Makefile b/arch/arm/cpu/armv7/tegra114/Makefile
index 886b509..77e2319 100644
--- a/arch/arm/cpu/armv7/tegra114/Makefile
+++ b/arch/arm/cpu/armv7/tegra114/Makefile
@@ -17,4 +17,5 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-obj- :=
+# necessary to create built-in.o
+obj- := __dummy__.o
diff --git a/arch/arm/cpu/armv7/tegra30/Makefile b/arch/arm/cpu/armv7/tegra30/Makefile
index 518d6d1..413eba1 100644
--- a/arch/arm/cpu/armv7/tegra30/Makefile
+++ b/arch/arm/cpu/armv7/tegra30/Makefile
@@ -17,4 +17,5 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-obj- :=
+# necessary to create built-in.o
+obj- := __dummy__.o
diff --git a/arch/nds32/cpu/n1213/Makefile b/arch/nds32/cpu/n1213/Makefile
index bb3550e..206d304 100644
--- a/arch/nds32/cpu/n1213/Makefile
+++ b/arch/nds32/cpu/n1213/Makefile
@@ -9,4 +9,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+# necessary to create built-in.o
+obj- := __dummy__.o
+
 extra-y	= start.o
diff --git a/board/freescale/common/Makefile b/board/freescale/common/Makefile
index 25f063d..f6a0879 100644
--- a/board/freescale/common/Makefile
+++ b/board/freescale/common/Makefile
@@ -13,7 +13,10 @@ MINIMAL=y
 endif
 endif
 
-ifndef MINIMAL
+ifdef MINIMAL
+# necessary to create built-in.o
+obj- := __dummy__.o
+else
 obj-$(CONFIG_FSL_CADMUS)	+= cadmus.o
 obj-$(CONFIG_FSL_VIA)		+= cds_via.o
 obj-$(CONFIG_FMAN_ENET)	+= fman.o
diff --git a/board/samsung/origen/Makefile b/board/samsung/origen/Makefile
index 37acba7..1add9fe 100644
--- a/board/samsung/origen/Makefile
+++ b/board/samsung/origen/Makefile
@@ -5,6 +5,9 @@
 #
 
 ifdef CONFIG_SPL_BUILD
+# necessary to create built-in.o
+obj- := __dummy__.o
+
 hostprogs-y := tools/mkorigenspl
 always := $(hostprogs-y)
 
diff --git a/board/samsung/smdkv310/Makefile b/board/samsung/smdkv310/Makefile
index 9e37b4e..de0da16 100644
--- a/board/samsung/smdkv310/Makefile
+++ b/board/samsung/smdkv310/Makefile
@@ -5,6 +5,9 @@
 #
 
 ifdef CONFIG_SPL_BUILD
+# necessary to create built-in.o
+obj- := __dummy__.o
+
 hostprogs-y := tools/mksmdkv310spl
 always := $(hostprogs-y)
 else
diff --git a/board/spear/common/Makefile b/board/spear/common/Makefile
index 08dc09f..b0ba320 100644
--- a/board/spear/common/Makefile
+++ b/board/spear/common/Makefile
@@ -5,7 +5,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-ifndef CONFIG_SPL_BUILD
+ifdef CONFIG_SPL_BUILD
+# necessary to create built-in.o
+obj- := __dummy__.o
+else
 obj-y	:= spr_misc.o
 obj-y	+= spr_lowlevel_init.o
 endif
diff --git a/board/spear/x600/Makefile b/board/spear/x600/Makefile
index f9053fe..18d3dd2 100644
--- a/board/spear/x600/Makefile
+++ b/board/spear/x600/Makefile
@@ -5,6 +5,9 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-ifndef CONFIG_SPL_BUILD
+ifdef CONFIG_SPL_BUILD
+# necessary to create built-in.o
+obj- := __dummy__.o
+else
 obj-y	:= fpga.o x600.o
 endif
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 19/38] Makefile: rename scripts/Makefile.build to scripts/Makefile.build.tmp
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (17 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 18/38] kbuild: add dummy obj-y to create built-in.o Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 20/38] kbuild: import more build scripts from Linux v3.13 tag Masahiro Yamada
                   ` (21 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

Some build scripts including scripts/Makefile.build
will be imported from Linux Kernel in the next commit.
We need to adjust them for U-Boot in the following commits.

To make it easier for reviewers to track the modification,
this commit renames scripts/Makefile.build to
scripts/Makefile.build.tmp beforehand.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 scripts/Kbuild.include                         | 2 +-
 scripts/{Makefile.build => Makefile.build.tmp} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename scripts/{Makefile.build => Makefile.build.tmp} (100%)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 6113c13..30a5551 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -165,7 +165,7 @@ ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
 # Usage:
 # $(Q)$(MAKE) $(build)=dir
-build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build.tmp obj
 
 ###
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
diff --git a/scripts/Makefile.build b/scripts/Makefile.build.tmp
similarity index 100%
rename from scripts/Makefile.build
rename to scripts/Makefile.build.tmp
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 20/38] kbuild: import more build scripts from Linux v3.13 tag
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (18 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 19/38] Makefile: rename scripts/Makefile.build to scripts/Makefile.build.tmp Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 21/38] kbuild: use Linux Kernel build scripts Masahiro Yamada
                   ` (20 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit imports build scripts from Linux Kernel v3.13
as they are.

I know they include some trailing spaces
but I am intentionally keeping them untouched.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 scripts/Makefile.build   | 479 +++++++++++++++++++++++++++++++++++++++++++++++
 scripts/Makefile.clean   | 104 ++++++++++
 scripts/Makefile.host    | 170 +++++++++++++++++
 scripts/Makefile.lib     | 373 ++++++++++++++++++++++++++++++++++++
 scripts/basic/.gitignore |   1 +
 scripts/basic/Makefile   |  15 ++
 scripts/basic/fixdep.c   | 462 +++++++++++++++++++++++++++++++++++++++++++++
 scripts/mkmakefile       |  59 ++++++
 8 files changed, 1663 insertions(+)
 create mode 100644 scripts/Makefile.build
 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

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
new file mode 100644
index 0000000..d5d859c
--- /dev/null
+++ b/scripts/Makefile.build
@@ -0,0 +1,479 @@
+# ==========================================================================
+# Building
+# ==========================================================================
+
+src := $(obj)
+
+PHONY := __build
+__build:
+
+# Init all relevant variables used in kbuild files so
+# 1) they have correct type
+# 2) they do not inherit any value from the environment
+obj-y :=
+obj-m :=
+lib-y :=
+lib-m :=
+always :=
+targets :=
+subdir-y :=
+subdir-m :=
+EXTRA_AFLAGS   :=
+EXTRA_CFLAGS   :=
+EXTRA_CPPFLAGS :=
+EXTRA_LDFLAGS  :=
+asflags-y  :=
+ccflags-y  :=
+cppflags-y :=
+ldflags-y  :=
+
+subdir-asflags-y :=
+subdir-ccflags-y :=
+
+# Read auto.conf if it exists, otherwise ignore
+-include include/config/auto.conf
+
+include scripts/Kbuild.include
+
+# For backward compatibility check that these variables do not change
+save-cflags := $(CFLAGS)
+
+# The filename Kbuild has precedence over Makefile
+kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
+kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
+include $(kbuild-file)
+
+# If the save-* variables changed error out
+ifeq ($(KBUILD_NOPEDANTIC),)
+        ifneq ("$(save-cflags)","$(CFLAGS)")
+                $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y)
+        endif
+endif
+
+#
+# make W=... settings
+#
+# W=1 - warnings that may be relevant and does not occur too often
+# W=2 - warnings that occur quite often but may still be relevant
+# W=3 - the more obscure warnings, can most likely be ignored
+#
+# $(call cc-option, -W...) handles gcc -W.. options which
+# are not supported by all versions of the compiler
+ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
+warning-  := $(empty)
+
+warning-1 := -Wextra -Wunused -Wno-unused-parameter
+warning-1 += -Wmissing-declarations
+warning-1 += -Wmissing-format-attribute
+warning-1 += -Wmissing-prototypes
+warning-1 += -Wold-style-definition
+warning-1 += $(call cc-option, -Wmissing-include-dirs)
+warning-1 += $(call cc-option, -Wunused-but-set-variable)
+warning-1 += $(call cc-disable-warning, missing-field-initializers)
+
+warning-2 := -Waggregate-return
+warning-2 += -Wcast-align
+warning-2 += -Wdisabled-optimization
+warning-2 += -Wnested-externs
+warning-2 += -Wshadow
+warning-2 += $(call cc-option, -Wlogical-op)
+warning-2 += $(call cc-option, -Wmissing-field-initializers)
+
+warning-3 := -Wbad-function-cast
+warning-3 += -Wcast-qual
+warning-3 += -Wconversion
+warning-3 += -Wpacked
+warning-3 += -Wpadded
+warning-3 += -Wpointer-arith
+warning-3 += -Wredundant-decls
+warning-3 += -Wswitch-default
+warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
+warning-3 += $(call cc-option, -Wvla)
+
+warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
+warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
+warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
+
+ifeq ("$(strip $(warning))","")
+        $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
+endif
+
+KBUILD_CFLAGS += $(warning)
+endif
+
+include scripts/Makefile.lib
+
+ifdef host-progs
+ifneq ($(hostprogs-y),$(host-progs))
+$(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!)
+hostprogs-y += $(host-progs)
+endif
+endif
+
+# Do not include host rules unless needed
+ifneq ($(hostprogs-y)$(hostprogs-m),)
+include scripts/Makefile.host
+endif
+
+ifneq ($(KBUILD_SRC),)
+# Create output directory if not already present
+_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
+
+# Create directories for object files if directory does not exist
+# Needed when obj-y := dir/file.o syntax is used
+_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
+endif
+
+ifndef obj
+$(warning kbuild: Makefile.build is included improperly)
+endif
+
+# ===========================================================================
+
+ifneq ($(strip $(lib-y) $(lib-m) $(lib-n) $(lib-)),)
+lib-target := $(obj)/lib.a
+endif
+
+ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(subdir-m) $(lib-target)),)
+builtin-target := $(obj)/built-in.o
+endif
+
+modorder-target := $(obj)/modules.order
+
+# We keep a list of all modules in $(MODVERDIR)
+
+__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
+	 $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
+	 $(subdir-ym) $(always)
+	@:
+
+# Linus' kernel sanity checking tool
+ifneq ($(KBUILD_CHECKSRC),0)
+  ifeq ($(KBUILD_CHECKSRC),2)
+    quiet_cmd_force_checksrc = CHECK   $<
+          cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
+  else
+      quiet_cmd_checksrc     = CHECK   $<
+            cmd_checksrc     = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
+  endif
+endif
+
+# Do section mismatch analysis for each module/built-in.o
+ifdef CONFIG_DEBUG_SECTION_MISMATCH
+  cmd_secanalysis = ; scripts/mod/modpost $@
+endif
+
+# Compile C sources (.c)
+# ---------------------------------------------------------------------------
+
+# Default is built-in, unless we know otherwise
+modkern_cflags =                                          \
+	$(if $(part-of-module),                           \
+		$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
+		$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
+quiet_modtag := $(empty)   $(empty)
+
+$(real-objs-m)        : part-of-module := y
+$(real-objs-m:.o=.i)  : part-of-module := y
+$(real-objs-m:.o=.s)  : part-of-module := y
+$(real-objs-m:.o=.lst): part-of-module := y
+
+$(real-objs-m)        : quiet_modtag := [M]
+$(real-objs-m:.o=.i)  : quiet_modtag := [M]
+$(real-objs-m:.o=.s)  : quiet_modtag := [M]
+$(real-objs-m:.o=.lst): quiet_modtag := [M]
+
+$(obj-m)              : quiet_modtag := [M]
+
+# Default for not multi-part modules
+modname = $(basetarget)
+
+$(multi-objs-m)         : modname = $(modname-multi)
+$(multi-objs-m:.o=.i)   : modname = $(modname-multi)
+$(multi-objs-m:.o=.s)   : modname = $(modname-multi)
+$(multi-objs-m:.o=.lst) : modname = $(modname-multi)
+$(multi-objs-y)         : modname = $(modname-multi)
+$(multi-objs-y:.o=.i)   : modname = $(modname-multi)
+$(multi-objs-y:.o=.s)   : modname = $(modname-multi)
+$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
+
+quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
+cmd_cc_s_c       = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
+
+$(obj)/%.s: $(src)/%.c FORCE
+	$(call if_changed_dep,cc_s_c)
+
+quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@
+cmd_cc_i_c       = $(CPP) $(c_flags)   -o $@ $<
+
+$(obj)/%.i: $(src)/%.c FORCE
+	$(call if_changed_dep,cc_i_c)
+
+cmd_gensymtypes =                                                           \
+    $(CPP) -D__GENKSYMS__ $(c_flags) $< |                                   \
+    $(GENKSYMS) $(if $(1), -T $(2))                                         \
+     $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))             \
+     $(if $(KBUILD_PRESERVE),-p)                                            \
+     -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
+
+quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
+cmd_cc_symtypes_c =                                                         \
+    set -e;                                                                 \
+    $(call cmd_gensymtypes,true,$@) >/dev/null;                             \
+    test -s $@ || rm -f $@
+
+$(obj)/%.symtypes : $(src)/%.c FORCE
+	$(call cmd,cc_symtypes_c)
+
+# C (.c) files
+# The C file is compiled and updated dependency information is generated.
+# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
+
+quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
+
+ifndef CONFIG_MODVERSIONS
+cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
+
+else
+# When module versioning is enabled the following steps are executed:
+# o compile a .tmp_<file>.o from <file>.c
+# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
+#   not export symbols, we just rename .tmp_<file>.o to <file>.o and
+#   are done.
+# o otherwise, we calculate symbol versions using the good old
+#   genksyms on the preprocessed source and postprocess them in a way
+#   that they are usable as a linker script
+# o generate <file>.o from .tmp_<file>.o using the linker to
+#   replace the unresolved symbols __crc_exported_symbol with
+#   the actual value of the checksum generated by genksyms
+
+cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
+cmd_modversions =								\
+	if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then		\
+		$(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes))	\
+		    > $(@D)/.tmp_$(@F:.o=.ver);					\
+										\
+		$(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) 			\
+			-T $(@D)/.tmp_$(@F:.o=.ver);				\
+		rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver);		\
+	else									\
+		mv -f $(@D)/.tmp_$(@F) $@;					\
+	fi;
+endif
+
+ifdef CONFIG_FTRACE_MCOUNT_RECORD
+ifdef BUILD_C_RECORDMCOUNT
+ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
+  RECORDMCOUNT_FLAGS = -w
+endif
+# Due to recursion, we must skip empty.o.
+# The empty.o file is created in the make process in order to determine
+#  the target endianness and word size. It is made before all other C
+#  files, including recordmcount.
+sub_cmd_record_mcount =					\
+	if [ $(@) != "scripts/mod/empty.o" ]; then	\
+		$(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)";	\
+	fi;
+recordmcount_source := $(srctree)/scripts/recordmcount.c \
+		    $(srctree)/scripts/recordmcount.h
+else
+sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
+	"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
+	"$(if $(CONFIG_64BIT),64,32)" \
+	"$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \
+	"$(LD)" "$(NM)" "$(RM)" "$(MV)" \
+	"$(if $(part-of-module),1,0)" "$(@)";
+recordmcount_source := $(srctree)/scripts/recordmcount.pl
+endif
+cmd_record_mcount = 						\
+	if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then	\
+		$(sub_cmd_record_mcount)			\
+	fi;
+endif
+
+define rule_cc_o_c
+	$(call echo-cmd,checksrc) $(cmd_checksrc)			  \
+	$(call echo-cmd,cc_o_c) $(cmd_cc_o_c);				  \
+	$(cmd_modversions)						  \
+	$(call echo-cmd,record_mcount)					  \
+	$(cmd_record_mcount)						  \
+	scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' >    \
+	                                              $(dot-target).tmp;  \
+	rm -f $(depfile);						  \
+	mv -f $(dot-target).tmp $(dot-target).cmd
+endef
+
+# Built-in and composite module parts
+$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
+	$(call cmd,force_checksrc)
+	$(call if_changed_rule,cc_o_c)
+
+# Single-part modules are special since we need to mark them in $(MODVERDIR)
+
+$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
+	$(call cmd,force_checksrc)
+	$(call if_changed_rule,cc_o_c)
+	@{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
+
+quiet_cmd_cc_lst_c = MKLST   $@
+      cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
+		     $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
+				     System.map $(OBJDUMP) > $@
+
+$(obj)/%.lst: $(src)/%.c FORCE
+	$(call if_changed_dep,cc_lst_c)
+
+# Compile assembler sources (.S)
+# ---------------------------------------------------------------------------
+
+modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
+
+$(real-objs-m)      : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
+$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
+
+quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
+cmd_as_s_S       = $(CPP) $(a_flags)   -o $@ $< 
+
+$(obj)/%.s: $(src)/%.S FORCE
+	$(call if_changed_dep,as_s_S)
+
+quiet_cmd_as_o_S = AS $(quiet_modtag)  $@
+cmd_as_o_S       = $(CC) $(a_flags) -c -o $@ $<
+
+$(obj)/%.o: $(src)/%.S FORCE
+	$(call if_changed_dep,as_o_S)
+
+targets += $(real-objs-y) $(real-objs-m) $(lib-y)
+targets += $(extra-y) $(MAKECMDGOALS) $(always)
+
+# Linker scripts preprocessor (.lds.S -> .lds)
+# ---------------------------------------------------------------------------
+quiet_cmd_cpp_lds_S = LDS     $@
+      cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
+	                     -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
+
+$(obj)/%.lds: $(src)/%.lds.S FORCE
+	$(call if_changed_dep,cpp_lds_S)
+
+# ASN.1 grammar
+# ---------------------------------------------------------------------------
+quiet_cmd_asn1_compiler = ASN.1   $@
+      cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \
+				$(subst .h,.c,$@) $(subst .c,.h,$@)
+
+.PRECIOUS: $(objtree)/$(obj)/%-asn1.c $(objtree)/$(obj)/%-asn1.h
+
+$(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
+	$(call cmd,asn1_compiler)
+
+# Build the compiled-in targets
+# ---------------------------------------------------------------------------
+
+# To build objects in subdirs, we need to descend into the directories
+$(sort $(subdir-obj-y)): $(subdir-ym) ;
+
+#
+# Rule to compile a set of .o files into one .o file
+#
+ifdef builtin-target
+quiet_cmd_link_o_target = LD      $@
+# If the list of objects to link is empty, just create an empty built-in.o
+cmd_link_o_target = $(if $(strip $(obj-y)),\
+		      $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \
+		      $(cmd_secanalysis),\
+		      rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@)
+
+$(builtin-target): $(obj-y) FORCE
+	$(call if_changed,link_o_target)
+
+targets += $(builtin-target)
+endif # builtin-target
+
+#
+# Rule to create modules.order file
+#
+# Create commands to either record .ko file or cat modules.order from
+# a subdirectory
+modorder-cmds =						\
+	$(foreach m, $(modorder),			\
+		$(if $(filter %/modules.order, $m),	\
+			cat $m;, echo kernel/$m;))
+
+$(modorder-target): $(subdir-ym) FORCE
+	$(Q)(cat /dev/null; $(modorder-cmds)) > $@
+
+#
+# Rule to compile a set of .o files into one .a file
+#
+ifdef lib-target
+quiet_cmd_link_l_target = AR      $@
+cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y)
+
+$(lib-target): $(lib-y) FORCE
+	$(call if_changed,link_l_target)
+
+targets += $(lib-target)
+endif
+
+#
+# Rule to link composite objects
+#
+#  Composite objects are specified in kbuild makefile as follows:
+#    <composite-object>-objs := <list of .o files>
+#  or
+#    <composite-object>-y    := <list of .o files>
+link_multi_deps =                     \
+$(filter $(addprefix $(obj)/,         \
+$($(subst $(obj)/,,$(@:.o=-objs)))    \
+$($(subst $(obj)/,,$(@:.o=-y)))), $^)
+ 
+quiet_cmd_link_multi-y = LD      $@
+cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
+
+quiet_cmd_link_multi-m = LD [M]  $@
+cmd_link_multi-m = $(cmd_link_multi-y)
+
+# We would rather have a list of rules like
+# 	foo.o: $(foo-objs)
+# but that's not so easy, so we rather make all composite objects depend
+# on the set of all their parts
+$(multi-used-y) : %.o: $(multi-objs-y) FORCE
+	$(call if_changed,link_multi-y)
+
+$(multi-used-m) : %.o: $(multi-objs-m) FORCE
+	$(call if_changed,link_multi-m)
+	@{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod)
+
+targets += $(multi-used-y) $(multi-used-m)
+
+
+# Descending
+# ---------------------------------------------------------------------------
+
+PHONY += $(subdir-ym)
+$(subdir-ym):
+	$(Q)$(MAKE) $(build)=$@
+
+# Add FORCE to the prequisites of a target to force it to be always rebuilt.
+# ---------------------------------------------------------------------------
+
+PHONY += FORCE
+
+FORCE:
+
+# Read all saved command lines and dependencies for the $(targets) we
+# may be building above, using $(if_changed{,_dep}). As an
+# optimization, we don't need to read them if the target does not
+# exist, we will rebuild anyway in that case.
+
+targets := $(wildcard $(sort $(targets)))
+cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
+
+ifneq ($(cmd_files),)
+  include $(cmd_files)
+endif
+
+# Declare the contents of the .PHONY variable as phony.  We keep that
+# information in a variable se we can use it in if_changed and friends.
+
+.PHONY: $(PHONY)
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
new file mode 100644
index 0000000..686cb0d
--- /dev/null
+++ b/scripts/Makefile.clean
@@ -0,0 +1,104 @@
+# ==========================================================================
+# Cleaning up
+# ==========================================================================
+
+src := $(obj)
+
+PHONY := __clean
+__clean:
+
+# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
+# Usage:
+# $(Q)$(MAKE) $(clean)=dir
+clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
+
+# The filename Kbuild has precedence over Makefile
+kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
+include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
+
+# Figure out what we need to build from the various variables
+# ==========================================================================
+
+__subdir-y	:= $(patsubst %/,%,$(filter %/, $(obj-y)))
+subdir-y	+= $(__subdir-y)
+__subdir-m	:= $(patsubst %/,%,$(filter %/, $(obj-m)))
+subdir-m	+= $(__subdir-m)
+__subdir-n	:= $(patsubst %/,%,$(filter %/, $(obj-n)))
+subdir-n	+= $(__subdir-n)
+__subdir-	:= $(patsubst %/,%,$(filter %/, $(obj-)))
+subdir-		+= $(__subdir-)
+
+# Subdirectories we need to descend into
+
+subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
+subdir-ymn      := $(sort $(subdir-ym) $(subdir-n) $(subdir-))
+
+# Add subdir path
+
+subdir-ymn	:= $(addprefix $(obj)/,$(subdir-ymn))
+
+# build a list of files to remove, usually relative to the current
+# directory
+
+__clean-files	:= $(extra-y) $(always)                  \
+		   $(targets) $(clean-files)             \
+		   $(host-progs)                         \
+		   $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
+
+__clean-files   := $(filter-out $(no-clean-files), $(__clean-files))
+
+# as clean-files is given relative to the current directory, this adds
+# a $(obj) prefix, except for absolute paths
+
+__clean-files   := $(wildcard                                               \
+                   $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \
+		   $(filter /%, $(__clean-files)))
+
+# as clean-dirs is given relative to the current directory, this adds
+# a $(obj) prefix, except for absolute paths
+
+__clean-dirs    := $(wildcard                                               \
+                   $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs)))    \
+		   $(filter /%, $(clean-dirs)))
+
+# ==========================================================================
+
+quiet_cmd_clean    = CLEAN   $(obj)
+      cmd_clean    = rm -f $(__clean-files)
+quiet_cmd_cleandir = CLEAN   $(__clean-dirs)
+      cmd_cleandir = rm -rf $(__clean-dirs)
+
+
+__clean: $(subdir-ymn)
+ifneq ($(strip $(__clean-files)),)
+	+$(call cmd,clean)
+endif
+ifneq ($(strip $(__clean-dirs)),)
+	+$(call cmd,cleandir)
+endif
+ifneq ($(strip $(clean-rule)),)
+	+$(clean-rule)
+endif
+	@:
+
+
+# ===========================================================================
+# Generic stuff
+# ===========================================================================
+
+# Descending
+# ---------------------------------------------------------------------------
+
+PHONY += $(subdir-ymn)
+$(subdir-ymn):
+	$(Q)$(MAKE) $(clean)=$@
+
+# If quiet is set, only print short version of command
+
+cmd = @$(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
+
+
+# Declare the contents of the .PHONY variable as phony.  We keep that
+# information in a variable se we can use it in if_changed and friends.
+
+.PHONY: $(PHONY)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
new file mode 100644
index 0000000..1ac414f
--- /dev/null
+++ b/scripts/Makefile.host
@@ -0,0 +1,170 @@
+# ==========================================================================
+# Building binaries on the host system
+# Binaries are used during the compilation of the kernel, for example
+# to preprocess a data file.
+#
+# Both C and C++ are supported, but preferred language is C for such utilities.
+#
+# Sample syntax (see Documentation/kbuild/makefiles.txt for reference)
+# hostprogs-y := bin2hex
+# Will compile bin2hex.c and create an executable named bin2hex
+#
+# hostprogs-y    := lxdialog
+# lxdialog-objs := checklist.o lxdialog.o
+# Will compile lxdialog.c and checklist.c, and then link the executable
+# lxdialog, based on checklist.o and lxdialog.o
+#
+# hostprogs-y      := qconf
+# qconf-cxxobjs   := qconf.o
+# qconf-objs      := menu.o
+# Will compile qconf as a C++ program, and menu as a C program.
+# They are linked as C++ code to the executable qconf
+
+# hostprogs-y := conf
+# conf-objs  := conf.o libkconfig.so
+# libkconfig-objs := expr.o type.o
+# Will create a shared library named libkconfig.so that consists of
+# expr.o and type.o (they are both compiled as C code and the object files
+# are made as position independent code).
+# conf.c is compiled as a C program, and conf.o is linked together with
+# libkconfig.so as the executable conf.
+# Note: Shared libraries consisting of C++ files are not supported
+
+__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
+
+# C code
+# Executables compiled from a single .c file
+host-csingle	:= $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
+
+# C executables linked based on several .o files
+host-cmulti	:= $(foreach m,$(__hostprogs),\
+		   $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
+
+# Object (.o) files compiled from .c files
+host-cobjs	:= $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
+
+# C++ code
+# C++ executables compiled from at least on .cc file
+# and zero or more .c files
+host-cxxmulti	:= $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m)))
+
+# C++ Object (.o) files compiled from .cc files
+host-cxxobjs	:= $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
+
+# Shared libaries (only .c supported)
+# Shared libraries (.so) - all .so files referenced in "xxx-objs"
+host-cshlib	:= $(sort $(filter %.so, $(host-cobjs)))
+# Remove .so files from "xxx-objs"
+host-cobjs	:= $(filter-out %.so,$(host-cobjs))
+
+#Object (.o) files used by the shared libaries
+host-cshobjs	:= $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
+
+# output directory for programs/.o files
+# hostprogs-y := tools/build may have been specified. Retrieve directory
+host-objdirs := $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f))))
+# directory of .o files from prog-objs notation
+host-objdirs += $(foreach f,$(host-cmulti),                  \
+                    $(foreach m,$($(f)-objs),                \
+                        $(if $(dir $(m)),$(dir $(m)))))
+# directory of .o files from prog-cxxobjs notation
+host-objdirs += $(foreach f,$(host-cxxmulti),                  \
+                    $(foreach m,$($(f)-cxxobjs),                \
+                        $(if $(dir $(m)),$(dir $(m)))))
+
+host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs))))
+
+
+__hostprogs     := $(addprefix $(obj)/,$(__hostprogs))
+host-csingle	:= $(addprefix $(obj)/,$(host-csingle))
+host-cmulti	:= $(addprefix $(obj)/,$(host-cmulti))
+host-cobjs	:= $(addprefix $(obj)/,$(host-cobjs))
+host-cxxmulti	:= $(addprefix $(obj)/,$(host-cxxmulti))
+host-cxxobjs	:= $(addprefix $(obj)/,$(host-cxxobjs))
+host-cshlib	:= $(addprefix $(obj)/,$(host-cshlib))
+host-cshobjs	:= $(addprefix $(obj)/,$(host-cshobjs))
+host-objdirs    := $(addprefix $(obj)/,$(host-objdirs))
+
+obj-dirs += $(host-objdirs)
+
+#####
+# Handle options to gcc. Support building with separate output directory
+
+_hostc_flags   = $(HOSTCFLAGS)   $(HOST_EXTRACFLAGS)   \
+                 $(HOSTCFLAGS_$(basetarget).o)
+_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
+                 $(HOSTCXXFLAGS_$(basetarget).o)
+
+ifeq ($(KBUILD_SRC),)
+__hostc_flags	= $(_hostc_flags)
+__hostcxx_flags	= $(_hostcxx_flags)
+else
+__hostc_flags	= -I$(obj) $(call flags,_hostc_flags)
+__hostcxx_flags	= -I$(obj) $(call flags,_hostcxx_flags)
+endif
+
+hostc_flags    = -Wp,-MD,$(depfile) $(__hostc_flags)
+hostcxx_flags  = -Wp,-MD,$(depfile) $(__hostcxx_flags)
+
+#####
+# Compile programs on the host
+
+# Create executable from a single .c file
+# host-csingle -> Executable
+quiet_cmd_host-csingle 	= HOSTCC  $@
+      cmd_host-csingle	= $(HOSTCC) $(hostc_flags) -o $@ $< \
+	  	$(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
+$(host-csingle): $(obj)/%: $(src)/%.c FORCE
+	$(call if_changed_dep,host-csingle)
+
+# Link an executable based on list of .o files, all plain c
+# host-cmulti -> executable
+quiet_cmd_host-cmulti	= HOSTLD  $@
+      cmd_host-cmulti	= $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
+			  $(addprefix $(obj)/,$($(@F)-objs)) \
+			  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
+$(host-cmulti): $(obj)/%: $(host-cobjs) $(host-cshlib) FORCE
+	$(call if_changed,host-cmulti)
+
+# Create .o file from a single .c file
+# host-cobjs -> .o
+quiet_cmd_host-cobjs	= HOSTCC  $@
+      cmd_host-cobjs	= $(HOSTCC) $(hostc_flags) -c -o $@ $<
+$(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE
+	$(call if_changed_dep,host-cobjs)
+
+# Link an executable based on list of .o files, a mixture of .c and .cc
+# host-cxxmulti -> executable
+quiet_cmd_host-cxxmulti	= HOSTLD  $@
+      cmd_host-cxxmulti	= $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \
+			  $(foreach o,objs cxxobjs,\
+			  $(addprefix $(obj)/,$($(@F)-$(o)))) \
+			  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
+$(host-cxxmulti): $(obj)/%: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE
+	$(call if_changed,host-cxxmulti)
+
+# Create .o file from a single .cc (C++) file
+quiet_cmd_host-cxxobjs	= HOSTCXX $@
+      cmd_host-cxxobjs	= $(HOSTCXX) $(hostcxx_flags) -c -o $@ $<
+$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE
+	$(call if_changed_dep,host-cxxobjs)
+
+# Compile .c file, create position independent .o file
+# host-cshobjs -> .o
+quiet_cmd_host-cshobjs	= HOSTCC  -fPIC $@
+      cmd_host-cshobjs	= $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $<
+$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
+	$(call if_changed_dep,host-cshobjs)
+
+# Link a shared library, based on position independent .o files
+# *.o -> .so shared library (host-cshlib)
+quiet_cmd_host-cshlib	= HOSTLLD -shared $@
+      cmd_host-cshlib	= $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \
+			  $(addprefix $(obj)/,$($(@F:.so=-objs))) \
+			  $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
+$(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
+	$(call if_changed,host-cshlib)
+
+targets += $(host-csingle)  $(host-cmulti) $(host-cobjs)\
+	   $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) 
+
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
new file mode 100644
index 0000000..49392ec
--- /dev/null
+++ b/scripts/Makefile.lib
@@ -0,0 +1,373 @@
+# Backward compatibility
+asflags-y  += $(EXTRA_AFLAGS)
+ccflags-y  += $(EXTRA_CFLAGS)
+cppflags-y += $(EXTRA_CPPFLAGS)
+ldflags-y  += $(EXTRA_LDFLAGS)
+
+#
+# flags that take effect in sub directories
+export KBUILD_SUBDIR_ASFLAGS := $(KBUILD_SUBDIR_ASFLAGS) $(subdir-asflags-y)
+export KBUILD_SUBDIR_CCFLAGS := $(KBUILD_SUBDIR_CCFLAGS) $(subdir-ccflags-y)
+
+# Figure out what we need to build from the various variables
+# ===========================================================================
+
+# When an object is listed to be built compiled-in and modular,
+# only build the compiled-in version
+
+obj-m := $(filter-out $(obj-y),$(obj-m))
+
+# Libraries are always collected in one lib file.
+# Filter out objects already built-in
+
+lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
+
+
+# Handle objects in subdirs
+# ---------------------------------------------------------------------------
+# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o
+#   and add the directory to the list of dirs to descend into: $(subdir-y)
+# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) 
+#   and add the directory to the list of dirs to descend into: $(subdir-m)
+
+# Determine modorder.
+# Unfortunately, we don't have information about ordering between -y
+# and -m subdirs.  Just put -y's first.
+modorder	:= $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
+
+__subdir-y	:= $(patsubst %/,%,$(filter %/, $(obj-y)))
+subdir-y	+= $(__subdir-y)
+__subdir-m	:= $(patsubst %/,%,$(filter %/, $(obj-m)))
+subdir-m	+= $(__subdir-m)
+obj-y		:= $(patsubst %/, %/built-in.o, $(obj-y))
+obj-m		:= $(filter-out %/, $(obj-m))
+
+# Subdirectories we need to descend into
+
+subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
+
+# if $(foo-objs) exists, foo.o is a composite object 
+multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
+multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
+multi-used   := $(multi-used-y) $(multi-used-m)
+single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
+
+# Build list of the parts of our composite objects, our composite
+# objects depend on those (obviously)
+multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
+multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
+multi-objs   := $(multi-objs-y) $(multi-objs-m)
+
+# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
+# tell kbuild to descend
+subdir-obj-y := $(filter %/built-in.o, $(obj-y))
+
+# $(obj-dirs) is a list of directories that contain object files
+obj-dirs := $(dir $(multi-objs) $(obj-y))
+
+# Replace multi-part objects by their individual parts, look at local dir only
+real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
+real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
+
+# Add subdir path
+
+extra-y		:= $(addprefix $(obj)/,$(extra-y))
+always		:= $(addprefix $(obj)/,$(always))
+targets		:= $(addprefix $(obj)/,$(targets))
+modorder	:= $(addprefix $(obj)/,$(modorder))
+obj-y		:= $(addprefix $(obj)/,$(obj-y))
+obj-m		:= $(addprefix $(obj)/,$(obj-m))
+lib-y		:= $(addprefix $(obj)/,$(lib-y))
+subdir-obj-y	:= $(addprefix $(obj)/,$(subdir-obj-y))
+real-objs-y	:= $(addprefix $(obj)/,$(real-objs-y))
+real-objs-m	:= $(addprefix $(obj)/,$(real-objs-m))
+single-used-m	:= $(addprefix $(obj)/,$(single-used-m))
+multi-used-y	:= $(addprefix $(obj)/,$(multi-used-y))
+multi-used-m	:= $(addprefix $(obj)/,$(multi-used-m))
+multi-objs-y	:= $(addprefix $(obj)/,$(multi-objs-y))
+multi-objs-m	:= $(addprefix $(obj)/,$(multi-objs-m))
+subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))
+obj-dirs	:= $(addprefix $(obj)/,$(obj-dirs))
+
+# These flags are needed for modversions and compiling, so we define them here
+# already
+# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will 
+# end up in (or would, if it gets compiled in)
+# Note: Files that end up in two or more modules are compiled without the
+#       KBUILD_MODNAME definition. The reason is that any made-up name would
+#       differ in different configs.
+name-fix = $(subst $(comma),_,$(subst -,_,$1))
+basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
+modname_flags  = $(if $(filter 1,$(words $(modname))),\
+                 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
+
+orig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
+                 $(ccflags-y) $(CFLAGS_$(basetarget).o)
+_c_flags       = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
+_a_flags       = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
+                 $(asflags-y) $(AFLAGS_$(basetarget).o)
+_cpp_flags     = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
+
+#
+# Enable gcov profiling flags for a file, directory or for all files depending
+# on variables GCOV_PROFILE_obj.o, GCOV_PROFILE and CONFIG_GCOV_PROFILE_ALL
+# (in this order)
+#
+ifeq ($(CONFIG_GCOV_KERNEL),y)
+_c_flags += $(if $(patsubst n%,, \
+		$(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \
+		$(CFLAGS_GCOV))
+endif
+
+# If building the kernel in a separate objtree expand all occurrences
+# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
+
+ifeq ($(KBUILD_SRC),)
+__c_flags	= $(_c_flags)
+__a_flags	= $(_a_flags)
+__cpp_flags     = $(_cpp_flags)
+else
+
+# -I$(obj) locates generated .h files
+# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
+#   and locates generated .h files
+# FIXME: Replace both with specific CFLAGS* statements in the makefiles
+__c_flags	= $(call addtree,-I$(obj)) $(call flags,_c_flags)
+__a_flags	=                          $(call flags,_a_flags)
+__cpp_flags     =                          $(call flags,_cpp_flags)
+endif
+
+c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+		 $(__c_flags) $(modkern_cflags)                           \
+		 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
+
+a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+		 $(__a_flags) $(modkern_aflags)
+
+cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+		 $(__cpp_flags)
+
+ld_flags       = $(LDFLAGS) $(ldflags-y)
+
+dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc                    \
+		 -I$(srctree)/arch/$(SRCARCH)/boot/dts                   \
+		 -I$(srctree)/arch/$(SRCARCH)/boot/dts/include           \
+		 -undef -D__DTS__
+
+# Finds the multi-part object the current object will be linked into
+modname-multi = $(sort $(foreach m,$(multi-used),\
+		$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
+
+ifdef REGENERATE_PARSERS
+
+# GPERF
+# ---------------------------------------------------------------------------
+quiet_cmd_gperf = GPERF $@
+      cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $<
+
+.PRECIOUS: $(src)/%.hash.c_shipped
+$(src)/%.hash.c_shipped: $(src)/%.gperf
+	$(call cmd,gperf)
+
+# LEX
+# ---------------------------------------------------------------------------
+LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy)
+
+quiet_cmd_flex = LEX     $@
+      cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $<
+
+.PRECIOUS: $(src)/%.lex.c_shipped
+$(src)/%.lex.c_shipped: $(src)/%.l
+	$(call cmd,flex)
+
+# YACC
+# ---------------------------------------------------------------------------
+YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy)
+
+quiet_cmd_bison = YACC    $@
+      cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $<
+
+.PRECIOUS: $(src)/%.tab.c_shipped
+$(src)/%.tab.c_shipped: $(src)/%.y
+	$(call cmd,bison)
+
+quiet_cmd_bison_h = YACC    $@
+      cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $<
+
+.PRECIOUS: $(src)/%.tab.h_shipped
+$(src)/%.tab.h_shipped: $(src)/%.y
+	$(call cmd,bison_h)
+
+endif
+
+# Shipped files
+# ===========================================================================
+
+quiet_cmd_shipped = SHIPPED $@
+cmd_shipped = cat $< > $@
+
+$(obj)/%: $(src)/%_shipped
+	$(call cmd,shipped)
+
+# Commands useful for building a boot image
+# ===========================================================================
+# 
+#	Use as following:
+#
+#	target: source(s) FORCE
+#		$(if_changed,ld/objcopy/gzip)
+#
+#	and add target to extra-y so that we know we have to
+#	read in the saved command line
+
+# Linking
+# ---------------------------------------------------------------------------
+
+quiet_cmd_ld = LD      $@
+cmd_ld = $(LD) $(LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) \
+	       $(filter-out FORCE,$^) -o $@ 
+
+# Objcopy
+# ---------------------------------------------------------------------------
+
+quiet_cmd_objcopy = OBJCOPY $@
+cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
+
+# Gzip
+# ---------------------------------------------------------------------------
+
+quiet_cmd_gzip = GZIP    $@
+cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
+	(rm -f $@ ; false)
+
+# DTC
+# ---------------------------------------------------------------------------
+
+# Generate an assembly file to wrap the output of the device tree compiler
+quiet_cmd_dt_S_dtb= DTB     $@
+cmd_dt_S_dtb=						\
+(							\
+	echo '\#include <asm-generic/vmlinux.lds.h>'; 	\
+	echo '.section .dtb.init.rodata,"a"';		\
+	echo '.balign STRUCT_ALIGNMENT';		\
+	echo '.global __dtb_$(*F)_begin';		\
+	echo '__dtb_$(*F)_begin:';			\
+	echo '.incbin "$<" ';				\
+	echo '__dtb_$(*F)_end:';			\
+	echo '.global __dtb_$(*F)_end';			\
+	echo '.balign STRUCT_ALIGNMENT'; 		\
+) > $@
+
+$(obj)/%.dtb.S: $(obj)/%.dtb
+	$(call cmd,dt_S_dtb)
+
+quiet_cmd_dtc = DTC     $@
+cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
+	$(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
+		-i $(dir $<) $(DTC_FLAGS) \
+		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
+	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
+
+$(obj)/%.dtb: $(src)/%.dts FORCE
+	$(call if_changed_dep,dtc)
+
+dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
+
+# Bzip2
+# ---------------------------------------------------------------------------
+
+# Bzip2 and LZMA do not include size in file... so we have to fake that;
+# append the size as a 32-bit littleendian number as gzip does.
+size_append = printf $(shell						\
+dec_size=0;								\
+for F in $1; do								\
+	fsize=$$(stat -c "%s" $$F);					\
+	dec_size=$$(expr $$dec_size + $$fsize);				\
+done;									\
+printf "%08x\n" $$dec_size |						\
+	sed 's/\(..\)/\1 /g' | {					\
+		read ch0 ch1 ch2 ch3;					\
+		for ch in $$ch3 $$ch2 $$ch1 $$ch0; do			\
+			printf '%s%03o' '\\' $$((0x$$ch)); 		\
+		done;							\
+	}								\
+)
+
+quiet_cmd_bzip2 = BZIP2   $@
+cmd_bzip2 = (cat $(filter-out FORCE,$^) | \
+	bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
+	(rm -f $@ ; false)
+
+# Lzma
+# ---------------------------------------------------------------------------
+
+quiet_cmd_lzma = LZMA    $@
+cmd_lzma = (cat $(filter-out FORCE,$^) | \
+	lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
+	(rm -f $@ ; false)
+
+quiet_cmd_lzo = LZO     $@
+cmd_lzo = (cat $(filter-out FORCE,$^) | \
+	lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
+	(rm -f $@ ; false)
+
+quiet_cmd_lz4 = LZ4     $@
+cmd_lz4 = (cat $(filter-out FORCE,$^) | \
+	lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
+	(rm -f $@ ; false)
+
+# U-Boot mkimage
+# ---------------------------------------------------------------------------
+
+MKIMAGE := $(srctree)/scripts/mkuboot.sh
+
+# SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces
+# the number of overrides in arch makefiles
+UIMAGE_ARCH ?= $(SRCARCH)
+UIMAGE_COMPRESSION ?= $(if $(2),$(2),none)
+UIMAGE_OPTS-y ?=
+UIMAGE_TYPE ?= kernel
+UIMAGE_LOADADDR ?= arch_must_set_this
+UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
+UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
+UIMAGE_IN ?= $<
+UIMAGE_OUT ?= $@
+
+quiet_cmd_uimage = UIMAGE  $(UIMAGE_OUT)
+      cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
+			-C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
+			-T $(UIMAGE_TYPE) \
+			-a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
+			-n $(UIMAGE_NAME) -d $(UIMAGE_IN) $(UIMAGE_OUT)
+
+# XZ
+# ---------------------------------------------------------------------------
+# Use xzkern to compress the kernel image and xzmisc to compress other things.
+#
+# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage
+# of the kernel decompressor. A BCJ filter is used if it is available for
+# the target architecture. xzkern also appends uncompressed size of the data
+# using size_append. The .xz format has the size information available at
+# the end of the file too, but it's in more complex format and it's good to
+# avoid changing the part of the boot code that reads the uncompressed size.
+# Note that the bytes added by size_append will make the xz tool think that
+# the file is corrupt. This is expected.
+#
+# xzmisc doesn't use size_append, so it can be used to create normal .xz
+# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very
+# big dictionary would increase the memory usage too much in the multi-call
+# decompression mode. A BCJ filter isn't used either.
+quiet_cmd_xzkern = XZKERN  $@
+cmd_xzkern = (cat $(filter-out FORCE,$^) | \
+	sh $(srctree)/scripts/xz_wrap.sh && \
+	$(call size_append, $(filter-out FORCE,$^))) > $@ || \
+	(rm -f $@ ; false)
+
+quiet_cmd_xzmisc = XZMISC  $@
+cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
+	xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
+	(rm -f $@ ; false)
+
+# misc stuff
+# ---------------------------------------------------------------------------
+quote:="
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore
new file mode 100644
index 0000000..a776371
--- /dev/null
+++ b/scripts/basic/.gitignore
@@ -0,0 +1 @@
+fixdep
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
new file mode 100644
index 0000000..4fcef87
--- /dev/null
+++ b/scripts/basic/Makefile
@@ -0,0 +1,15 @@
+###
+# Makefile.basic lists the most basic programs used during the build process.
+# The programs listed herein are what are needed to do the basic stuff,
+# such as fix file dependencies.
+# This initial step is needed to avoid files to be recompiled
+# when kernel configuration changes (which is what happens when
+# .config is included by main Makefile.
+# ---------------------------------------------------------------------------
+# fixdep: 	 Used to generate dependency information during build process
+
+hostprogs-y	:= fixdep
+always		:= $(hostprogs-y)
+
+# fixdep is needed to compile other host programs
+$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
new file mode 100644
index 0000000..078fe1d
--- /dev/null
+++ b/scripts/basic/fixdep.c
@@ -0,0 +1,462 @@
+/*
+ * "Optimize" a list of dependencies as spit out by gcc -MD
+ * for the kernel build
+ * ===========================================================================
+ *
+ * Author       Kai Germaschewski
+ * Copyright    2002 by Kai Germaschewski  <kai.germaschewski@gmx.de>
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ *
+ *
+ * Introduction:
+ *
+ * gcc produces a very nice and correct list of dependencies which
+ * tells make when to remake a file.
+ *
+ * To use this list as-is however has the drawback that virtually
+ * every file in the kernel includes autoconf.h.
+ *
+ * If the user re-runs make *config, autoconf.h will be
+ * regenerated.  make notices that and will rebuild every file which
+ * includes autoconf.h, i.e. basically all files. This is extremely
+ * annoying if the user just changed CONFIG_HIS_DRIVER from n to m.
+ *
+ * So we play the same trick that "mkdep" played before. We replace
+ * the dependency on autoconf.h by a dependency on every config
+ * option which is mentioned in any of the listed prequisites.
+ *
+ * kconfig populates a tree in include/config/ with an empty file
+ * for each config symbol and when the configuration is updated
+ * the files representing changed config options are touched
+ * which then let make pick up the changes and the files that use
+ * the config symbols are rebuilt.
+ *
+ * So if the user changes his CONFIG_HIS_DRIVER option, only the objects
+ * which depend on "include/linux/config/his/driver.h" will be rebuilt,
+ * so most likely only his driver ;-)
+ *
+ * The idea above dates, by the way, back to Michael E Chastain, AFAIK.
+ *
+ * So to get dependencies right, there are two issues:
+ * o if any of the files the compiler read changed, we need to rebuild
+ * o if the command line given to the compile the file changed, we
+ *   better rebuild as well.
+ *
+ * The former is handled by using the -MD output, the later by saving
+ * the command line used to compile the old object and comparing it
+ * to the one we would now use.
+ *
+ * Again, also this idea is pretty old and has been discussed on
+ * kbuild-devel a long time ago. I don't have a sensibly working
+ * internet connection right now, so I rather don't mention names
+ * without double checking.
+ *
+ * This code here has been based partially based on mkdep.c, which
+ * says the following about its history:
+ *
+ *   Copyright abandoned, Michael Chastain, <mailto:mec@shout.net>.
+ *   This is a C version of syncdep.pl by Werner Almesberger.
+ *
+ *
+ * It is invoked as
+ *
+ *   fixdep <depfile> <target> <cmdline>
+ *
+ * and will read the dependency file <depfile>
+ *
+ * The transformed dependency snipped is written to stdout.
+ *
+ * It first generates a line
+ *
+ *   cmd_<target> = <cmdline>
+ *
+ * and then basically copies the .<target>.d file to stdout, in the
+ * process filtering out the dependency on autoconf.h and adding
+ * dependencies on include/config/my/option.h for every
+ * CONFIG_MY_OPTION encountered in any of the prequisites.
+ *
+ * It will also filter out all the dependencies on *.ver. We need
+ * to make sure that the generated version checksum are globally up
+ * to date before even starting the recursive build, so it's too late
+ * at this point anyway.
+ *
+ * The algorithm to grep for "CONFIG_..." is bit unusual, but should
+ * be fast ;-) We don't even try to really parse the header files, but
+ * merely grep, i.e. if CONFIG_FOO is mentioned in a comment, it will
+ * be picked up as well. It's not a problem with respect to
+ * correctness, since that can only give too many dependencies, thus
+ * we cannot miss a rebuild. Since people tend to not mention totally
+ * unrelated CONFIG_ options all over the place, it's not an
+ * efficiency problem either.
+ *
+ * (Note: it'd be easy to port over the complete mkdep state machine,
+ *  but I don't think the added complexity is worth it)
+ */
+/*
+ * Note 2: if somebody writes HELLO_CONFIG_BOOM in a file, it will depend onto
+ * CONFIG_BOOM. This could seem a bug (not too hard to fix), but please do not
+ * fix it! Some UserModeLinux files (look at arch/um/) call CONFIG_BOOM as
+ * UML_CONFIG_BOOM, to avoid conflicts with /usr/include/linux/autoconf.h,
+ * through arch/um/include/uml-config.h; this fixdep "bug" makes sure that
+ * those files will have correct dependencies.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <limits.h>
+#include <ctype.h>
+#include <arpa/inet.h>
+
+#define INT_CONF ntohl(0x434f4e46)
+#define INT_ONFI ntohl(0x4f4e4649)
+#define INT_NFIG ntohl(0x4e464947)
+#define INT_FIG_ ntohl(0x4649475f)
+
+char *target;
+char *depfile;
+char *cmdline;
+
+static void usage(void)
+{
+	fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n");
+	exit(1);
+}
+
+/*
+ * Print out the commandline prefixed with cmd_<target filename> :=
+ */
+static void print_cmdline(void)
+{
+	printf("cmd_%s := %s\n\n", target, cmdline);
+}
+
+struct item {
+	struct item	*next;
+	unsigned int	len;
+	unsigned int	hash;
+	char		name[0];
+};
+
+#define HASHSZ 256
+static struct item *hashtab[HASHSZ];
+
+static unsigned int strhash(const char *str, unsigned int sz)
+{
+	/* fnv32 hash */
+	unsigned int i, hash = 2166136261U;
+
+	for (i = 0; i < sz; i++)
+		hash = (hash ^ str[i]) * 0x01000193;
+	return hash;
+}
+
+/*
+ * Lookup a value in the configuration string.
+ */
+static int is_defined_config(const char *name, int len, unsigned int hash)
+{
+	struct item *aux;
+
+	for (aux = hashtab[hash % HASHSZ]; aux; aux = aux->next) {
+		if (aux->hash == hash && aux->len == len &&
+		    memcmp(aux->name, name, len) == 0)
+			return 1;
+	}
+	return 0;
+}
+
+/*
+ * Add a new value to the configuration string.
+ */
+static void define_config(const char *name, int len, unsigned int hash)
+{
+	struct item *aux = malloc(sizeof(*aux) + len);
+
+	if (!aux) {
+		perror("fixdep:malloc");
+		exit(1);
+	}
+	memcpy(aux->name, name, len);
+	aux->len = len;
+	aux->hash = hash;
+	aux->next = hashtab[hash % HASHSZ];
+	hashtab[hash % HASHSZ] = aux;
+}
+
+/*
+ * Clear the set of configuration strings.
+ */
+static void clear_config(void)
+{
+	struct item *aux, *next;
+	unsigned int i;
+
+	for (i = 0; i < HASHSZ; i++) {
+		for (aux = hashtab[i]; aux; aux = next) {
+			next = aux->next;
+			free(aux);
+		}
+		hashtab[i] = NULL;
+	}
+}
+
+/*
+ * Record the use of a CONFIG_* word.
+ */
+static void use_config(const char *m, int slen)
+{
+	unsigned int hash = strhash(m, slen);
+	int c, i;
+
+	if (is_defined_config(m, slen, hash))
+	    return;
+
+	define_config(m, slen, hash);
+
+	printf("    $(wildcard include/config/");
+	for (i = 0; i < slen; i++) {
+		c = m[i];
+		if (c == '_')
+			c = '/';
+		else
+			c = tolower(c);
+		putchar(c);
+	}
+	printf(".h) \\\n");
+}
+
+static void parse_config_file(const char *map, size_t len)
+{
+	const int *end = (const int *) (map + len);
+	/* start@+1, so that p can never be < map */
+	const int *m   = (const int *) map + 1;
+	const char *p, *q;
+
+	for (; m < end; m++) {
+		if (*m == INT_CONF) { p = (char *) m  ; goto conf; }
+		if (*m == INT_ONFI) { p = (char *) m-1; goto conf; }
+		if (*m == INT_NFIG) { p = (char *) m-2; goto conf; }
+		if (*m == INT_FIG_) { p = (char *) m-3; goto conf; }
+		continue;
+	conf:
+		if (p > map + len - 7)
+			continue;
+		if (memcmp(p, "CONFIG_", 7))
+			continue;
+		for (q = p + 7; q < map + len; q++) {
+			if (!(isalnum(*q) || *q == '_'))
+				goto found;
+		}
+		continue;
+
+	found:
+		if (!memcmp(q - 7, "_MODULE", 7))
+			q -= 7;
+		if( (q-p-7) < 0 )
+			continue;
+		use_config(p+7, q-p-7);
+	}
+}
+
+/* test is s ends in sub */
+static int strrcmp(char *s, char *sub)
+{
+	int slen = strlen(s);
+	int sublen = strlen(sub);
+
+	if (sublen > slen)
+		return 1;
+
+	return memcmp(s + slen - sublen, sub, sublen);
+}
+
+static void do_config_file(const char *filename)
+{
+	struct stat st;
+	int fd;
+	void *map;
+
+	fd = open(filename, O_RDONLY);
+	if (fd < 0) {
+		fprintf(stderr, "fixdep: error opening config file: ");
+		perror(filename);
+		exit(2);
+	}
+	fstat(fd, &st);
+	if (st.st_size == 0) {
+		close(fd);
+		return;
+	}
+	map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+	if ((long) map == -1) {
+		perror("fixdep: mmap");
+		close(fd);
+		return;
+	}
+
+	parse_config_file(map, st.st_size);
+
+	munmap(map, st.st_size);
+
+	close(fd);
+}
+
+/*
+ * Important: The below generated source_foo.o and deps_foo.o variable
+ * assignments are parsed not only by make, but also by the rather simple
+ * parser in scripts/mod/sumversion.c.
+ */
+static void parse_dep_file(void *map, size_t len)
+{
+	char *m = map;
+	char *end = m + len;
+	char *p;
+	char s[PATH_MAX];
+	int is_target;
+	int saw_any_target = 0;
+	int is_first_dep = 0;
+
+	clear_config();
+
+	while (m < end) {
+		/* Skip any "white space" */
+		while (m < end && (*m == ' ' || *m == '\\' || *m == '\n'))
+			m++;
+		/* Find next "white space" */
+		p = m;
+		while (p < end && *p != ' ' && *p != '\\' && *p != '\n')
+			p++;
+		/* Is the token we found a target name? */
+		is_target = (*(p-1) == ':');
+		/* Don't write any target names into the dependency file */
+		if (is_target) {
+			/* The /next/ file is the first dependency */
+			is_first_dep = 1;
+		} else {
+			/* Save this token/filename */
+			memcpy(s, m, p-m);
+			s[p - m] = 0;
+
+			/* Ignore certain dependencies */
+			if (strrcmp(s, "include/generated/autoconf.h") &&
+			    strrcmp(s, "arch/um/include/uml-config.h") &&
+			    strrcmp(s, "include/linux/kconfig.h") &&
+			    strrcmp(s, ".ver")) {
+				/*
+				 * Do not list the source file as dependency,
+				 * so that kbuild is not confused if a .c file
+				 * is rewritten into .S or vice versa. Storing
+				 * it in source_* is needed for modpost to
+				 * compute srcversions.
+				 */
+				if (is_first_dep) {
+					/*
+					 * If processing the concatenation of
+					 * multiple dependency files, only
+					 * process the first target name, which
+					 * will be the original source name,
+					 * and ignore any other target names,
+					 * which will be intermediate temporary
+					 * files.
+					 */
+					if (!saw_any_target) {
+						saw_any_target = 1;
+						printf("source_%s := %s\n\n",
+							target, s);
+						printf("deps_%s := \\\n",
+							target);
+					}
+					is_first_dep = 0;
+				} else
+					printf("  %s \\\n", s);
+				do_config_file(s);
+			}
+		}
+		/*
+		 * Start searching for next token immediately after the first
+		 * "whitespace" character that follows this token.
+		 */
+		m = p + 1;
+	}
+
+	if (!saw_any_target) {
+		fprintf(stderr, "fixdep: parse error; no targets found\n");
+		exit(1);
+	}
+
+	printf("\n%s: $(deps_%s)\n\n", target, target);
+	printf("$(deps_%s):\n", target);
+}
+
+static void print_deps(void)
+{
+	struct stat st;
+	int fd;
+	void *map;
+
+	fd = open(depfile, O_RDONLY);
+	if (fd < 0) {
+		fprintf(stderr, "fixdep: error opening depfile: ");
+		perror(depfile);
+		exit(2);
+	}
+	if (fstat(fd, &st) < 0) {
+                fprintf(stderr, "fixdep: error fstat'ing depfile: ");
+                perror(depfile);
+                exit(2);
+        }
+	if (st.st_size == 0) {
+		fprintf(stderr,"fixdep: %s is empty\n",depfile);
+		close(fd);
+		return;
+	}
+	map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+	if ((long) map == -1) {
+		perror("fixdep: mmap");
+		close(fd);
+		return;
+	}
+
+	parse_dep_file(map, st.st_size);
+
+	munmap(map, st.st_size);
+
+	close(fd);
+}
+
+static void traps(void)
+{
+	static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
+	int *p = (int *)test;
+
+	if (*p != INT_CONF) {
+		fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
+			*p);
+		exit(2);
+	}
+}
+
+int main(int argc, char *argv[])
+{
+	traps();
+
+	if (argc != 4)
+		usage();
+
+	depfile = argv[1];
+	target = argv[2];
+	cmdline = argv[3];
+
+	print_cmdline();
+	print_deps();
+
+	return 0;
+}
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
new file mode 100644
index 0000000..0cc0442
--- /dev/null
+++ b/scripts/mkmakefile
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Generates a small Makefile used in the root of the output
+# directory, to allow make to be started from there.
+# The Makefile also allow for more convinient build of external modules
+
+# Usage
+# $1 - Kernel src directory
+# $2 - Output directory
+# $3 - version
+# $4 - patchlevel
+
+
+test ! -r $2/Makefile -o -O $2/Makefile || exit 0
+# Only overwrite automatically generated Makefiles
+# (so we do not overwrite kernel Makefile)
+if test -e $2/Makefile && ! grep -q Automatically $2/Makefile
+then
+	exit 0
+fi
+if [ "${quiet}" != "silent_" ]; then
+	echo "  GEN     $2/Makefile"
+fi
+
+cat << EOF > $2/Makefile
+# Automatically generated by $0: don't edit
+
+VERSION = $3
+PATCHLEVEL = $4
+
+lastword = \$(word \$(words \$(1)),\$(1))
+makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
+
+ifeq ("\$(origin V)", "command line")
+VERBOSE := \$(V)
+endif
+ifneq (\$(VERBOSE),1)
+Q := @
+endif
+
+MAKEARGS := -C $1
+MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
+
+MAKEFLAGS += --no-print-directory
+
+.PHONY: all \$(MAKECMDGOALS)
+
+all	:= \$(filter-out all Makefile,\$(MAKECMDGOALS))
+
+all:
+	\$(Q)\$(MAKE) \$(MAKEARGS) \$(all)
+
+Makefile:;
+
+\$(all): all
+	@:
+
+%/: all
+	@:
+EOF
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 21/38] kbuild: use Linux Kernel build scripts
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (19 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 20/38] kbuild: import more build scripts from Linux v3.13 tag Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 22/38] kbuild: delete temporary " Masahiro Yamada
                   ` (19 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

Now we are ready to switch over to real Kbuild.

This commit disables temporary scripts:
  scripts/{Makefile.build.tmp, Makefile.host.tmp}
and enables real Kbuild scripts:
  scripts/{Makefile.build,Makefile.host,Makefile.lib}.

This switch is triggered by the line in scripts/Kbuild.include
  -build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build.tmp obj
  +build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj

We need to adjust some build scripts for U-Boot.
But smaller amount of modification is preferable.

Additionally, we need to fix compiler flags which are
locally added or removed.

In Kbuild, it is not allowed to change CFLAGS locally.
Instead, ccflags-y, asflags-y, cppflags-y,
CFLAGS_$(basetarget).o, CFLAGS_REMOVE_$(basetarget).o
are prepared for that purpose.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Gerhard Sittig <gsi@denx.de>
---

Please note that we are not allowed to change CFLAGS locally.

See the following snippet from scripts/Makefile.build

  # If the save-* variables changed error out
  ifeq ($(KBUILD_NOPEDANTIC),)
          ifneq ("$(save-cflags)","$(CFLAGS)")
                  $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y)
          endif
  endif

If you are not familiar with Kbuild style makefiles,
I recommend you to read the document in Linux Kernel:
  Documentation/kbuild/makefiles.txt


Changes in v8: None
Changes in v7:
  - Rebuild SPL liner script everytime.
    This fixes a bug in spl build:
    In v6, build failed if we try to build another SPL board
    without "make clobber".
    For example,
       $ make omap3_beagle_config
       $ make CROSS_COMPILE=<your_gcc_prefix>
       $ make am335x_evm_config
       $ make CROSS_COMPILE=<your_gcc_prefix>
    This failed in v6. We needed either "make clobber" or "make mrproper"
    before switching to another board.
    Now, we can build two or more boards continuously.

Changes in v6:
  - Fix doc/DocBook/Makefile
  - Minor change in post/lib_powerpc/fpu/Makefile
  - Include cmd_files in nand_spl/board/*/*/Makefile
      and examples/standalone/Makefile

Changes in v5:
  - Rebase on the current u-boot/master

Changes in v4: None
Changes in v3:
  - Use "all:" instead of "__build:" in nand_spl Makefiles

Changes in v2: None

 Makefile                                      | 239 +++++++++++++++++++++-----
 arch/arm/imx-common/Makefile                  |   2 +-
 arch/blackfin/cpu/Makefile                    |   5 +-
 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/powerpc/cpu/mpc8xx/Makefile              |   2 +-
 arch/powerpc/lib/Makefile                     |   4 +-
 arch/sandbox/cpu/Makefile                     |  11 +-
 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/ip04/config.mk                          |   7 +-
 board/matrix_vision/mvblx/Makefile            |   2 +-
 board/pr1/config.mk                           |   7 +-
 board/sandburst/karef/Makefile                |   2 +-
 board/sandburst/metrobox/Makefile             |   2 +-
 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                               |  10 +-
 config.mk                                     |  13 +-
 disk/Makefile                                 |   2 +-
 doc/DocBook/Makefile                          |  67 ++++----
 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                                  |   2 +-
 examples/api/Makefile                         |  15 +-
 examples/standalone/Makefile                  |  22 ++-
 fs/ubifs/Makefile                             |   2 +-
 fs/yaffs2/Makefile                            |   9 +-
 lib/Makefile                                  |   2 +-
 lib/lzma/Makefile                             |   2 +-
 nand_spl/board/amcc/acadia/Makefile           |   9 +-
 nand_spl/board/amcc/bamboo/Makefile           |   9 +-
 nand_spl/board/amcc/canyonlands/Makefile      |   9 +-
 nand_spl/board/amcc/kilauea/Makefile          |   9 +-
 nand_spl/board/amcc/sequoia/Makefile          |   9 +-
 nand_spl/board/freescale/mpc8315erdb/Makefile |   9 +-
 nand_spl/board/freescale/mpc8536ds/Makefile   |   9 +-
 nand_spl/board/freescale/mpc8569mds/Makefile  |   9 +-
 nand_spl/board/freescale/mpc8572ds/Makefile   |   9 +-
 nand_spl/board/freescale/p1023rds/Makefile    |   9 +-
 nand_spl/board/freescale/p1_p2_rdb/Makefile   |   9 +-
 nand_spl/board/sheldon/simpc8313/Makefile     |   9 +-
 net/Makefile                                  |   2 +-
 post/lib_powerpc/fpu/Makefile                 |  29 ++--
 scripts/Kbuild.include                        |   2 +-
 scripts/Makefile.build                        |  21 ++-
 scripts/Makefile.lib                          |  14 +-
 spl/Makefile                                  |  27 +--
 tools/Makefile                                |  23 +--
 77 files changed, 525 insertions(+), 325 deletions(-)

diff --git a/Makefile b/Makefile
index 1409c8b..4f00f08 100644
--- a/Makefile
+++ b/Makefile
@@ -43,6 +43,78 @@ else
 XECHO = :
 endif
 
+# *DOCUMENTATION*
+# To see a list of typical targets execute "make help"
+# More info can be located in ./README
+# Comments in this file are targeted only to the developer, do not
+# expect to learn how to build the kernel reading this file.
+
+# Do not:
+# o  use make's built-in rules and variables
+#    (this increases performance and avoids hard-to-debug behaviour);
+# o  print "Entering directory ...";
+MAKEFLAGS += -rR --no-print-directory
+
+# Avoid funny character set dependencies
+unexport LC_ALL
+LC_COLLATE=C
+LC_NUMERIC=C
+export LC_COLLATE LC_NUMERIC
+
+# We are using a recursive build, so we need to do a little thinking
+# to get the ordering right.
+#
+# Most importantly: sub-Makefiles should only ever modify files in
+# their own directory. If in some directory we have a dependency on
+# a file in another dir (which doesn't happen often, but it's often
+# unavoidable when linking the built-in.o targets which finally
+# turn into vmlinux), we will call a sub make in that other dir, and
+# after that we are sure that everything which is in that other dir
+# is now up to date.
+#
+# The only cases where we need to modify files which have global
+# effects are thus separated out and done before the recursive
+# descending is started. They are now explicitly listed as the
+# prepare rule.
+
+# To put more focus on warnings, be less verbose as default
+# Use 'make V=1' to see the full commands
+
+ifeq ("$(origin V)", "command line")
+  KBUILD_VERBOSE = $(V)
+endif
+ifndef KBUILD_VERBOSE
+  KBUILD_VERBOSE = 0
+endif
+
+# Call a source code checker (by default, "sparse") as part of the
+# C compilation.
+#
+# Use 'make C=1' to enable checking of only re-compiled files.
+# Use 'make C=2' to enable checking of *all* source files, regardless
+# of whether they are re-compiled or not.
+#
+# See the file "Documentation/sparse.txt" for more details, including
+# where to get the "sparse" utility.
+
+ifeq ("$(origin C)", "command line")
+  KBUILD_CHECKSRC = $(C)
+endif
+ifndef KBUILD_CHECKSRC
+  KBUILD_CHECKSRC = 0
+endif
+
+# Use make M=dir to specify directory of external module to build
+# Old syntax make ... SUBDIRS=$PWD is still supported
+# Setting the environment variable KBUILD_EXTMOD take precedence
+ifdef SUBDIRS
+  KBUILD_EXTMOD ?= $(SUBDIRS)
+endif
+
+ifeq ("$(origin M)", "command line")
+  KBUILD_EXTMOD := $(M)
+endif
+
 # kbuild supports saving output files in a separate directory.
 # To locate output files in a separate directory two syntaxes are supported.
 # In both cases the working directory must be the root of the kernel src.
@@ -107,8 +179,14 @@ endif # ifeq ($(KBUILD_SRC),)
 # We process the rest of the Makefile if this is the final invocation of make
 ifeq ($(skip-makefile),)
 
+# If building an external module we do not care about the all: rule
+# but instead _all depend on modules
 PHONY += all
+ifeq ($(KBUILD_EXTMOD),)
 _all: all
+else
+_all: modules
+endif
 
 srctree		:= $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
 objtree		:= $(CURDIR)
@@ -119,24 +197,6 @@ VPATH		:= $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
 
 export srctree objtree VPATH
 
-# Call a source code checker (by default, "sparse") as part of the
-# C compilation.
-#
-# Use 'make C=1' to enable checking of re-compiled files.
-#
-# See the linux kernel file "Documentation/sparse.txt" for more details,
-# including where to get the "sparse" utility.
-
-ifdef C
-ifeq ("$(origin C)", "command line")
-CHECKSRC := $(C)
-endif
-endif
-ifndef CHECKSRC
-  CHECKSRC = 0
-endif
-export CHECKSRC
-
 OBJTREE		:= $(objtree)
 SPLTREE		:= $(OBJTREE)/spl
 TPLTREE		:= $(OBJTREE)/tpl
@@ -222,6 +282,78 @@ HOSTCFLAGS  += $(call os_x_before, 10, 4, "-traditional-cpp")
 HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
 endif
 
+# Decide whether to build built-in, modular, or both.
+# Normally, just do built-in.
+
+KBUILD_MODULES :=
+KBUILD_BUILTIN := 1
+
+#	If we have only "make modules", don't compile built-in objects.
+#	When we're building modules with modversions, we need to consider
+#	the built-in objects during the descend as well, in order to
+#	make sure the checksums are up to date before we record them.
+
+ifeq ($(MAKECMDGOALS),modules)
+  KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
+endif
+
+#	If we have "make <whatever> modules", compile modules
+#	in addition to whatever we do anyway.
+#	Just "make" or "make all" shall build modules as well
+
+# U-Boot does not need modules
+#ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
+#  KBUILD_MODULES := 1
+#endif
+
+#ifeq ($(MAKECMDGOALS),)
+#  KBUILD_MODULES := 1
+#endif
+
+export KBUILD_MODULES KBUILD_BUILTIN
+export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
+
+# Beautify output
+# ---------------------------------------------------------------------------
+#
+# Normally, we echo the whole command before executing it. By making
+# that echo $($(quiet)$(cmd)), we now have the possibility to set
+# $(quiet) to choose other forms of output instead, e.g.
+#
+#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
+#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
+#
+# If $(quiet) is empty, the whole command will be printed.
+# If it is set to "quiet_", only the short version will be printed. 
+# If it is set to "silent_", nothing will be printed@all, since
+# the variable $(silent_cmd_cc_o_c) doesn't exist.
+#
+# A simple variant is to prefix commands with $(Q) - that's useful
+# for commands that shall be hidden in non-verbose mode.
+#
+#	$(Q)ln $@ :<
+#
+# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
+# If KBUILD_VERBOSE equals 1 then the above command is displayed.
+
+ifeq ($(KBUILD_VERBOSE),1)
+  quiet =
+  Q =
+else
+  quiet=quiet_
+  Q = @
+endif
+
+# If the user is running make -s (silent mode), suppress echoing of
+# commands
+
+ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
+  quiet=silent_
+endif
+
+export quiet Q KBUILD_VERBOSE
+
+
 # Look for make include files relative to root of kernel src
 MAKEFLAGS += --include-dir=$(srctree)
 
@@ -278,6 +410,31 @@ export DTC CHECK CHECKFLAGS
 export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE
 export KBUILD_CFLAGS KBUILD_AFLAGS
 
+# When compiling out-of-tree modules, put MODVERDIR in the module
+# tree rather than in the kernel tree. The kernel tree might
+# even be read-only.
+export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
+
+# Files to ignore in find ... statements
+
+RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
+		   -o -name .pc -o -name .hg -o -name .git \) -prune -o
+export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
+			 --exclude CVS --exclude .pc --exclude .hg --exclude .git
+
+# ===========================================================================
+# Rules shared between *config targets and build targets
+
+# Basic helpers built in scripts/
+PHONY += scripts_basic
+scripts_basic:
+	$(Q)$(MAKE) $(build)=scripts/basic
+	$(Q)rm -f .tmp_quiet_recordmcount
+
+# To avoid any implicit rule to kick in, define an empty command.
+scripts/basic/%: scripts_basic ;
+
+
 KBUILD_CFLAGS += -Os #-fomit-frame-pointer
 
 ifdef BUILD_TAG
@@ -333,6 +490,10 @@ endif
 endif
 endif
 
+# FIX ME
+cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
+c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
+
 # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
 # that (or fail if absent).  Otherwise, search for a linker script in a
 # standard location.
@@ -446,12 +607,12 @@ LIBS := $(sort $(LIBS-y))
 # Add GCC lib
 ifdef USE_PRIVATE_LIBGCC
 ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
-PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o
+PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/lib.a
 else
 PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
 endif
 else
-PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
+PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
 endif
 PLATFORM_LIBS += $(PLATFORM_LIBGCC)
 export PLATFORM_LIBS
@@ -701,7 +862,7 @@ u-boot:	depend $(SUBDIR_TOOLS) $(OBJS) $(LIBS) u-boot.lds
 ifeq ($(CONFIG_KALLSYMS),y)
 		smap=`$(call SYSTEM_MAP,u-boot) | \
 			awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
-		$(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \
+		$(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \
 			-c $(srctree)/common/system_map.c -o common/system_map.o
 		$(GEN_UBOOT) common/system_map.o
 endif
@@ -709,27 +870,27 @@ endif
 $(OBJS):
 	@:
 
-$(LIBS):	depend $(SUBDIR_TOOLS)
-		$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
+$(LIBS):	depend $(SUBDIR_TOOLS) scripts_basic
+		$(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
 
-$(SUBDIRS):	depend
-		$(MAKE) $(build)=$@ all
+$(SUBDIRS):	depend scripts_basic
+		$(Q)$(MAKE) $(build)=$@
 
 $(SUBDIR_EXAMPLES-y): u-boot
 
 u-boot.lds: $(LDSCRIPT) depend
-		$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
+		$(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
-nand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
+nand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend scripts_basic
 		$(MAKE) $(build)=nand_spl/board/$(BOARDDIR) all
 
 u-boot-nand.bin:	nand_spl u-boot.bin
 		cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin
 
-spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend
+spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend scripts_basic
 		$(MAKE) obj=spl -f $(srctree)/spl/Makefile all
 
-tpl/u-boot-tpl.bin:	$(SUBDIR_TOOLS) depend
+tpl/u-boot-tpl.bin:	$(SUBDIR_TOOLS) depend scripts_basic
 		$(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y
 
 # Explicitly make _depend in subdirs containing multiple targets to prevent
@@ -804,14 +965,14 @@ checkdtc:
 include/autoconf.mk.dep: include/config.h include/common.h
 	@$(XECHO) Generating $@ ; \
 	: Generate the dependancies ; \
-	$(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \
+	$(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \
 		-MQ include/autoconf.mk $(srctree)/include/common.h > $@ || \
 		rm $@
 
 include/autoconf.mk: include/config.h
 	@$(XECHO) Generating $@ ; \
 	: Extract the config macros ; \
-	$(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
+	$(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
 		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
 	rm $@.tmp
 
@@ -819,7 +980,7 @@ include/autoconf.mk: include/config.h
 include/tpl-autoconf.mk: include/config.h
 	@$(XECHO) Generating $@ ; \
 	: Extract the config macros ; \
-	$(CPP) $(CFLAGS) -DCONFIG_TPL_BUILD  -DCONFIG_SPL_BUILD\
+	$(CPP) $(c_flags) -DCONFIG_TPL_BUILD  -DCONFIG_SPL_BUILD\
 			-DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
 		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
 	rm $@.tmp
@@ -827,7 +988,7 @@ include/tpl-autoconf.mk: include/config.h
 include/spl-autoconf.mk: include/config.h
 	@$(XECHO) Generating $@ ; \
 	: Extract the config macros ; \
-	$(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
+	$(CPP) $(c_flags) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
 		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
 	rm $@.tmp
 
@@ -838,7 +999,7 @@ include/generated/generic-asm-offsets.h: lib/asm-offsets.s
 lib/asm-offsets.s: include/config.h $(srctree)/lib/asm-offsets.c
 	@mkdir -p lib
 	$(CC) -DDO_DEPS_ONLY \
-		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
+		$(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
 		-o $@ $(srctree)/lib/asm-offsets.c -c -S
 
 include/generated/asm-offsets.h: $(CPUDIR)/$(SOC)/asm-offsets.s
@@ -849,7 +1010,7 @@ $(CPUDIR)/$(SOC)/asm-offsets.s:	include/config.h
 	@mkdir -p $(CPUDIR)/$(SOC)
 	if [ -f $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
 		$(CC) -DDO_DEPS_ONLY \
-		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
+		$(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
 			-o $@ $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
 	else \
 		touch $@; \
@@ -900,15 +1061,15 @@ $(TIMESTAMP_FILE):
 		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
 
 easylogo env gdb:
-	$(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION}
+	$(Q)$(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION}
 
 gdbtools: gdb
 
 xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc
-	$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) $(build)=doc/DocBook $@
+	$(Q)$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) $(build)=doc/DocBook $@
 
 tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
-	$(MAKE) $(build)=tools HOST_TOOLS_ALL=y
+	$(Q)$(MAKE) $(build)=tools HOST_TOOLS_ALL=y
 
 .PHONY : CHANGELOG
 CHANGELOG:
@@ -968,7 +1129,7 @@ clean:
 	@$(MAKE) -f $(srctree)/doc/DocBook/Makefile cleandocs
 	@find $(OBJTREE) -type f \
 		\( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
-		-o -name '*.o'	-o -name '*.a' -o -name '*.exe' \
+		-o -name '*.o'	-o -name '*.a' -o -name '*.exe' -o -name '*.cmd' \
 		-o -name '*.cfgtmp' \) -print \
 		| xargs rm -f
 
diff --git a/arch/arm/imx-common/Makefile b/arch/arm/imx-common/Makefile
index ee5c872..9dda59d 100644
--- a/arch/arm/imx-common/Makefile
+++ b/arch/arm/imx-common/Makefile
@@ -25,7 +25,7 @@ obj-$(CONFIG_CMD_HDMIDETECT) += cmd_hdmidet.o
 
 $(OBJTREE)/$(patsubst "%",%,$(CONFIG_IMX_CONFIG)).cfgtmp: $(OBJTREE)/%.cfgtmp : $(SRCTREE)/%
 	mkdir -p $(dir $@)
-	$(CC) -E -x c $< $(CPPFLAGS) -o $@
+	$(CPP) $(cpp_flags) -x c -o $@ $<
 
 $(OBJTREE)/u-boot.imx: $(OBJTREE)/u-boot.bin $(OBJTREE)/$(patsubst "%",%,$(CONFIG_IMX_CONFIG)).cfgtmp
 	$(OBJTREE)/tools/mkimage -n $(filter-out %.bin,$^) -T imximage \
diff --git a/arch/blackfin/cpu/Makefile b/arch/blackfin/cpu/Makefile
index 369dc74..dd4d2d1 100644
--- a/arch/blackfin/cpu/Makefile
+++ b/arch/blackfin/cpu/Makefile
@@ -25,7 +25,7 @@ extra-y += check_initcode
 
 # make sure our initcode (which goes into LDR) does not
 # have relocs or external references
-$(obj)/initcode.o: CFLAGS += -fno-function-sections -fno-data-sections
+CFLAGS_REMOVE_initcode.o := -ffunction-sections -fdata-sections
 READINIT = env LC_ALL=C $(CROSS_COMPILE)readelf -s $<
 $(obj)/check_initcode: $(obj)/initcode.o
 ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS)
@@ -35,7 +35,6 @@ ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS)
 	fi
 endif
 
-$(obj)/init.lds: $(src)/init.lds.S
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P $^ -o $@
+CPPFLAGS_init.lds := -ansi
 $(obj)/init.elf: $(obj)/init.lds $(obj)/init.o $(obj)/initcode.o
 	$(LD) $(LDFLAGS) -T $^ -o $@
diff --git a/arch/blackfin/lib/Makefile b/arch/blackfin/lib/Makefile
index a5c552f..4ba7bf6 100644
--- a/arch/blackfin/lib/Makefile
+++ b/arch/blackfin/lib/Makefile
@@ -9,7 +9,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS += -DBFIN_BOARD_NAME='"$(BOARD)"'
+# Unnecessary.
+# Use CONFIG_SYS_BOARD instead of BFIN_BOARD_NAME
+# and delete this.
+ccflags-y += -DBFIN_BOARD_NAME='"$(BOARD)"'
 
 obj-y	+= ins.o
 obj-y	+= memcmp.o
diff --git a/arch/m68k/cpu/mcf5227x/Makefile b/arch/m68k/cpu/mcf5227x/Makefile
index a47fd56..e0c5db6 100644
--- a/arch/m68k/cpu/mcf5227x/Makefile
+++ b/arch/m68k/cpu/mcf5227x/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# CFLAGS += -DET_DEBUG
+# ccflags-y += -DET_DEBUG
 
 extra-y	= start.o
 obj-y	= cpu.o speed.o cpu_init.o interrupts.o
diff --git a/arch/m68k/cpu/mcf523x/Makefile b/arch/m68k/cpu/mcf523x/Makefile
index a47fd56..e0c5db6 100644
--- a/arch/m68k/cpu/mcf523x/Makefile
+++ b/arch/m68k/cpu/mcf523x/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# CFLAGS += -DET_DEBUG
+# ccflags-y += -DET_DEBUG
 
 extra-y	= start.o
 obj-y	= cpu.o speed.o cpu_init.o interrupts.o
diff --git a/arch/m68k/cpu/mcf52x2/Makefile b/arch/m68k/cpu/mcf52x2/Makefile
index d9bf900..b92fd86 100644
--- a/arch/m68k/cpu/mcf52x2/Makefile
+++ b/arch/m68k/cpu/mcf52x2/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# CFLAGS += -DET_DEBUG
+# ccflags-y += -DET_DEBUG
 
 extra-y	= start.o
 obj-y	= interrupts.o cpu.o speed.o cpu_init.o
diff --git a/arch/m68k/cpu/mcf532x/Makefile b/arch/m68k/cpu/mcf532x/Makefile
index 97aa3f1..9c53c50 100644
--- a/arch/m68k/cpu/mcf532x/Makefile
+++ b/arch/m68k/cpu/mcf532x/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# CFLAGS += -DET_DEBUG
+# ccflags-y += -DET_DEBUG
 
 extra-y := start.o
 obj-y	= cpu.o speed.o cpu_init.o interrupts.o
diff --git a/arch/m68k/cpu/mcf5445x/Makefile b/arch/m68k/cpu/mcf5445x/Makefile
index b506719..9be91ed 100644
--- a/arch/m68k/cpu/mcf5445x/Makefile
+++ b/arch/m68k/cpu/mcf5445x/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# CFLAGS += -DET_DEBUG
+# ccflags-y += -DET_DEBUG
 
 extra-y	= start.o
 obj-y	= cpu.o speed.o cpu_init.o interrupts.o pci.o
diff --git a/arch/m68k/cpu/mcf547x_8x/Makefile b/arch/m68k/cpu/mcf547x_8x/Makefile
index 0fa50bf..4f82099 100644
--- a/arch/m68k/cpu/mcf547x_8x/Makefile
+++ b/arch/m68k/cpu/mcf547x_8x/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# CFLAGS += -DET_DEBUG
+# ccflags-y += -DET_DEBUG
 
 extra-y = start.o
 obj-y	= cpu.o speed.o cpu_init.o pci.o interrupts.o slicetimer.o
diff --git a/arch/powerpc/cpu/mpc8xx/Makefile b/arch/powerpc/cpu/mpc8xx/Makefile
index d40bdab..f83fd5e 100644
--- a/arch/powerpc/cpu/mpc8xx/Makefile
+++ b/arch/powerpc/cpu/mpc8xx/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# CFLAGS += -DET_DEBUG
+# ccflags-y += -DET_DEBUG
 
 extra-y += start.o
 extra-y += traps.o
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index ac780d4..e6d8be5 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -54,11 +54,11 @@ ifndef CONFIG_SPL_BUILD
 # Workaround for local bus unaligned access problems
 # on MPC512x and MPC5200
 ifdef CONFIG_MPC512X
-$(obj)/ppcstring.o: AFLAGS += -Dmemcpy=__memcpy
+AFLAGS_ppcstring.o += -Dmemcpy=__memcpy
 obj-y += memcpy_mpc5200.o
 endif
 ifdef CONFIG_MPC5200
-$(obj)/ppcstring.o: AFLAGS += -Dmemcpy=__memcpy
+AFLAGS_ppcstring.o += -Dmemcpy=__memcpy
 obj-y += memcpy_mpc5200.o
 endif
 endif
diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile
index c5f5426..63deded 100644
--- a/arch/sandbox/cpu/Makefile
+++ b/arch/sandbox/cpu/Makefile
@@ -10,7 +10,10 @@
 obj-y	:= cpu.o os.o start.o state.o
 
 # os.c is build in the system environment, so needs standard includes
-$(obj)/os.o: CFLAGS := $(filter-out -nostdinc,\
-	$(patsubst -I%,-idirafter%,$(CFLAGS)))
-$(obj)/.depend.os: CPPFLAGS := $(filter-out -nostdinc,\
-	$(patsubst -I%,-idirafter%,$(CPPFLAGS)))
+# CFLAGS_REMOVE_os.o cannot be used to drop header include path
+quiet_cmd_cc_os.o = CC $(quiet_modtag)  $@
+cmd_cc_os.o = $(CC) $(filter-out -nostdinc, \
+	$(patsubst -I%,-idirafter%,$(c_flags))) -c -o $@ $<
+
+$(obj)/os.o: $(src)/os.c FORCE
+	$(call if_changed_dep,cc_os.o)
diff --git a/board/bct-brettl2/config.mk b/board/bct-brettl2/config.mk
index f1ef9bf..0d3df2d 100644
--- a/board/bct-brettl2/config.mk
+++ b/board/bct-brettl2/config.mk
@@ -7,6 +7,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
diff --git a/board/bf518f-ezbrd/config.mk b/board/bf518f-ezbrd/config.mk
index f1ef9bf..0d3df2d 100644
--- a/board/bf518f-ezbrd/config.mk
+++ b/board/bf518f-ezbrd/config.mk
@@ -7,6 +7,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
diff --git a/board/bf526-ezbrd/config.mk b/board/bf526-ezbrd/config.mk
index f1ef9bf..0d3df2d 100644
--- a/board/bf526-ezbrd/config.mk
+++ b/board/bf526-ezbrd/config.mk
@@ -7,6 +7,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
diff --git a/board/bf527-ad7160-eval/config.mk b/board/bf527-ad7160-eval/config.mk
index f1ef9bf..0d3df2d 100644
--- a/board/bf527-ad7160-eval/config.mk
+++ b/board/bf527-ad7160-eval/config.mk
@@ -7,6 +7,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
diff --git a/board/bf527-ezkit/config.mk b/board/bf527-ezkit/config.mk
index f1ef9bf..0d3df2d 100644
--- a/board/bf527-ezkit/config.mk
+++ b/board/bf527-ezkit/config.mk
@@ -7,6 +7,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
diff --git a/board/bf527-sdp/config.mk b/board/bf527-sdp/config.mk
index 5f327a9..af299f5 100644
--- a/board/bf527-sdp/config.mk
+++ b/board/bf527-sdp/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 6
diff --git a/board/bf533-ezkit/config.mk b/board/bf533-ezkit/config.mk
index 973d357..97eaafe 100644
--- a/board/bf533-ezkit/config.mk
+++ b/board/bf533-ezkit/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
diff --git a/board/bf533-stamp/config.mk b/board/bf533-stamp/config.mk
index 973d357..97eaafe 100644
--- a/board/bf533-stamp/config.mk
+++ b/board/bf533-stamp/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
diff --git a/board/bf537-stamp/config.mk b/board/bf537-stamp/config.mk
index ae2ea0b..bc0e747 100644
--- a/board/bf537-stamp/config.mk
+++ b/board/bf537-stamp/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
diff --git a/board/bf538f-ezkit/config.mk b/board/bf538f-ezkit/config.mk
index 973d357..97eaafe 100644
--- a/board/bf538f-ezkit/config.mk
+++ b/board/bf538f-ezkit/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
diff --git a/board/bf548-ezkit/config.mk b/board/bf548-ezkit/config.mk
index ad3a729..8d2c60f 100644
--- a/board/bf548-ezkit/config.mk
+++ b/board/bf548-ezkit/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA       := --dma 6
diff --git a/board/bf561-acvilon/config.mk b/board/bf561-acvilon/config.mk
index c33aef9..ce94715 100644
--- a/board/bf561-acvilon/config.mk
+++ b/board/bf561-acvilon/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16
diff --git a/board/bf561-ezkit/config.mk b/board/bf561-ezkit/config.mk
index c33aef9..ce94715 100644
--- a/board/bf561-ezkit/config.mk
+++ b/board/bf561-ezkit/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16
diff --git a/board/br4/config.mk b/board/br4/config.mk
index 5c18d5c..2436ec0 100644
--- a/board/br4/config.mk
+++ b/board/br4/config.mk
@@ -9,6 +9,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
diff --git a/board/cm-bf527/config.mk b/board/cm-bf527/config.mk
index f1ef9bf..0d3df2d 100644
--- a/board/cm-bf527/config.mk
+++ b/board/cm-bf527/config.mk
@@ -7,6 +7,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
diff --git a/board/cm-bf533/config.mk b/board/cm-bf533/config.mk
index 973d357..97eaafe 100644
--- a/board/cm-bf533/config.mk
+++ b/board/cm-bf533/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
diff --git a/board/cm-bf537e/config.mk b/board/cm-bf537e/config.mk
index 973d357..97eaafe 100644
--- a/board/cm-bf537e/config.mk
+++ b/board/cm-bf537e/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
diff --git a/board/cm-bf537u/config.mk b/board/cm-bf537u/config.mk
index 973d357..97eaafe 100644
--- a/board/cm-bf537u/config.mk
+++ b/board/cm-bf537u/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
diff --git a/board/cm-bf548/config.mk b/board/cm-bf548/config.mk
index c005afb..289c8a4 100644
--- a/board/cm-bf548/config.mk
+++ b/board/cm-bf548/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA       := --dma 6
diff --git a/board/cm-bf561/config.mk b/board/cm-bf561/config.mk
index c33aef9..ce94715 100644
--- a/board/cm-bf561/config.mk
+++ b/board/cm-bf561/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16
diff --git a/board/ip04/config.mk b/board/ip04/config.mk
index ae2ea0b..bc0e747 100644
--- a/board/ip04/config.mk
+++ b/board/ip04/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
diff --git a/board/matrix_vision/mvblx/Makefile b/board/matrix_vision/mvblx/Makefile
index c6c0933..c056eba 100644
--- a/board/matrix_vision/mvblx/Makefile
+++ b/board/matrix_vision/mvblx/Makefile
@@ -8,4 +8,4 @@
 obj-y += mvblx.o fpga.o
 obj-$(CONFIG_ID_EEPROM) += sys_eeprom.o
 
-CFLAGS += -Werror
+ccflags-y += -Werror
diff --git a/board/pr1/config.mk b/board/pr1/config.mk
index 5c18d5c..2436ec0 100644
--- a/board/pr1/config.mk
+++ b/board/pr1/config.mk
@@ -9,6 +9,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
diff --git a/board/sandburst/karef/Makefile b/board/sandburst/karef/Makefile
index f890008..d5a9b34 100644
--- a/board/sandburst/karef/Makefile
+++ b/board/sandburst/karef/Makefile
@@ -13,7 +13,7 @@
 BUILDUSER := $(shell whoami)
 FORCEBUILD := $(shell rm -f karef.o)
 
-CFLAGS += -DBUILDUSER='"$(BUILDUSER)"'
+ccflags-y += -DBUILDUSER='"$(BUILDUSER)"'
 # TBS: end debugging
 
 obj-y	= karef.o ../common/flash.o ../common/sb_common.o
diff --git a/board/sandburst/metrobox/Makefile b/board/sandburst/metrobox/Makefile
index 37d91a5..8121cce 100644
--- a/board/sandburst/metrobox/Makefile
+++ b/board/sandburst/metrobox/Makefile
@@ -12,7 +12,7 @@
 BUILDUSER := $(shell whoami)
 FORCEBUILD := $(shell rm -f metrobox.o)
 
-CFLAGS += -DBUILDUSER='"$(BUILDUSER)"'
+ccflags-y += -DBUILDUSER='"$(BUILDUSER)"'
 # TBS: end debugging
 
 obj-y	= metrobox.o ../common/flash.o ../common/sb_common.o
diff --git a/board/st-ericsson/snowball/Makefile b/board/st-ericsson/snowball/Makefile
index 6867a70..f0605e2 100644
--- a/board/st-ericsson/snowball/Makefile
+++ b/board/st-ericsson/snowball/Makefile
@@ -4,6 +4,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS += -D__RELEASE -D__STN_8500
+ccflags-y += -D__RELEASE -D__STN_8500
 
 obj-y	:= snowball.o
diff --git a/board/st-ericsson/u8500/Makefile b/board/st-ericsson/u8500/Makefile
index b9dfbe9..d6c4280 100644
--- a/board/st-ericsson/u8500/Makefile
+++ b/board/st-ericsson/u8500/Makefile
@@ -4,6 +4,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS += -D__RELEASE -D__STN_8500
+ccflags-y += -D__RELEASE -D__STN_8500
 
 obj-y	:= u8500_href.o gpio.o
diff --git a/board/tcm-bf518/config.mk b/board/tcm-bf518/config.mk
index f1ef9bf..0d3df2d 100644
--- a/board/tcm-bf518/config.mk
+++ b/board/tcm-bf518/config.mk
@@ -7,6 +7,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
diff --git a/board/tcm-bf537/config.mk b/board/tcm-bf537/config.mk
index 973d357..97eaafe 100644
--- a/board/tcm-bf537/config.mk
+++ b/board/tcm-bf537/config.mk
@@ -7,9 +7,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS_lib += -O2
-CFLAGS_lib/lzma += -O2
-CFLAGS_lib/zlib += -O2
+# FIX ME
+ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
+ccflags-y := -O2
+endif
 
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
diff --git a/common/Makefile b/common/Makefile
index a292ee8..9c90722 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -234,10 +234,6 @@ obj-$(CONFIG_FIT_SIGNATURE) += image-sig.o
 obj-y += memsize.o
 obj-y += stdio.o
 
-$(obj)/env_embedded.o: $(src)/env_embedded.c
-	$(CC) $(AFLAGS) -Wa,--no-warn \
-		-DENV_CRC=$(shell tools/envcrc) -c -o $@ $<
-
-# SEE README.arm-unaligned-accesses
-$(obj)/hush.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
-$(obj)/fdt_support.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
+CFLAGS_env_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2>/dev/null)
+CFLAGS_hush.o := $(PLATFORM_NO_UNALIGNED)
+CFLAGS_fdt_support.o := $(PLATFORM_NO_UNALIGNED)
diff --git a/config.mk b/config.mk
index 0fa3167..1336ef8 100644
--- a/config.mk
+++ b/config.mk
@@ -58,19 +58,10 @@ RELFLAGS= $(PLATFORM_RELFLAGS)
 
 OBJCFLAGS += --gap-fill=0xff
 
-CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
-CPPFLAGS += $(UBOOTINCLUDE)
-CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
-
-CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
+CPPFLAGS = $(RELFLAGS)
+CPPFLAGS += -pipe $(PLATFORM_CPPFLAGS)
 
 BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
 
-AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
-
 LDFLAGS += $(PLATFORM_LDFLAGS)
 LDFLAGS_FINAL += -Bstatic
-
-#########################################################################
-
-export PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
diff --git a/disk/Makefile b/disk/Makefile
index 48abec8..6970cec 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-#CFLAGS += -DET_DEBUG -DDEBUG
+#ccflags-y += -DET_DEBUG -DDEBUG
 
 obj-$(CONFIG_PARTITIONS) 	+= part.o
 obj-$(CONFIG_MAC_PARTITION)   += part_mac.o
diff --git a/doc/DocBook/Makefile b/doc/DocBook/Makefile
index aa7c44b..75e59c2 100644
--- a/doc/DocBook/Makefile
+++ b/doc/DocBook/Makefile
@@ -24,9 +24,9 @@ PS_METHOD	= $(prefer-db2x)
 
 ###
 # The targets that may be used.
-PHONY += $(obj).depend xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs cleandocs
+PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs cleandocs
 
-BOOKS := $(addprefix $(OBJTREE)/doc/DocBook/,$(DOCBOOKS))
+BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
 xmldocs: $(BOOKS)
 sgmldocs: xmldocs
 
@@ -51,10 +51,10 @@ installmandocs: mandocs
 
 ###
 #External programs used
-KERNELDOC = $(SRCTREE)/tools/kernel-doc/kernel-doc
-DOCPROC   = $(OBJTREE)/tools/kernel-doc/docproc
+KERNELDOC = $(srctree)/tools/kernel-doc/kernel-doc
+DOCPROC   = $(objtree)/tools/kernel-doc/docproc
 
-XMLTOFLAGS = -m $(SRCTREE)/doc/DocBook/stylesheet.xsl
+XMLTOFLAGS = -m $(srctree)/doc/DocBook/stylesheet.xsl
 XMLTOFLAGS += --skip-validation
 
 ###
@@ -64,28 +64,36 @@ XMLTOFLAGS += --skip-validation
 #     appropriate parameters.
 # The following rules are used to generate the .xml documentation
 # required to generate the final targets. (ps, pdf, html).
-%.xml: %.tmpl
-	$(DOCPROC) doc $< >$@
-
-ifeq ($@, "cleandocs")
-sinclude $(obj).depend
-$(obj).depend: $(patsubst %.xml, %.tmpl, $(DOCBOOKS))
-	rm -f $(obj).depend ;					\
-	touch $(obj).depend ;					\
-	for file in $^ ; do					\
-		xmlfile=`echo "$${file}" |			\
-			sed "s/tmpl$$/xml/"` ;			\
-		echo -n "$${xmlfile}: ">> $(obj).depend ;	\
-		$(DOCPROC) depend $$file >> $(obj).depend ;	\
-		echo -e "\n\t$(DOCPROC) doc $< >$${xmlfile} " >>	\
-			$(obj).depend ;				\
-	done
+quiet_cmd_docproc = DOCPROC $@
+      cmd_docproc = SRCTREE=$(srctree)/ $(DOCPROC) doc $< >$@
+define rule_docproc
+	set -e;								\
+        $(if $($(quiet)cmd_$(1)),echo '  $($(quiet)cmd_$(1))';) 	\
+        $(cmd_$(1)); 							\
+        ( 								\
+          echo 'cmd_$@ := $(cmd_$(1))'; 				\
+          echo $@: `SRCTREE=$(srctree) $(DOCPROC) depend $<`; 		\
+        ) > $(dir $@).$(notdir $@).cmd
+endef
+
+%.xml: %.tmpl FORCE
+	$(call if_changed_rule,docproc)
+
+###
+#Read in all saved dependency files
+cmd_files := $(wildcard $(foreach f,$(BOOKS),$(dir $(f)).$(notdir $(f)).cmd))
+
+ifneq ($(cmd_files),)
+  include $(cmd_files)
 endif
 
 ###
 # Changes in kernel-doc force a rebuild of all documentation
 $(BOOKS): $(KERNELDOC)
 
+# Tell kbuild to always build the programs
+always := $(hostprogs-y)
+
 notfoundtemplate = echo "*** You have to install docbook-utils or xmlto ***"; \
 		   exit 1
 db2xtemplate = db2TYPE -o $(dir $@) $<
@@ -111,12 +119,12 @@ endif
 quiet_cmd_db2ps = PS      $@
       cmd_db2ps = $(subst TYPE,ps, $($(PS_METHOD)template))
 %.ps : %.xml
-	$(call cmd_db2ps)
+	$(call cmd,db2ps)
 
 quiet_cmd_db2pdf = PDF     $@
       cmd_db2pdf = $(subst TYPE,pdf, $($(PDF_METHOD)template))
 %.pdf : %.xml
-	$(call cmd_db2pdf)
+	$(call cmd,db2pdf)
 
 
 index = index.html
@@ -132,16 +140,16 @@ build_main_index = rm -rf $(main_idx); \
 quiet_cmd_db2html = HTML    $@
       cmd_db2html = xmlto html $(XMLTOFLAGS) -o $(patsubst %.html,%,$@) $< && \
 		echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/index.html"> \
-	$(patsubst %.html,%,$(notdir $@))</a><p>' > $@
+        $(patsubst %.html,%,$(notdir $@))</a><p>' > $@
 
 %.html:	%.xml
 	@(which xmlto > /dev/null 2>&1) || \
 	 (echo "*** You need to install xmlto ***"; \
 	  exit 1)
 	@rm -rf $@ $(patsubst %.html,%,$@)
-	$(call cmd_db2html)
+	$(call cmd,db2html)
 	@if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \
-	    cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
+            cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
 
 quiet_cmd_db2man = MAN     $@
       cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; gzip -f $(obj)/man/*.9; fi
@@ -150,7 +158,7 @@ quiet_cmd_db2man = MAN     $@
 	 (echo "*** You need to install xmlto ***"; \
 	  exit 1)
 	$(Q)mkdir -p $(obj)/man
-	$(call cmd_db2man)
+	$(call cmd,db2man)
 	@touch $@
 
 ###
@@ -162,7 +170,7 @@ quiet_cmd_fig2eps = FIG2EPS $@
 	@(which fig2dev > /dev/null 2>&1) || \
 	 (echo "*** You need to install transfig ***"; \
 	  exit 1)
-	$(call cmd_fig2eps)
+	$(call cmd,fig2eps)
 
 quiet_cmd_fig2png = FIG2PNG $@
       cmd_fig2png = fig2dev -Lpng $< $@
@@ -171,7 +179,7 @@ quiet_cmd_fig2png = FIG2PNG $@
 	@(which fig2dev > /dev/null 2>&1) || \
 	 (echo "*** You need to install transfig ***"; \
 	  exit 1)
-	$(call cmd_fig2png)
+	$(call cmd,fig2png)
 
 ###
 # Rule to convert a .c file to inline XML documentation
@@ -217,7 +225,6 @@ clean-files := $(DOCBOOKS) \
 clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) man
 
 cleandocs:
-	@rm -f $(obj).depend
 	@$(Q)rm -f $(call objectify, $(clean-files))
 	@$(Q)rm -rf $(call objectify, $(clean-dirs))
 
diff --git a/drivers/bios_emulator/Makefile b/drivers/bios_emulator/Makefile
index 330f36f..e56356e 100644
--- a/drivers/bios_emulator/Makefile
+++ b/drivers/bios_emulator/Makefile
@@ -8,8 +8,5 @@ obj-y = atibios.o biosemu.o besys.o bios.o \
 	$(X86DIR)/sys.o \
 	$(X86DIR)/debug.o
 
-EXTRA_CFLAGS += -I$(srctree)/$(src) -I$(srctree)/$(src)/include \
+ccflags-y := -I$(srctree)/$(src) -I$(srctree)/$(src)/include \
 	-D__PPC__  -D__BIG_ENDIAN__
-
-CFLAGS += $(EXTRA_CFLAGS)
-CPPFLAGS += $(EXTRA_CFLAGS)
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index a78a724..25b8e8a 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -8,7 +8,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-#CFLAGS += -DDEBUG
+#ccflags-y += -DDEBUG
 
 obj-$(CONFIG_DTT_ADM1021) += adm1021.o
 obj-$(CONFIG_DTT_ADT7460) += adt7460.o
diff --git a/drivers/net/npe/Makefile b/drivers/net/npe/Makefile
index 0779255..ff554cf 100644
--- a/drivers/net/npe/Makefile
+++ b/drivers/net/npe/Makefile
@@ -5,9 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-LOCAL_CFLAGS  += -I$(TOPDIR)/drivers/net/npe/include -DCONFIG_IXP425_COMPONENT_ETHDB -D__linux
-CFLAGS  += $(LOCAL_CFLAGS)
-CPPFLAGS  += $(LOCAL_CFLAGS) # needed for depend
+ccflags-y += -I$(src)/include -DCONFIG_IXP425_COMPONENT_ETHDB -D__linux
 
 obj-y := npe.o \
 	miiphy.o \
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index d5a2725..003d322 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-#CFLAGS += -DDEBUG
+#ccflags-y += -DDEBUG
 
 obj-$(CONFIG_RTC_AT91SAM9_RTT) += at91sam9_rtt.o
 obj-$(CONFIG_RTC_BFIN) += bfin_rtc.o
diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile
index ba72348..3facf0f 100644
--- a/drivers/usb/musb-new/Makefile
+++ b/drivers/usb/musb-new/Makefile
@@ -9,7 +9,6 @@ obj-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o
 obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o
 obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o
 
-CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \
-			$(call cc-option,-Wno-unused-but-set-variable) \
-			$(call cc-option,-Wno-unused-label)
-CFLAGS += $(CFLAGS_NO_WARN)
+ccflags-y := $(call cc-option,-Wno-unused-variable) \
+		$(call cc-option,-Wno-unused-but-set-variable) \
+		$(call cc-option,-Wno-unused-label)
diff --git a/dts/Makefile b/dts/Makefile
index d81f32d..cc6ecf6 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -36,7 +36,7 @@ process_lds = \
 	$(1) | sed -r -n 's/^OUTPUT_$(2)[ ("]*([^")]*).*/\1/p'
 
 # Run the compiler and get the link script from the linker
-GET_LDS = $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--verbose 2>&1
+GET_LDS = $(CC) $(c_flags) $(ld_flags) -Wl,--verbose 2>&1
 
 $(obj)/dt.o: $(DT_BIN)
 	# We want the output format and arch.
diff --git a/examples/api/Makefile b/examples/api/Makefile
index db0bb34..8b79886 100644
--- a/examples/api/Makefile
+++ b/examples/api/Makefile
@@ -5,7 +5,7 @@
 #
 
 ifdef FTRACE
-CFLAGS += -finstrument-functions -DFTRACE
+ccflags-y += -finstrument-functions -DFTRACE
 endif
 
 ifeq ($(ARCH),powerpc)
@@ -33,12 +33,6 @@ EXT_COBJ_FILES-y += lib/time.o
 EXT_COBJ_FILES-y += lib/vsprintf.o
 EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
 
-# Create a list of source files so their dependencies can be auto-generated
-SRCS	+= $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
-SRCS	+= $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
-SRCS	+= $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
-SRCS	+= $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
-
 # Create a list of object files to be compiled
 OBJS	+= $(addprefix $(obj)/,$(SOBJ_FILES-y))
 OBJS	+= $(addprefix $(obj)/,$(COBJ_FILES-y))
@@ -54,9 +48,10 @@ $(obj)/demo.bin: $(obj)/demo
 		$(OBJCOPY) -O binary $< $@ 2>/dev/null
 
 # Rule to build generic library C files
-$(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c
-	$(CC) -g $(CFLAGS) -c -o $@ $<
+$(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c FORCE
+	$(call cmd,force_checksrc)
+	$(call if_changed_rule,cc_o_c)
 
 # Rule to build architecture-specific library assembly files
 $(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
-	$(CC) -g $(CFLAGS) -c -o $@ $<
+	$(call if_changed_dep,as_o_S)
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index a6819f7..90e173b 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -6,7 +6,7 @@
 #
 
 ifdef FTRACE
-CFLAGS += -finstrument-functions -DFTRACE
+ccflags-y += -finstrument-functions -DFTRACE
 endif
 
 extra-y        := hello_world
@@ -39,10 +39,11 @@ LIBAOBJS := $(LIBAOBJS-y)
 
 LIBCOBJS = stubs.o
 
+.SECONDARY: $(call objectify,$(COBJS))
+targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBAOBJS) $(LIBCOBJS)
+
 LIBOBJS	= $(addprefix $(obj)/,$(LIBAOBJS) $(LIBCOBJS))
 
-SRCS	:= $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
-OBJS	:= $(addprefix $(obj)/,$(COBJS))
 ELF	:= $(addprefix $(obj)/,$(ELF))
 
 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
@@ -52,19 +53,22 @@ gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
 # also causes the entry point of the standalone application to be
 # inconsistent.
 ifeq ($(ARCH),powerpc)
-AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
-CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
-CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
+# FIX ME
+CPPFLAGS := $(filter-out $(RELFLAGS), $(CPPFLAGS))
 endif
 
 # We don't want gcc reordering functions if possible.  This ensures that an
 # application's entry point will be the first function in the application's
 # source file.
-CFLAGS += $(call cc-option,-fno-toplevel-reorder)
+ccflags-y += $(call cc-option,-fno-toplevel-reorder)
 
 #########################################################################
-$(LIB):	$(LIBOBJS)
-	$(call cmd_link_o_target, $(LIBOBJS))
+
+quiet_cmd_link_lib = LD      $@
+      cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^)
+
+$(LIB):	$(LIBOBJS) FORCE
+	$(call if_changed,link_lib)
 
 $(ELF):
 $(obj)/%:	$(obj)/%.o $(LIB)
diff --git a/fs/ubifs/Makefile b/fs/ubifs/Makefile
index 5682b16..6b1a9a5 100644
--- a/fs/ubifs/Makefile
+++ b/fs/ubifs/Makefile
@@ -15,4 +15,4 @@ obj-y += tnc.o tnc_misc.o debug.o crc16.o budget.o
 obj-y += log.o orphan.o recovery.o replay.o
 
 # SEE README.arm-unaligned-accesses
-$(obj)/super.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
+CFLAGS_super.o := $(PLATFORM_NO_UNALIGNED)
diff --git a/fs/yaffs2/Makefile b/fs/yaffs2/Makefile
index d811287..45ff745 100644
--- a/fs/yaffs2/Makefile
+++ b/fs/yaffs2/Makefile
@@ -24,9 +24,6 @@ obj-y := \
 	yaffs_summary.o yaffs_tagscompat.o yaffs_verify.o yaffs_yaffs1.o \
 	yaffs_yaffs2.o yaffs_mtdif.o yaffs_mtdif2.o
 
-YCFLAGS =  -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM
-YCFLAGS += -DCONFIG_YAFFS_YAFFS2 -DNO_Y_INLINE
-YCFLAGS += -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES
-
-CFLAGS += $(YCFLAGS)
-CPPFLAGS +=  $(YCFLAGS)
+ccflags-y = -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM \
+		-DCONFIG_YAFFS_YAFFS2 -DNO_Y_INLINE \
+		-DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES
diff --git a/lib/Makefile b/lib/Makefile
index 43b13d0..8c483c9 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -67,4 +67,4 @@ obj-$(CONFIG_BOOTP_RANDOM_DELAY) += rand.o
 obj-$(CONFIG_CMD_LINK_LOCAL) += rand.o
 
 # SEE README.arm-unaligned-accesses
-$(obj)/bzlib.o: CFLAGS += $(PLATFORM_NO_UNALIGNED)
+CFLAGS_bzlib.o := $(PLATFORM_NO_UNALIGNED)
diff --git a/lib/lzma/Makefile b/lib/lzma/Makefile
index f8eda06..b6c8067 100644
--- a/lib/lzma/Makefile
+++ b/lib/lzma/Makefile
@@ -8,6 +8,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-CFLAGS += -D_LZMA_PROB32
+ccflags-y += -D_LZMA_PROB32
 
 obj-y += LzmaDec.o LzmaTools.o
diff --git a/nand_spl/board/amcc/acadia/Makefile b/nand_spl/board/amcc/acadia/Makefile
index 041213f..d256abf 100644
--- a/nand_spl/board/amcc/acadia/Makefile
+++ b/nand_spl/board/amcc/acadia/Makefile
@@ -12,17 +12,18 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o resetvec.o cache.o
 COBJS	= gpio.o nand_boot.o nand_ecc.o memory.o ndfc.o pll.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin \
 	$(nandobj)System.map
 
@@ -42,7 +43,7 @@ $(nandobj)System.map:	$(nandobj)u-boot-spl
 		sort > $@
 
 $(nandobj)u-boot.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/amcc/bamboo/Makefile b/nand_spl/board/amcc/bamboo/Makefile
index 92b604e..4f36d6c 100644
--- a/nand_spl/board/amcc/bamboo/Makefile
+++ b/nand_spl/board/amcc/bamboo/Makefile
@@ -12,17 +12,18 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o init.o resetvec.o
 COBJS	= nand_boot.o nand_ecc.o ndfc.o sdram.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
@@ -36,7 +37,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/amcc/canyonlands/Makefile b/nand_spl/board/amcc/canyonlands/Makefile
index 9a730e9..5c9c8e8 100644
--- a/nand_spl/board/amcc/canyonlands/Makefile
+++ b/nand_spl/board/amcc/canyonlands/Makefile
@@ -12,8 +12,8 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	:= start.o
 SOBJS	+= init.o
@@ -23,11 +23,12 @@ COBJS	+= nand_boot.o
 COBJS	+= nand_ecc.o
 COBJS	+= ndfc.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
@@ -41,7 +42,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/amcc/kilauea/Makefile b/nand_spl/board/amcc/kilauea/Makefile
index 1c5498c..cfe3082 100644
--- a/nand_spl/board/amcc/kilauea/Makefile
+++ b/nand_spl/board/amcc/kilauea/Makefile
@@ -12,17 +12,18 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o resetvec.o cache.o
 COBJS	= 44x_spd_ddr2.o nand_boot.o nand_ecc.o ndfc.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
@@ -36,7 +37,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/amcc/sequoia/Makefile b/nand_spl/board/amcc/sequoia/Makefile
index 62131ab..de02886 100644
--- a/nand_spl/board/amcc/sequoia/Makefile
+++ b/nand_spl/board/amcc/sequoia/Makefile
@@ -12,17 +12,18 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \
 	   $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o init.o resetvec.o
 COBJS	= denali_data_eye.o nand_boot.o nand_ecc.o ndfc.o sdram.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
@@ -36,7 +37,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/freescale/mpc8315erdb/Makefile b/nand_spl/board/freescale/mpc8315erdb/Makefile
index a2054ee..a685674 100644
--- a/nand_spl/board/freescale/mpc8315erdb/Makefile
+++ b/nand_spl/board/freescale/mpc8315erdb/Makefile
@@ -13,18 +13,19 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 	   $(LDFLAGS) $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o ticks.o
 COBJS	= nand_boot_fsl_elbc.o $(BOARD).o sdram.o ns16550.o spl_minimal.o \
 	  time.o cache.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
@@ -38,7 +39,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
 
 # create symbolic links for common files
 
diff --git a/nand_spl/board/freescale/mpc8536ds/Makefile b/nand_spl/board/freescale/mpc8536ds/Makefile
index f711cf3..f0beaed 100644
--- a/nand_spl/board/freescale/mpc8536ds/Makefile
+++ b/nand_spl/board/freescale/mpc8536ds/Makefile
@@ -15,18 +15,19 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o resetvec.o
 COBJS	= cache.o cpu_init_early.o spl_minimal.o fsl_law.o law.o \
 	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
@@ -40,7 +41,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \
 		-ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
diff --git a/nand_spl/board/freescale/mpc8569mds/Makefile b/nand_spl/board/freescale/mpc8569mds/Makefile
index f711cf3..f0beaed 100644
--- a/nand_spl/board/freescale/mpc8569mds/Makefile
+++ b/nand_spl/board/freescale/mpc8569mds/Makefile
@@ -15,18 +15,19 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o resetvec.o
 COBJS	= cache.o cpu_init_early.o spl_minimal.o fsl_law.o law.o \
 	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
@@ -40,7 +41,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \
 		-ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
diff --git a/nand_spl/board/freescale/mpc8572ds/Makefile b/nand_spl/board/freescale/mpc8572ds/Makefile
index f711cf3..f0beaed 100644
--- a/nand_spl/board/freescale/mpc8572ds/Makefile
+++ b/nand_spl/board/freescale/mpc8572ds/Makefile
@@ -15,18 +15,19 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o resetvec.o
 COBJS	= cache.o cpu_init_early.o spl_minimal.o fsl_law.o law.o \
 	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
@@ -40,7 +41,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \
 		-ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
diff --git a/nand_spl/board/freescale/p1023rds/Makefile b/nand_spl/board/freescale/p1023rds/Makefile
index 21a6920..3918ac5 100644
--- a/nand_spl/board/freescale/p1023rds/Makefile
+++ b/nand_spl/board/freescale/p1023rds/Makefile
@@ -11,18 +11,19 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o resetvec.o
 COBJS	= cache.o cpu_init_early.o spl_minimal.o fsl_law.o law.o \
 	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
@@ -36,7 +37,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \
 		-ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
diff --git a/nand_spl/board/freescale/p1_p2_rdb/Makefile b/nand_spl/board/freescale/p1_p2_rdb/Makefile
index f711cf3..f0beaed 100644
--- a/nand_spl/board/freescale/p1_p2_rdb/Makefile
+++ b/nand_spl/board/freescale/p1_p2_rdb/Makefile
@@ -15,18 +15,19 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/$(CPUDIR)/u-boot-nand_spl.lds
 LDFLAGS := -T $(nandobj)u-boot-nand_spl.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 		$(LDFLAGS) $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o resetvec.o
 COBJS	= cache.o cpu_init_early.o spl_minimal.o fsl_law.o law.o \
 	  nand_boot.o nand_boot_fsl_elbc.o ns16550.o tlb.o tlb_table.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl
@@ -40,7 +41,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot-nand_spl.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \
 		-ansi -D__ASSEMBLY__ -P - <$< >$@
 
 # create symbolic links for common files
diff --git a/nand_spl/board/sheldon/simpc8313/Makefile b/nand_spl/board/sheldon/simpc8313/Makefile
index ca45ecd..35b1f97 100644
--- a/nand_spl/board/sheldon/simpc8313/Makefile
+++ b/nand_spl/board/sheldon/simpc8313/Makefile
@@ -12,18 +12,19 @@ nandobj	:= $(OBJTREE)/nand_spl/
 LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds
 LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE_SPL) \
 	   $(LDFLAGS) $(LDFLAGS_FINAL)
-AFLAGS	+= -DCONFIG_NAND_SPL
-CFLAGS	+= -DCONFIG_NAND_SPL
+asflags-y += -DCONFIG_NAND_SPL
+ccflags-y += -DCONFIG_NAND_SPL
 
 SOBJS	= start.o ticks.o
 COBJS	= nand_boot_fsl_elbc.o $(BOARD).o sdram.o ns16550.o spl_minimal.o \
 	  time.o cache.o
 
-SRCS	:= $(addprefix $(obj)/,$(SOBJS:.o=.S) $(COBJS:.o=.c))
 OBJS	:= $(addprefix $(obj)/,$(SOBJS) $(COBJS))
 __OBJS	:= $(SOBJS) $(COBJS)
 LNDIR	:= $(nandobj)board/$(BOARDDIR)
 
+targets += $(__OBJS)
+
 all: $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin
 
 $(nandobj)u-boot-spl-16k.bin:	$(nandobj)u-boot-spl
@@ -37,7 +38,7 @@ $(nandobj)u-boot-spl:	$(OBJS) $(nandobj)u-boot.lds
 		-Map $(nandobj)u-boot-spl.map -o $@
 
 $(nandobj)u-boot.lds: $(LDSCRIPT)
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
 
 # create symbolic links for common files
 
diff --git a/net/Makefile b/net/Makefile
index 31aadc2..9425950 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# CFLAGS += -DDEBUG
+#ccflags-y += -DDEBUG
 
 obj-$(CONFIG_CMD_NET)  += arp.o
 obj-$(CONFIG_CMD_NET)  += bootp.o
diff --git a/post/lib_powerpc/fpu/Makefile b/post/lib_powerpc/fpu/Makefile
index c720a26..556a833 100644
--- a/post/lib_powerpc/fpu/Makefile
+++ b/post/lib_powerpc/fpu/Makefile
@@ -5,20 +5,19 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-y	+= 20001122-1.o
-obj-y	+= 20010114-2.o
-obj-y	+= 20010226-1.o
-obj-y	+= 980619-1.o
-obj-y	+= acc1.o
-obj-y	+= compare-fp-1.o
-obj-y	+= fpu.o
-obj-y	+= mul-subnormal-single-1.o
-obj-y	+= darwin-ldouble.o
+objs-before-objcopy := 20001122-1.o 20010114-2.o 20010226-1.o 980619-1.o \
+	acc1.o compare-fp-1.o fpu.o mul-subnormal-single-1.o darwin-ldouble.o
+targets += $(objs-before-objcopy)
 
-CFLAGS := $(shell echo $(CFLAGS) | sed s/-msoft-float//)
-CFLAGS += -mhard-float -fkeep-inline-functions
+# remove -msoft-float flag
+$(foreach m, $(objs-before-objcopy), $(eval CFLAGS_REMOVE_$m := -msoft-float))
+ccflags-y := -mhard-float -fkeep-inline-functions
 
-$(addprefix $(obj)/,$(obj-y)): $(obj)/%.o: $(src)/%.c
-	$(CC)  $(ALL_CFLAGS) -o $@.fp $< -c
-	$(OBJCOPY) -R .gnu.attributes $@.fp $@
-	rm -f $@.fp
+# Do not delete intermidiate files (*.o)
+.SECONDARY: $(call objectify, $(objs-before-objcopy))
+
+obj-y := $(objs-before-objcopy:.o=_.o)
+
+OBJCOPYFLAGS := -R .gnu.attributes
+$(obj)/%_.o: $(obj)/%.o
+	$(call if_changed,objcopy)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 30a5551..6113c13 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -165,7 +165,7 @@ ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
 # Usage:
 # $(Q)$(MAKE) $(build)=dir
-build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build.tmp obj
+build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
 
 ###
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index d5d859c..921fbbf 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -2,7 +2,16 @@
 # Building
 # ==========================================================================
 
-src := $(obj)
+# Modified for U-Boot
+ifeq ($(CONFIG_TPL_BUILD),y)
+  src := $(patsubst tpl/%,%,$(obj))
+else
+  ifeq ($(CONFIG_SPL_BUILD),y)
+    src := $(patsubst spl/%,%,$(obj))
+  else
+    src := $(obj)
+  endif
+endif
 
 PHONY := __build
 __build:
@@ -34,6 +43,10 @@ subdir-ccflags-y :=
 -include include/config/auto.conf
 
 include scripts/Kbuild.include
+# Modified for U-Boot
+#  We must include config.mk after Kbuild.include:
+#  Some config.mk use cc-option
+include config.mk
 
 # For backward compatibility check that these variables do not change
 save-cflags := $(CFLAGS)
@@ -115,14 +128,16 @@ ifneq ($(hostprogs-y)$(hostprogs-m),)
 include scripts/Makefile.host
 endif
 
-ifneq ($(KBUILD_SRC),)
+# Uncommented for U-Boot
+#  We need to create output dicrectory for SPL and TPL even for in-tree build
+#ifneq ($(KBUILD_SRC),)
 # Create output directory if not already present
 _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
 
 # Create directories for object files if directory does not exist
 # Needed when obj-y := dir/file.o syntax is used
 _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
-endif
+#endif
 
 ifndef obj
 $(warning kbuild: Makefile.build is included improperly)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 49392ec..d4b5cb5 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -101,12 +101,13 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
 modname_flags  = $(if $(filter 1,$(words $(modname))),\
                  -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
 
-orig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
+# U-Boot also uses $(CPPFLAGS)
+orig_c_flags   = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
                  $(ccflags-y) $(CFLAGS_$(basetarget).o)
 _c_flags       = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
-_a_flags       = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
+_a_flags       = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
                  $(asflags-y) $(AFLAGS_$(basetarget).o)
-_cpp_flags     = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
+_cpp_flags     = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
 
 #
 # Enable gcov profiling flags for a file, directory or for all files depending
@@ -137,14 +138,15 @@ __a_flags	=                          $(call flags,_a_flags)
 __cpp_flags     =                          $(call flags,_cpp_flags)
 endif
 
-c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+# Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE
+c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE)     \
 		 $(__c_flags) $(modkern_cflags)                           \
 		 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
 
-a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE)     \
 		 $(__a_flags) $(modkern_aflags)
 
-cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE)     \
 		 $(__cpp_flags)
 
 ld_flags       = $(LDFLAGS) $(ldflags-y)
diff --git a/spl/Makefile b/spl/Makefile
index 3950df2..e2728fd 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -105,8 +105,7 @@ LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y))
 
 # Add GCC lib
 ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
-PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
-PLATFORM_LIBS := $(filter-out %/libgcc.o, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
+PLATFORM_LIBS := $(SPLTREE)/arch/$(ARCH)/lib/lib.a
 endif
 
 LIBS-y := $(sort $(LIBS-y))
@@ -154,7 +153,7 @@ $(OBJTREE)/MLO.byteswap: $(obj)/u-boot-spl.bin
 	$(OBJTREE)/tools/mkimage -T omapimage -n byteswap \
 		-a $(CONFIG_SPL_TEXT_BASE) -d $< $@
 
-$(objtree)/SPL : $(obj)/u-boot-spl.bin depend
+$(objtree)/SPL : $(obj)/u-boot-spl.bin
 		$(MAKE) $(build)=spl/arch/arm/imx-common $@
 
 ALL-y	+= $(obj)/$(SPL_BIN).bin
@@ -190,20 +189,24 @@ GEN_UBOOT = \
 		--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
 		-Map $(SPL_BIN).map -o $(SPL_BIN)
 
-$(obj)/$(SPL_BIN):	depend $(START) $(LIBS) $(obj)/u-boot-spl.lds
+$(obj)/$(SPL_BIN): $(START) $(LIBS) $(obj)/u-boot-spl.lds
 	$(GEN_UBOOT)
 
 $(START):
 	@:
 
-$(LIBS):	depend
-	$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
+$(LIBS):
+	$(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
 
-$(obj)/u-boot-spl.lds: $(LDSCRIPT) depend
-	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(obj). -ansi -D__ASSEMBLY__ -P - < $< > $@
+# FIX ME
+cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
 
-depend:	$(obj)/.depend
-.PHONY: depend
+$(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE
+	$(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(obj). -ansi -D__ASSEMBLY__ -P - < $< > $@
 
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
+PHONY += FORCE
+FORCE:
+
+# Declare the contents of the .PHONY variable as phony.  We keep that
+# information in a variable so we can use it in if_changed and friends.
+.PHONY: $(PHONY)
diff --git a/tools/Makefile b/tools/Makefile
index 9b19dcb..70a3fc2 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -40,19 +40,19 @@ hostprogs-$(CONFIG_CMD_LICENSE) += bin2header$(SFX)
 
 hostprogs-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
 hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
-HOSTCFLAGS_bmp_logo$(SFX) := -pedantic
+HOSTCFLAGS_bmp_logo$(SFX).o := -pedantic
 
 hostprogs-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
 envcrc$(SFX)-objs := crc32.o env_embedded.o envcrc.o sha1.o
 
 hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
-HOSTCFLAGS_gen_eth_addr$(SFX) := -pedantic
+HOSTCFLAGS_gen_eth_addr$(SFX).o := -pedantic
 
 hostprogs-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
-HOSTCFLAGS_img2srec$(SFX) := -pedantic
+HOSTCFLAGS_img2srec$(SFX).o := -pedantic
 
 hostprogs-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
-HOSTCFLAGS_xway-swap-bytes$(SFX) := -pedantic
+HOSTCFLAGS_xway-swap-bytes$(SFX).o := -pedantic
 
 hostprogs-y += mkenvimage$(SFX)
 mkenvimage$(SFX)-objs := crc32.o mkenvimage.o os_support.o
@@ -97,7 +97,7 @@ HOSTLOADLIBES_dumpimage$(SFX) := -lssl -lcrypto
 HOSTLOADLIBES_mkimage$(SFX) := -lssl -lcrypto
 # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
 # the mxsimage support within tools/mxsimage.c .
-HOSTCFLAGS	+= -DCONFIG_MXS
+HOSTCFLAGS_mxsimage.o += -DCONFIG_MXS
 endif
 
 ifdef CONFIG_FIT_SIGNATURE
@@ -111,11 +111,11 @@ endif
 
 hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl$(SFX)
 hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl$(SFX)
-HOSTCFLAGS_mkexynosspl$(SFX) := -pedantic
+HOSTCFLAGS_mkexynosspl$(SFX).o := -pedantic
 
 hostprogs-$(CONFIG_MX23) += mxsboot$(SFX)
 hostprogs-$(CONFIG_MX28) += mxsboot$(SFX)
-HOSTCFLAGS_mxsboot$(SFX) := -pedantic
+HOSTCFLAGS_mxsboot$(SFX).o := -pedantic
 
 hostprogs-$(CONFIG_NETCONSOLE) += ncb$(SFX)
 hostprogs-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
@@ -137,7 +137,7 @@ HOSTCFLAGS_sha1.o := -pedantic
 
 # Don't build by default
 #hostprogs-$(CONFIG_PPC) += mpc86x_clk$(SFX)
-#HOSTCFLAGS_mpc86x_clk$(SFX) := -pedantic
+#HOSTCFLAGS_mpc86x_clk$(SFX).o := -pedantic
 
 always := $(hostprogs-y)
 
@@ -164,11 +164,6 @@ endif
 
 endif # !LOGO_BMP
 
-# now $(obj) is defined
-HOSTSRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
-HOSTSRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
-HOSTSRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
-
 #
 # Use native tools and options
 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
@@ -183,7 +178,7 @@ HOST_EXTRACFLAGS += -include $(SRCTREE)/include/libfdt_env.h \
 		-D__KERNEL_STRICT_NAMES \
 		-D_GNU_SOURCE
 
-all:	$(LOGO-y)
+__build:	$(LOGO-y)
 
 subdir-y := kernel-doc
 
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 22/38] kbuild: delete temporary build scripts
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (20 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 21/38] kbuild: use Linux Kernel build scripts Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 23/38] kbuild: move some lines to more suitable place Masahiro Yamada
                   ` (18 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

We had switched to Kbuild.
We do not need old build scripts any more.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 rules.mk                   |  47 -----------------
 scripts/Makefile.build.tmp | 127 ---------------------------------------------
 scripts/Makefile.host.tmp  |  61 ----------------------
 3 files changed, 235 deletions(-)
 delete mode 100644 rules.mk
 delete mode 100644 scripts/Makefile.build.tmp
 delete mode 100644 scripts/Makefile.host.tmp

diff --git a/rules.mk b/rules.mk
deleted file mode 100644
index e4fd337..0000000
--- a/rules.mk
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# (C) Copyright 2006-2013
-# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-#########################################################################
-
-_depend:	$(obj)/.depend
-
-# Split the source files into two camps: those in the current directory, and
-# those somewhere else. For the first camp we want to support CPPFLAGS_<fname>
-# and for the second we don't / can't.
-PWD_SRCS := $(foreach f,$(SRCS), $(if \
-	$(filter $(if $(KBUILD_SRC),$(srctree)/)$(src)/$(notdir $f),$f), $f))
-OTHER_SRCS := $(filter-out $(PWD_SRCS),$(SRCS))
-
-# This is a list of dependency files to generate
-DEPS := $(basename $(addprefix $(obj)/.depend., $(notdir $(PWD_SRCS))))
-
-# Join all the dependencies into a single file, in three parts
-#	1 .Concatenate all the generated depend files together
-#	2. Add in the deps from OTHER_SRCS which we couldn't process
-#	3. Add in the HOSTSRCS
-$(obj)/.depend:	$(TOPDIR)/config.mk $(DEPS) $(OTHER_SRCS) \
-		$(HOSTSRCS)
-	cat /dev/null $(DEPS) >$@
-	@for f in $(OTHER_SRCS); do \
-		g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
-		$(CC) -M $(CPPFLAGS) -MQ $(obj)/$$g $$f >> $@ ; \
-	done
-	@for f in $(HOSTSRCS); do \
-		g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
-		$(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)/$$g $$f >> $@ ; \
-	done
-
-MAKE_DEPEND = $(CC) -M $(CPPFLAGS) $(EXTRA_CPPFLAGS_DEP) \
-		-MQ $(addsuffix .o,$(obj)$(basename $<)) $< >$@
-
-
-$(obj)/.depend.%:	$(src)/%.c
-	$(MAKE_DEPEND)
-
-$(obj)/.depend.%:	$(src)/%.S
-	$(MAKE_DEPEND)
-
-#########################################################################
diff --git a/scripts/Makefile.build.tmp b/scripts/Makefile.build.tmp
deleted file mode 100644
index 52a44ff..0000000
--- a/scripts/Makefile.build.tmp
+++ /dev/null
@@ -1,127 +0,0 @@
-# our default target
-.PHONY: all
-all:
-
-ifeq ($(CONFIG_TPL_BUILD),y)
-  src := $(patsubst tpl/%,%,$(obj))
-else
-  ifeq ($(CONFIG_SPL_BUILD),y)
-    src := $(patsubst spl/%,%,$(obj))
-  else
-    src := $(obj)
-  endif
-endif
-
-include $(srctree)/scripts/Kbuild.include
-include $(srctree)/config.mk
-
-# variable LIB is used in examples/standalone/Makefile
-__LIB := $(obj)/built-in.o
-LIBGCC = $(obj)/libgcc.o
-SRCS :=
-subdir-y :=
-obj-dirs :=
-
-kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
-include $(kbuild-dir)/Makefile
-
-# Do not include host rules unless needed
-ifneq ($(hostprogs-y)$(hostprogs-m),)
-include $(SRCTREE)/scripts/Makefile.host.tmp
-endif
-
-# Going forward use the following
-obj-y := $(sort $(obj-y))
-extra-y := $(sort $(extra-y))
-always := $(sort $(always))
-lib-y := $(sort $(lib-y))
-
-subdir-y 	+= $(patsubst %/,%,$(filter %/, $(obj-y)))
-obj-y		:= $(patsubst %/, %/built-in.o, $(obj-y))
-subdir-obj-y	:= $(filter %/built-in.o, $(obj-y))
-subdir-obj-y	:= $(addprefix $(obj)/,$(subdir-obj-y))
-
-SRCS	+= $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) \
-	$(lib-y:.o=.S) $(extra-y:.o=.c) $(extra-y:.o=.S)
-
-SRCS := $(addprefix $(if $(KBUILD_SRC),$(srctree)/$(src)/,$(src)/),$(SRCS))
-SRCS := $(wildcard $(SRCS))
-
-OBJS	:= $(addprefix $(obj)/,$(obj-y))
-
-# $(obj-dirs) is a list of directories that contain object files
-
-obj-dirs += $(dir $(OBJS))
-
-_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
-
-# Create directories for object files if directory does not exist
-# Needed when obj-y := dir/file.o syntax is used
-_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
-
-LGOBJS := $(addprefix $(obj)/,$(sort $(lib-y)))
-
-all: $(__LIB) $(addprefix $(obj)/,$(extra-y) $(always)) $(subdir-y)
-
-$(__LIB):	$(obj)/.depend $(OBJS)
-	$(call cmd_link_o_target, $(OBJS))
-
-ifneq ($(strip $(lib-y)),)
-all: $(LIBGCC)
-
-$(LIBGCC): $(obj)/.depend $(LGOBJS)
-	$(call cmd_link_o_target, $(LGOBJS))
-endif
-
-ifneq ($(subdir-obj-y),)
-# Descending
-$(subdir-obj-y): $(subdir-y)
-endif
-
-ifneq ($(subdir-y),)
-$(subdir-y): FORCE
-	$(MAKE) $(build)=$(obj)/$@
-endif
-
-#########################################################################
-
-# Allow boards to use custom optimize flags on a per dir/file basis
-ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
-ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
-EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR))
-ALL_CFLAGS += $(EXTRA_CPPFLAGS)
-
-# The _DEP version uses the $< file target (for dependency generation)
-# See rules.mk
-EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \
-		$(CPPFLAGS_$(BCURDIR))
-$(obj)/%.s:	$(src)/%.S
-	$(CPP) $(ALL_AFLAGS) -o $@ $<
-$(obj)/%.o:	$(src)/%.S
-	$(CC)  $(ALL_AFLAGS) -o $@ $< -c
-$(obj)/%.o:	$(src)/%.c
-ifneq ($(CHECKSRC),0)
-	$(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $<
-endif
-	$(CC)  $(ALL_CFLAGS) -o $@ $< -c
-$(obj)/%.i:	$(src)/%.c
-	$(CPP) $(ALL_CFLAGS) -o $@ $< -c
-$(obj)/%.s:	$(src)/%.c
-	$(CC)  $(ALL_CFLAGS) -o $@ $< -c -S
-
-# If the list of objects to link is empty, just create an empty built-in.o
-cmd_link_o_target = $(if $(strip $1),\
-		      $(LD) $(LDFLAGS) -r -o $@ $1,\
-		      rm -f $@; $(AR) rcs $@ )
-
-#########################################################################
-
-# defines $(obj)/.depend target
-
-include $(TOPDIR)/rules.mk
-
-sinclude $(obj)/.depend
-
-#########################################################################
-
-.PHONY: FORCE
diff --git a/scripts/Makefile.host.tmp b/scripts/Makefile.host.tmp
deleted file mode 100644
index 53fe930..0000000
--- a/scripts/Makefile.host.tmp
+++ /dev/null
@@ -1,61 +0,0 @@
-
-__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
-
-# C code
-# Executables compiled from a single .c file
-host-csingle	:= $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
-
-# C executables linked based on several .o files
-host-cmulti	:= $(foreach m,$(__hostprogs),$(if $($(m)-objs),$(m)))
-
-# Object (.o) files compiled from .c files
-host-cobjs	:= $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
-
-# output directory for programs/.o files
-# hostprogs-y := tools/build may have been specified. Retrieve directory
-host-objdirs := $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f))))
-# directory of .o files from prog-objs notation
-host-objdirs += $(foreach f,$(host-cmulti),                  \
-                    $(foreach m,$($(f)-objs),                \
-                        $(if $(dir $(m)),$(dir $(m)))))
-
-host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs))))
-
-__hostprogs     := $(addprefix $(obj)/,$(__hostprogs))
-host-csingle	:= $(addprefix $(obj)/,$(host-csingle))
-host-cmulti	:= $(addprefix $(obj)/,$(host-cmulti))
-host-cobjs	:= $(addprefix $(obj)/,$(host-cobjs))
-host-objdirs    := $(addprefix $(obj)/,$(host-objdirs))
-
-obj-dirs += $(host-objdirs)
-
-#####
-# Handle options to gcc. Support building with separate output directory
-
-_hostc_flags   = $(HOSTCFLAGS)   $(HOST_EXTRACFLAGS)   \
-                 $(HOSTCFLAGS_$(basetarget).o)
-
-# Find all -I options and call addtree
-flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
-
-ifeq ($(OBJTREE),$(SRCTREE))
-__hostc_flags	= $(_hostc_flags)
-else
-__hostc_flags	= -I$(obj) $(call flags,_hostc_flags)
-endif
-
-hostc_flags    = $(__hostc_flags)
-
-#####
-# Compile programs on the host
-
-$(host-csingle): $(obj)/%: $(src)/%.c
-	$(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTLDFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $<
-
-$(host-cmulti): $(obj)/%: $(host-cobjs)
-	$(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj)/,$($(@F)-objs)) $(HOSTLOADLIBES_$(@F))
-
-$(host-cobjs): $(obj)/%.o: $(src)/%.c
-	$(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
-
-targets += $(host-csingle)  $(host-cmulti) $(host-cobjs)
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 23/38] kbuild: move some lines to more suitable place
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (21 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 22/38] kbuild: delete temporary " Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 24/38] kbuild: convert some make rules to Kbuild style Masahiro Yamada
                   ` (17 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

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

Changes in v8: None
Changes in v7: None
Changes in v6:
  - Rebase on the current u-boot/master

Changes in v5: None
Changes in v4:
  - Move the line where U_BOOT_VERSION is defined

Changes in v3: None
Changes in v2: None

 Makefile | 66 ++++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/Makefile b/Makefile
index 4f00f08..baa7b3d 100644
--- a/Makefile
+++ b/Makefile
@@ -9,39 +9,7 @@ VERSION = 2014
 PATCHLEVEL = 01
 SUBLEVEL =
 EXTRAVERSION =
-ifneq "$(SUBLEVEL)" ""
-U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
-else
-U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION)
-endif
-TIMESTAMP_FILE = include/generated/timestamp_autogenerated.h
-VERSION_FILE = include/generated/version_autogenerated.h
-
-HOSTARCH := $(shell uname -m | \
-	sed -e s/i.86/x86/ \
-	    -e s/sun4u/sparc64/ \
-	    -e s/arm.*/arm/ \
-	    -e s/sa110/arm/ \
-	    -e s/ppc64/powerpc/ \
-	    -e s/ppc/powerpc/ \
-	    -e s/macppc/powerpc/\
-	    -e s/sh.*/sh/)
-
-HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
-	    sed -e 's/\(cygwin\).*/cygwin/')
-
-export	HOSTARCH HOSTOS
-
-# Deal with colliding definitions from tcsh etc.
-VENDOR=
-
-#########################################################################
-# Allow for silent builds
-ifeq (,$(findstring s,$(MAKEFLAGS)))
-XECHO = echo
-else
-XECHO = :
-endif
+NAME =
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
@@ -212,6 +180,35 @@ unexport CDPATH
 
 #########################################################################
 
+TIMESTAMP_FILE = include/generated/timestamp_autogenerated.h
+VERSION_FILE = include/generated/version_autogenerated.h
+
+HOSTARCH := $(shell uname -m | \
+	sed -e s/i.86/x86/ \
+	    -e s/sun4u/sparc64/ \
+	    -e s/arm.*/arm/ \
+	    -e s/sa110/arm/ \
+	    -e s/ppc64/powerpc/ \
+	    -e s/ppc/powerpc/ \
+	    -e s/macppc/powerpc/\
+	    -e s/sh.*/sh/)
+
+HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
+	    sed -e 's/\(cygwin\).*/cygwin/')
+
+export	HOSTARCH HOSTOS
+
+# Deal with colliding definitions from tcsh etc.
+VENDOR=
+
+#########################################################################
+# Allow for silent builds
+ifeq (,$(findstring s,$(MAKEFLAGS)))
+XECHO = echo
+else
+XECHO = :
+endif
+
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
 # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
@@ -402,6 +399,9 @@ KBUILD_CFLAGS   := -Wall -Wstrict-prototypes \
 		   -fno-builtin -ffreestanding
 KBUILD_AFLAGS   := -D__ASSEMBLY__
 
+U_BOOT_VERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
+
+export VERSION PATCHLEVEL SUBLEVEL U_BOOT_VERSION
 export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
 export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
 export MAKE AWK
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 24/38] kbuild: convert some make rules to Kbuild style
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (22 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 23/38] kbuild: move some lines to more suitable place Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 25/38] kbuild: move include directives of board configuration files Masahiro Yamada
                   ` (16 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

We can get Kbuild-ish log style like this:
  GEN     include/autoconf.mk
  GEN     include/autoconf.mk.dep

We do not need XECHO any more.

And also change checkstack target like Linux Kernel.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
  - Change checkstack target

Changes in v3: None
Changes in v2: None

 Makefile | 77 ++++++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 43 insertions(+), 34 deletions(-)

diff --git a/Makefile b/Makefile
index baa7b3d..7af404a 100644
--- a/Makefile
+++ b/Makefile
@@ -202,12 +202,6 @@ export	HOSTARCH HOSTOS
 VENDOR=
 
 #########################################################################
-# Allow for silent builds
-ifeq (,$(findstring s,$(MAKEFLAGS)))
-XECHO = echo
-else
-XECHO = :
-endif
 
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
@@ -909,10 +903,11 @@ TAG_SUBDIRS += include
 FIND := find
 FINDFLAGS := -L
 
+PHONY += checkstack
+
 checkstack:
-		$(CROSS_COMPILE)objdump -d u-boot \
-			`$(FIND) . -name u-boot-spl -print` | \
-			perl $(src)/scripts/checkstack.pl $(ARCH)
+	$(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \
+	$(PERL) $(src)/scripts/checkstack.pl $(ARCH)
 
 tags ctags:
 		ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
@@ -962,52 +957,63 @@ checkdtc:
 # This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
 # the dep file is only include in this top level makefile to determine when
 # to regenerate the autoconf.mk file.
+
+quiet_cmd_autoconf_dep = GEN     $@
+      cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \
+	-MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@
+
 include/autoconf.mk.dep: include/config.h include/common.h
-	@$(XECHO) Generating $@ ; \
-	: Generate the dependancies ; \
-	$(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \
-		-MQ include/autoconf.mk $(srctree)/include/common.h > $@ || \
-		rm $@
+	$(call cmd,autoconf_dep)
 
-include/autoconf.mk: include/config.h
-	@$(XECHO) Generating $@ ; \
-	: Extract the config macros ; \
+quiet_cmd_autoconf = GEN     $@
+      cmd_autoconf = \
 	$(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
-		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
+	sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
 	rm $@.tmp
 
+include/autoconf.mk: include/config.h
+	$(call cmd,autoconf)
+
 # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
-include/tpl-autoconf.mk: include/config.h
-	@$(XECHO) Generating $@ ; \
-	: Extract the config macros ; \
+quiet_cmd_tpl-autoconf = GEN     $@
+      cmd_tpl-autoconf = \
 	$(CPP) $(c_flags) -DCONFIG_TPL_BUILD  -DCONFIG_SPL_BUILD\
 			-DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
 		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
 	rm $@.tmp
 
-include/spl-autoconf.mk: include/config.h
-	@$(XECHO) Generating $@ ; \
-	: Extract the config macros ; \
+include/tpl-autoconf.mk: include/config.h
+	$(call cmd,tpl-autoconf)
+
+quiet_cmd_spl-autoconf = GEN     $@
+      cmd_spl-autoconf = \
 	$(CPP) $(c_flags) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
 		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
 	rm $@.tmp
 
+include/spl-autoconf.mk: include/config.h
+	$(call cmd,spl-autoconf)
+
+quiet_cmd_offsets = GEN     $@
+      cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@
+
 include/generated/generic-asm-offsets.h: lib/asm-offsets.s
-	@$(XECHO) Generating $@
-	$(srctree)/tools/scripts/make-asm-offsets lib/asm-offsets.s $@
+	$(call cmd,offsets)
 
-lib/asm-offsets.s: include/config.h $(srctree)/lib/asm-offsets.c
-	@mkdir -p lib
-	$(CC) -DDO_DEPS_ONLY \
+quiet_cmd_asm-offsets.s = CC      $@
+      cmd_asm-offsets.s = mkdir -p lib; \
+		$(CC) -DDO_DEPS_ONLY \
 		$(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
-		-o $@ $(srctree)/lib/asm-offsets.c -c -S
+		-o $@ $< -c -S
+
+lib/asm-offsets.s: $(srctree)/lib/asm-offsets.c include/config.h
+	$(call cmd,asm-offsets.s)
 
 include/generated/asm-offsets.h: $(CPUDIR)/$(SOC)/asm-offsets.s
-	@$(XECHO) Generating $@
-	$(srctree)/tools/scripts/make-asm-offsets $(CPUDIR)/$(SOC)/asm-offsets.s $@
+	$(call cmd,offsets)
 
-$(CPUDIR)/$(SOC)/asm-offsets.s:	include/config.h
-	@mkdir -p $(CPUDIR)/$(SOC)
+quiet_cmd_soc_asm-offsets.s = CC      $@
+      cmd_soc_asm-offsets.s = mkdir -p $(CPUDIR)/$(SOC); \
 	if [ -f $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
 		$(CC) -DDO_DEPS_ONLY \
 		$(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
@@ -1016,6 +1022,9 @@ $(CPUDIR)/$(SOC)/asm-offsets.s:	include/config.h
 		touch $@; \
 	fi
 
+$(CPUDIR)/$(SOC)/asm-offsets.s:	include/config.h
+	$(call cmd,soc_asm-offsets.s)
+
 #########################################################################
 else	# !config.mk
 all u-boot.hex u-boot.srec u-boot.bin \
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 25/38] kbuild: move include directives of board configuration files
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (23 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 24/38] kbuild: convert some make rules to Kbuild style Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 26/38] kbuild: generate {spl, tpl}-autoconf.mk only when it is necessary Masahiro Yamada
                   ` (15 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit changes the location of include directives
of board configuration files.

The purpose of this change is:
 - Slim down $(TOPDIR)/config.mk
 - Prevent $(TOPDIR)/Makefile from including the same
    configuration file twice
 - Do not include include/config.mk multiple times
    because ARCH, CPU, BOARD, VENDOR, SOC are exported

Before this commit:

 - include/autoconf.mk was included from $(TOPDIR)/Makefile
   and $(TOPDIR)/config.mk
   (This means $(TOPDIR)/Makefile included include/autoconf.mk twice)

 - include/{spl,tpl}-autoconf.mk was included from $(TOPDIR)/config.mk

 - include/config.mk was included from $(TOPDIR)/Makefile
   and $(TOPDIR)/config.mk
   (This means $(TOPDIR)/Makefile included include/config.mk twice)

After this commit:

 - include/autoconf.mk is included from $(TOPDIR)/Makefile
   and $(TOPDIR)/scripts/Makefile.build

 - include/{spl,tpl}-autoconf.mk is included from $(TOPDIR)/spl/Makefile
   and $(TOPDIR)/scripts/Makefile.build

 - include/config.mk is included from $(TOPDIR)/config.mk and
   $(TOPDIR)/spl/Makefile

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 config.mk              | 15 ---------------
 scripts/Makefile.build | 11 +++++++++++
 spl/Makefile           |  8 ++++++++
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/config.mk b/config.mk
index 1336ef8..5b886aa 100644
--- a/config.mk
+++ b/config.mk
@@ -13,21 +13,6 @@ PLATFORM_LDFLAGS =
 
 #########################################################################
 
-# Load generated board configuration
-ifeq ($(CONFIG_TPL_BUILD),y)
-# Include TPL autoconf
-sinclude include/tpl-autoconf.mk
-else
-ifeq ($(CONFIG_SPL_BUILD),y)
-# Include SPL autoconf
-sinclude include/spl-autoconf.mk
-else
-# Include normal autoconf
-sinclude include/autoconf.mk
-endif
-endif
-sinclude $(OBJTREE)/include/config.mk
-
 # Some architecture config.mk files need to know what CPUDIR is set to,
 # so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.
 # Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 921fbbf..f37957f 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -42,6 +42,17 @@ subdir-ccflags-y :=
 # Read auto.conf if it exists, otherwise ignore
 -include include/config/auto.conf
 
+# Added for U-Boot: Load U-Boot configuration
+ifeq ($(CONFIG_TPL_BUILD),y)
+  -include include/tpl-autoconf.mk
+else
+  ifeq ($(CONFIG_SPL_BUILD),y)
+    -include include/spl-autoconf.mk
+  else
+    -include include/autoconf.mk
+  endif
+endif
+
 include scripts/Kbuild.include
 # Modified for U-Boot
 #  We must include config.mk after Kbuild.include:
diff --git a/spl/Makefile b/spl/Makefile
index e2728fd..65fd42e 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -38,6 +38,14 @@ else
 SPL_BIN := u-boot-spl
 endif
 
+include include/config.mk
+
+ifeq ($(CONFIG_TPL_BUILD),y)
+  -include include/tpl-autoconf.mk
+else
+  -include include/spl-autoconf.mk
+endif
+
 include $(srctree)/scripts/Kbuild.include
 
 include $(TOPDIR)/config.mk
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 26/38] kbuild: generate {spl, tpl}-autoconf.mk only when it is necessary
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (24 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 25/38] kbuild: move include directives of board configuration files Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 27/38] Makefile: remove a cleaning target "tidy" Masahiro Yamada
                   ` (14 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

Before this commit, {spl,tpl}-autoconf.mk was always generated
at the top Makefile even if SPL(TPL) build was not selected.

This commit moves the build rule of {spl,tpl}-autoconf.mk
from the top Makefile to spl/Makefile.
It prevents unnecessary {spl,tpl}-autoconf.mk from being
generated.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile     | 23 -----------------------
 spl/Makefile | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/Makefile b/Makefile
index 7af404a..1611957 100644
--- a/Makefile
+++ b/Makefile
@@ -890,9 +890,6 @@ tpl/u-boot-tpl.bin:	$(SUBDIR_TOOLS) depend scripts_basic
 # Explicitly make _depend in subdirs containing multiple targets to prevent
 # parallel sub-makes creating .depend files simultaneously.
 depend dep:	$(TIMESTAMP_FILE) $(VERSION_FILE) \
-		include/spl-autoconf.mk \
-		include/tpl-autoconf.mk \
-		include/autoconf.mk \
 		include/generated/generic-asm-offsets.h \
 		include/generated/asm-offsets.h
 
@@ -974,26 +971,6 @@ quiet_cmd_autoconf = GEN     $@
 include/autoconf.mk: include/config.h
 	$(call cmd,autoconf)
 
-# Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
-quiet_cmd_tpl-autoconf = GEN     $@
-      cmd_tpl-autoconf = \
-	$(CPP) $(c_flags) -DCONFIG_TPL_BUILD  -DCONFIG_SPL_BUILD\
-			-DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
-		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
-	rm $@.tmp
-
-include/tpl-autoconf.mk: include/config.h
-	$(call cmd,tpl-autoconf)
-
-quiet_cmd_spl-autoconf = GEN     $@
-      cmd_spl-autoconf = \
-	$(CPP) $(c_flags) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
-		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
-	rm $@.tmp
-
-include/spl-autoconf.mk: include/config.h
-	$(call cmd,spl-autoconf)
-
 quiet_cmd_offsets = GEN     $@
       cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@
 
diff --git a/spl/Makefile b/spl/Makefile
index 65fd42e..48eec65 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -50,6 +50,22 @@ include $(srctree)/scripts/Kbuild.include
 
 include $(TOPDIR)/config.mk
 
+# FIX ME
+c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
+
+# Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
+quiet_cmd_autoconf = GEN     $@
+      cmd_autoconf = \
+	$(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
+		sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
+	rm $@.tmp
+
+include/tpl-autoconf.mk: include/config.h
+	$(call cmd,autoconf)
+
+include/spl-autoconf.mk: include/config.h
+	$(call cmd,autoconf)
+
 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(SRCTREE)/board/$(VENDOR)/common/Makefile),y,n)
 
 ifdef	CONFIG_SPL_START_S_PATH
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 27/38] Makefile: remove a cleaning target "tidy"
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (25 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 26/38] kbuild: generate {spl, tpl}-autoconf.mk only when it is necessary Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 28/38] kbuild: change the top Makefile to more Kbuild-ish structure Masahiro Yamada
                   ` (13 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

Before this commit, "make tidy" did
"make clean" + delete "*.depend*" files.

But, we do not have "*.depend*" files any more,
which means "make tidy" is the same as "make clean".

This commit removes the redandant target "tidy".

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
  - Rebase on v2014.01-rc2 tag
  - Omit "*.depend*" from .gitignore

 .gitignore | 1 -
 MAKEALL    | 2 +-
 Makefile   | 8 ++------
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore
index b613586..24019b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,7 +61,6 @@
 # Generated files
 #
 
-*.depend*
 /LOG
 /errlog
 /reloc_off
diff --git a/MAKEALL b/MAKEALL
index 01d0598..27147ff 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -696,7 +696,7 @@ build_target() {
 	if [ $BUILD_MANY == 1 ] ; then
 		trap - TERM
 
-		${MAKE} -s tidy
+		${MAKE} -s clean
 
 		if [ -s ${LOG_DIR}/${target}.ERR ] ; then
 			cp ${LOG_DIR}/${target}.ERR ${OUTPUT_PREFIX}/ERR/${target}
diff --git a/Makefile b/Makefile
index 1611957..ac7dccd 100644
--- a/Makefile
+++ b/Makefile
@@ -472,7 +472,7 @@ LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
 endif
 
 # Targets which don't build the source code
-NON_BUILD_TARGETS = backup clean clobber distclean mrproper tidy unconfig %_config
+NON_BUILD_TARGETS = backup clean clobber distclean mrproper unconfig %_config
 
 # Only do the generic board check when actually building, not configuring
 ifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),)
@@ -1119,11 +1119,7 @@ clean:
 		-o -name '*.cfgtmp' \) -print \
 		| xargs rm -f
 
-# Removes everything not needed for testing u-boot
-tidy:	clean
-	@find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f
-
-clobber:	tidy
+clobber: clean
 	@find $(OBJTREE) -type f \( -name '*.srec' \
 		-o -name '*.bin' -o -name u-boot.img \) \
 		-print0 | xargs -0 rm -f
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 28/38] kbuild: change the top Makefile to more Kbuild-ish structure
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (26 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 27/38] Makefile: remove a cleaning target "tidy" Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 29/38] examples: move api/ and standalone/ entry to examples/Makefile Masahiro Yamada
                   ` (12 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit changes the top Makefile to handle various targets
nicely.
Make targets are divided into four categories:

 - mixed-targets
     We can call a configuration target and build targets
     at one command line like follows:
     $ make <board_name>_config u-boot

     They are handled one by one.

 - config targets
     <board_name>_config

 - no-dot-config-targets
     Targets we can run without board configuration such as
       clean, mrproper, distclean, TAGS, %docs, etc.

 - build targets
     The other target which need board configuration.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
  - Rebase on the current u-boot/master
  - Fix a bug:
        make <board>; make tools
      failed at version 4.

Changes in v4: None
Changes in v3: None
Changes in v2:
  - Rebase on v2014.01-rc2 tag

 Makefile | 287 ++++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 166 insertions(+), 121 deletions(-)

diff --git a/Makefile b/Makefile
index ac7dccd..2f273b9 100644
--- a/Makefile
+++ b/Makefile
@@ -203,34 +203,6 @@ VENDOR=
 
 #########################################################################
 
-# The "tools" are needed early, so put this first
-# Don't include stuff already done in $(LIBS)
-# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
-# is "yes"), so compile examples after U-Boot is compiled.
-SUBDIR_TOOLS = tools
-SUBDIRS = $(SUBDIR_TOOLS)
-
-.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
-
-ifeq (include/config.mk,$(wildcard include/config.mk))
-
-# Include autoconf.mk before config.mk so that the config options are available
-# to all top level build files.  We need the dummy all: target to prevent the
-# dependency target in autoconf.mk.dep from being the default.
-all:
-sinclude include/autoconf.mk.dep
-sinclude include/autoconf.mk
-
-SUBDIR_EXAMPLES-y := examples/standalone
-SUBDIR_EXAMPLES-$(CONFIG_API) += examples/api
-ifndef CONFIG_SANDBOX
-SUBDIRS += $(SUBDIR_EXAMPLES-y)
-endif
-
-# load ARCH, BOARD, and CPU configuration
-include include/config.mk
-export	ARCH CPU BOARD VENDOR SOC
-
 # set default to nothing for native builds
 ifeq ($(HOSTARCH),$(ARCH))
 CROSS_COMPILE ?=
@@ -377,15 +349,6 @@ CHECK		= sparse
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
 
-# Use UBOOTINCLUDE when you must reference the include/ directory.
-# Needed to be compatible with the O= option
-UBOOTINCLUDE    :=
-ifneq ($(OBJTREE),$(SRCTREE))
-UBOOTINCLUDE	+= -I$(OBJTREE)/include
-endif
-UBOOTINCLUDE	+= -I$(srctree)/include \
-		-I$(srctree)/arch/$(ARCH)/include
-
 KBUILD_CPPFLAGS := -D__KERNEL__
 
 KBUILD_CFLAGS   := -Wall -Wstrict-prototypes \
@@ -396,6 +359,7 @@ KBUILD_AFLAGS   := -D__ASSEMBLY__
 U_BOOT_VERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
 
 export VERSION PATCHLEVEL SUBLEVEL U_BOOT_VERSION
+export ARCH CPU BOARD VENDOR SOC
 export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
 export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
 export MAKE AWK
@@ -428,65 +392,107 @@ scripts_basic:
 # To avoid any implicit rule to kick in, define an empty command.
 scripts/basic/%: scripts_basic ;
 
+# To make sure we do not include .config for any of the *config targets
+# catch them early, and hand them over to scripts/kconfig/Makefile
+# It is allowed to specify more targets when calling make, including
+# mixing *config targets and build targets.
+# For example 'make oldconfig all'.
+# Detect when mixed targets is specified, and make a second invocation
+# of make so .config is not included in this case either (for *config).
+
+no-dot-config-targets := clean clobber mrproper distclean \
+			 cscope TAGS %tags help %docs check% coccicheck \
+			 backup
+
+config-targets := 0
+mixed-targets  := 0
+dot-config     := 1
+
+ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
+	ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
+		dot-config := 0
+	endif
+endif
 
-KBUILD_CFLAGS += -Os #-fomit-frame-pointer
-
-ifdef BUILD_TAG
-KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
+ifeq ($(KBUILD_EXTMOD),)
+        ifneq ($(filter config %config,$(MAKECMDGOALS)),)
+                config-targets := 1
+                ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
+                        mixed-targets := 1
+                endif
+        endif
 endif
 
-KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
+ifeq ($(mixed-targets),1)
+# ===========================================================================
+# We're called with mixed targets (*config and build targets).
+# Handle them one by one.
 
-KBUILD_CFLAGS	+= -g
-# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
-# option to the assembler.
-KBUILD_AFLAGS	+= -g
+%:: FORCE
+	$(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
 
-NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
-CHECKFLAGS     += $(NOSTDINC_FLAGS)
+else
+ifeq ($(config-targets),1)
+# ===========================================================================
+# *config targets only - make sure prerequisites are updated, and descend
+# in scripts/kconfig to make the *config target
 
-# Report stack usage if supported
-KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
+# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
+# KBUILD_DEFCONFIG may point out an alternative default configuration
+# used for 'make defconfig'
 
-KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
+%_config::
+	@$(MKCONFIG) -A $(@:_config=)
 
-# turn jbsr into jsr for m68k
-ifeq ($(ARCH),m68k)
-ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
-KBUILD_AFLAGS += -Wa,-gstabs,-S
-endif
-endif
+else
+# ===========================================================================
+# Build targets only - this includes vmlinux, arch specific targets, clean
+# targets and others. In general all targets except *config targets.
+
+# load ARCH, BOARD, and CPU configuration
+-include include/config.mk
+
+ifeq ($(dot-config),1)
+# Read in config
+-include include/autoconf.mk
+-include include/autoconf.mk.dep
 
 # load other configuration
-include $(TOPDIR)/config.mk
+include $(srctree)/config.mk
 
-ifneq ($(CONFIG_SYS_TEXT_BASE),)
-KBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
-endif
+#
+# Auto-generate the autoconf.mk file (which is included by all makefiles)
+#
+# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
+# the dep file is only include in this top level makefile to determine when
+# to regenerate the autoconf.mk file.
 
-export CONFIG_SYS_TEXT_BASE
+quiet_cmd_autoconf_dep = GEN     $@
+      cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \
+	-MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@
 
-LDFLAGS_u-boot += -T u-boot.lds $(LDFLAGS_FINAL)
-ifneq ($(CONFIG_SYS_TEXT_BASE),)
-LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
-endif
+include/autoconf.mk.dep: include/config.h include/common.h
+	$(call cmd,autoconf_dep)
 
-# Targets which don't build the source code
-NON_BUILD_TARGETS = backup clean clobber distclean mrproper unconfig %_config
+quiet_cmd_autoconf = GEN     $@
+      cmd_autoconf = \
+	$(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
+	sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
+	rm $@.tmp
+
+include/autoconf.mk: include/config.h
+	$(call cmd,autoconf)
+
+ifeq ($(wildcard include/config.mk),)
+$(error "System not configured - see README")
+endif
 
-# Only do the generic board check when actually building, not configuring
-ifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),)
 ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
 ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
-CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \
+$(error Your architecture does not support generic board. \
 Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
 endif
 endif
-endif
-
-# FIX ME
-cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
-c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
 
 # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
 # that (or fail if absent).  Otherwise, search for a linker script in a
@@ -526,6 +532,73 @@ $(error could not find linker script)
 	endif
 endif
 
+else
+
+
+endif # $(dot-config)
+
+KBUILD_CFLAGS += -Os #-fomit-frame-pointer
+
+ifdef BUILD_TAG
+KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
+endif
+
+KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
+
+KBUILD_CFLAGS	+= -g
+# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
+# option to the assembler.
+KBUILD_AFLAGS	+= -g
+
+# Report stack usage if supported
+KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
+
+KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
+
+# turn jbsr into jsr for m68k
+ifeq ($(ARCH),m68k)
+ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
+KBUILD_AFLAGS += -Wa,-gstabs,-S
+endif
+endif
+
+ifneq ($(CONFIG_SYS_TEXT_BASE),)
+KBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
+endif
+
+export CONFIG_SYS_TEXT_BASE
+
+# Use UBOOTINCLUDE when you must reference the include/ directory.
+# Needed to be compatible with the O= option
+UBOOTINCLUDE    :=
+ifneq ($(OBJTREE),$(SRCTREE))
+UBOOTINCLUDE	+= -I$(OBJTREE)/include
+endif
+UBOOTINCLUDE	+= -I$(srctree)/include \
+		-I$(srctree)/arch/$(ARCH)/include
+
+NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
+CHECKFLAGS     += $(NOSTDINC_FLAGS)
+
+# FIX ME
+cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
+c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
+
+# The "tools" are needed early, so put this first
+# Don't include stuff already done in $(LIBS)
+# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
+# is "yes"), so compile examples after U-Boot is compiled.
+SUBDIR_TOOLS = tools
+SUBDIRS = $(SUBDIR_TOOLS)
+
+.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
+
+SUBDIR_EXAMPLES-y := examples/standalone
+SUBDIR_EXAMPLES-$(CONFIG_API) += examples/api
+ifndef CONFIG_SANDBOX
+SUBDIRS += $(SUBDIR_EXAMPLES-y)
+endif
+
 #########################################################################
 # U-Boot objects....order is important (i.e. start must be first)
 
@@ -675,6 +748,11 @@ endif
 endif
 endif
 
+LDFLAGS_u-boot += -T u-boot.lds $(LDFLAGS_FINAL)
+ifneq ($(CONFIG_SYS_TEXT_BASE),)
+LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
+endif
+
 all:		$(ALL-y) $(SUBDIR_EXAMPLES-y)
 
 u-boot.dtb:	checkdtc u-boot
@@ -867,7 +945,7 @@ $(OBJS):
 $(LIBS):	depend $(SUBDIR_TOOLS) scripts_basic
 		$(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
 
-$(SUBDIRS):	depend scripts_basic
+$(SUBDIRS):	scripts_basic $(TIMESTAMP_FILE) $(VERSION_FILE)
 		$(Q)$(MAKE) $(build)=$@
 
 $(SUBDIR_EXAMPLES-y): u-boot
@@ -948,28 +1026,6 @@ checkdtc:
 		false; \
 	fi
 
-#
-# Auto-generate the autoconf.mk file (which is included by all makefiles)
-#
-# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
-# the dep file is only include in this top level makefile to determine when
-# to regenerate the autoconf.mk file.
-
-quiet_cmd_autoconf_dep = GEN     $@
-      cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \
-	-MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@
-
-include/autoconf.mk.dep: include/config.h include/common.h
-	$(call cmd,autoconf_dep)
-
-quiet_cmd_autoconf = GEN     $@
-      cmd_autoconf = \
-	$(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
-	sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
-	rm $@.tmp
-
-include/autoconf.mk: include/config.h
-	$(call cmd,autoconf)
 
 quiet_cmd_offsets = GEN     $@
       cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@
@@ -1003,17 +1059,6 @@ $(CPUDIR)/$(SOC)/asm-offsets.s:	include/config.h
 	$(call cmd,soc_asm-offsets.s)
 
 #########################################################################
-else	# !config.mk
-all u-boot.hex u-boot.srec u-boot.bin \
-u-boot.img u-boot.dis u-boot \
-$(filter-out tools,$(SUBDIRS)) \
-depend dep tags ctags etags cscope System.map:
-	@echo "System not configured - see README" >&2
-	@ exit 1
-
-tools: $(VERSION_FILE) $(TIMESTAMP_FILE)
-	$(MAKE) $(build)=$@ all
-endif	# config.mk
 
 # ARM relocations should all be R_ARM_RELATIVE (32-bit) or
 # R_AARCH64_RELATIVE (64-bit).
@@ -1066,15 +1111,6 @@ include/license.h: tools/bin2header COPYING
 	cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
 #########################################################################
 
-unconfig:
-	@rm -f include/config.h include/config.mk \
-		board/*/config.tmp board/*/*/config.tmp \
-		include/autoconf.mk include/autoconf.mk.dep \
-		include/spl-autoconf.mk \
-		include/tpl-autoconf.mk
-
-%_config::	unconfig
-	@$(MKCONFIG) -A $(@:_config=)
 
 #########################################################################
 
@@ -1151,8 +1187,14 @@ clobber: clean
 	@rm -f dts/*.tmp
 	@rm -f $(addprefix spl/, u-boot-spl.ais, u-boot-spl-pad.ais)
 
-mrproper \
-distclean:	clobber unconfig
+mrproper: clobber
+	@rm -f include/config.h include/config.mk \
+		board/*/config.tmp board/*/*/config.tmp \
+		include/autoconf.mk include/autoconf.mk.dep \
+		include/spl-autoconf.mk \
+		include/tpl-autoconf.mk
+
+distclean: mrproper
 ifneq ($(OBJTREE),$(SRCTREE))
 	rm -rf *
 endif
@@ -1163,6 +1205,9 @@ backup:
 
 #########################################################################
 
+endif #ifeq ($(config-targets),1)
+endif #ifeq ($(mixed-targets),1)
+
 endif	# skip-makefile
 
 PHONY += FORCE
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 29/38] examples: move api/ and standalone/ entry to examples/Makefile
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (27 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 28/38] kbuild: change the top Makefile to more Kbuild-ish structure Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 30/38] kbuild: refactor Makefile and spl/Makefile more Masahiro Yamada
                   ` (11 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile                     | 5 +----
 examples/Makefile            | 9 +++++++++
 examples/api/Makefile        | 4 ----
 examples/standalone/Makefile | 4 ----
 4 files changed, 10 insertions(+), 12 deletions(-)
 create mode 100644 examples/Makefile

diff --git a/Makefile b/Makefile
index 2f273b9..32642aa 100644
--- a/Makefile
+++ b/Makefile
@@ -593,11 +593,8 @@ SUBDIRS = $(SUBDIR_TOOLS)
 
 .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
 
-SUBDIR_EXAMPLES-y := examples/standalone
-SUBDIR_EXAMPLES-$(CONFIG_API) += examples/api
-ifndef CONFIG_SANDBOX
+SUBDIR_EXAMPLES-y := examples
 SUBDIRS += $(SUBDIR_EXAMPLES-y)
-endif
 
 #########################################################################
 # U-Boot objects....order is important (i.e. start must be first)
diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644
index 0000000..18d008e
--- /dev/null
+++ b/examples/Makefile
@@ -0,0 +1,9 @@
+ifndef CONFIG_SANDBOX
+
+ifdef FTRACE
+subdir-ccflags-y += -finstrument-functions -DFTRACE
+endif
+
+subdir-y += standalone
+subdir-$(CONFIG_API) += api
+endif
diff --git a/examples/api/Makefile b/examples/api/Makefile
index 8b79886..09475f8 100644
--- a/examples/api/Makefile
+++ b/examples/api/Makefile
@@ -4,10 +4,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-ifdef FTRACE
-ccflags-y += -finstrument-functions -DFTRACE
-endif
-
 ifeq ($(ARCH),powerpc)
 LOAD_ADDR = 0x40000
 endif
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index 90e173b..47c9d54 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -5,10 +5,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-ifdef FTRACE
-ccflags-y += -finstrument-functions -DFTRACE
-endif
-
 extra-y        := hello_world
 extra-$(CONFIG_SMC91111)           += smc91111_eeprom
 extra-$(CONFIG_SMC911X)            += smc911x_eeprom
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 30/38] kbuild: refactor Makefile and spl/Makefile more
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (28 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 29/38] examples: move api/ and standalone/ entry to examples/Makefile Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 31/38] Makefile: Do not pass MTD_VERSION from the top Makefile Masahiro Yamada
                   ` (10 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit refactors rules of directory descending
and defines u-boot-dirs and u-boot-all-dirs.
(We will need u-boot-all-dirs when using
scripts/Makefile.clean)

Additionally, rename LIBS-y to libs-y.

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

Changes in v8:
  - Rebase on the current u-boot/master

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile     | 165 ++++++++++++++++++++++++++++++-----------------------------
 spl/Makefile | 111 ++++++++++++++++++++--------------------
 2 files changed, 140 insertions(+), 136 deletions(-)

diff --git a/Makefile b/Makefile
index 32642aa..2e28fba 100644
--- a/Makefile
+++ b/Makefile
@@ -584,17 +584,7 @@ CHECKFLAGS     += $(NOSTDINC_FLAGS)
 cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
 c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
 
-# The "tools" are needed early, so put this first
-# Don't include stuff already done in $(LIBS)
-# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
-# is "yes"), so compile examples after U-Boot is compiled.
-SUBDIR_TOOLS = tools
-SUBDIRS = $(SUBDIR_TOOLS)
-
-.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
-
-SUBDIR_EXAMPLES-y := examples
-SUBDIRS += $(SUBDIR_EXAMPLES-y)
+.PHONY : $(VERSION_FILE) $(TIMESTAMP_FILE)
 
 #########################################################################
 # U-Boot objects....order is important (i.e. start must be first)
@@ -603,70 +593,76 @@ head-y := $(CPUDIR)/start.o
 head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
 head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
 
-OBJS := $(head-y)
-
 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
 
-LIBS-y += lib/
-LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
-LIBS-y += $(CPUDIR)/
+libs-y += lib/
+libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
+libs-y += $(CPUDIR)/
 ifdef SOC
-LIBS-y += $(CPUDIR)/$(SOC)/
+libs-y += $(CPUDIR)/$(SOC)/
 endif
-LIBS-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/
-LIBS-$(CONFIG_OF_EMBED) += dts/
-LIBS-y += arch/$(ARCH)/lib/
-LIBS-y += fs/
-LIBS-y += net/
-LIBS-y += disk/
-LIBS-y += drivers/
-LIBS-y += drivers/dma/
-LIBS-y += drivers/gpio/
-LIBS-y += drivers/i2c/
-LIBS-y += drivers/input/
-LIBS-y += drivers/mmc/
-LIBS-y += drivers/mtd/
-LIBS-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
-LIBS-y += drivers/mtd/onenand/
-LIBS-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
-LIBS-y += drivers/mtd/spi/
-LIBS-y += drivers/net/
-LIBS-y += drivers/net/phy/
-LIBS-y += drivers/pci/
-LIBS-y += drivers/power/ \
+libs-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/
+libs-$(CONFIG_OF_EMBED) += dts/
+libs-y += arch/$(ARCH)/lib/
+libs-y += fs/
+libs-y += net/
+libs-y += disk/
+libs-y += drivers/
+libs-y += drivers/dma/
+libs-y += drivers/gpio/
+libs-y += drivers/i2c/
+libs-y += drivers/input/
+libs-y += drivers/mmc/
+libs-y += drivers/mtd/
+libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
+libs-y += drivers/mtd/onenand/
+libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
+libs-y += drivers/mtd/spi/
+libs-y += drivers/net/
+libs-y += drivers/net/phy/
+libs-y += drivers/pci/
+libs-y += drivers/power/ \
 	drivers/power/fuel_gauge/ \
 	drivers/power/mfd/ \
 	drivers/power/pmic/ \
 	drivers/power/battery/
-LIBS-y += drivers/spi/
-LIBS-$(CONFIG_FMAN_ENET) += drivers/net/fm/
-LIBS-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
-LIBS-y += drivers/serial/
-LIBS-y += drivers/usb/eth/
-LIBS-y += drivers/usb/gadget/
-LIBS-y += drivers/usb/host/
-LIBS-y += drivers/usb/musb/
-LIBS-y += drivers/usb/musb-new/
-LIBS-y += drivers/usb/phy/
-LIBS-y += drivers/usb/ulpi/
-LIBS-y += common/
-LIBS-y += lib/libfdt/
-LIBS-$(CONFIG_API) += api/
-LIBS-$(CONFIG_HAS_POST) += post/
-LIBS-y += test/
+libs-y += drivers/spi/
+libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/
+libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
+libs-y += drivers/serial/
+libs-y += drivers/usb/eth/
+libs-y += drivers/usb/gadget/
+libs-y += drivers/usb/host/
+libs-y += drivers/usb/musb/
+libs-y += drivers/usb/musb-new/
+libs-y += drivers/usb/phy/
+libs-y += drivers/usb/ulpi/
+libs-y += common/
+libs-y += lib/libfdt/
+libs-$(CONFIG_API) += api/
+libs-$(CONFIG_HAS_POST) += post/
+libs-y += test/
 
 ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
-LIBS-y += arch/$(ARCH)/imx-common/
+libs-y += arch/$(ARCH)/imx-common/
 endif
 
-LIBS-$(CONFIG_ARM) += arch/arm/cpu/
-LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/
+libs-$(CONFIG_ARM) += arch/arm/cpu/
+libs-$(CONFIG_PPC) += arch/powerpc/cpu/
+
+libs-y += board/$(BOARDDIR)/
+
+libs-y := $(sort $(libs-y))
 
-LIBS-y += board/$(BOARDDIR)/
+u-boot-dirs	:= $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples
+
+u-boot-alldirs	:= $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-))))
+
+libs-y		:= $(patsubst %/, %/built-in.o, $(libs-y))
+
+u-boot-init := $(head-y)
+u-boot-main := $(libs-y)
 
-LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y))
-LIBS := $(sort $(LIBS-y))
-.PHONY : $(LIBS)
 
 # Add GCC lib
 ifdef USE_PRIVATE_LIBGCC
@@ -750,7 +746,7 @@ ifneq ($(CONFIG_SYS_TEXT_BASE),)
 LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
 endif
 
-all:		$(ALL-y) $(SUBDIR_EXAMPLES-y)
+all:		$(ALL-y)
 
 u-boot.dtb:	checkdtc u-boot
 		$(MAKE) $(build)=dts binary
@@ -797,7 +793,7 @@ u-boot.img:	u-boot.bin
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
 
-u-boot.imx: u-boot.bin depend
+u-boot.imx: u-boot.bin
 		$(MAKE) $(build)=arch/arm/imx-common $(objtree)/u-boot.imx
 
 u-boot.kwb:       u-boot.bin
@@ -916,17 +912,17 @@ u-boot.elf: u-boot.bin
 ifeq ($(CONFIG_SANDBOX),y)
 GEN_UBOOT = \
 		$(CC) $(SYMS) -T u-boot.lds \
-			-Wl,--start-group $(LIBS) -Wl,--end-group \
+			-Wl,--start-group $(u-boot-main) -Wl,--end-group \
 			$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
 else
 GEN_UBOOT = \
 		$(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
-			$(OBJS) \
-			--start-group $(LIBS) --end-group $(PLATFORM_LIBS) \
+			$(u-boot-init) \
+			--start-group $(u-boot-main) --end-group $(PLATFORM_LIBS) \
 			-Map u-boot.map -o u-boot
 endif
 
-u-boot:	depend $(SUBDIR_TOOLS) $(OBJS) $(LIBS) u-boot.lds
+u-boot:	$(u-boot-init) $(u-boot-main) u-boot.lds
 		$(GEN_UBOOT)
 ifeq ($(CONFIG_KALLSYMS),y)
 		smap=`$(call SYSTEM_MAP,u-boot) | \
@@ -936,16 +932,27 @@ ifeq ($(CONFIG_KALLSYMS),y)
 		$(GEN_UBOOT) common/system_map.o
 endif
 
-$(OBJS):
-	@:
+# The actual objects are generated when descending, 
+# make sure no implicit rule kicks in
+$(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
 
-$(LIBS):	depend $(SUBDIR_TOOLS) scripts_basic
-		$(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
+# Handle descending into subdirectories listed in $(vmlinux-dirs)
+# Preset locale variables to speed up the build process. Limit locale
+# tweaks to this spot to avoid wrong language settings when running
+# make menuconfig etc.
+# Error messages still appears in the original language
 
-$(SUBDIRS):	scripts_basic $(TIMESTAMP_FILE) $(VERSION_FILE)
-		$(Q)$(MAKE) $(build)=$@
+PHONY += $(u-boot-dirs)
+$(u-boot-dirs): depend scripts_basic
+	$(Q)$(MAKE) $(build)=$@
+
+tools: $(TIMESTAMP_FILE) $(VERSION_FILE)
+# The "tools" are needed early
+$(filter-out tools, $(u-boot-dirs)): tools
+# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
+# is "yes"), so compile examples after U-Boot is compiled.
+examples: $(filter-out examples, $(u-boot-dirs))
 
-$(SUBDIR_EXAMPLES-y): u-boot
 
 u-boot.lds: $(LDSCRIPT) depend
 		$(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
@@ -956,10 +963,10 @@ nand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend scripts_basic
 u-boot-nand.bin:	nand_spl u-boot.bin
 		cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin
 
-spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend scripts_basic
+spl/u-boot-spl.bin: tools depend scripts_basic
 		$(MAKE) obj=spl -f $(srctree)/spl/Makefile all
 
-tpl/u-boot-tpl.bin:	$(SUBDIR_TOOLS) depend scripts_basic
+tpl/u-boot-tpl.bin: tools depend scripts_basic
 		$(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y
 
 # Explicitly make _depend in subdirs containing multiple targets to prevent
@@ -968,9 +975,7 @@ depend dep:	$(TIMESTAMP_FILE) $(VERSION_FILE) \
 		include/generated/generic-asm-offsets.h \
 		include/generated/asm-offsets.h
 
-TAG_SUBDIRS = $(SUBDIRS)
-TAG_SUBDIRS += $(dir $(LIBS))
-TAG_SUBDIRS += include
+TAG_SUBDIRS := $(u-boot-dirs) include
 
 FIND := find
 FINDFLAGS := -L
@@ -1156,7 +1161,7 @@ clobber: clean
 	@find $(OBJTREE) -type f \( -name '*.srec' \
 		-o -name '*.bin' -o -name u-boot.img \) \
 		-print0 | xargs -0 rm -f
-	@rm -f $(OBJS) *.bak ctags etags TAGS \
+	@rm -f *.bak ctags etags TAGS \
 		cscope.* *.*~
 	@rm -f u-boot u-boot.map u-boot.hex $(ALL-y)
 	@rm -f u-boot.kwb
diff --git a/spl/Makefile b/spl/Makefile
index 48eec65..26000a2 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -79,66 +79,64 @@ head-$(CONFIG_X86) += $(START_PATH)/start16.o $(START_PATH)/resetvec.o
 head-$(CONFIG_4xx) += $(START_PATH)/resetvec.o
 head-$(CONFIG_MPC85xx) += $(START_PATH)/resetvec.o
 
-LIBS-y += arch/$(ARCH)/lib/
+libs-y += arch/$(ARCH)/lib/
 
-LIBS-y += $(CPUDIR)/
+libs-y += $(CPUDIR)/
 
 ifdef SOC
-LIBS-y += $(CPUDIR)/$(SOC)/
-endif
-LIBS-y += board/$(BOARDDIR)/
-LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
-
-LIBS-$(CONFIG_SPL_FRAMEWORK) += common/spl/
-LIBS-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/
-LIBS-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
-LIBS-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/
-LIBS-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/
-LIBS-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/
-LIBS-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/
-LIBS-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/
-LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/
-LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/
-LIBS-y += fs/
-LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
-LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ \
-	drivers/power/pmic/
-LIBS-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/
-LIBS-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/
-LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/
-LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/
-LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
-LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/
-LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/
-LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/
-LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/
-LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/
-LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/
-LIBS-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/
-LIBS-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/
-LIBS-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/
+libs-y += $(CPUDIR)/$(SOC)/
+endif
+libs-y += board/$(BOARDDIR)/
+libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
+
+libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/
+libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/
+libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
+libs-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/
+libs-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/
+libs-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/
+libs-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/
+libs-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/
+libs-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/
+libs-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/
+libs-y += fs/
+libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
+libs-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ drivers/power/pmic/
+libs-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/
+libs-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/
+libs-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/
+libs-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/
+libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
+libs-$(CONFIG_SPL_NET_SUPPORT) += net/
+libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/
+libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/
+libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/
+libs-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/
+libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/
+libs-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/
+libs-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/
+libs-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/
 
 ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
-LIBS-y += arch/$(ARCH)/imx-common/
+libs-y += arch/$(ARCH)/imx-common/
 endif
 
-LIBS-$(CONFIG_ARM) += arch/arm/cpu/
-LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/
+libs-$(CONFIG_ARM) += arch/arm/cpu/
+libs-$(CONFIG_PPC) += arch/powerpc/cpu/
 
-LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y))
+head-y		:= $(addprefix $(obj)/,$(head-y))
+libs-y		:= $(addprefix $(obj)/,$(libs-y))
+u-boot-spl-dirs	:= $(patsubst %/,%,$(filter %/, $(libs-y)))
+
+libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
 
 # Add GCC lib
 ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
 PLATFORM_LIBS := $(SPLTREE)/arch/$(ARCH)/lib/lib.a
 endif
 
-LIBS-y := $(sort $(LIBS-y))
-
-__START := $(head-y)
-__LIBS := $(LIBS-y)
-
-START := $(addprefix $(obj)/,$(head-y))
-LIBS := $(addprefix $(obj)/,$(LIBS-y))
+u-boot-spl-init := $(head-y)
+u-boot-spl-main := $(libs-y)
 
 # Linker Script
 ifdef CONFIG_SPL_LDSCRIPT
@@ -208,19 +206,20 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),)
 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
 endif
 
-GEN_UBOOT = \
-	cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $(__START) \
-		--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
-		-Map $(SPL_BIN).map -o $(SPL_BIN)
+quiet_cmd_u-boot-spl = LD      $@
+      cmd_u-boot-spl = cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
+		       $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
+		       $(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \
+		       $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN)
 
-$(obj)/$(SPL_BIN): $(START) $(LIBS) $(obj)/u-boot-spl.lds
-	$(GEN_UBOOT)
+$(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds
+	$(call cmd,u-boot-spl)
 
-$(START):
-	@:
+$(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
 
-$(LIBS):
-	$(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
+PHONY += $(u-boot-spl-dirs)
+$(u-boot-spl-dirs):
+	$(Q)$(MAKE) $(build)=$@
 
 # FIX ME
 cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 31/38] Makefile: Do not pass MTD_VERSION from the top Makefile
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (29 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 30/38] kbuild: refactor Makefile and spl/Makefile more Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 32/38] Makefile: refactor tools-all targets Masahiro Yamada
                   ` (9 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

$(MTD_VERSION) is used in tools/env/Makefile

If you specify a variable at a command line like:
  $ make MTD_VERSION=old env
or specify it thru an envrionment variable like:
  $ export MTD_VERSION=old
  $ make env
it is inherited to the sub-make too.
We do not need to pass it from the top Makefile explicitely.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 2e28fba..1ac6399 100644
--- a/Makefile
+++ b/Makefile
@@ -1094,7 +1094,7 @@ $(TIMESTAMP_FILE):
 		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
 
 easylogo env gdb:
-	$(Q)$(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION}
+	$(Q)$(MAKE) $(build)=tools/$@
 
 gdbtools: gdb
 
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 32/38] Makefile: refactor tools-all targets
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (30 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 31/38] Makefile: Do not pass MTD_VERSION from the top Makefile Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 33/38] kbuild: use scripts/Makefile.clean Masahiro Yamada
                   ` (8 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

 - Move "easylogo", "gdb" tagets to tools/Makefile
 - Delete "gdbtools" target (same as "gdb")

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
 - Revive "env" target

Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile       | 8 +++-----
 tools/Makefile | 8 +++++++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 1ac6399..42d9639 100644
--- a/Makefile
+++ b/Makefile
@@ -1093,16 +1093,14 @@ $(TIMESTAMP_FILE):
 		@LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
 		@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
 
-easylogo env gdb:
+env: depend scripts_basic
 	$(Q)$(MAKE) $(build)=tools/$@
 
-gdbtools: gdb
-
 xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc
 	$(Q)$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) $(build)=doc/DocBook $@
 
-tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
-	$(Q)$(MAKE) $(build)=tools HOST_TOOLS_ALL=y
+tools-all: HOST_TOOLS_ALL=y
+tools-all: env tools ;
 
 .PHONY : CHANGELOG
 CHANGELOG:
diff --git a/tools/Makefile b/tools/Makefile
index 70a3fc2..783e643 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -24,6 +24,9 @@ CONFIG_NETCONSOLE = y
 CONFIG_SHA1_CHECK_UB_IMG = y
 endif
 
+subdir-$(HOST_TOOLS_ALL) += easylogo
+subdir-$(HOST_TOOLS_ALL) += gdb
+
 # Merge all the different vars for envcrc into one
 ENVCRC-$(CONFIG_ENV_IS_EMBEDDED) = y
 ENVCRC-$(CONFIG_ENV_IS_IN_DATAFLASH) = y
@@ -180,10 +183,13 @@ HOST_EXTRACFLAGS += -include $(SRCTREE)/include/libfdt_env.h \
 
 __build:	$(LOGO-y)
 
-subdir-y := kernel-doc
+subdir-y += kernel-doc
 
 $(LOGO_H):	$(obj)/bmp_logo $(LOGO_BMP)
 	$(obj)/bmp_logo --gen-info $(LOGO_BMP) > $@
 
 $(LOGO_DATA_H):	$(obj)/bmp_logo $(LOGO_BMP)
 	$(obj)/bmp_logo --gen-data $(LOGO_BMP) > $@
+
+# Let clean descend into subdirs
+subdir- += env
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 33/38] kbuild: use scripts/Makefile.clean
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (31 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 32/38] Makefile: refactor tools-all targets Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 34/38] kbuild: support simultaneous board configuration and "make all" Masahiro Yamada
                   ` (7 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit refactors cleaning targets such as
clean, clobber, mrpropper, distclean
with scripts/Makefile.clean.

By using scripts/Makefile.clean, we can recursively descend
into subdirectories and delete generated files there.

We do not need add a big list of generated files
to the "clean" target.

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

We can delete ugly stuff like follows:

  clean:
	@rm -f examples/standalone/atmel_df_pow2			  \
	       examples/standalone/hello_world				  \
	       examples/standalone/interrupt				  \
	       examples/standalone/mem_to_mem_idma2intr			  \
	       examples/standalone/sched				  \
	       $(addprefix examples/standalone/, smc91111_eeprom smc911x_eeprom) \
	       examples/standalone/test_burst				  \
	       examples/standalone/timer
	@rm -f $(addprefix examples/api/, demo demo.bin)
	@rm -f tools/bmp_logo	   tools/easylogo/easylogo		  \
	       tools/env/fw_printenv					  \
	       tools/envcrc						  \
	       $(addprefix tools/gdb/, gdbcont gdbsend)			  \
	       tools/gen_eth_addr    tools/img2srec			  \
	       tools/dumpimage						  \
	       $(addprefix tools/, mkenvimage mkimage)			  \
	       tools/mpc86x_clk						  \
	       $(addprefix tools/, mk$(BOARD)spl mkexynosspl)		  \
	       tools/mxsboot						  \
	       tools/ncb		   tools/ubsha1			  \
	       tools/kernel-doc/docproc					  \
	       tools/proftool
	@rm -f $(addprefix board/cray/L1/, bootscript.c bootscript.image) \
	       board/matrix_vision/*/bootscript.img			  \
	       spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl		  \
	       u-boot.lds						  \
	       $(addprefix arch/blackfin/cpu/, init.lds init.elf)
	       $(obj)arch/blackfin/cpu/init.{lds,elf}

By the way, I am keeping "make clobber" for now.
Do we need "make clobber"?
If we like 3-level cleaning targets, clean, mrproper, distclean,
like Linux Kernel, we can squash "clobber" to "clean".


Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
  - Remove "*.imx" and "*.map" files by pattern matching.
  - Remove u-boot.elf

Changes in v4: None
Changes in v3: None
Changes in v2:
  - Rebase on v2014.01-rc2 tag

 Makefile                   | 188 +++++++++++++++++++++++++--------------------
 arch/blackfin/cpu/Makefile |   1 +
 board/cray/L1/Makefile     |   2 +
 dts/Makefile               |  12 +--
 scripts/Makefile           |   2 +
 scripts/Makefile.clean     |   4 +
 6 files changed, 121 insertions(+), 88 deletions(-)
 create mode 100644 scripts/Makefile

diff --git a/Makefile b/Makefile
index 42d9639..0bb1f96 100644
--- a/Makefile
+++ b/Makefile
@@ -1111,93 +1111,106 @@ include/license.h: tools/bin2header COPYING
 	cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
 #########################################################################
 
+###
+# Cleaning is done on three levels.
+# make clean     Delete most generated files
+#                Leave enough to build external modules
+# make mrproper  Delete the current configuration, and all generated files
+# make distclean Remove editor backup files, patch leftover files and the like
+
+# Directories & files removed with 'make clean'
+CLEAN_DIRS  += $(MODVERDIR)
+CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h \
+               board/*/config.tmp board/*/*/config.tmp dts/*.tmp \
+               include/autoconf.mk include/autoconf.mk.dep \
+               include/spl-autoconf.mk include/tpl-autoconf.mk
+
+# Directories & files removed with 'make clobber'
+CLOBBER_DIRS  += tpl \
+		 $(patsubst %/,spl/%, $(filter-out Makefile, $(filter %/, \
+			$(shell ls -1 --file-type spl 2>/dev/null))))
+CLOBBER_FILES += u-boot u-boot.elf u-boot.hex u-boot.img  \
+		 u-boot.kwb u-boot.pbl u-boot.ldr \
+		 u-boot.ubl u-boot.ais u-boot.dtb \
+		 u-boot.sb u-boot.spr MLO MLO.byteswap SPL \
+		 $(patsubst %,spl/%, $(filter-out Makefile %/, \
+			$(shell ls -1 --file-type spl 2>/dev/null))) \
+		 $(addprefix nand_spl/, u-boot.lds u-boot.lst \
+		 u-boot-nand_spl.lds u-boot-spl)
+
+# Directories & files removed with 'make mrproper'
+MRPROPER_DIRS  += include/config include/generated
+MRPROPER_FILES += .config .config.old \
+		  tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
+		  include/config.h include/config.mk
+
+# clean - Delete most, but leave enough to build external modules
+#
+clean: rm-dirs  := $(CLEAN_DIRS)
+clean: rm-files := $(CLEAN_FILES)
+
+clean-dirs	:= $(foreach f,$(u-boot-alldirs),$(if $(wildcard $f/Makefile),$f))
+
+clean-dirs      := $(addprefix _clean_, $(clean-dirs) doc/DocBook)
+
+PHONY += $(clean-dirs) clean archclean
+$(clean-dirs):
+	$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
+
+# TODO: Do not use *.cfgtmp
+clean: $(clean-dirs)
+	$(call cmd,rmdirs)
+	$(call cmd,rmfiles)
+	@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
+		\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
+		-o -name '*.ko.*' -o -name '*.su' -o -name '*.cfgtmp' \
+		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
+		-o -name '*.symtypes' -o -name 'modules.order' \
+		-o -name modules.builtin -o -name '.tmp_*.o.*' \
+		-o -name '*.gcno' \) -type f -print | xargs rm -f
+	@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
+		-path './nand_spl/*' -type l -print | xargs rm -f
+
+# clobber
+#
+clobber: rm-dirs  := $(CLOBBER_DIRS)
+clobber: rm-files := $(CLOBBER_FILES)
 
-#########################################################################
-
-clean:
-	@rm -f examples/standalone/atmel_df_pow2			  \
-	       examples/standalone/hello_world				  \
-	       examples/standalone/interrupt				  \
-	       examples/standalone/mem_to_mem_idma2intr			  \
-	       examples/standalone/sched				  \
-	       $(addprefix examples/standalone/, smc91111_eeprom smc911x_eeprom) \
-	       examples/standalone/test_burst				  \
-	       examples/standalone/timer
-	@rm -f $(addprefix examples/api/, demo demo.bin)
-	@rm -f tools/bmp_logo	   tools/easylogo/easylogo		  \
-	       tools/env/fw_printenv					  \
-	       tools/envcrc						  \
-	       $(addprefix tools/gdb/, gdbcont gdbsend)			  \
-	       tools/gen_eth_addr    tools/img2srec			  \
-	       tools/dumpimage						  \
-	       $(addprefix tools/, mkenvimage mkimage)			  \
-	       tools/mpc86x_clk						  \
-	       $(addprefix tools/, mk$(BOARD)spl mkexynosspl)		  \
-	       tools/mxsboot						  \
-	       tools/ncb		   tools/ubsha1			  \
-	       tools/kernel-doc/docproc					  \
-	       tools/proftool
-	@rm -f $(addprefix board/cray/L1/, bootscript.c bootscript.image) \
-	       board/matrix_vision/*/bootscript.img			  \
-	       spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl		  \
-	       u-boot.lds						  \
-	       $(addprefix arch/blackfin/cpu/, init.lds init.elf)
-	@rm -f include/bmp_logo.h
-	@rm -f include/bmp_logo_data.h
-	@rm -f lib/asm-offsets.s
-	@rm -f include/generated/asm-offsets.h
-	@rm -f $(CPUDIR)/$(SOC)/asm-offsets.s
-	@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
-	@$(MAKE) -f $(srctree)/doc/DocBook/Makefile cleandocs
-	@find $(OBJTREE) -type f \
-		\( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
-		-o -name '*.o'	-o -name '*.a' -o -name '*.exe' -o -name '*.cmd' \
-		-o -name '*.cfgtmp' \) -print \
-		| xargs rm -f
+PHONY += clobber
 
 clobber: clean
-	@find $(OBJTREE) -type f \( -name '*.srec' \
-		-o -name '*.bin' -o -name u-boot.img \) \
-		-print0 | xargs -0 rm -f
-	@rm -f *.bak ctags etags TAGS \
-		cscope.* *.*~
-	@rm -f u-boot u-boot.map u-boot.hex $(ALL-y)
-	@rm -f u-boot.kwb
-	@rm -f u-boot.pbl
-	@rm -f u-boot.imx
-	@rm -f u-boot-with-spl.imx
-	@rm -f u-boot-with-nand-spl.imx
-	@rm -f u-boot.ubl
-	@rm -f u-boot.ais
-	@rm -f u-boot.dtb
-	@rm -f u-boot.sb
-	@rm -f u-boot.spr
-	@rm -f $(addprefix nand_spl/, u-boot.lds u-boot.lst System.map)
-	@rm -f $(addprefix nand_spl/, u-boot-nand_spl.lds u-boot-spl u-boot-spl.map)
-	@rm -f $(addprefix spl/, u-boot-spl u-boot-spl.bin u-boot-spl.map)
-	@rm -f spl/u-boot-spl.lds
-	@rm -f $(addprefix tpl/, u-boot-tpl u-boot-tpl.bin u-boot-tpl.map)
-	@rm -f tpl/u-boot-spl.lds
-	@rm -f MLO MLO.byteswap
-	@rm -f SPL
-	@rm -f tools/xway-swap-bytes
-	@rm -fr include/asm/proc include/asm/arch include/asm
-	@rm -fr include/generated
-	@[ ! -d nand_spl ] || find nand_spl -name "*" -type l -print | xargs rm -f
-	@rm -f dts/*.tmp
-	@rm -f $(addprefix spl/, u-boot-spl.ais, u-boot-spl-pad.ais)
-
-mrproper: clobber
-	@rm -f include/config.h include/config.mk \
-		board/*/config.tmp board/*/*/config.tmp \
-		include/autoconf.mk include/autoconf.mk.dep \
-		include/spl-autoconf.mk \
-		include/tpl-autoconf.mk
+	$(call cmd,rmdirs)
+	$(call cmd,rmfiles)
+	@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
+		\( -name '*.srec' -o -name '*.bin' -o -name "*.imx" \
+		-o -name '*.map' \) -type f -print | xargs rm -f
+
+# mrproper - Delete all generated files, including .config
+#
+mrproper: rm-dirs  := $(wildcard $(MRPROPER_DIRS))
+mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
+mrproper-dirs      := $(addprefix _mrproper_,scripts)
+
+PHONY += $(mrproper-dirs) mrproper archmrproper
+$(mrproper-dirs):
+	$(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
+
+mrproper: clobber $(mrproper-dirs)
+	$(call cmd,rmdirs)
+	$(call cmd,rmfiles)
+	@rm -f arch/*/include/asm/arch arch/*/include/asm/proc
+
+# distclean
+#
+PHONY += distclean
 
 distclean: mrproper
-ifneq ($(OBJTREE),$(SRCTREE))
-	rm -rf *
-endif
+	@find $(srctree) $(RCS_FIND_IGNORE) \
+		\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
+		-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
+		-o -name '.*.rej' \
+		-o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
+		-type f -print | xargs rm -f
 
 backup:
 	F=`basename $(TOPDIR)` ; cd .. ; \
@@ -1208,6 +1221,17 @@ backup:
 endif #ifeq ($(config-targets),1)
 endif #ifeq ($(mixed-targets),1)
 
+quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN   $(wildcard $(rm-dirs)))
+      cmd_rmdirs = rm -rf $(rm-dirs)
+
+quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files)))
+      cmd_rmfiles = rm -f $(rm-files)
+
+# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
+# Usage:
+# $(Q)$(MAKE) $(clean)=dir
+clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
+
 endif	# skip-makefile
 
 PHONY += FORCE
diff --git a/arch/blackfin/cpu/Makefile b/arch/blackfin/cpu/Makefile
index dd4d2d1..426292f 100644
--- a/arch/blackfin/cpu/Makefile
+++ b/arch/blackfin/cpu/Makefile
@@ -22,6 +22,7 @@ obj-y  += reset.o
 obj-y  += traps.o
 
 extra-y += check_initcode
+clean-files := init.lds
 
 # make sure our initcode (which goes into LDR) does not
 # have relocs or external references
diff --git a/board/cray/L1/Makefile b/board/cray/L1/Makefile
index 6aae9fa..63f43da 100644
--- a/board/cray/L1/Makefile
+++ b/board/cray/L1/Makefile
@@ -14,3 +14,5 @@ $(obj)/bootscript.c: $(obj)/bootscript.image
 
 $(obj)/bootscript.image: $(src)/bootscript.hush
 	-$(OBJTREE)/tools/mkimage -A ppc -O linux -T script -C none -a 0 -e 0 -n bootscript -d $< $@
+
+clean-files := bootscript.c bootscript.image
\ No newline@end of file
diff --git a/dts/Makefile b/dts/Makefile
index cc6ecf6..1e7609a 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -7,12 +7,6 @@
 # This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is
 # enabled. See doc/README.fdt-control for more details.
 
-ifeq ($(DEVICE_TREE),)
-$(if $(CONFIG_DEFAULT_DEVICE_TREE),,\
-$(error Please define CONFIG_DEFAULT_DEVICE_TREE in your board header file))
-DEVICE_TREE = $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
-endif
-
 DTS_INCDIRS =  $(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts
 DTS_INCDIRS += $(SRCTREE)/board/$(VENDOR)/dts
 DTS_INCDIRS += $(SRCTREE)/arch/$(ARCH)/dts
@@ -28,9 +22,15 @@ DTC_FLAGS := -R 4 -p 0x1000 \
 # the filename.
 DT_BIN	:= $(obj)/dt.dtb
 
+DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
+ifeq ($(DEVICE_TREE),)
+$(DT_BIN): FORCE
+	echo >&2 "Please define CONFIG_DEFAULT_DEVICE_TREE in your board header file"
+else
 $(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts
 	$(CPP) $(DTS_CPPFLAGS) $< -o $(DT_BIN).dts.tmp
 	$(DTC) $(DTC_FLAGS) -O dtb -o ${DT_BIN} $(DT_BIN).dts.tmp
+endif
 
 process_lds = \
 	$(1) | sed -r -n 's/^OUTPUT_$(2)[ ("]*([^")]*).*/\1/p'
diff --git a/scripts/Makefile b/scripts/Makefile
new file mode 100644
index 0000000..ebbadc9
--- /dev/null
+++ b/scripts/Makefile
@@ -0,0 +1,2 @@
+# Let clean descend into subdirs
+subdir-	+= basic
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 686cb0d..5cd0f51 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -37,6 +37,10 @@ subdir-ymn      := $(sort $(subdir-ym) $(subdir-n) $(subdir-))
 
 subdir-ymn	:= $(addprefix $(obj)/,$(subdir-ymn))
 
+# Temporal work-around for U-Boot
+
+subdir-ymn	:= $(foreach f, $(subdir-ymn), $(if $(wildcard $f/Makefile),$f))
+
 # build a list of files to remove, usually relative to the current
 # directory
 
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 34/38] kbuild: support simultaneous board configuration and "make all"
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (32 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 33/38] kbuild: use scripts/Makefile.clean Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 35/38] kbuild: check clean source and generate Makefile for out-of-tree build Masahiro Yamada
                   ` (6 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

This commit fixes two problems:

[1] We could not do board configuration and "make all"
    in one command line.

For example, the following did not work as we expect:
  $ make sandbox_config all
  Configuring for sandbox board...
  make: Nothing to be done for `all'.

[2] mixed-target build did not work with -j option

For example, the following did not work:
  $ make -j8 sandbox_config u-boot
  Makefile:481: *** "System not configured - see README".  Stop.
  make: *** [u-boot] Error 2
  make: *** Waiting for unfinished jobs....
  Configuring for sandbox board...

Going forward, we can do
  $ make -j8 sandbox_config all

This is the same as
  $ make sandbox_config
  $ make -j8

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 0bb1f96..6ae16d0 100644
--- a/Makefile
+++ b/Makefile
@@ -428,8 +428,16 @@ ifeq ($(mixed-targets),1)
 # We're called with mixed targets (*config and build targets).
 # Handle them one by one.
 
-%:: FORCE
-	$(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
+PHONY += $(MAKECMDGOALS) build-one-by-one
+
+$(MAKECMDGOALS): build-one-by-one
+	@:
+
+build-one-by-one:
+	$(Q)set -e; \
+	for i in $(MAKECMDGOALS); do \
+		$(MAKE) -f $(srctree)/Makefile $$i; \
+	done
 
 else
 ifeq ($(config-targets),1)
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 35/38] kbuild: check clean source and generate Makefile for out-of-tree build
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (33 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 34/38] kbuild: support simultaneous board configuration and "make all" Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 36/38] board: sandburst: delete FORCEBUILD Masahiro Yamada
                   ` (5 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

For out-of-tree build
  - Check if the source tree is clean
  - Create a Makefile in the output directory

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
  - Newly added

 Makefile | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 57 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 6ae16d0..21274be 100644
--- a/Makefile
+++ b/Makefile
@@ -392,6 +392,17 @@ scripts_basic:
 # To avoid any implicit rule to kick in, define an empty command.
 scripts/basic/%: scripts_basic ;
 
+PHONY += outputmakefile
+# outputmakefile generates a Makefile in the output directory, if using a
+# separate output directory. This allows convenient use of make in the
+# output directory.
+outputmakefile:
+ifneq ($(KBUILD_SRC),)
+	$(Q)ln -fsn $(srctree) source
+	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
+	    $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
+endif
+
 # To make sure we do not include .config for any of the *config targets
 # catch them early, and hand them over to scripts/kconfig/Makefile
 # It is allowed to specify more targets when calling make, including
@@ -449,7 +460,7 @@ ifeq ($(config-targets),1)
 # KBUILD_DEFCONFIG may point out an alternative default configuration
 # used for 'make defconfig'
 
-%_config::
+%_config:: outputmakefile
 	@$(MKCONFIG) -A $(@:_config=)
 
 else
@@ -951,7 +962,7 @@ $(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
 # Error messages still appears in the original language
 
 PHONY += $(u-boot-dirs)
-$(u-boot-dirs): depend scripts_basic
+$(u-boot-dirs): depend prepare
 	$(Q)$(MAKE) $(build)=$@
 
 tools: $(TIMESTAMP_FILE) $(VERSION_FILE)
@@ -962,19 +973,56 @@ $(filter-out tools, $(u-boot-dirs)): tools
 examples: $(filter-out examples, $(u-boot-dirs))
 
 
+# Things we need to do before we recursively start building the kernel
+# or the modules are listed in "prepare".
+# A multi level approach is used. prepareN is processed before prepareN-1.
+# archprepare is used in arch Makefiles and when processed asm symlink,
+# version.h and scripts_basic is processed / created.
+
+# Listed in dependency order
+PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
+
+# prepare3 is used to check if we are building in a separate output directory,
+# and if so do:
+# 1) Check that make has not been executed in the kernel src $(srctree)
+prepare3:
+ifneq ($(KBUILD_SRC),)
+	@$(kecho) '  Using $(srctree) as source for u-boot'
+	$(Q)if [ -f $(srctree)/include/config.mk ]; then \
+		echo >&2 "  $(srctree) is not clean, please run 'make mrproper'"; \
+		echo >&2 "  in the '$(srctree)' directory.";\
+		/bin/false; \
+	fi;
+endif
+
+# prepare2 creates a makefile if using a separate output directory
+prepare2: prepare3 outputmakefile
+
+prepare1: prepare2
+	@:
+
+archprepare: prepare1 scripts_basic
+
+prepare0: archprepare FORCE
+	@:
+
+# All the preparing..
+prepare: prepare0
+
+
 u-boot.lds: $(LDSCRIPT) depend
 		$(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
-nand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend scripts_basic
+nand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend prepare
 		$(MAKE) $(build)=nand_spl/board/$(BOARDDIR) all
 
 u-boot-nand.bin:	nand_spl u-boot.bin
 		cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin
 
-spl/u-boot-spl.bin: tools depend scripts_basic
+spl/u-boot-spl.bin: tools depend prepare 
 		$(MAKE) obj=spl -f $(srctree)/spl/Makefile all
 
-tpl/u-boot-tpl.bin: tools depend scripts_basic
+tpl/u-boot-tpl.bin: tools depend prepare
 		$(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y
 
 # Explicitly make _depend in subdirs containing multiple targets to prevent
@@ -1224,7 +1272,10 @@ backup:
 	F=`basename $(TOPDIR)` ; cd .. ; \
 	gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
 
-#########################################################################
+# Dummies...
+PHONY += prepare scripts
+prepare: ;
+scripts: ;
 
 endif #ifeq ($(config-targets),1)
 endif #ifeq ($(mixed-targets),1)
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 36/38] board: sandburst: delete FORCEBUILD
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (34 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 35/38] kbuild: check clean source and generate Makefile for out-of-tree build Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 37/38] kbuild: Do not generate .*.su files at the top directory Masahiro Yamada
                   ` (4 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

We had switched to Kbuild, so we do not need to
delete sandburst board files at every build.

U-Boot conventional build system did not check the
update of command line option, -DBUILDUSER.

Kbuild can handle it nicely and re-builds object files
when command line options are changed.
(The file ".*.cmd" stores the information how the file
was generated at the previous build.)

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
  - Newly added

Changes in v2: None

 board/sandburst/karef/Makefile    | 6 +-----
 board/sandburst/metrobox/Makefile | 6 +-----
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/board/sandburst/karef/Makefile b/board/sandburst/karef/Makefile
index d5a9b34..ce29b41 100644
--- a/board/sandburst/karef/Makefile
+++ b/board/sandburst/karef/Makefile
@@ -10,11 +10,7 @@
 #
 
 # TBS: add for debugging purposes
-BUILDUSER := $(shell whoami)
-FORCEBUILD := $(shell rm -f karef.o)
-
-ccflags-y += -DBUILDUSER='"$(BUILDUSER)"'
-# TBS: end debugging
+ccflags-y += -DBUILDUSER='"$(shell whoami)"'
 
 obj-y	= karef.o ../common/flash.o ../common/sb_common.o
 extra-y	+= init.o
diff --git a/board/sandburst/metrobox/Makefile b/board/sandburst/metrobox/Makefile
index 8121cce..2c1028b 100644
--- a/board/sandburst/metrobox/Makefile
+++ b/board/sandburst/metrobox/Makefile
@@ -9,11 +9,7 @@
 #
 
 # TBS: add for debugging purposes
-BUILDUSER := $(shell whoami)
-FORCEBUILD := $(shell rm -f metrobox.o)
-
-ccflags-y += -DBUILDUSER='"$(BUILDUSER)"'
-# TBS: end debugging
+ccflags-y += -DBUILDUSER='"$(shell whoami)"'
 
 obj-y	= metrobox.o ../common/flash.o ../common/sb_common.o
 extra-y	+= init.o
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 37/38] kbuild: Do not generate .*.su files at the top directory
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (35 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 36/38] board: sandburst: delete FORCEBUILD Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 38/38] tools/env: cross-compile fw_printenv without setting HOSTCC Masahiro Yamada
                   ` (3 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

Without this workaround, you will see a lot of ".*.su" files
at the top directory after building with a compiler
which supports "-fstack-usage" option.

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

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
  - Newly added

Changes in v3: None
Changes in v2: None

 scripts/Kbuild.include | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 6113c13..6504571 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -85,14 +85,16 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
 # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
 # Exit code chooses option. "$$TMP" is can be used as temporary file and
 # is automatically cleaned up.
+# modifed for U-Boot: prevent cc-option from leaving .*.su files
 try-run = $(shell set -e;		\
 	TMP="$(TMPOUT).$$$$.tmp";	\
 	TMPO="$(TMPOUT).$$$$.o";	\
+	TMPSU="$(TMPOUT).$$$$.su";	\
 	if ($(1)) >/dev/null 2>&1;	\
 	then echo "$(2)";		\
 	else echo "$(3)";		\
 	fi;				\
-	rm -f "$$TMP" "$$TMPO")
+	rm -f "$$TMP" "$$TMPO" "$$TMPSU")
 
 # as-option
 # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 38/38] tools/env: cross-compile fw_printenv without setting HOSTCC
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (36 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 37/38] kbuild: Do not generate .*.su files at the top directory Masahiro Yamada
@ 2014-01-29 12:26 ` Masahiro Yamada
  2014-01-30 21:35 ` [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Andreas Bießmann
                   ` (2 subsequent siblings)
  40 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-29 12:26 UTC (permalink / raw)
  To: u-boot

fw_printenv is a program which mostly runs on the target Linux.

Before switching to Kbuild, we needed to set HOSTCC at the
command line like this:
    make HOSTCC=<your CC cross-compiler> env

Going forward we can cross compile it by specifying CROSS_COMPILE:
    make CROSS_COMPILE=<your cross-compiler prefix> env
This looks more natural.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Gerhard Sittig <gsi@denx.de>
---

Changes in v8:
  - Fix a typo in comment

Changes in v7: None
Changes in v6: None
Changes in v5:
  - Newly added

Changes in v4: None
Changes in v3: None
Changes in v2: None

 tools/.gitignore     |  1 -
 tools/env/.gitignore |  2 ++
 tools/env/Makefile   | 17 ++++++++++++++---
 tools/env/README     |  5 ++---
 4 files changed, 18 insertions(+), 7 deletions(-)
 create mode 100644 tools/env/.gitignore

diff --git a/tools/.gitignore b/tools/.gitignore
index 13283b7..6e4a287 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -16,7 +16,6 @@
 /xway-swap-bytes
 /*.exe
 /easylogo/easylogo
-/env/fw_printenv
 /gdb/gdbcont
 /gdb/gdbsend
 /kernel-doc/docproc
diff --git a/tools/env/.gitignore b/tools/env/.gitignore
new file mode 100644
index 0000000..804abac
--- /dev/null
+++ b/tools/env/.gitignore
@@ -0,0 +1,2 @@
+fw_printenv
+fw_printenv_unstripped
diff --git a/tools/env/Makefile b/tools/env/Makefile
index d47fe16..6ad81fd 100644
--- a/tools/env/Makefile
+++ b/tools/env/Makefile
@@ -5,6 +5,11 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+# fw_printenv is supposed to run on the target system, which means it should be
+# built with cross tools. Although it may look weird, we only replace "HOSTCC"
+# with "CC" here for the maximum code reuse of scripts/Makefile.host.
+HOSTCC = $(CC)
+
 # Compile for a hosted environment on the target
 HOST_EXTRACFLAGS  = $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
 		-idirafter $(SRCTREE)/tools/env \
@@ -15,9 +20,15 @@ ifeq ($(MTD_VERSION),old)
 HOST_EXTRACFLAGS += -DMTD_OLD
 endif
 
-hostprogs-y := fw_printenv
-always := $(hostprogs-y)
+always := fw_printenv
+hostprogs-y := fw_printenv_unstripped
 
-fw_printenv-objs := fw_env.o fw_env_main.o \
+fw_printenv_unstripped-objs := fw_env.o fw_env_main.o \
 	crc32.o ctype.o linux_string.o \
 	env_attr.o env_flags.o
+
+quiet_cmd_strip = STRIP   $@
+      cmd_strip = $(STRIP) -o $@ $<
+
+$(obj)/fw_printenv: $(obj)/fw_printenv_unstripped FORCE
+	$(call if_changed,strip)
diff --git a/tools/env/README b/tools/env/README
index 1020b57..24e31bc 100644
--- a/tools/env/README
+++ b/tools/env/README
@@ -2,11 +2,10 @@
 This is a demo implementation of a Linux command line tool to access
 the U-Boot's environment variables.
 
-In the current version, there is an issue in cross-compilation.
 In order to cross-compile fw_printenv, run
-    make HOSTCC=<your CC cross-compiler> env
+    make CROSS_COMPILE=<your cross-compiler prefix> env
 in the root directory of the U-Boot distribution. For example,
-    make HOSTCC=arm-linux-gcc env
+    make CROSS_COMPILE=arm-linux- env
 
 For the run-time utility configuration uncomment the line
 #define CONFIG_FILE  "/etc/fw_env.config"
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (37 preceding siblings ...)
  2014-01-29 12:26 ` [U-Boot] [PATCH v8 38/38] tools/env: cross-compile fw_printenv without setting HOSTCC Masahiro Yamada
@ 2014-01-30 21:35 ` Andreas Bießmann
  2014-01-31  1:48   ` Masahiro Yamada
  2014-01-31  9:12 ` Masahiro Yamada
  2014-01-31 20:35 ` Simon Glass
  40 siblings, 1 reply; 58+ messages in thread
From: Andreas Bießmann @ 2014-01-30 21:35 UTC (permalink / raw)
  To: u-boot

Dear Masahiro Yamada,

On 29.01.14 13:25, Masahiro Yamada wrote:

<snip>

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

compile test for this setup and a few others run successfully on OS X
Lion as build-host.
Runtime test on at least one avr32 and one at91 board will follow this
weekend.

I saw a few times full compiler output instead of the shortened 'CC
...'. Especially generating the linker script, reformatting binaries
with objcopy and doing the final linkage of u-boot ELF. Maybe you want
to sort that out?
Sorry if that was discussed before, haven't followed the whole discussion.

Nevertheless, many thanks for your great work!

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-01-30 21:35 ` [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Andreas Bießmann
@ 2014-01-31  1:48   ` Masahiro Yamada
  0 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-31  1:48 UTC (permalink / raw)
  To: u-boot

Hello Andreas,

Thanks for your test.

> I saw a few times full compiler output instead of the shortened 'CC
> ...'. Especially generating the linker script, reformatting binaries
> with objcopy and doing the final linkage of u-boot ELF. Maybe you want
> to sort that out?

Yes, I will do this in a follow-up series.


Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (38 preceding siblings ...)
  2014-01-30 21:35 ` [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Andreas Bießmann
@ 2014-01-31  9:12 ` Masahiro Yamada
  2014-02-01 12:09   ` Tom Rini
  2014-01-31 20:35 ` Simon Glass
  40 siblings, 1 reply; 58+ messages in thread
From: Masahiro Yamada @ 2014-01-31  9:12 UTC (permalink / raw)
  To: u-boot

Hello Tom,
 
Now, this kbuild series cleanly applies on the current u-boot/master.
(commit 07e2822d158940a0e8ba45b6ab0344ffa1011a07)

What's your plan about this series?
Are we ready to switch to Kbuild, or need more review?

Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
                   ` (39 preceding siblings ...)
  2014-01-31  9:12 ` Masahiro Yamada
@ 2014-01-31 20:35 ` Simon Glass
  2014-02-03  3:46   ` Masahiro Yamada
  40 siblings, 1 reply; 58+ messages in thread
From: Simon Glass @ 2014-01-31 20:35 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 29 January 2014 05:25, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
>
> 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. We need more progress.
>
> 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...

Everything looks good except for me I see a significant performance
regression on this. I suspect it is just that -j is not working
properly on make.

HEAD is now at 05ed548 dts: re-write dts/Makefile more simply with Kbuild
(=05ed54) u> time crosfw -b snow -w
Configuring for snow board...

real 0m27.723s
user 0m47.940s
sys 0m10.320s
(=05ed54) u> co upstream/master
Note: checking out 'upstream/master'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 07e2822... board: nios2: Check if flash is configured
before calling early_flash_cmd_reset()
(<detached:remotes/upstream/master=07e282) u> time crosfw -b snow -w
Configuring for snow board...

real 0m8.818s
user 0m36.290s
sys 0m5.040s


So it is 3x slower with Kbuild for some reason. Do you see this? For
reference my commit stack is:

05ed548 (HEAD, try-masa8) dts: re-write dts/Makefile more simply with Kbuild
f23f43b kernel-doc: fix some errors
ddb3799 kernel-doc: update kernel-doc related files to Linux v3.13
13101c1 kernel-doc: move kernel-doc tools to scripts/
f1e1317 tools/env: cross-compile fw_printenv without setting HOSTCC
7da0fca kbuild: Do not generate .*.su files at the top directory
7b7bc27 board: sandburst: delete FORCEBUILD
a34156a kbuild: check clean source and generate Makefile for out-of-tree build
e575e1d kbuild: support simultaneous board configuration and "make all"
08fe20b kbuild: use scripts/Makefile.clean
fc90fc8 Makefile: refactor tools-all targets
1f8bd74 Makefile: Do not pass MTD_VERSION from the top Makefile
59f28d7 kbuild: refactor Makefile and spl/Makefile more
bfdce2c examples: move api/ and standalone/ entry to examples/Makefile
4e7826b kbuild: change the top Makefile to more Kbuild-ish structure
0b1d2bf Makefile: remove a cleaning target "tidy"
ae96eae kbuild: generate {spl, tpl}-autoconf.mk only when it is necessary
7583bbb kbuild: move include directives of board configuration files
1917011 kbuild: convert some make rules to Kbuild style
b848d52 kbuild: move some lines to more suitable place
d5503c3 kbuild: delete temporary build scripts
6353f2b kbuild: use Linux Kernel build scripts
e0a95fa kbuild: import more build scripts from Linux v3.13 tag
d4911b8 Makefile: rename scripts/Makefile.build to scripts/Makefile.build.tmp
cee0118 kbuild: add dummy obj-y to create built-in.o
2799542 kbuild: change out-of-tree build
4591455 Makefile: move some flags to examples makefiles
9ef671c Makefile: move some flags to spl/Makefile
f0d005c Makefile: move more stuff to top Makefile
9ff6912 Makefile: refactor include path settings
cf2c342 Makefile: move more flags to the top Makefile
78d5a5e kbuild: Use Kbuild.include
846ef21 kbuild: import Kbuild.include from linux v3.13 tag
a022d38 Makefile: move BFD_ROOT_DIR to tools/gdb/Makefile
4295829 Makefile: move some variable definitions to the top Makefile
63f247e Makfile: move suffix rules to Makefile.build
a2d8588 nand-spl: Use scripts/Makefile.build
2188969 examples: Use scripts/Makefile.build
a72f52f board: samsung: refactor host programs
296248d tools: convert makefiles to kbuild style
cf5e39b Makefile.host.tmp: add a new script to refactor tools
1bb87d8 .gitignore: ingore files generated by Kbuild
07e2822 (upstream/master) board: nios2: Check if flash is configured
before calling early_flash_cmd_reset()


Regards,
Simon

>
>  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 simply.
>           Just add objects to "obj-y" like this:
>           obj-$(CONFIG_FOO) += foo.o
>
>        (b) We can describe directory descending nicely.
>           Add directories with a slash 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 the followings beforehand to use this series.
>
> [1] sandbox: Use system headers first for sandbox's os.c in a different way
> http://patchwork.ozlabs.org/patch/294233/
>
> I confirmed this series can apply on:
> Commit 0876703cf + prerequisite[1].
>
>  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.
>
>  Note
>  ----
>
>  - 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.
>
>  Run Test
>  --------
>
>  - Tested for MPC5121 on an ifm AC14xx board,
>      Beagle (C4) board and Wand (quad) board by Gerhard Sittig
>
>  - Tested for Zynq ZC706 board by me
>
> Run test report for your board is welcome!
>
> Changes for v8:
>   - Rebase on commit 0876703c.
>   - Fix a typo in comment in 38/38
>
> Changes for v7:
>   - Fix a bug in spl build:
>     In v6, build failed if we try to build another SPL board
>     without doing "make clobber".
>     For example,
>       $ make omap3_beagle_config
>       $ make CROSS_COMPILE=<your_gcc_prefix>
>       $ make am335x_evm_config
>       $ make CROSS_COMPILE=<your_gcc_prefix>
>     This failed in v6. We needed either "make clobber" or "make mrproper"
>     before switching to another board.
>     Now, we can two or more boards continuously.
>
> Changes for v6:
>   - Rebase on the current u-boot/master
>   - Linux Kernel 3.13 was released on Jan. 20, so import build scripts
>     from v3.13 to be breeding edge.
>   - Minor change in post/lib_powerpc/fpu/Makefile
>   - Include cmd_files under nand_spl/board/*/*/Makefile
>
> Changes for v5:
>   - Fix a bug reported by Gerhard Sittig:
>         "make tools" before running "make" failed at v4.
>   - Revive "env" target so that we can build only under tools/env/.
>   - Add a new patch at the tail:
>       38/38 "tools/env: cross-compile fw_printenv without setting HOSTCC"
>   - Describe "clobber" target shortly by deleteing "*.imx" and "*.map"
>      with wildcard matching.
>   - Rebase on the current u-boot/master
>
> Changes for v4:
>   - Add a new patch at the tail:
>       37/37 "kbuild: Do not generate .*.su files at the top directory"
>   - Change "checkstack" target to Kbuild style
>   - Move the line where U_BOOT_VERSION is defined
>
> Changes for v3:
>   - Rebase on the current u-boot/master
>   - Add a new patch at the tail:
>       36/36 "board: sandburst: delete FORCEBUILD"
>
> 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 (38):
>   .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.13 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 build
>   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.13 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/ entry 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
>   board: sandburst: delete FORCEBUILD
>   kbuild: Do not generate .*.su files at the top directory
>   tools/env: cross-compile fw_printenv without setting HOSTCC
>
>  .gitignore                                         |   30 +-
>  MAKEALL                                            |    8 +-
>  Makefile                                           | 1310 +++++++++++++-------
>  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-ng/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                     |    6 +-
>  board/sandburst/metrobox/Makefile                  |    6 +-
>  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                               |   73 +-
>  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                       |   74 +-
>  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                      |   29 +-
>  rules.mk                                           |   51 -
>  scripts/Kbuild.include                             |  284 +++++
>  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                                       |  197 +--
>  tools/.gitignore                                   |    3 +-
>  tools/Makefile                                     |  373 ++----
>  tools/crc32.c                                      |    1 +
>  tools/easylogo/Makefile                            |   12 +-
>  tools/env/.gitignore                               |    2 +
>  tools/env/Makefile                                 |   39 +-
>  tools/env/README                                   |    5 +-
>  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 +
>  153 files changed, 3693 insertions(+), 2057 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/.gitignore
>  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
>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-01-31  9:12 ` Masahiro Yamada
@ 2014-02-01 12:09   ` Tom Rini
  0 siblings, 0 replies; 58+ messages in thread
From: Tom Rini @ 2014-02-01 12:09 UTC (permalink / raw)
  To: u-boot

On Fri, Jan 31, 2014 at 06:12:49PM +0900, Masahiro Yamada wrote:

> Hello Tom,
>  
> Now, this kbuild series cleanly applies on the current u-boot/master.
> (commit 07e2822d158940a0e8ba45b6ab0344ffa1011a07)
> 
> What's your plan about this series?
> Are we ready to switch to Kbuild, or need more review?

Lets get the performance problem Simon found figured out, but then
otherwise, yes, I think we're about ready to merge.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140201/26fd37c9/attachment.pgp>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-01-31 20:35 ` Simon Glass
@ 2014-02-03  3:46   ` Masahiro Yamada
  2014-02-06 21:10     ` Tom Rini
  0 siblings, 1 reply; 58+ messages in thread
From: Masahiro Yamada @ 2014-02-03  3:46 UTC (permalink / raw)
  To: u-boot

Hello Simon and Tom,


This is my analysis of Kbuild performance.



[1] -j option is working

What I must say first is -j option is working correctly with Kbuild.

You can double-check by following the steps below.

Apply Kbuild series v8 on
commit 07e2822d158940a0e8ba45b6ab0344ffa1011a07.


First, build without -j option.

$ make mrproper
$ time make CROSS_COMPILE=arm-linux-gnueabi-  snow_config all
Configuring for snow board...
  GEN     include/autoconf.mk.dep
  [snip]

real	1m15.089s
user	0m44.092s
sys	0m32.513s


Next, build with -j8 option.
(Run "make mrproper" every time because we want to be sure
that there are no generated files before build.)

$ make mrproper
$ time make -j8 CROSS_COMPILE=arm-linux-gnueabi-  snow_config all 
  [snip]

real	0m17.223s
user	0m50.010s
sys	0m29.038s


It is much faster with -j8 option than without -j option.
(4.3 times faster on my box.)



You will easily notice another proof that -j option is working.


If you do not add -j option, the shorten log will be displayed
in the alphabetical order of output file name:

  LD      arch/arm/cpu/built-in.o
  CC      arch/arm/cpu/armv7/cache_v7.o
  CC      arch/arm/cpu/armv7/cpu.o
  CC      arch/arm/cpu/armv7/syslib.o
  CC      arch/arm/cpu/armv7/s5p-common/cpu_info.o
  CC      arch/arm/cpu/armv7/s5p-common/timer.o
  CC      arch/arm/cpu/armv7/s5p-common/sromc.o
  CC      arch/arm/cpu/armv7/s5p-common/pwm.o
  LD      arch/arm/cpu/armv7/s5p-common/built-in.o
  LD      arch/arm/cpu/armv7/built-in.o
  AS      arch/arm/cpu/armv7/start.o
  CC      arch/arm/cpu/armv7/exynos/clock.o
  CC      arch/arm/cpu/armv7/exynos/power.o
 

On the other hand, if you add -j option, the log will be shown
in a different order:

  LD      arch/arm/cpu/built-in.o
  CC      arch/arm/cpu/armv7/cache_v7.o
  CC      arch/arm/cpu/armv7/exynos/clock.o
  CC      disk/part.o
  AS      arch/arm/lib/crt0.o
  CC      board/samsung/common/board.o
  CC      board/samsung/smdk5250/smdk5250_spl.o
  CC      common/main.o
  LD      drivers/block/built-in.o
  LD      board/samsung/common/built-in.o
  CC      arch/arm/cpu/armv7/cpu.o
  AS      arch/arm/lib/relocate.o
  CC      disk/part_dos.o
  CC      arch/arm/cpu/armv7/exynos/power.o



[2] Is Kbuild slower than the old U-Boot build system?

Yes, Kbuild is definitely slower.
(But, as far as I tested,  I don't think it is 3 times slower.)

Let's compare the build time with the conventional build system.

Checkout master branch.
(commit 07e2822d158940a0e8ba45b6ab0344ffa1011a07)

$ make mrproper
$ time make CROSS_COMPILE=arm-linux-gnueabi-  snow

real	0m45.612s
user	0m28.367s
sys	0m18.969s


So, Kbuild(=real 1m15.089s) is 1.6 times slower
than the old U-Boot build system.


[3] Why is Kbuild slower?

One reason is "fixdep".

The helper program, fixdep, parses the source file
and all headers included from it to search all CONFIG
macro used there. This is a rather heavy task.

If you don't know the reason why "fixdep" is necessary,
please read the comment block of scripts/basic/fixdep.c
It is true that fixdep is meaningless for now,
but it will be a great help when switching to Kconfig.
We will get more return than we pay.
(And Kconfig series is almost ready.
I will test more and post version 1 within a couple of weeks.)


Let' check how big the impact of fixdep is.

I prepared a patch for you to disable fixdep:
http://patchwork.ozlabs.org/patch/316057/

Apply it on
commit 07e2822d158940a0e8ba45b6ab0344ffa1011a07 + Kbuild v8

And then, build.

$ make mrproper
$ time make CROSS_COMPILE=arm-linux-gnueabi-  snow_config all 

real	1m2.436s
user	0m38.281s
sys	0m25.871s

It is faster by 1.2 times faster without fixdep than it is with fixdep.


Another big factor is "arg-check".
This excellent routine is defined in scripts/Kbuild.include.

The dependency tracking of U-Boot old build system is
absolutely unreliable.
It compares the timestamp between object files and source files,
but never checks the arguments given to the compiler.

Kbuild checks both of them to precisely detect which objects must
be re-built.

To see how heavy "arg-check" task is,
build with KBUILD_NOCMDDEP=1 option to disable "arg-check".

$ make mrproper
$ time make CROSS_COMPILE=arm-linux-gnueabi- KBUILD_NOCMDDEP=1 snow_config all

real	0m41.882s
user	0m28.432s
sys	0m14.971s

See?
It is as fast as the old U-boot system(=0m45.612) .


Conclusion:
The main reasons of the slow down with Kbuild are "fixdep" and "arg-check".
Both of them are really important features for Kbuild and Kconfig.
    - "fixdep" is mandatory for our better life with Kconfig.
    - "arg-check" is for perfect dependency tracking.



> > What's your plan about this series?
> > Are we ready to switch to Kbuild, or need more review?
> 
> Lets get the performance problem Simon found figured out, but then
> otherwise, yes, I think we're about ready to merge.

Tom, are you satisfied with my analisys?

But, please hold merging Kbuild series.
I will post version 9 with a little minor update.



Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-03  3:46   ` Masahiro Yamada
@ 2014-02-06 21:10     ` Tom Rini
  2014-02-16  1:30       ` Simon Glass
  0 siblings, 1 reply; 58+ messages in thread
From: Tom Rini @ 2014-02-06 21:10 UTC (permalink / raw)
  To: u-boot

On Mon, Feb 03, 2014 at 12:46:30PM +0900, Masahiro Yamada wrote:

> Hello Simon and Tom,
> 
> 
> This is my analysis of Kbuild performance.
[snip]
> Conclusion:
> The main reasons of the slow down with Kbuild are "fixdep" and "arg-check".
> Both of them are really important features for Kbuild and Kconfig.
>     - "fixdep" is mandatory for our better life with Kconfig.
>     - "arg-check" is for perfect dependency tracking.
> 
> 
> 
> > > What's your plan about this series?
> > > Are we ready to switch to Kbuild, or need more review?
> > 
> > Lets get the performance problem Simon found figured out, but then
> > otherwise, yes, I think we're about ready to merge.
> 
> Tom, are you satisfied with my analisys?

I am, yes.  I guess if we're unhappy with the times, if we can improve
them we can push that back to the kernel and that's a good thing.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140206/5b854665/attachment.pgp>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-06 21:10     ` Tom Rini
@ 2014-02-16  1:30       ` Simon Glass
  2014-02-16  2:51         ` Simon Glass
  2014-02-18 14:44         ` Tom Rini
  0 siblings, 2 replies; 58+ messages in thread
From: Simon Glass @ 2014-02-16  1:30 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 6 February 2014 14:10, Tom Rini <trini@ti.com> wrote:
> On Mon, Feb 03, 2014 at 12:46:30PM +0900, Masahiro Yamada wrote:
>
>> Hello Simon and Tom,
>>
>>
>> This is my analysis of Kbuild performance.
> [snip]
>> Conclusion:
>> The main reasons of the slow down with Kbuild are "fixdep" and "arg-check".
>> Both of them are really important features for Kbuild and Kconfig.
>>     - "fixdep" is mandatory for our better life with Kconfig.
>>     - "arg-check" is for perfect dependency tracking.
>>

Thanks for your detailed analysis of this. The slower build time is
unfortunate but I think it is worth it. The fixdep thing is similar to
the penalty from the autoconf series I did a while ago. Maybe the
scripts can be sped up, I'm not sure.

>>
>>
>> > > What's your plan about this series?
>> > > Are we ready to switch to Kbuild, or need more review?
>> >
>> > Lets get the performance problem Simon found figured out, but then
>> > otherwise, yes, I think we're about ready to merge.
>>
>> Tom, are you satisfied with my analisys?
>
> I am, yes.  I guess if we're unhappy with the times, if we can improve
> them we can push that back to the kernel and that's a good thing.

Well IMO the sooner this is merged the better so that the Makefiles
become stable again.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-16  1:30       ` Simon Glass
@ 2014-02-16  2:51         ` Simon Glass
  2014-02-18  9:02           ` Masahiro Yamada
  2014-02-18 14:44         ` Tom Rini
  1 sibling, 1 reply; 58+ messages in thread
From: Simon Glass @ 2014-02-16  2:51 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 15 February 2014 18:30, Simon Glass <sjg@chromium.org> wrote:
> Hi Masahiro,
>
> On 6 February 2014 14:10, Tom Rini <trini@ti.com> wrote:
>> On Mon, Feb 03, 2014 at 12:46:30PM +0900, Masahiro Yamada wrote:
>>
>>> Hello Simon and Tom,
>>>
>>>
>>> This is my analysis of Kbuild performance.
>> [snip]
>>> Conclusion:
>>> The main reasons of the slow down with Kbuild are "fixdep" and "arg-check".
>>> Both of them are really important features for Kbuild and Kconfig.
>>>     - "fixdep" is mandatory for our better life with Kconfig.
>>>     - "arg-check" is for perfect dependency tracking.
>>>
>
> Thanks for your detailed analysis of this. The slower build time is
> unfortunate but I think it is worth it. The fixdep thing is similar to
> the penalty from the autoconf series I did a while ago. Maybe the
> scripts can be sped up, I'm not sure.

I'm not sure whether to start a new thread or not, but here in one
observations which might be useful.

With current master, a 'null' build (with nothing changed) takes about
5s for me.

time CROSS_COMPILE=/opt/linaro/gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux/bin/arm
-linux-gnueabihf- ARCH=arm make -j1
real 0m4.978s
user 0m1.144s
sys 0m0.360s


With the kbuild series, it takes a lot longer:

real 0m46.600s
user 0m17.628s
sys 0m8.664s

There seem to be noticeable pauses between things happening. I'm not
quite sure how to dig into it more. Is it possible that cc-option is
no-longer caching the various compiler options?

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-16  2:51         ` Simon Glass
@ 2014-02-18  9:02           ` Masahiro Yamada
  2014-02-19  6:09             ` Simon Glass
  2014-02-19 17:28             ` Tom Rini
  0 siblings, 2 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-02-18  9:02 UTC (permalink / raw)
  To: u-boot

Hello Simon,


> 
> I'm not sure whether to start a new thread or not, but here in one
> observations which might be useful.
> 
> With current master, a 'null' build (with nothing changed) takes about
> 5s for me.
> 
> time CROSS_COMPILE=/opt/linaro/gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux/bin/arm
> -linux-gnueabihf- ARCH=arm make -j1
> real 0m4.978s
> user 0m1.144s
> sys 0m0.360s
> 
> 
> With the kbuild series, it takes a lot longer:
> 
> real 0m46.600s
> user 0m17.628s
> sys 0m8.664s

Thanks for your feedback.

Hmm, Kbuild is 9 times slower on your computer.
This is a big difference. (It was about 1.6 x slower on my box.)

I don't know where such a difference came from.

> There seem to be noticeable pauses between things happening. I'm not
> quite sure how to dig into it more. Is it possible that cc-option is
> no-longer caching the various compiler options?

I guess it's possible.

Is sandbox build slow as well?
Sandbox has no cc-option.
If cc-option is the cause of pauses, sandbox build
should be faster.

Anyway, evaluating cc-option multiple times isn't nice
and its optimization is on my TODO list.

Historically, U-Boot has included all
config.mk (arch/*/config.mk and board/*/config.mk)
every time descending into subdirectories.
That means cc-options are evaluated over and over again.
Caching cc-option is one of work arounds, but we should not
revive it.

What we should do is to include arch/*/config.mk and board/*/config.mk
only once at the top Makefile and export options.


Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-16  1:30       ` Simon Glass
  2014-02-16  2:51         ` Simon Glass
@ 2014-02-18 14:44         ` Tom Rini
  2014-02-19  1:57           ` Masahiro Yamada
  1 sibling, 1 reply; 58+ messages in thread
From: Tom Rini @ 2014-02-18 14:44 UTC (permalink / raw)
  To: u-boot

On Sat, Feb 15, 2014 at 06:30:59PM -0700, Simon Glass wrote:
> Hi Masahiro,
> 
> On 6 February 2014 14:10, Tom Rini <trini@ti.com> wrote:
> > On Mon, Feb 03, 2014 at 12:46:30PM +0900, Masahiro Yamada wrote:
> >
> >> Hello Simon and Tom,
> >>
> >>
> >> This is my analysis of Kbuild performance.
> > [snip]
> >> Conclusion:
> >> The main reasons of the slow down with Kbuild are "fixdep" and "arg-check".
> >> Both of them are really important features for Kbuild and Kconfig.
> >>     - "fixdep" is mandatory for our better life with Kconfig.
> >>     - "arg-check" is for perfect dependency tracking.
> >>
> 
> Thanks for your detailed analysis of this. The slower build time is
> unfortunate but I think it is worth it. The fixdep thing is similar to
> the penalty from the autoconf series I did a while ago. Maybe the
> scripts can be sped up, I'm not sure.
> 
> >>
> >>
> >> > > What's your plan about this series?
> >> > > Are we ready to switch to Kbuild, or need more review?
> >> >
> >> > Lets get the performance problem Simon found figured out, but then
> >> > otherwise, yes, I think we're about ready to merge.
> >>
> >> Tom, are you satisfied with my analisys?
> >
> > I am, yes.  I guess if we're unhappy with the times, if we can improve
> > them we can push that back to the kernel and that's a good thing.
> 
> Well IMO the sooner this is merged the better so that the Makefiles
> become stable again.

Agreed.  Weather ate most of last week for me when I had hoped to clear
out some things and then grab this series.  Back at it all now..

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140218/d3c34f2a/attachment.pgp>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-18 14:44         ` Tom Rini
@ 2014-02-19  1:57           ` Masahiro Yamada
  2014-02-19 12:54             ` Tom Rini
  0 siblings, 1 reply; 58+ messages in thread
From: Masahiro Yamada @ 2014-02-19  1:57 UTC (permalink / raw)
  To: u-boot

Hello Tom,

I notice Kbuild fails to build venice2 board
because commit 52ef43b0529  added an empty Makefile,
arch/arm/cpu/armv7/tegra124/Makefile.

What shall we do with this?

Do you need v10 or shall I fix it in a follow-up patch?


Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-18  9:02           ` Masahiro Yamada
@ 2014-02-19  6:09             ` Simon Glass
  2014-02-19  9:51               ` Masahiro Yamada
  2014-02-19 17:28             ` Tom Rini
  1 sibling, 1 reply; 58+ messages in thread
From: Simon Glass @ 2014-02-19  6:09 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 18 February 2014 01:02, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
> Hello Simon,
>
>
>>
>> I'm not sure whether to start a new thread or not, but here in one
>> observations which might be useful.
>>
>> With current master, a 'null' build (with nothing changed) takes about
>> 5s for me.
>>
>> time CROSS_COMPILE=/opt/linaro/gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux/bin/arm
>> -linux-gnueabihf- ARCH=arm make -j1
>> real 0m4.978s
>> user 0m1.144s
>> sys 0m0.360s
>>
>>
>> With the kbuild series, it takes a lot longer:
>>
>> real 0m46.600s
>> user 0m17.628s
>> sys 0m8.664s
>
> Thanks for your feedback.
>
> Hmm, Kbuild is 9 times slower on your computer.
> This is a big difference. (It was about 1.6 x slower on my box.)
>
> I don't know where such a difference came from.

Note this is a 32-core machine.

>
>> There seem to be noticeable pauses between things happening. I'm not
>> quite sure how to dig into it more. Is it possible that cc-option is
>> no-longer caching the various compiler options?
>
> I guess it's possible.
>
> Is sandbox build slow as well?
> Sandbox has no cc-option.
> If cc-option is the cause of pauses, sandbox build
> should be faster.

Yes actually sandbox is pretty fast.

>
> Anyway, evaluating cc-option multiple times isn't nice
> and its optimization is on my TODO list.
>
> Historically, U-Boot has included all
> config.mk (arch/*/config.mk and board/*/config.mk)
> every time descending into subdirectories.
> That means cc-options are evaluated over and over again.
> Caching cc-option is one of work arounds, but we should not
> revive it.
>
> What we should do is to include arch/*/config.mk and board/*/config.mk
> only once at the top Makefile and export options.

That sounds good to me. Thanks for looking at it.

Regards,
Simon

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-19  6:09             ` Simon Glass
@ 2014-02-19  9:51               ` Masahiro Yamada
  0 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-02-19  9:51 UTC (permalink / raw)
  To: u-boot

Hello Simon,


> > Thanks for your feedback.
> >
> > Hmm, Kbuild is 9 times slower on your computer.
> > This is a big difference. (It was about 1.6 x slower on my box.)
> >
> > I don't know where such a difference came from.
> 
> Note this is a 32-core machine.

You are passing -j1 to the command line in here,

> >> time CROSS_COMPILE=/opt/linaro/gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux/bin/arm
> >> -linux-gnueabihf- ARCH=arm make -j1

So you are using only 1 core, right?


> >
> >> There seem to be noticeable pauses between things happening. I'm not
> >> quite sure how to dig into it more. Is it possible that cc-option is
> >> no-longer caching the various compiler options?
> >
> > I guess it's possible.
> >
> > Is sandbox build slow as well?
> > Sandbox has no cc-option.
> > If cc-option is the cause of pauses, sandbox build
> > should be faster.
> 
> Yes actually sandbox is pretty fast.

It's interesting and I want to know how fast.
Could you post the result of Sandbox build?


Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-19  1:57           ` Masahiro Yamada
@ 2014-02-19 12:54             ` Tom Rini
  2014-02-19 13:28               ` Masahiro Yamada
  0 siblings, 1 reply; 58+ messages in thread
From: Tom Rini @ 2014-02-19 12:54 UTC (permalink / raw)
  To: u-boot

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/18/2014 08:57 PM, Masahiro Yamada wrote:
> Hello Tom,
> 
> I notice Kbuild fails to build venice2 board because commit 
> 52ef43b0529  added an empty Makefile, 
> arch/arm/cpu/armv7/tegra124/Makefile.
> 
> What shall we do with this?
> 
> Do you need v10 or shall I fix it in a follow-up patch?

Lets go with follow up patch.

- -- 
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTBKluAAoJENk4IS6UOR1WxNAP/0ITe8+c1IjxQjdNL2Otyh4K
y23jEXo3wypC1t1NO11b0wuhr/3eXMgmKIE3S3vuo/zgNatCiPuuer+XDaHyYW00
4IZcD/CFulMyWOFAzoZvdvInuY60QPvBZi2LEjmtlsm35CC/gR7jtPWzOTOvdPxl
Fnk0tUNa1p5s7B+lRWnVbp6Mg6UEBP55p3nO0jKwYO6dQkGXj0qvqr21eMz+QcDL
3T+pV/llPieh+gwkHgz6Ze6sOOhQpAWmUr3GmYEUiXTJFTyTzxplWNEcluAzwGU/
RjboXErzNPdr3nRUjQ6qGwUe0plR4DU39uxjd87ipxK+4kvRpT2yiDQIxQp+0Aqi
6OthFlR0UJzEg2yFYwz1oQsRLoGzPJeYhfNtBXhBU0Jv1iBEEZb83+narnhgkyQg
kXHUeoRmfctlNPqAxMVv5k6UpHTB8cchZ1btNaaxLNv+hcQ7sfecfEPflmUyf/aD
sttN43PvT26GvcnH79x8dgR/r/ShJPlTVkvW32Z8hRostrGHyL7IefEMLe9zGYC5
+BG65pz0U0d9/taYwdL+UfukYzbjiOQufGlfnoQ1JJjsN7L30rrTcMSgOc0PzJXN
oDIEpcNwyUvbM4e8MnIexVtLmdm44mOWqvSfOvVrPTMzlkDYsWFOYmsgeLKhtW2j
Q6efuCYcEvJWP1zcdP+X
=KiYY
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-19 12:54             ` Tom Rini
@ 2014-02-19 13:28               ` Masahiro Yamada
  0 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2014-02-19 13:28 UTC (permalink / raw)
  To: u-boot

Hello Tom,


> > I notice Kbuild fails to build venice2 board because commit 
> > 52ef43b0529  added an empty Makefile, 
> > arch/arm/cpu/armv7/tegra124/Makefile.
> > 
> > What shall we do with this?
> > 
> > Do you need v10 or shall I fix it in a follow-up patch?
> 
> Lets go with follow up patch.

I have posted it.
http://patchwork.ozlabs.org/patch/321899/



Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-18  9:02           ` Masahiro Yamada
  2014-02-19  6:09             ` Simon Glass
@ 2014-02-19 17:28             ` Tom Rini
  2014-02-20  8:25               ` Masahiro Yamada
  1 sibling, 1 reply; 58+ messages in thread
From: Tom Rini @ 2014-02-19 17:28 UTC (permalink / raw)
  To: u-boot

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/18/2014 04:02 AM, Masahiro Yamada wrote:
> Hello Simon,
> 
> 
>> 
>> I'm not sure whether to start a new thread or not, but here in
>> one observations which might be useful.
>> 
>> With current master, a 'null' build (with nothing changed) takes
>> about 5s for me.
>> 
>> time
>> CROSS_COMPILE=/opt/linaro/gcc-linaro-arm-linux-gnueabihf-4.8-2013.08_linux/bin/arm
>>
>> 
- -linux-gnueabihf- ARCH=arm make -j1
>> real 0m4.978s user 0m1.144s sys 0m0.360s
>> 
>> 
>> With the kbuild series, it takes a lot longer:
>> 
>> real 0m46.600s user 0m17.628s sys 0m8.664s
> 
> Thanks for your feedback.
> 
> Hmm, Kbuild is 9 times slower on your computer. This is a big
> difference. (It was about 1.6 x slower on my box.)
> 
> I don't know where such a difference came from.
> 
>> There seem to be noticeable pauses between things happening. I'm
>> not quite sure how to dig into it more. Is it possible that
>> cc-option is no-longer caching the various compiler options?
> 
> I guess it's possible.
> 
> Is sandbox build slow as well? Sandbox has no cc-option. If
> cc-option is the cause of pauses, sandbox build should be faster.
> 
> Anyway, evaluating cc-option multiple times isn't nice and its
> optimization is on my TODO list.

Can we move this up on the TODO list please?  Some quick testing
around here says that this is the big culprit on build times.  I get
pre-Kbuild series build time to match post-Kbuild series by building
with CONFIG_CC_OPT_CACHE_DISABLE=y.

- -- 
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTBOnSAAoJENk4IS6UOR1WlKsP/ArbW+W4MkrKoAM6WCyWrPRh
6uDCK9Hhf3HanF49ejwGFUhvI2dHNAKuuvQ2PF523OVfxzZRUPH+D8FJQ5eA7ezO
N+yIcTDpvGI4y6aR4X/H5QCwvqeL0GsUhqP+xDQ4exAkaI/Ij92i/BYuZSwyoU8w
yfJU13RRjwstXcVheERJzQRdsC7lY2O+c1Z0+o+S9L0aJ25iuo57huUPD+6V0zsg
VEgzfFUGjPWtjtfkU9jzCIMqedhQbz4Hoewav1Bn8SNq6aG6mZtysUJitWanjJrl
fCb9a1vPbkhgJLACewkpbtUDLTys+sofSl5mbULT03bGNKDK+QG443nvSvPkfh/I
6QDdk7bH/o38ZP1kvLuzatFUXK7Z66LPwOIMVlgheIbZnyVkryOfpA8stwWRhpGk
rueQjJBuhbrcfdwRswfAX8iDRYMcuXsMyk4/Kpg2KcwEC+H540pEeZZKJYL3Enf6
Mpe7koYtnhN0AFdgIK97qQ7QYSJ9DmrsDVYAro1oL4jTqDQS8y02zdW2rhlIpIFW
vqlQ861AiXdmzUPkJS5t9qAEU9JqfK7SKS53yNBPD0tocEeJOWp9veEjvoUgm3rH
LmwCGmdNzQLlyVj0w+gTeFb90L4fb/MAfwGcb7cQak6Rc7FbgX/3MkMB6cDOpYKu
AIQTrHf3stEVnjPSAHAm
=gu7X
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-19 17:28             ` Tom Rini
@ 2014-02-20  8:25               ` Masahiro Yamada
  2014-02-20 13:29                 ` Tom Rini
  0 siblings, 1 reply; 58+ messages in thread
From: Masahiro Yamada @ 2014-02-20  8:25 UTC (permalink / raw)
  To: u-boot

Hello Tom,


> > Anyway, evaluating cc-option multiple times isn't nice and its
> > optimization is on my TODO list.
> 
> Can we move this up on the TODO list please?  Some quick testing
> around here says that this is the big culprit on build times.  I get
> pre-Kbuild series build time to match post-Kbuild series by building
> with CONFIG_CC_OPT_CACHE_DISABLE=y.

Sure.
I will deal with this task as the first priority.

Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild
  2014-02-20  8:25               ` Masahiro Yamada
@ 2014-02-20 13:29                 ` Tom Rini
  0 siblings, 0 replies; 58+ messages in thread
From: Tom Rini @ 2014-02-20 13:29 UTC (permalink / raw)
  To: u-boot

On Thu, Feb 20, 2014 at 05:25:27PM +0900, Masahiro Yamada wrote:

> Hello Tom,
> 
> > > Anyway, evaluating cc-option multiple times isn't nice and its
> > > optimization is on my TODO list.
> > 
> > Can we move this up on the TODO list please?  Some quick testing
> > around here says that this is the big culprit on build times.  I get
> > pre-Kbuild series build time to match post-Kbuild series by building
> > with CONFIG_CC_OPT_CACHE_DISABLE=y.
> 
> Sure.
> I will deal with this task as the first priority.

Thanks!  This is something we can push up to the kernel community too
and I hope they'll (a) agree with and (b) be happy about.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140220/86f79dd5/attachment.pgp>

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2014-02-20 13:29 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-29 12:25 [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Masahiro Yamada
2014-01-29 12:25 ` [U-Boot] [PATCH v8 01/38] .gitignore: ingore files generated by Kbuild Masahiro Yamada
2014-01-29 12:25 ` [U-Boot] [PATCH v8 02/38] Makefile.host.tmp: add a new script to refactor tools Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 03/38] tools: convert makefiles to kbuild style Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 04/38] board: samsung: refactor host programs Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 05/38] examples: Use scripts/Makefile.build Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 06/38] nand-spl: " Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 07/38] Makfile: move suffix rules to Makefile.build Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 08/38] Makefile: move some variable definitions to the top Makefile Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 09/38] Makefile: move BFD_ROOT_DIR to tools/gdb/Makefile Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 10/38] kbuild: import Kbuild.include from linux v3.13 tag Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 11/38] kbuild: Use Kbuild.include Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 12/38] Makefile: move more flags to the top Makefile Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 13/38] Makefile: refactor include path settings Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 14/38] Makefile: move more stuff to top Makefile Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 15/38] Makefile: move some flags to spl/Makefile Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 16/38] Makefile: move some flags to examples makefiles Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 17/38] kbuild: change out-of-tree build Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 18/38] kbuild: add dummy obj-y to create built-in.o Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 19/38] Makefile: rename scripts/Makefile.build to scripts/Makefile.build.tmp Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 20/38] kbuild: import more build scripts from Linux v3.13 tag Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 21/38] kbuild: use Linux Kernel build scripts Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 22/38] kbuild: delete temporary " Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 23/38] kbuild: move some lines to more suitable place Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 24/38] kbuild: convert some make rules to Kbuild style Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 25/38] kbuild: move include directives of board configuration files Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 26/38] kbuild: generate {spl, tpl}-autoconf.mk only when it is necessary Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 27/38] Makefile: remove a cleaning target "tidy" Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 28/38] kbuild: change the top Makefile to more Kbuild-ish structure Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 29/38] examples: move api/ and standalone/ entry to examples/Makefile Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 30/38] kbuild: refactor Makefile and spl/Makefile more Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 31/38] Makefile: Do not pass MTD_VERSION from the top Makefile Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 32/38] Makefile: refactor tools-all targets Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 33/38] kbuild: use scripts/Makefile.clean Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 34/38] kbuild: support simultaneous board configuration and "make all" Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 35/38] kbuild: check clean source and generate Makefile for out-of-tree build Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 36/38] board: sandburst: delete FORCEBUILD Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 37/38] kbuild: Do not generate .*.su files at the top directory Masahiro Yamada
2014-01-29 12:26 ` [U-Boot] [PATCH v8 38/38] tools/env: cross-compile fw_printenv without setting HOSTCC Masahiro Yamada
2014-01-30 21:35 ` [U-Boot] [PATCH v8 0/38] Switch over to real Kbuild Andreas Bießmann
2014-01-31  1:48   ` Masahiro Yamada
2014-01-31  9:12 ` Masahiro Yamada
2014-02-01 12:09   ` Tom Rini
2014-01-31 20:35 ` Simon Glass
2014-02-03  3:46   ` Masahiro Yamada
2014-02-06 21:10     ` Tom Rini
2014-02-16  1:30       ` Simon Glass
2014-02-16  2:51         ` Simon Glass
2014-02-18  9:02           ` Masahiro Yamada
2014-02-19  6:09             ` Simon Glass
2014-02-19  9:51               ` Masahiro Yamada
2014-02-19 17:28             ` Tom Rini
2014-02-20  8:25               ` Masahiro Yamada
2014-02-20 13:29                 ` Tom Rini
2014-02-18 14:44         ` Tom Rini
2014-02-19  1:57           ` Masahiro Yamada
2014-02-19 12:54             ` Tom Rini
2014-02-19 13:28               ` Masahiro Yamada

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.