Skip to contentSkip to conversation

Switch over to real Kbuild

PATCH Superseded Masahiro Yamada 4 participants 58 messages Jan 29, 2014 – Feb 20, 2014

Subsystems (16)

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v8 cover Switch over to real Kbuild

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
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v8 1/38 .gitignore: ingore files generated by Kbuild

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, \#*#

---

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(-)
.gitignore +20 -9
index d7d5538..b613586 100644
@@ -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
+*~
+\#*#
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH v8 2/38 Makefile.host.tmp: add a new script to refactor tools

In reply to Masahiro Yamada

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.

---

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
scripts/Makefile.build +14 -3
index e3354aa..c451fbf 100644
@@ -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
scripts/Makefile.host.tmp new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#3 lore raw

PATCH v8 3/38 tools: convert makefiles to kbuild style

In reply to Masahiro Yamada

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

---

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
Makefile +11 -7
index 1687e2e..a1e2810 100644
@@ -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 $@ [email protected] && rm -f [email protected] || mv -f [email protected] $@
 
 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				  \
config.mk +1 -27
index 60e297a..07afb35 100644
@@ -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
 
rules.mk +0 -5
index f4510b7..b36de4d 100644
@@ -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
-
 #########################################################################
spl/Makefile +3 -1
index 4143e38..d5164e0 100644
@@ -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)
tools/.gitignore +1 -1
index cd2f041..13283b7 100644
@@ -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
tools/Makefile +104 -234

376 lines not on this page · raw message

tools/crc32.c new file +1 -0
new file mode 100644
index 0000000..aed7112
@@ -0,0 +1 @@
+#include "../lib/crc32.c"
tools/easylogo/Makefile +2 -10
index d8e28b0..10aba2b 100644
@@ -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)
tools/env/Makefile +7 -25
index 27892f7..c303815 100644
@@ -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
tools/env/crc32.c new file +1 -0
new file mode 100644
index 0000000..34f8178
@@ -0,0 +1 @@
+#include "../../lib/crc32.c"
tools/env/ctype.c new file +1 -0
new file mode 100644
index 0000000..21050e9
@@ -0,0 +1 @@
+#include "../../lib/ctype.c"
tools/env/env_attr.c new file +1 -0
new file mode 100644
index 0000000..502d4c9
@@ -0,0 +1 @@
+#include "../../common/env_attr.c"
tools/env/env_flags.c new file +1 -0
new file mode 100644
index 0000000..b261cb8
@@ -0,0 +1 @@
+#include "../../common/env_flags.c"
tools/env/linux_string.c new file +1 -0
new file mode 100644
index 0000000..6c01add
@@ -0,0 +1 @@
+#include "../../lib/linux_string.c"
tools/env_embedded.c new file +1 -0
new file mode 100644
index 0000000..59a6357
@@ -0,0 +1 @@
+#include "../common/env_embedded.c"
tools/fdt.c new file +1 -0
new file mode 100644
index 0000000..1eafc56
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt.c"
tools/fdt_ro.c new file +1 -0
new file mode 100644
index 0000000..9005fe3
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_ro.c"
tools/fdt_rw.c new file +1 -0
new file mode 100644
index 0000000..adc3fdf
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_rw.c"
tools/fdt_strerror.c new file +1 -0
new file mode 100644
index 0000000..d0b5822
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_strerror.c"
tools/fdt_wip.c new file +1 -0
new file mode 100644
index 0000000..7810f07
@@ -0,0 +1 @@
+#include "../lib/libfdt/fdt_wip.c"
tools/gdb/Makefile +6 -37

55 lines not on this page · raw message

tools/image-fit.c new file +1 -0
new file mode 100644
index 0000000..037e5cc
@@ -0,0 +1 @@
+#include "../common/image-fit.c"
tools/image-sig.c new file +1 -0
new file mode 100644
index 0000000..e45419f
@@ -0,0 +1 @@
+#include "../common/image-sig.c"
tools/image.c new file +1 -0
new file mode 100644
index 0000000..0f9bacc
@@ -0,0 +1 @@
+#include "../common/image.c"
tools/kernel-doc/Makefile +3 -18
index eb56e2e..f15a4b7 100644
@@ -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
tools/md5.c new file +1 -0
new file mode 100644
index 0000000..befaa32
@@ -0,0 +1 @@
+#include "../lib/md5.c"
tools/rsa-sign.c new file +1 -0
new file mode 100644
index 0000000..150bbe1
@@ -0,0 +1 @@
+#include "../lib/rsa/rsa-sign.c"
tools/sha1.c new file +1 -0
new file mode 100644
index 0000000..0d717df
@@ -0,0 +1 @@
+#include "../lib/sha1.c"
Signature · 1 line
1.8.3.2
#4 lore raw

PATCH v8 4/38 board: samsung: refactor host programs

In reply to Masahiro Yamada

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

---

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%)
Makefile +1 -0
index a1e2810..8c585b6 100644
@@ -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
board/samsung/origen/Makefile +10 -10
index e8818bf..31e88f4 100644
@@ -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
board/samsung/origen/tools/mkorigenspl.c renamed from board/samsung/origen/tools/mkv310_image.c +0 -0
similarity index 100%
rename from board/samsung/origen/tools/mkv310_image.c
rename to board/samsung/origen/tools/mkorigenspl.c
board/samsung/smdkv310/Makefile +4 -11
index dbc621b..9e37b4e 100644
@@ -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
board/samsung/smdkv310/tools/mksmdkv310spl.c renamed from board/samsung/smdkv310/tools/mkv310_image.c +0 -0
similarity index 100%
rename from board/samsung/smdkv310/tools/mkv310_image.c
rename to board/samsung/smdkv310/tools/mksmdkv310spl.c
spl/Makefile +2 -2
index d5164e0..e76b2b4 100644
@@ -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
 
Signature · 1 line
1.8.3.2
#5 lore raw

PATCH v8 5/38 examples: Use scripts/Makefile.build

In reply to Masahiro Yamada

---

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(-)
Makefile +1 -4
index 8c585b6..b10d3b1 100644
@@ -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
examples/api/Makefile +5 -16
index cad10a3..f770859 100644
@@ -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
-
-#########################################################################
examples/standalone/Makefile +14 -32

81 lines not on this page · raw message

scripts/Makefile.build +4 -3
index c451fbf..50c0394 100644
@@ -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)),)
Signature · 1 line
1.8.3.2
#6 lore raw

PATCH v8 6/38 nand-spl: Use scripts/Makefile.build

In reply to Masahiro Yamada

---

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(-)
Makefile +1 -1
index b10d3b1..5204ab4 100644
@@ -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
nand_spl/board/amcc/acadia/Makefile +0 -8
index 022a205..3b00d49 100644
@@ -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
-
-#########################################################################
nand_spl/board/amcc/bamboo/Makefile +0 -8
index d413a48..4063274 100644
@@ -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
-
-#########################################################################
nand_spl/board/amcc/canyonlands/Makefile +0 -8
index b2ef03f..13c8b36 100644
@@ -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
-
-#########################################################################
nand_spl/board/amcc/kilauea/Makefile +0 -8
index 5899b9e..9d07147 100644
@@ -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
-
-#########################################################################
nand_spl/board/amcc/sequoia/Makefile +0 -8
index fea6c4e..111bb0d 100644
@@ -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
-
-#########################################################################
nand_spl/board/freescale/mpc8315erdb/Makefile +0 -10
index c49a6e0..7813823 100644
@@ -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
-
-#########################################################################
nand_spl/board/freescale/mpc8536ds/Makefile +0 -10
index 6233081..5d9953b 100644
@@ -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
-
-#########################################################################
nand_spl/board/freescale/mpc8569mds/Makefile +0 -10
index 6233081..5d9953b 100644
@@ -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
-
-#########################################################################
nand_spl/board/freescale/mpc8572ds/Makefile +0 -10
index 6233081..5d9953b 100644
@@ -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
-
-#########################################################################
nand_spl/board/freescale/p1023rds/Makefile +1 -10
index dbdfa19..652590d 100644
@@ -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
-
-#########################################################################
nand_spl/board/freescale/p1_p2_rdb/Makefile +0 -10
index 6233081..5d9953b 100644
@@ -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
-
-#########################################################################
nand_spl/board/sheldon/simpc8313/Makefile +0 -11
index 90f132c..5e83abc 100644
@@ -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
-
-#########################################################################
Signature · 1 line
1.8.3.2
#7 lore raw

PATCH v8 7/38 Makfile: move suffix rules to Makefile.build

In reply to Masahiro Yamada

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.

---

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(-)
config.mk +0 -35
index 07afb35..b08be7a 100644
@@ -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 $@ )
-
-#########################################################################
examples/api/Makefile +2 -2
index f770859..52f4368 100644
@@ -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 $@ $<
post/lib_powerpc/fpu/Makefile +1 -1
index ae56a82..a7aa5bc 100644
@@ -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 [email protected] $< -c
 	$(OBJCOPY) -R .gnu.attributes [email protected] $@
 	rm -f [email protected]
scripts/Makefile.build +31 -0
index 50c0394..1b3d77f 100644
@@ -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
Signature · 1 line
1.8.3.2
#8 lore raw

PATCH v8 8/38 Makefile: move some variable definitions to the top Makefile

In reply to Masahiro Yamada

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.

---

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(-)
Makefile +81 -13
index 5204ab4..0c1eef3 100644
@@ -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
config.mk +3 -75

106 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#9 lore raw

PATCH v8 9/38 Makefile: move BFD_ROOT_DIR to tools/gdb/Makefile

In reply to Masahiro Yamada

BFD_ROOT_DIR is used only in tools/gdb/Makefile

---

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(-)
config.mk +0 -23
index 74617d3..dfe81fa 100644
@@ -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
tools/gdb/Makefile +21 -0
index 850bb9b..4513320 100644
@@ -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
 #
Signature · 1 line
1.8.3.2
#10 lore raw

PATCH v8 10/38 kbuild: import Kbuild.include from linux v3.13 tag

In reply to Masahiro Yamada

---

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
scripts/Kbuild.include new file +278 -0
new file mode 100644
index 0000000..547e15d
@@ -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)) < $< > [email protected];		\
+	if [ -r $@ ] && cmp -s $@ [email protected]; then	\
+		rm -f [email protected];			\
+	else					\
+		$(kecho) '  UPD     $@';	\
+		mv -f [email protected] $@;		\
+	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
Signature · 1 line
1.8.3.2
#11 lore raw

PATCH v8 11/38 kbuild: Use Kbuild.include

In reply to Masahiro Yamada

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.

---

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(-)
Makefile +6 -3
index 0c1eef3..e4045bc 100644
@@ -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
config.mk +0 -29
index dfe81fa..ba42641 100644
@@ -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)
scripts/Kbuild.include +7 -1
index 547e15d..ca5fd56 100644
@@ -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=
scripts/Makefile.build +1 -0
index 1b3d77f..7789efa 100644
@@ -2,6 +2,7 @@
 .PHONY: all
 all:
 
+include $(srctree)/scripts/Kbuild.include
 include $(TOPDIR)/config.mk
 
 # variable LIB is used in examples/standalone/Makefile
spl/Makefile +2 -2
index e76b2b4..736acd7 100644
@@ -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.
Signature · 1 line
1.8.3.2
#12 lore raw

PATCH v8 12/38 Makefile: move more flags to the top Makefile

In reply to Masahiro Yamada

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.

---

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(-)
Makefile +35 -0
index e4045bc..3a97483 100644
@@ -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
 
config.mk +4 -37

67 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#13 lore raw

PATCH v8 13/38 Makefile: refactor include path settings

In reply to Masahiro Yamada

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

---

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(-)
Makefile +13 -1
index 3a97483..9c39022 100644
@@ -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)
 
config.mk +2 -9
index 04b63f6..f700ee1 100644
@@ -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)
 
tools/Makefile +3 -5
index c3cdaf0..21341b7 100644
@@ -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 \
tools/env/Makefile +1 -3
index c303815..d47fe16 100644
@@ -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)
Signature · 1 line
1.8.3.2
#14 lore raw

PATCH v8 14/38 Makefile: move more stuff to top Makefile

In reply to Masahiro Yamada

---

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(-)
Makefile +17 -3
index 9c39022..b24b425 100644
@@ -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
 
config.mk +1 -18
index f700ee1..54d1d8b 100644
@@ -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
Signature · 1 line
1.8.3.2
#15 lore raw

PATCH v8 15/38 Makefile: move some flags to spl/Makefile

In reply to Masahiro Yamada

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

---

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(-)
config.mk +0 -19
index 54d1d8b..597a566 100644
@@ -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
spl/Makefile +14 -0
index 736acd7..001205b 100644
@@ -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) \
Signature · 1 line
1.8.3.2
#16 lore raw

PATCH v8 16/38 Makefile: move some flags to examples makefiles

In reply to Masahiro Yamada

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

---

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(-)
config.mk +0 -8
index 597a566..ed1a519 100644
@@ -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)
examples/api/Makefile +4 -0
index 52f4368..ee3c487 100644
@@ -4,6 +4,10 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+ifdef FTRACE
+CFLAGS += -finstrument-functions -DFTRACE
+endif
+
 ifeq ($(ARCH),powerpc)
 LOAD_ADDR = 0x40000
 endif
examples/standalone/Makefile +4 -0
index cad4409..1f8d70c 100644
@@ -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
Signature · 1 line
1.8.3.2
#17 lore raw

PATCH v8 17/38 kbuild: change out-of-tree build

In reply to Masahiro Yamada

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.

---

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(-)
MAKEALL +4 -2
index 562071a..01d0598 100755
@@ -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
 
Makefile +298 -271

903 lines not on this page · raw message

arch/arm/cpu/arm1136/config.mk +1 -1
index f74228c..ab1fc4a 100644
@@ -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
arch/arm/cpu/arm926ejs/config.mk +1 -1
index 4d9895f..f27ca15 100644
@@ -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
arch/arm/cpu/arm926ejs/davinci/config.mk +1 -1
index d5c978b..69e9d5a 100644
@@ -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
arch/arm/cpu/armv7/am33xx/config.mk +1 -1
index 8e3668f..1c06fb4 100644
@@ -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
arch/arm/cpu/armv7/config.mk +1 -1
index 38b7c40..d01f3d9 100644
@@ -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
arch/arm/cpu/armv7/omap3/config.mk +1 -1
index 1d6a57c..2a3d1c5 100644
@@ -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
arch/arm/cpu/armv7/omap4/config.mk +1 -1
index 1d6a57c..2a3d1c5 100644
@@ -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
arch/arm/cpu/armv7/omap5/config.mk +1 -1
index 2673af9..261b272 100644
@@ -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
arch/arm/cpu/armv7/socfpga/config.mk +1 -1
index d33ab7d..3d18491 100644
@@ -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
arch/blackfin/config.mk +5 -5
index 73fa798..c752025 100644
@@ -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
arch/blackfin/cpu/Makefile +4 -4
index a61594a..369dc74 100644
@@ -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 $@
arch/mips/cpu/mips32/config.mk +1 -1
index 067f871..7ee7faa 100644
@@ -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
arch/mips/cpu/mips64/config.mk +1 -1
index d1a8b2c..02113a1 100644
@@ -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
arch/mips/cpu/xburst/config.mk +1 -1
index d81da21..00b0fd9 100644
@@ -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
arch/nds32/config.mk +1 -1
index e93e3a8..550f8a4 100644
@@ -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
arch/powerpc/lib/Makefile +2 -2
index a706d3c..ac780d4 100644
@@ -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
arch/sandbox/cpu/Makefile +2 -2
index b564294..c5f5426 100644
@@ -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)))
arch/sparc/config.mk +2 -1
index e94e7cb..9bb3724 100644
@@ -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__
arch/x86/lib/Makefile +1 -1
index 638f790..a35d062 100644
@@ -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_
board/ait/cam_enc_4xx/config.mk +1 -1
index d7e7894..c7cfaca 100644
@@ -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
board/avionic-design/medcom-wide/Makefile +1 -1
index 87e1912..bcf7ccf 100644
@@ -9,4 +9,4 @@
 
 obj-y	:= ../common/tamonten.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
board/avionic-design/plutux/Makefile +1 -1
index 87e1912..bcf7ccf 100644
@@ -9,4 +9,4 @@
 
 obj-y	:= ../common/tamonten.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
board/avionic-design/tec-ng/Makefile +1 -1
index 79d8602..a556b92 100644
@@ -7,4 +7,4 @@
 
 obj-y	:= ../common/tamonten-ng.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
board/avionic-design/tec/Makefile +1 -1
index 87e1912..bcf7ccf 100644
@@ -9,4 +9,4 @@
 
 obj-y	:= ../common/tamonten.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
board/compal/paz00/Makefile +1 -1
index b2d3b6b..e6a0b29 100644
@@ -16,4 +16,4 @@
 
 obj-y	:= paz00.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
board/compulab/trimslice/Makefile +1 -1
index f3bd00d..311eb92 100644
@@ -7,4 +7,4 @@
 
 obj-y	:= trimslice.o
 
-include ../../nvidia/common/common.mk
+include $(srctree)/board/nvidia/common/common.mk
board/cray/L1/Makefile +4 -4
index 5f6c690..6aae9fa 100644
@@ -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 $< $@
board/h2200/Makefile +1 -1
index d4fa153..e516e91 100644
@@ -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 $< $@
board/matrix_vision/mvblm7/Makefile +2 -2
index 879d794..1bc1d61 100644
@@ -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 $< $@
board/matrix_vision/mvsmr/Makefile +1 -1
index b6a4f67..9454259 100644
@@ -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 $< $@
board/nvidia/common/Makefile +1 -1
index e3fcf2b..e3b2651 100644
@@ -1,4 +1,4 @@
 # Copyright (c) 2011 The Chromium OS Authors.
 # SPDX-License-Identifier:	GPL-2.0+
 
-include common.mk
+include $(src)/common.mk
board/pcs440ep/config.mk +1 -1
index 1e76128..b90d5d0 100644
@@ -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
 
board/samsung/origen/Makefile +1 -1
index 31e88f4..37acba7 100644
@@ -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
common/Makefile +4 -5
index 4d99ecd..a292ee8 100644
@@ -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)
config.mk +3 -39

59 lines not on this page · raw message

doc/DocBook/Makefile +2 -4
index 29b79d7..aa7c44b 100644
@@ -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 $@
 
drivers/bios_emulator/Makefile +1 -1
index 52a2ceb..330f36f 100644
@@ -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)
dts/Makefile +3 -3
index 6c7198f..d81f32d 100644
@@ -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
examples/api/Makefile +8 -8
index ee3c487..db0bb34 100644
@@ -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 $@ $<
examples/standalone/Makefile +7 -7
index 1f8d70c..a6819f7 100644
@@ -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
fs/ubifs/Makefile +1 -1
index 389b0e3..5682b16 100644
@@ -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)
lib/Makefile +1 -1
index 760340f..43b13d0 100644
@@ -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)
mkconfig +1 -1
index b96c81f..5f516f2 100755
@@ -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
nand_spl/board/amcc/acadia/Makefile +11 -19
index 3b00d49..041213f 100644
@@ -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 $@ $<
nand_spl/board/amcc/bamboo/Makefile +8 -22
index 4063274..92b604e 100644
@@ -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 $@ $<
nand_spl/board/amcc/canyonlands/Makefile +8 -22
index 13c8b36..9a730e9 100644
@@ -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 $@ $<
nand_spl/board/amcc/kilauea/Makefile +10 -18
index 9d07147..1c5498c 100644
@@ -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 $@ $<
nand_spl/board/amcc/sequoia/Makefile +12 -20
index 111bb0d..62131ab 100644
@@ -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 $@ $<
nand_spl/board/freescale/mpc8315erdb/Makefile +11 -19
index 7813823..a2054ee 100644
@@ -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 $@ $<
nand_spl/board/freescale/mpc8536ds/Makefile +14 -28

86 lines not on this page · raw message

nand_spl/board/freescale/mpc8569mds/Makefile +14 -28

86 lines not on this page · raw message

nand_spl/board/freescale/mpc8572ds/Makefile +14 -28

86 lines not on this page · raw message

nand_spl/board/freescale/p1023rds/Makefile +14 -28

86 lines not on this page · raw message

nand_spl/board/freescale/p1_p2_rdb/Makefile +14 -28

86 lines not on this page · raw message

nand_spl/board/sheldon/simpc8313/Makefile +11 -19
index 5e83abc..ca45ecd 100644
@@ -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 $@ $<
post/lib_powerpc/fpu/Makefile +1 -1
index a7aa5bc..c720a26 100644
@@ -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 [email protected] $< -c
 	$(OBJCOPY) -R .gnu.attributes [email protected] $@
 	rm -f [email protected]
rules.mk +10 -9
index b36de4d..e4fd337 100644
@@ -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)
 
 #########################################################################
scripts/Kbuild.include +1 -3
index ca5fd56..6113c13 100644
@@ -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=
scripts/Makefile.build +37 -20

121 lines not on this page · raw message

scripts/Makefile.host.tmp +9 -9
index 4b57846..53fe930 100644
@@ -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)
spl/Makefile +24 -25

111 lines not on this page · raw message

tools/Makefile +9 -9
index 21341b7..9b19dcb 100644
@@ -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) > $@
Signature · 1 line
1.8.3.2
#18 lore raw

PATCH v8 18/38 kbuild: add dummy obj-y to create built-in.o

In reply to Masahiro Yamada

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.

---

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(-)
arch/arm/cpu/armv7/tegra114/Makefile +2 -1
index 886b509..77e2319 100644
@@ -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
arch/arm/cpu/armv7/tegra30/Makefile +2 -1
index 518d6d1..413eba1 100644
@@ -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
arch/nds32/cpu/n1213/Makefile +3 -0
index bb3550e..206d304 100644
@@ -9,4 +9,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+# necessary to create built-in.o
+obj- := __dummy__.o
+
 extra-y	= start.o
board/freescale/common/Makefile +4 -1
index 25f063d..f6a0879 100644
@@ -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
board/samsung/origen/Makefile +3 -0
index 37acba7..1add9fe 100644
@@ -5,6 +5,9 @@
 #
 
 ifdef CONFIG_SPL_BUILD
+# necessary to create built-in.o
+obj- := __dummy__.o
+
 hostprogs-y := tools/mkorigenspl
 always := $(hostprogs-y)
 
board/samsung/smdkv310/Makefile +3 -0
index 9e37b4e..de0da16 100644
@@ -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
board/spear/common/Makefile +4 -1
index 08dc09f..b0ba320 100644
@@ -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
board/spear/x600/Makefile +4 -1
index f9053fe..18d3dd2 100644
@@ -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
Signature · 1 line
1.8.3.2
#19 lore raw

PATCH v8 19/38 Makefile: rename scripts/Makefile.build to scripts/Makefile.build.tmp

In reply to Masahiro Yamada

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.

---

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%)
scripts/Kbuild.include +1 -1
index 6113c13..30a5551 100644
@@ -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=
scripts/Makefile.build.tmp renamed from scripts/Makefile.build +0 -0
similarity index 100%
rename from scripts/Makefile.build
rename to scripts/Makefile.build.tmp
Signature · 1 line
1.8.3.2
#20 lore raw

PATCH v8 20/38 kbuild: import more build scripts from Linux v3.13 tag

In reply to Masahiro Yamada

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.

---

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
scripts/Makefile.build new file +479 -0
new file mode 100644
index 0000000..d5d859c
@@ -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)
scripts/Makefile.clean new file +104 -0

104 lines not on this page · raw message

scripts/Makefile.host new file +170 -0

170 lines not on this page · raw message

scripts/Makefile.lib new file +373 -0

373 lines not on this page · raw message

scripts/basic/.gitignore new file +1 -0
new file mode 100644
index 0000000..a776371
@@ -0,0 +1 @@
+fixdep
scripts/basic/Makefile new file +15 -0
new file mode 100644
index 0000000..4fcef87
@@ -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
scripts/basic/fixdep.c new file +462 -0

462 lines not on this page · raw message

scripts/mkmakefile new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#21 lore raw

PATCH v8 21/38 kbuild: use Linux Kernel build scripts

In reply to Masahiro Yamada

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.

---

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(-)
Makefile +200 -39
index 1409c8b..4f00f08 100644
@@ -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 > [email protected] && \
+	$(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > [email protected] && \
 		sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
 	rm [email protected]
 
@@ -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 > [email protected] && \
 		sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
 	rm [email protected]
@@ -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 > [email protected] && \
+	$(CPP) $(c_flags) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > [email protected] && \
 		sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
 	rm [email protected]
 
@@ -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 $@ [email protected] && rm -f [email protected] || mv -f [email protected] $@
 
 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
 
arch/arm/imx-common/Makefile +1 -1
index ee5c872..9dda59d 100644
@@ -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 \
arch/blackfin/cpu/Makefile +2 -3
index 369dc74..dd4d2d1 100644
@@ -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 $@
arch/blackfin/lib/Makefile +4 -1
index a5c552f..4ba7bf6 100644
@@ -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
arch/m68k/cpu/mcf5227x/Makefile +1 -1
index a47fd56..e0c5db6 100644
@@ -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
arch/m68k/cpu/mcf523x/Makefile +1 -1
index a47fd56..e0c5db6 100644
@@ -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
arch/m68k/cpu/mcf52x2/Makefile +1 -1
index d9bf900..b92fd86 100644
@@ -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
arch/m68k/cpu/mcf532x/Makefile +1 -1
index 97aa3f1..9c53c50 100644
@@ -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
arch/m68k/cpu/mcf5445x/Makefile +1 -1
index b506719..9be91ed 100644
@@ -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
arch/m68k/cpu/mcf547x_8x/Makefile +1 -1
index 0fa50bf..4f82099 100644
@@ -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
arch/powerpc/cpu/mpc8xx/Makefile +1 -1
index d40bdab..f83fd5e 100644
@@ -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
arch/powerpc/lib/Makefile +2 -2
index ac780d4..e6d8be5 100644
@@ -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
arch/sandbox/cpu/Makefile +7 -4
index c5f5426..63deded 100644
@@ -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)
board/bct-brettl2/config.mk +4 -3
index f1ef9bf..0d3df2d 100644
@@ -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
board/bf518f-ezbrd/config.mk +4 -3
index f1ef9bf..0d3df2d 100644
@@ -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
board/bf526-ezbrd/config.mk +4 -3
index f1ef9bf..0d3df2d 100644
@@ -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
board/bf527-ad7160-eval/config.mk +4 -3
index f1ef9bf..0d3df2d 100644
@@ -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
board/bf527-ezkit/config.mk +4 -3
index f1ef9bf..0d3df2d 100644
@@ -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
board/bf527-sdp/config.mk +4 -3
index 5f327a9..af299f5 100644
@@ -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
board/bf533-ezkit/config.mk +4 -3
index 973d357..97eaafe 100644
@@ -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
board/bf533-stamp/config.mk +4 -3
index 973d357..97eaafe 100644
@@ -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
board/bf537-stamp/config.mk +4 -3
index ae2ea0b..bc0e747 100644
@@ -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
board/bf538f-ezkit/config.mk +4 -3
index 973d357..97eaafe 100644
@@ -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
board/bf548-ezkit/config.mk +4 -3
index ad3a729..8d2c60f 100644
@@ -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
board/bf561-acvilon/config.mk +4 -3
index c33aef9..ce94715 100644
@@ -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
board/bf561-ezkit/config.mk +4 -3
index c33aef9..ce94715 100644
@@ -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
board/br4/config.mk +4 -3
index 5c18d5c..2436ec0 100644
@@ -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
board/cm-bf527/config.mk +4 -3
index f1ef9bf..0d3df2d 100644
@@ -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
board/cm-bf533/config.mk +4 -3
index 973d357..97eaafe 100644
@@ -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
board/cm-bf537e/config.mk +4 -3
index 973d357..97eaafe 100644
@@ -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
board/cm-bf537u/config.mk +4 -3
index 973d357..97eaafe 100644
@@ -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
board/cm-bf548/config.mk +4 -3
index c005afb..289c8a4 100644
@@ -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
board/cm-bf561/config.mk +4 -3
index c33aef9..ce94715 100644
@@ -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
board/ip04/config.mk +4 -3
index ae2ea0b..bc0e747 100644
@@ -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
board/matrix_vision/mvblx/Makefile +1 -1
index c6c0933..c056eba 100644
@@ -8,4 +8,4 @@
 obj-y += mvblx.o fpga.o
 obj-$(CONFIG_ID_EEPROM) += sys_eeprom.o
 
-CFLAGS += -Werror
+ccflags-y += -Werror
board/pr1/config.mk +4 -3
index 5c18d5c..2436ec0 100644
@@ -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
board/sandburst/karef/Makefile +1 -1
index f890008..d5a9b34 100644
@@ -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
board/sandburst/metrobox/Makefile +1 -1
index 37d91a5..8121cce 100644
@@ -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
board/st-ericsson/snowball/Makefile +1 -1
index 6867a70..f0605e2 100644
@@ -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
board/st-ericsson/u8500/Makefile +1 -1
index b9dfbe9..d6c4280 100644
@@ -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
board/tcm-bf518/config.mk +4 -3
index f1ef9bf..0d3df2d 100644
@@ -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
board/tcm-bf537/config.mk +4 -3
index 973d357..97eaafe 100644
@@ -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
common/Makefile +3 -7
index a292ee8..9c90722 100644
@@ -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)
config.mk +2 -11
index 0fa3167..1336ef8 100644
@@ -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
disk/Makefile +1 -1
index 48abec8..6970cec 100644
@@ -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
doc/DocBook/Makefile +37 -30

140 lines not on this page · raw message

drivers/bios_emulator/Makefile +1 -4
index 330f36f..e56356e 100644
@@ -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)
drivers/hwmon/Makefile +1 -1
index a78a724..25b8e8a 100644
@@ -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
drivers/net/npe/Makefile +1 -3
index 0779255..ff554cf 100644
@@ -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 \
drivers/rtc/Makefile +1 -1
index d5a2725..003d322 100644
@@ -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
drivers/usb/musb-new/Makefile +3 -4
index ba72348..3facf0f 100644
@@ -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)
dts/Makefile +1 -1
index d81f32d..cc6ecf6 100644
@@ -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.
examples/api/Makefile +5 -10
index db0bb34..8b79886 100644
@@ -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)
examples/standalone/Makefile +13 -9
index a6819f7..90e173b 100644
@@ -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)
fs/ubifs/Makefile +1 -1
index 5682b16..6b1a9a5 100644
@@ -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)
fs/yaffs2/Makefile +3 -6
index d811287..45ff745 100644
@@ -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
lib/Makefile +1 -1
index 43b13d0..8c483c9 100644
@@ -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)
lib/lzma/Makefile +1 -1
index f8eda06..b6c8067 100644
@@ -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
nand_spl/board/amcc/acadia/Makefile +5 -4
index 041213f..d256abf 100644
@@ -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
 
nand_spl/board/amcc/bamboo/Makefile +5 -4
index 92b604e..4f36d6c 100644
@@ -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
 
nand_spl/board/amcc/canyonlands/Makefile +5 -4
index 9a730e9..5c9c8e8 100644
@@ -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
 
nand_spl/board/amcc/kilauea/Makefile +5 -4
index 1c5498c..cfe3082 100644
@@ -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
 
nand_spl/board/amcc/sequoia/Makefile +5 -4
index 62131ab..de02886 100644
@@ -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
 
nand_spl/board/freescale/mpc8315erdb/Makefile +5 -4
index a2054ee..a685674 100644
@@ -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
 
nand_spl/board/freescale/mpc8536ds/Makefile +5 -4
index f711cf3..f0beaed 100644
@@ -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
nand_spl/board/freescale/mpc8569mds/Makefile +5 -4
index f711cf3..f0beaed 100644
@@ -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
nand_spl/board/freescale/mpc8572ds/Makefile +5 -4
index f711cf3..f0beaed 100644
@@ -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
nand_spl/board/freescale/p1023rds/Makefile +5 -4
index 21a6920..3918ac5 100644
@@ -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
nand_spl/board/freescale/p1_p2_rdb/Makefile +5 -4
index f711cf3..f0beaed 100644
@@ -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
nand_spl/board/sheldon/simpc8313/Makefile +5 -4
index ca45ecd..35b1f97 100644
@@ -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
 
net/Makefile +1 -1
index 31aadc2..9425950 100644
@@ -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
post/lib_powerpc/fpu/Makefile +14 -15
index c720a26..556a833 100644
@@ -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 [email protected] $< -c
-	$(OBJCOPY) -R .gnu.attributes [email protected] $@
-	rm -f [email protected]
+# 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)
scripts/Kbuild.include +1 -1
index 30a5551..6113c13 100644
@@ -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=
scripts/Makefile.build +18 -3
index d5d859c..921fbbf 100644
@@ -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)
scripts/Makefile.lib +8 -6
index 49392ec..d4b5cb5 100644
@@ -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)
spl/Makefile +15 -12
index 3950df2..e2728fd 100644
@@ -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)
tools/Makefile +9 -14
index 9b19dcb..70a3fc2 100644
@@ -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
 
Signature · 1 line
1.8.3.2
#22 lore raw

PATCH v8 22/38 kbuild: delete temporary build scripts

In reply to Masahiro Yamada

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

---

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
rules.mk deleted +0 -47
deleted file mode 100644
index e4fd337..0000000
@@ -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)
-
-#########################################################################
scripts/Makefile.build.tmp deleted +0 -127

127 lines not on this page · raw message

scripts/Makefile.host.tmp deleted +0 -61

61 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#23 lore raw

PATCH v8 23/38 kbuild: move some lines to more suitable place

In reply to Masahiro Yamada

---

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(-)
Makefile +33 -33
index 4f00f08..baa7b3d 100644
@@ -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
Signature · 1 line
1.8.3.2
#24 lore raw

PATCH v8 24/38 kbuild: convert some make rules to Kbuild style

In reply to Masahiro Yamada

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.

---

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(-)
Makefile +43 -34
index baa7b3d..7af404a 100644
@@ -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 > [email protected] && \
-		sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
+	sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
 	rm [email protected]
 
+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 > [email protected] && \
 		sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
 	rm [email protected]
 
-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 > [email protected] && \
 		sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
 	rm [email protected]
 
+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 \
Signature · 1 line
1.8.3.2
#25 lore raw

PATCH v8 25/38 kbuild: move include directives of board configuration files

In reply to Masahiro Yamada

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

---

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(-)
config.mk +0 -15
index 1336ef8..5b886aa 100644
@@ -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
scripts/Makefile.build +11 -0
index 921fbbf..f37957f 100644
@@ -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:
spl/Makefile +8 -0
index e2728fd..65fd42e 100644
@@ -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
Signature · 1 line
1.8.3.2
#26 lore raw

PATCH v8 26/38 kbuild: generate {spl, tpl}-autoconf.mk only when it is necessary

In reply to Masahiro Yamada

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.

---

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(-)
Makefile +0 -23
index 7af404a..1611957 100644
@@ -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 > [email protected] && \
-		sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
-	rm [email protected]
-
-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 > [email protected] && \
-		sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
-	rm [email protected]
-
-include/spl-autoconf.mk: include/config.h
-	$(call cmd,spl-autoconf)
-
 quiet_cmd_offsets = GEN     $@
       cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@
 
spl/Makefile +16 -0
index 65fd42e..48eec65 100644
@@ -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 > [email protected] && \
+		sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
+	rm [email protected]
+
+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
Signature · 1 line
1.8.3.2
#27 lore raw

PATCH v8 27/38 Makefile: remove a cleaning target "tidy"

In reply to Masahiro Yamada

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

---

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(-)
.gitignore +0 -1
index b613586..24019b3 100644
@@ -61,7 +61,6 @@
 # Generated files
 #
 
-*.depend*
 /LOG
 /errlog
 /reloc_off
MAKEALL +1 -1
index 01d0598..27147ff 100755
@@ -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}
Makefile +2 -6
index 1611957..ac7dccd 100644
@@ -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
Signature · 1 line
1.8.3.2
#28 lore raw

PATCH v8 28/38 kbuild: change the top Makefile to more Kbuild-ish structure

In reply to Masahiro Yamada

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.

---

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(-)
Makefile +166 -121
index ac7dccd..2f273b9 100644
@@ -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 > [email protected] && \
+	sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
+	rm [email protected]
+
+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 > [email protected] && \
-	sed -n -f $(srctree)/tools/scripts/define2mk.sed [email protected] > $@; \
-	rm [email protected]
-
-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
Signature · 1 line
1.8.3.2
#29 lore raw

PATCH v8 29/38 examples: move api/ and standalone/ entry to examples/Makefile

In reply to Masahiro Yamada

---

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
Makefile +1 -4
index 2f273b9..32642aa 100644
@@ -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)
examples/Makefile new file +9 -0
new file mode 100644
index 0000000..18d008e
@@ -0,0 +1,9 @@
+ifndef CONFIG_SANDBOX
+
+ifdef FTRACE
+subdir-ccflags-y += -finstrument-functions -DFTRACE
+endif
+
+subdir-y += standalone
+subdir-$(CONFIG_API) += api
+endif
examples/api/Makefile +0 -4
index 8b79886..09475f8 100644
@@ -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
examples/standalone/Makefile +0 -4
index 90e173b..47c9d54 100644
@@ -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
Signature · 1 line
1.8.3.2
#30 lore raw

PATCH v8 30/38 kbuild: refactor Makefile and spl/Makefile more

In reply to Masahiro Yamada

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.

---

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(-)
Makefile +85 -80
index 32642aa..2e28fba 100644
@@ -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
spl/Makefile +55 -56

140 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#31 lore raw

PATCH v8 31/38 Makefile: Do not pass MTD_VERSION from the top Makefile

In reply to Masahiro Yamada

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

---

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(-)
Makefile +1 -1
index 2e28fba..1ac6399 100644
@@ -1094,7 +1094,7 @@ $(TIMESTAMP_FILE):
 		@cmp -s $@ [email protected] && rm -f [email protected] || mv -f [email protected] $@
 
 easylogo env gdb:
-	$(Q)$(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION}
+	$(Q)$(MAKE) $(build)=tools/$@
 
 gdbtools: gdb
 
Signature · 1 line
1.8.3.2
#32 lore raw

PATCH v8 32/38 Makefile: refactor tools-all targets

In reply to Masahiro Yamada

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

---

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(-)
Makefile +3 -5
index 1ac6399..42d9639 100644
@@ -1093,16 +1093,14 @@ $(TIMESTAMP_FILE):
 		@LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> [email protected]
 		@cmp -s $@ [email protected] && rm -f [email protected] || mv -f [email protected] $@
 
-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:
tools/Makefile +7 -1
index 70a3fc2..783e643 100644
@@ -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
Signature · 1 line
1.8.3.2
#33 lore raw

PATCH v8 33/38 kbuild: use scripts/Makefile.clean

In reply to Masahiro Yamada

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.

---

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
Makefile +106 -82
index 42d9639..0bb1f96 100644
@@ -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
arch/blackfin/cpu/Makefile +1 -0
index dd4d2d1..426292f 100644
@@ -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
board/cray/L1/Makefile +2 -0
index 6aae9fa..63f43da 100644
@@ -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
dts/Makefile +6 -6
index cc6ecf6..1e7609a 100644
@@ -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'
scripts/Makefile new file +2 -0
new file mode 100644
index 0000000..ebbadc9
@@ -0,0 +1,2 @@
+# Let clean descend into subdirs
+subdir-	+= basic
scripts/Makefile.clean +4 -0
index 686cb0d..5cd0f51 100644
@@ -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
 
Signature · 1 line
1.8.3.2
#34 lore raw

PATCH v8 34/38 kbuild: support simultaneous board configuration and "make all"

In reply to Masahiro Yamada

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

---

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(-)
Makefile +10 -2
index 0bb1f96..6ae16d0 100644
@@ -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)
Signature · 1 line
1.8.3.2
#35 lore raw

PATCH v8 35/38 kbuild: check clean source and generate Makefile for out-of-tree build

In reply to Masahiro Yamada

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

---

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(-)
Makefile +57 -6
index 6ae16d0..21274be 100644
@@ -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)
Signature · 1 line
1.8.3.2
#36 lore raw

PATCH v8 36/38 board: sandburst: delete FORCEBUILD

In reply to Masahiro Yamada

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

---

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(-)
board/sandburst/karef/Makefile +1 -5
index d5a9b34..ce29b41 100644
@@ -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
board/sandburst/metrobox/Makefile +1 -5
index 8121cce..2c1028b 100644
@@ -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
Signature · 1 line
1.8.3.2
#37 lore raw

PATCH v8 37/38 kbuild: Do not generate .*.su files at the top directory

In reply to Masahiro Yamada

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.

---

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(-)
scripts/Kbuild.include +3 -1
index 6113c13..6504571 100644
@@ -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,)
Signature · 1 line
1.8.3.2
#38 lore raw

PATCH v8 38/38 tools/env: cross-compile fw_printenv without setting HOSTCC

In reply to Masahiro Yamada

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.

---

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
tools/.gitignore +0 -1
index 13283b7..6e4a287 100644
@@ -16,7 +16,6 @@
 /xway-swap-bytes
 /*.exe
 /easylogo/easylogo
-/env/fw_printenv
 /gdb/gdbcont
 /gdb/gdbsend
 /kernel-doc/docproc
tools/env/.gitignore new file +2 -0
new file mode 100644
index 0000000..804abac
@@ -0,0 +1,2 @@
+fw_printenv
+fw_printenv_unstripped
tools/env/Makefile +14 -3
index d47fe16..6ad81fd 100644
@@ -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)
tools/env/README +2 -3
index 1020b57..24e31bc 100644
@@ -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"
Signature · 1 line
1.8.3.2
#39 lore raw

v8 cover Switch over to real Kbuild

In reply to Masahiro Yamada

Dear Masahiro Yamada,

On 29.01.14 13:25, Masahiro Yamada wrote:

<snip>

Quoted 22 lines

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

Quoted 6 lines

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

#40 lore raw

v8 cover Switch over to real Kbuild

Hello Andreas,

Thanks for your test.

Quoted 4 lines

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

#41 lore raw

v8 cover Switch over to real Kbuild

In reply to Masahiro Yamada

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

#42 lore raw

v8 cover Switch over to real Kbuild

Quoted 7 lines · Masahiro Yamada

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.

Signature · 8 lines
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>
#43 lore raw

v8 cover Switch over to real Kbuild

In reply to Masahiro Yamada

Hi Masahiro,

Quoted 5 lines · Masahiro Yamada

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.

Quoted 7 lines

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

Quoted 430 lines

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

#44 lore raw

v8 cover Switch over to real Kbuild

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.

Quoted 5 lines
Quoted 2 lines

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

#45 lore raw

v8 cover Switch over to real Kbuild

Quoted 4 lines · Masahiro Yamada

Hello Simon and Tom,

This is my analysis of Kbuild performance.

[snip]

Quoted 8 lines

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.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

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.

Signature · 8 lines
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>
#46 lore raw

v8 cover Switch over to real Kbuild

Hi Masahiro,

Quoted 5 lines · Tom Rini
Quoted 3 lines · Masahiro Yamada

Hello Simon and Tom,

Quoted 8 lines
Quoted 1 line

This is my analysis of Kbuild performance.

[snip]

Quoted 6 lines

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.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

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

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

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

#47 lore raw

v8 cover Switch over to real Kbuild

Hi Masahiro,

Quoted 17 lines · Simon Glass

Hi Masahiro,

Quoted 5 lines · Tom Rini
Quoted 3 lines · Masahiro Yamada

Hello Simon and Tom,

Quoted 8 lines
Quoted 1 line

This is my analysis of Kbuild performance.

[snip]

Quoted 6 lines

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.

Quoted 4 lines

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

#48 lore raw

v8 cover Switch over to real Kbuild

Hello Simon,

Quoted 14 lines

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

Quoted 5 lines

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.

Quoted 3 lines

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

#49 lore raw

v8 cover Switch over to real Kbuild

Hi Masahiro,

Quoted 23 lines · Masahiro Yamada

Hello Simon,

Quoted 14 lines

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

Quoted 5 lines

With the kbuild series, it takes a lot longer:

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

Quoted 6 lines

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.

Quoted 11 lines
Quoted 4 lines

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.

Quoted 11 lines

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.

Quoted 2 lines

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

#50 lore raw

v8 cover Switch over to real Kbuild

Hello Simon,

Quoted 8 lines
Quoted 6 lines

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,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

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?

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

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?

Quoted 8 lines
Quoted 6 lines

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

#51 lore raw

v8 cover Switch over to real Kbuild

In reply to Masahiro Yamada

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

Quoted 14 lines · Masahiro Yamada

Hello Simon,

Quoted 11 lines

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

Quoted 18 lines
Quoted 6 lines

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.

Quoted 3 lines

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?

Quoted 7 lines

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

#52 lore raw

v8 cover Switch over to real Kbuild

Hello Tom,

Quoted 7 lines
Quoted 2 lines

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

#53 lore raw

v8 cover Switch over to real Kbuild

Quoted 5 lines · Masahiro Yamada

Hello Tom,

Quoted 3 lines
Quoted 2 lines

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

Quoted 7 lines
Quoted 4 lines

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.

Signature · 8 lines
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>
#54 lore raw

v8 cover Switch over to real Kbuild

In reply to Simon Glass
Quoted 30 lines · Simon Glass

Hi Masahiro,

Quoted 5 lines · Tom Rini
Quoted 3 lines · Masahiro Yamada

Hello Simon and Tom,

Quoted 8 lines
Quoted 1 line

This is my analysis of Kbuild performance.

[snip]

Quoted 6 lines

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.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

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.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

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

Signature · 8 lines
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>
#55 lore raw

v8 cover Switch over to real Kbuild

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

#56 lore raw

v8 cover Switch over to real Kbuild

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

Quoted 9 lines · Masahiro Yamada

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

#57 lore raw

v8 cover Switch over to real Kbuild

Hello Tom,

Quoted 9 lines
Quoted 7 lines

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