[U-Boot] [PATCH v4 0/37] 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/
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.
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
Changes in v4: - Change a little checkstack target: Use $(src) rather than $(srctree) where Linux Kernel does so. - Move the line where U_BOOT_VERSION is defined - Change checkstack target - Newly added
Changes in v3: - Rebase on the current u-boot/master - Use "all:" instead of "__build:" in nand_spl Makefiles - Newly added
Changes in v2: - Do not double "*~" - Ignore more patterns - Rebase on v2014.01-rc2 tag - 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 - At version 1, nand_spl boards got broken by this commit (and fixed again in the lator commit.) Fix this problem - 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. - Rebase on v2014.01-rc2 tag - Omit "*.depend*" from .gitignore - Rebase on v2014.01-rc2 tag - Rebase on v2014.01-rc2 tag - Newly added
Masahiro Yamada (37): .gitignore: ingore files generated by Kbuild Makefile.host.tmp: add a new script to refactor tools tools: convert makefiles to kbuild style board: samsung: refactor host programs examples: Use scripts/Makefile.build nand-spl: Use scripts/Makefile.build Makfile: move suffix rules to Makefile.build Makefile: move some variable definitions to the top Makefile Makefile: move BFD_ROOT_DIR to tools/gdb/Makefile kbuild: import Kbuild.include from linux v3.12 tag kbuild: Use Kbuild.include Makefile: move more flags to the top Makefile Makefile: refactor include path settings Makefile: move more stuff to top Makefile Makefile: move some flags to spl/Makefile Makefile: move some flags to examples makefiles kbuild: change out-of-tree 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.12 tag kbuild: use Linux Kernel build scripts kbuild: delete temporary build scripts kbuild: move some lines to more suitable place kbuild: convert some make rules to Kbuild style kbuild: move include directives of board configuration files kbuild: generate {spl,tpl}-autoconf.mk only when it is necessary Makefile: remove a cleaning target "tidy" kbuild: change the top Makefile to more Kbuild-ish structure examples: move api/ and standalone/ to examples/Makefile kbuild: refactor Makefile and spl/Makefile more Makefile: Do not pass MTD_VERSION from the top Makefile Makefile: refactor tools-all targets kbuild: use scripts/Makefile.clean kbuild: support simultaneous board configuration and "make all" kbuild: check clean source and generate Makefile for out-of-tree build board: sandburst: delete FORCEBUILD kbuild: Do not generate .*.su files at the top directory
.gitignore | 28 +- MAKEALL | 8 +- Makefile | 1299 +++++++++++++------- arch/arm/cpu/arm1136/config.mk | 2 +- arch/arm/cpu/arm926ejs/config.mk | 2 +- arch/arm/cpu/arm926ejs/davinci/config.mk | 2 +- arch/arm/cpu/armv7/am33xx/config.mk | 2 +- arch/arm/cpu/armv7/config.mk | 2 +- arch/arm/cpu/armv7/omap3/config.mk | 2 +- arch/arm/cpu/armv7/omap4/config.mk | 2 +- arch/arm/cpu/armv7/omap5/config.mk | 2 +- arch/arm/cpu/armv7/socfpga/config.mk | 2 +- arch/arm/cpu/armv7/tegra114/Makefile | 3 +- arch/arm/cpu/armv7/tegra30/Makefile | 3 +- arch/arm/imx-common/Makefile | 2 +- arch/blackfin/config.mk | 10 +- arch/blackfin/cpu/Makefile | 10 +- arch/blackfin/lib/Makefile | 5 +- arch/m68k/cpu/mcf5227x/Makefile | 2 +- arch/m68k/cpu/mcf523x/Makefile | 2 +- arch/m68k/cpu/mcf52x2/Makefile | 2 +- arch/m68k/cpu/mcf532x/Makefile | 2 +- arch/m68k/cpu/mcf5445x/Makefile | 2 +- arch/m68k/cpu/mcf547x_8x/Makefile | 2 +- arch/mips/cpu/mips32/config.mk | 2 +- arch/mips/cpu/mips64/config.mk | 2 +- arch/mips/cpu/xburst/config.mk | 2 +- arch/nds32/config.mk | 2 +- arch/nds32/cpu/n1213/Makefile | 3 + arch/powerpc/cpu/mpc8xx/Makefile | 2 +- arch/powerpc/lib/Makefile | 4 +- arch/sandbox/cpu/Makefile | 11 +- arch/sparc/config.mk | 3 +- arch/x86/lib/Makefile | 2 +- board/ait/cam_enc_4xx/config.mk | 2 +- board/avionic-design/medcom-wide/Makefile | 2 +- board/avionic-design/plutux/Makefile | 2 +- board/avionic-design/tec/Makefile | 2 +- board/bct-brettl2/config.mk | 7 +- board/bf518f-ezbrd/config.mk | 7 +- board/bf526-ezbrd/config.mk | 7 +- board/bf527-ad7160-eval/config.mk | 7 +- board/bf527-ezkit/config.mk | 7 +- board/bf527-sdp/config.mk | 7 +- board/bf533-ezkit/config.mk | 7 +- board/bf533-stamp/config.mk | 7 +- board/bf537-stamp/config.mk | 7 +- board/bf538f-ezkit/config.mk | 7 +- board/bf548-ezkit/config.mk | 7 +- board/bf561-acvilon/config.mk | 7 +- board/bf561-ezkit/config.mk | 7 +- board/br4/config.mk | 7 +- board/cm-bf527/config.mk | 7 +- board/cm-bf533/config.mk | 7 +- board/cm-bf537e/config.mk | 7 +- board/cm-bf537u/config.mk | 7 +- board/cm-bf548/config.mk | 7 +- board/cm-bf561/config.mk | 7 +- board/compal/paz00/Makefile | 2 +- board/compulab/trimslice/Makefile | 2 +- board/cray/L1/Makefile | 10 +- board/freescale/common/Makefile | 5 +- board/h2200/Makefile | 2 +- board/ip04/config.mk | 7 +- board/matrix_vision/mvblm7/Makefile | 4 +- board/matrix_vision/mvblx/Makefile | 2 +- board/matrix_vision/mvsmr/Makefile | 2 +- board/nvidia/common/Makefile | 2 +- board/pcs440ep/config.mk | 2 +- board/pr1/config.mk | 7 +- board/samsung/origen/Makefile | 23 +- .../origen/tools/{mkv310_image.c => mkorigenspl.c} | 0 board/samsung/smdkv310/Makefile | 16 +- .../tools/{mkv310_image.c => mksmdkv310spl.c} | 0 board/sandburst/karef/Makefile | 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 | 17 - drivers/bios_emulator/Makefile | 5 +- drivers/hwmon/Makefile | 2 +- drivers/net/npe/Makefile | 4 +- drivers/rtc/Makefile | 2 +- drivers/usb/musb-new/Makefile | 7 +- dts/Makefile | 20 +- examples/Makefile | 9 + examples/api/Makefile | 44 +- examples/standalone/Makefile | 71 +- fs/ubifs/Makefile | 2 +- fs/yaffs2/Makefile | 9 +- lib/Makefile | 2 +- lib/lzma/Makefile | 2 +- mkconfig | 2 +- nand_spl/board/amcc/acadia/Makefile | 43 +- nand_spl/board/amcc/bamboo/Makefile | 43 +- nand_spl/board/amcc/canyonlands/Makefile | 43 +- nand_spl/board/amcc/kilauea/Makefile | 41 +- nand_spl/board/amcc/sequoia/Makefile | 45 +- nand_spl/board/freescale/mpc8315erdb/Makefile | 45 +- nand_spl/board/freescale/mpc8536ds/Makefile | 57 +- nand_spl/board/freescale/mpc8569mds/Makefile | 57 +- nand_spl/board/freescale/mpc8572ds/Makefile | 57 +- nand_spl/board/freescale/p1023rds/Makefile | 58 +- nand_spl/board/freescale/p1_p2_rdb/Makefile | 57 +- nand_spl/board/sheldon/simpc8313/Makefile | 46 +- net/Makefile | 2 +- post/lib_powerpc/fpu/Makefile | 30 +- 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 | 185 +-- tools/.gitignore | 2 +- tools/Makefile | 364 ++---- tools/crc32.c | 1 + tools/easylogo/Makefile | 12 +- tools/env/Makefile | 34 +- tools/env/crc32.c | 1 + tools/env/ctype.c | 1 + tools/env/env_attr.c | 1 + tools/env/env_flags.c | 1 + tools/env/linux_string.c | 1 + tools/env_embedded.c | 1 + tools/fdt.c | 1 + tools/fdt_ro.c | 1 + tools/fdt_rw.c | 1 + tools/fdt_strerror.c | 1 + tools/fdt_wip.c | 1 + tools/gdb/Makefile | 64 +- tools/image-fit.c | 1 + tools/image-sig.c | 1 + tools/image.c | 1 + tools/kernel-doc/Makefile | 21 +- tools/md5.c | 1 + tools/rsa-sign.c | 1 + tools/sha1.c | 1 + 150 files changed, 3597 insertions(+), 2022 deletions(-) rename board/samsung/origen/tools/{mkv310_image.c => mkorigenspl.c} (100%) rename board/samsung/smdkv310/tools/{mkv310_image.c => mksmdkv310spl.c} (100%) create mode 100644 examples/Makefile delete mode 100644 rules.mk create mode 100644 scripts/Kbuild.include create mode 100644 scripts/Makefile create mode 100644 scripts/Makefile.clean create mode 100644 scripts/Makefile.host create mode 100644 scripts/Makefile.lib create mode 100644 scripts/basic/.gitignore create mode 100644 scripts/basic/Makefile create mode 100644 scripts/basic/fixdep.c create mode 100644 scripts/mkmakefile create mode 100644 tools/crc32.c create mode 100644 tools/env/crc32.c create mode 100644 tools/env/ctype.c create mode 100644 tools/env/env_attr.c create mode 100644 tools/env/env_flags.c create mode 100644 tools/env/linux_string.c create mode 100644 tools/env_embedded.c create mode 100644 tools/fdt.c create mode 100644 tools/fdt_ro.c create mode 100644 tools/fdt_rw.c create mode 100644 tools/fdt_strerror.c create mode 100644 tools/fdt_wip.c create mode 100644 tools/image-fit.c create mode 100644 tools/image-sig.c create mode 100644 tools/image.c create mode 100644 tools/md5.c create mode 100644 tools/rsa-sign.c create mode 100644 tools/sha1.c

Ignore generated files by Kbuild such as .*.cmd, *.order, etc.
Besides above, - Ignore *.s files We do not need to ignore with file name, asm-offsets.s - Do not ignore *.rej (for quilt) - Ignore backup files, #*#
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: - Do not double "*~" - Ignore more patterns
.gitignore | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore index 3b14c25..d18ebf3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,16 +5,19 @@ # # Normal rules # - -*.rej -*.orig -*.a +.* *.o +*.o.* +*.a +*.s *.su -*~ +*.mod.c +*.i +*.lst +*.order *.swp -*.patch *.bin +*.patch *.cfgtmp *.dts.tmp
@@ -24,7 +27,6 @@ # # Top-level generic files # - /MLO* /SPL /System.map @@ -49,6 +51,12 @@ /u-boot.sb
# +# git files that we don't want to ignore even it they are dot-files +# +!.gitignore +!.mailmap + +# # Generated files #
@@ -64,7 +72,6 @@ /include/generated/ /include/spl-autoconf.mk /include/tpl-autoconf.mk -asm-offsets.s
# stgit generated dirs patches-* @@ -90,3 +97,7 @@ GPATH GRTAGS GSYMS GTAGS + +*.orig +*~ +#*#

This commit adds scripts/Makefile.host.tmp which will be used in the next commit to convert makefiles under tools/ directory to Kbuild style.
Notice this script, scripts/Makefile.host.tmp is temporary.
When switching over to real Kbuild, it will be replaced with scripts/Makefile.host of Linux Kernel.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
scripts/Makefile.build | 17 ++++++++++--- scripts/Makefile.host.tmp | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 scripts/Makefile.host.tmp
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index e3354aa..c451fbf 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -7,15 +7,23 @@ include $(TOPDIR)/config.mk LIB := $(obj)built-in.o LIBGCC = $(obj)libgcc.o SRCS := +subdir-y := +obj-dirs :=
include Makefile
+# Do not include host rules unless needed +ifneq ($(hostprogs-y)$(hostprogs-m),) +include $(SRCTREE)/scripts/Makefile.host.tmp +endif + # Going forward use the following obj-y := $(sort $(obj-y)) extra-y := $(sort $(extra-y)) +always := $(sort $(always)) lib-y := $(sort $(lib-y))
-subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) +subdir-y += $(patsubst %/,%,$(filter %/, $(obj-y))) obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) subdir-obj-y := $(filter %/built-in.o, $(obj-y)) subdir-obj-y := $(addprefix $(obj),$(subdir-obj-y)) @@ -25,7 +33,8 @@ SRCS += $(wildcard $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) \ OBJS := $(addprefix $(obj),$(obj-y))
# $(obj-dirs) is a list of directories that contain object files -obj-dirs := $(dir $(OBJS)) + +obj-dirs += $(dir $(OBJS))
# Create directories for object files if directory does not exist # Needed when obj-y := dir/file.o syntax is used @@ -33,7 +42,7 @@ _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
LGOBJS := $(addprefix $(obj),$(sort $(lib-y)))
-all: $(LIB) $(addprefix $(obj),$(extra-y)) +all: $(LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
$(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) @@ -48,7 +57,9 @@ endif ifneq ($(subdir-obj-y),) # Descending $(subdir-obj-y): $(subdir-y) +endif
+ifneq ($(subdir-y),) $(subdir-y): FORCE $(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build endif diff --git a/scripts/Makefile.host.tmp b/scripts/Makefile.host.tmp new file mode 100644 index 0000000..4b57846 --- /dev/null +++ b/scripts/Makefile.host.tmp @@ -0,0 +1,61 @@ + +__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) + +# C code +# Executables compiled from a single .c file +host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))) + +# C executables linked based on several .o files +host-cmulti := $(foreach m,$(__hostprogs),$(if $($(m)-objs),$(m))) + +# Object (.o) files compiled from .c files +host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs))) + +# output directory for programs/.o files +# hostprogs-y := tools/build may have been specified. Retrieve directory +host-objdirs := $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f)))) +# directory of .o files from prog-objs notation +host-objdirs += $(foreach f,$(host-cmulti), \ + $(foreach m,$($(f)-objs), \ + $(if $(dir $(m)),$(dir $(m))))) + +host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs)))) + +__hostprogs := $(addprefix $(obj),$(__hostprogs)) +host-csingle := $(addprefix $(obj),$(host-csingle)) +host-cmulti := $(addprefix $(obj),$(host-cmulti)) +host-cobjs := $(addprefix $(obj),$(host-cobjs)) +host-objdirs := $(addprefix $(obj),$(host-objdirs)) + +obj-dirs += $(host-objdirs) + +##### +# Handle options to gcc. Support building with separate output directory + +_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ + $(HOSTCFLAGS_$(basetarget).o) + +# Find all -I options and call addtree +flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) + +ifeq ($(OBJTREE),$(SRCTREE)) +__hostc_flags = $(_hostc_flags) +else +__hostc_flags = -I$(obj) $(call flags,_hostc_flags) +endif + +hostc_flags = $(__hostc_flags) + +##### +# Compile programs on the host + +$(host-csingle): $(obj)%: %.c + $(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTLDFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< + +$(host-cmulti): $(obj)%: $(host-cobjs) + $(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj),$($(@F)-objs)) $(HOSTLOADLIBES_$(@F)) + +$(host-cobjs): $(obj)%.o: %.c + $(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c + +targets += $(host-csingle) $(host-cmulti) $(host-cobjs)

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

Some Samsung boards have their own tools under board/samsung/<board>/tools/. This commit refactor more makefiles with "hostprogs-y".
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Note1: Samsung boards have tools under board/samsung/<board>/tools/ and have tools/mkexynosspl.c too. It is inconsistent, so we should choose the appropriate directory in which Samsung-specific tools are stored.
Note2:
I marded TODO item in board/samsung/origen/Makefile.
Samsung engineers, I hope you will fix the root cause of the warning.
# omit -O2 option to suppress # warning: dereferencing type-punned pointer will break strict-aliasing rules # # TODO: # Fix the root cause in tools/mkorigenspl.c and delete the following work-around $(obj)/tools/mkorigenspl: HOSTCFLAGS:=$(filter-out -O2,$(HOSTCFLAGS))
Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 1 + board/samsung/origen/Makefile | 20 ++++++++++---------- .../origen/tools/{mkv310_image.c => mkorigenspl.c} | 0 board/samsung/smdkv310/Makefile | 15 ++++----------- .../tools/{mkv310_image.c => mksmdkv310spl.c} | 0 spl/Makefile | 4 ++-- 6 files changed, 17 insertions(+), 23 deletions(-) rename board/samsung/origen/tools/{mkv310_image.c => mkorigenspl.c} (100%) rename board/samsung/smdkv310/tools/{mkv310_image.c => mksmdkv310spl.c} (100%)
diff --git a/Makefile b/Makefile index 4ee2240..1a9b5c4 100644 --- a/Makefile +++ b/Makefile @@ -778,6 +778,7 @@ clean: $(obj)tools/proftool @rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image} \ $(obj)board/matrix_vision/*/bootscript.img \ + $(obj)spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl \ $(obj)u-boot.lds \ $(obj)arch/blackfin/cpu/init.{lds,elf} @rm -f $(obj)include/bmp_logo.h diff --git a/board/samsung/origen/Makefile b/board/samsung/origen/Makefile index e8818bf..31e88f4 100644 --- a/board/samsung/origen/Makefile +++ b/board/samsung/origen/Makefile @@ -4,16 +4,16 @@ # SPDX-License-Identifier: GPL-2.0+ #
-ifndef CONFIG_SPL_BUILD -obj-y += origen.o -endif - ifdef CONFIG_SPL_BUILD -all: $(OBJTREE)/tools/mk$(BOARD)spl -endif +hostprogs-y := tools/mkorigenspl +always := $(hostprogs-y)
-# Fix ME after we implement hostprogs-y. -ifdef CONFIG_SPL_BUILD -$(OBJTREE)/tools/mk$(BOARD)spl: tools/mkv310_image.c - $(HOSTCC) tools/mkv310_image.c -o $(OBJTREE)/tools/mk$(BOARD)spl +# omit -O2 option to suppress +# warning: dereferencing type-punned pointer will break strict-aliasing rules +# +# TODO: +# Fix the root cause in tools/mkorigenspl.c and delete the following work-around +$(obj)tools/mkorigenspl: HOSTCFLAGS:=$(filter-out -O2,$(HOSTCFLAGS)) +else +obj-y += origen.o endif diff --git a/board/samsung/origen/tools/mkv310_image.c b/board/samsung/origen/tools/mkorigenspl.c similarity index 100% rename from board/samsung/origen/tools/mkv310_image.c rename to board/samsung/origen/tools/mkorigenspl.c diff --git a/board/samsung/smdkv310/Makefile b/board/samsung/smdkv310/Makefile index dbc621b..9e37b4e 100644 --- a/board/samsung/smdkv310/Makefile +++ b/board/samsung/smdkv310/Makefile @@ -4,16 +4,9 @@ # SPDX-License-Identifier: GPL-2.0+ #
-ifndef CONFIG_SPL_BUILD -obj-y += smdkv310.o -endif - ifdef CONFIG_SPL_BUILD -all: $(OBJTREE)/tools/mk$(BOARD)spl -endif - -# Fix ME after we implement hostprogs-y. -ifdef CONFIG_SPL_BUILD -$(OBJTREE)/tools/mk$(BOARD)spl: tools/mkv310_image.c - $(HOSTCC) tools/mkv310_image.c -o $(OBJTREE)/tools/mk$(BOARD)spl +hostprogs-y := tools/mksmdkv310spl +always := $(hostprogs-y) +else +obj-y += smdkv310.o endif diff --git a/board/samsung/smdkv310/tools/mkv310_image.c b/board/samsung/smdkv310/tools/mksmdkv310spl.c similarity index 100% rename from board/samsung/smdkv310/tools/mkv310_image.c rename to board/samsung/smdkv310/tools/mksmdkv310spl.c diff --git a/spl/Makefile b/spl/Makefile index b23ade8..a3253ba 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -156,8 +156,8 @@ all: $(ALL-y)
ifdef CONFIG_SAMSUNG $(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) $< $@ endif

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

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

This commit moves suffix rules from config.mk to scripts/Makefile.build, which will allow us to switch smoothly to real Kbuild.
Note1: post/lib_powerpc/fpu/Makefile has its own rule to compile C sources. We need to tweak it to keep the same behavior.
Note2: There are two file2 with the same name: arch/arm/lib/crt0.S and eamples/api/crt0.S. To keep the same build behavior, examples/api/Makefile also has to be treaked.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
config.mk | 35 ----------------------------------- examples/api/Makefile | 4 ++-- post/lib_powerpc/fpu/Makefile | 2 +- scripts/Makefile.build | 31 +++++++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 38 deletions(-)
diff --git a/config.mk b/config.mk index 07afb35..b08be7a 100644 --- a/config.mk +++ b/config.mk @@ -318,38 +318,3 @@ endif export HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE \ AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS - -######################################################################### - -# Allow boards to use custom optimize flags on a per dir/file basis -ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR)) -ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) -EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR)) -ALL_CFLAGS += $(EXTRA_CPPFLAGS) - -# The _DEP version uses the $< file target (for dependency generation) -# See rules.mk -EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \ - $(CPPFLAGS_$(BCURDIR)) -$(obj)%.s: %.S - $(CPP) $(ALL_AFLAGS) -o $@ $< -$(obj)%.o: %.S - $(CC) $(ALL_AFLAGS) -o $@ $< -c -$(obj)%.o: %.c -ifneq ($(CHECKSRC),0) - $(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $< -endif - $(CC) $(ALL_CFLAGS) -o $@ $< -c -$(obj)%.i: %.c - $(CPP) $(ALL_CFLAGS) -o $@ $< -c -$(obj)%.s: %.c - $(CC) $(ALL_CFLAGS) -o $@ $< -c -S - -######################################################################### - -# If the list of objects to link is empty, just create an empty built-in.o -cmd_link_o_target = $(if $(strip $1),\ - $(LD) $(LDFLAGS) -r -o $@ $1,\ - rm -f $@; $(AR) rcs $@ ) - -######################################################################### diff --git a/examples/api/Makefile b/examples/api/Makefile index f770859..52f4368 100644 --- a/examples/api/Makefile +++ b/examples/api/Makefile @@ -50,9 +50,9 @@ $(obj)demo.bin: $(obj)demo $(OBJCOPY) -O binary $< $@ 2>/dev/null
# Rule to build generic library C files -$(obj)%.o: $(SRCTREE)/lib/%.c +$(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y))): $(obj)%.o: $(SRCTREE)/lib/%.c $(CC) -g $(CFLAGS) -c -o $@ $<
# Rule to build architecture-specific library assembly files -$(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S +$(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y))): $(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S $(CC) -g $(CFLAGS) -c -o $@ $< diff --git a/post/lib_powerpc/fpu/Makefile b/post/lib_powerpc/fpu/Makefile index ae56a82..a7aa5bc 100644 --- a/post/lib_powerpc/fpu/Makefile +++ b/post/lib_powerpc/fpu/Makefile @@ -18,7 +18,7 @@ obj-y += darwin-ldouble.o CFLAGS := $(shell echo $(CFLAGS) | sed s/-msoft-float//) CFLAGS += -mhard-float -fkeep-inline-functions
-$(obj)%.o: %.c +$(addprefix $(obj),$(obj-y)): $(obj)%.o: %.c $(CC) $(ALL_CFLAGS) -o $@.fp $< -c $(OBJCOPY) -R .gnu.attributes $@.fp $@ rm -f $@.fp diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 50c0394..1b3d77f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -67,6 +67,37 @@ endif
#########################################################################
+# Allow boards to use custom optimize flags on a per dir/file basis +ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR)) +ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) +EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR)) +ALL_CFLAGS += $(EXTRA_CPPFLAGS) + +# The _DEP version uses the $< file target (for dependency generation) +# See rules.mk +EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \ + $(CPPFLAGS_$(BCURDIR)) +$(obj)%.s: %.S + $(CPP) $(ALL_AFLAGS) -o $@ $< +$(obj)%.o: %.S + $(CC) $(ALL_AFLAGS) -o $@ $< -c +$(obj)%.o: %.c +ifneq ($(CHECKSRC),0) + $(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $< +endif + $(CC) $(ALL_CFLAGS) -o $@ $< -c +$(obj)%.i: %.c + $(CPP) $(ALL_CFLAGS) -o $@ $< -c +$(obj)%.s: %.c + $(CC) $(ALL_CFLAGS) -o $@ $< -c -S + +# If the list of objects to link is empty, just create an empty built-in.o +cmd_link_o_target = $(if $(strip $1),\ + $(LD) $(LDFLAGS) -r -o $@ $1,\ + rm -f $@; $(AR) rcs $@ ) + +######################################################################### + # defines $(obj).depend target
include $(TOPDIR)/rules.mk

This commit moves some variable definitions from config.mk to the top Makefile:
- HOSTCC, HOSTCFLAGS, HOSTLDFLAGS - AS, LD, CC, CPP, etc. - SHELL (renamed to CONFIG_SHELL)
I'd like to slim down config.mk file because it is included from all recursive make. It is redundant to re-define the variables every time descending into sub directories. We should rather define them at the top Makefile and export them.
U-Boot makefiles has been used "SHELL" variable to store shell chosen for the user, whereas Linux Kernel uses "CONFIG_SHELL".
We should never use "SHELL" variable because it is a special variable for GNU Make. Changing SHELL may cause unpredictable side effects whose root cause is usually difficult to find. We should use a generic variable name "CONFIG_SHELL".
We should not use the syntax as follows either:
rm -f $(obj)tools/env/{fw_printenv,fw_setenv}
This depends on "bash" although GNU Make generally invokes "sh" to run the each rule.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
O'REILLY GNU Make says like follows about SHELL variable:
By default, /bin/sh is used for the shell. This shell is controlled by the make variable SHELL but it is not inherited from the environment. When make starts, it imports all the variables from the user’s environment as make variables, except SHELL. This is because the user’s choice of shell should not cause a makefile (possibly included in some downloaded software package) to fail. If a user really wants to change the default shell used by make, he can set the SHELL variable explicitly in the makefile.
Please refer to the first page of the following PDF file: http://oreilly.com/catalog/make3/book/ch05.pdf
Changes in v4: None Changes in v3: None Changes in v2: - Do not use bash-dependent clean rules: For example, rm -f $(obj)tools/env/{fw_printenv,fw_setenv} should be converted to rm -f $(addprefix $(obj)tools/env/, fw_printenv fw_setenv) - Add more comments in commit log - Rebase on v2014.01-rc2 tag
Makefile | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- config.mk | 78 ++-------------------------------------------------- 2 files changed, 84 insertions(+), 88 deletions(-)
diff --git a/Makefile b/Makefile index 37719be..7328216 100644 --- a/Makefile +++ b/Makefile @@ -161,6 +161,73 @@ ifeq ($(HOSTARCH),$(ARCH)) CROSS_COMPILE ?= endif
+# SHELL used by kbuild +CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ + else if [ -x /bin/bash ]; then echo /bin/bash; \ + else echo sh; fi ; fi) + +HOSTCC = gcc +HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer + +ifeq ($(HOSTOS),cygwin) +HOSTCFLAGS += -ansi +endif + +# Mac OS X / Darwin's C preprocessor is Apple specific. It +# generates numerous errors and warnings. We want to bypass it +# and use GNU C's cpp. To do this we pass the -traditional-cpp +# option to the compiler. Note that the -traditional-cpp flag +# DOES NOT have the same semantics as GNU C's flag, all it does +# is invoke the GNU preprocessor in stock ANSI/ISO C fashion. +# +# Apple's linker is similar, thanks to the new 2 stage linking +# multiple symbol definitions are treated as errors, hence the +# -multiply_defined suppress option to turn off this error. +# +ifeq ($(HOSTOS),darwin) +# get major and minor product version (e.g. '10' and '6' for Snow Leopard) +DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.') +DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.') + +os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \ + $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;) + +# Snow Leopards build environment has no longer restrictions as described above +HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc") +HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp") +HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress") +endif + +# Make variables (CC, etc...) + +AS = $(CROSS_COMPILE)as +# Always use GNU ld +ifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),) +LD = $(CROSS_COMPILE)ld.bfd +else +LD = $(CROSS_COMPILE)ld +endif +CC = $(CROSS_COMPILE)gcc +CPP = $(CC) -E +AR = $(CROSS_COMPILE)ar +NM = $(CROSS_COMPILE)nm +LDR = $(CROSS_COMPILE)ldr +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump +AWK = awk +RANLIB = $(CROSS_COMPILE)RANLIB +DTC = dtc +CHECK = sparse + +CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ + -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF) + +export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC +export CPP AR NM LDR STRIP OBJCOPY OBJDUMP +export MAKE AWK +export DTC CHECK CHECKFLAGS + # load other configuration include $(TOPDIR)/config.mk
@@ -757,27 +824,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 @@ -812,11 +880,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 @@ -825,7 +893,7 @@ clobber: tidy @rm -fr $(obj)include/generated @[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f @rm -f $(obj)dts/*.tmp - @rm -f $(obj)spl/u-boot-spl{,-pad}.ais + @rm -f $(addprefix $(obj)spl/, u-boot-spl.ais, u-boot-spl-pad.ais)
mrproper \ distclean: clobber unconfig diff --git a/config.mk b/config.mk index b08be7a..74617d3 100644 --- a/config.mk +++ b/config.mk @@ -6,13 +6,6 @@ # #########################################################################
-# Set shell to bash if possible, otherwise fall back to sh -SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ - else if [ -x /bin/bash ]; then echo /bin/bash; \ - else echo sh; fi; fi) - -export SHELL - ifeq ($(CURDIR),$(SRCTREE)) dir := else @@ -55,44 +48,6 @@ PLATFORM_CPPFLAGS = PLATFORM_LDFLAGS =
######################################################################### - -HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ - $(HOSTCPPFLAGS) - -# -# Mac OS X / Darwin's C preprocessor is Apple specific. It -# generates numerous errors and warnings. We want to bypass it -# and use GNU C's cpp. To do this we pass the -traditional-cpp -# option to the compiler. Note that the -traditional-cpp flag -# DOES NOT have the same semantics as GNU C's flag, all it does -# is invoke the GNU preprocessor in stock ANSI/ISO C fashion. -# -# Apple's linker is similar, thanks to the new 2 stage linking -# multiple symbol definitions are treated as errors, hence the -# -multiply_defined suppress option to turn off this error. -# - -ifeq ($(HOSTOS),darwin) -# get major and minor product version (e.g. '10' and '6' for Snow Leopard) -DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.') -DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.') - -os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \ - $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;) - -# Snow Leopards build environment has no longer restrictions as described above -HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc") -HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp") -HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress") -else -HOSTCC = gcc -endif - -ifeq ($(HOSTOS),cygwin) -HOSTCFLAGS += -ansi -endif - -######################################################################### # # Option checker, gcc version (courtesy linux kernel) to ensure # only supported compiler options are used @@ -117,30 +72,9 @@ endif
# cc-version # Usage gcc-ver := $(call cc-version) -cc-version = $(shell $(SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC)) -binutils-version = $(shell $(SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS)) -dtc-version = $(shell $(SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC)) - -# -# Include the make variables (CC, etc...) -# -AS = $(CROSS_COMPILE)as - -# Always use GNU ld -LD = $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \ - then echo "$(CROSS_COMPILE)ld.bfd"; else echo "$(CROSS_COMPILE)ld"; fi;) - -CC = $(CROSS_COMPILE)gcc -CPP = $(CC) -E -AR = $(CROSS_COMPILE)ar -NM = $(CROSS_COMPILE)nm -LDR = $(CROSS_COMPILE)ldr -STRIP = $(CROSS_COMPILE)strip -OBJCOPY = $(CROSS_COMPILE)objcopy -OBJDUMP = $(CROSS_COMPILE)objdump -RANLIB = $(CROSS_COMPILE)RANLIB -DTC = dtc -CHECK = sparse +cc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC)) +binutils-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS)) +dtc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC))
#########################################################################
@@ -286,10 +220,6 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),) LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) endif
-# Linus' kernel sanity checking tool -CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ - -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF) - # Location of a usable BFD library, where we define "usable" as # "built for ${HOST}, supports ${TARGET}". Sensible values are # - When cross-compiling: the root of the cross-environment @@ -315,6 +245,4 @@ endif
#########################################################################
-export HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE \ - AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS

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

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

This commit adjusts some files to use Kbuild.include.
- Use cc-option defined in Kbuild.include (Delete cc-option in config.mk) - Use cc-version defined in (Delete cc-version in config.mk) - Move binutils-version and dtc-version to Kbuild.include by analogy to cc-version
This commit also adds srctree (same as SRCTREE) to use Kbuild scripts.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 9 ++++++--- config.mk | 29 ----------------------------- scripts/Kbuild.include | 8 +++++++- scripts/Makefile.build | 1 + spl/Makefile | 4 ++-- 5 files changed, 16 insertions(+), 35 deletions(-)
diff --git a/Makefile b/Makefile index 7328216..b166ccc 100644 --- a/Makefile +++ b/Makefile @@ -102,9 +102,10 @@ OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR)) SPLTREE := $(OBJTREE)/spl TPLTREE := $(OBJTREE)/tpl SRCTREE := $(CURDIR) +srctree := $(SRCTREE) TOPDIR := $(SRCTREE) LNDIR := $(OBJTREE) -export TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE +export TOPDIR SRCTREE srctree OBJTREE SPLTREE TPLTREE
MKCONFIG := $(SRCTREE)/mkconfig export MKCONFIG @@ -126,8 +127,6 @@ unexport CDPATH
#########################################################################
-build := -f $(TOPDIR)/scripts/Makefile.build -C - # The "tools" are needed early, so put this first # Don't include stuff already done in $(LIBS) # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC @@ -198,6 +197,10 @@ HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp") HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress") endif
+# We need some generic definitions (do not try to remake the file). +$(srctree)/scripts/Kbuild.include: ; +include $(srctree)/scripts/Kbuild.include + # Make variables (CC, etc...)
AS = $(CROSS_COMPILE)as diff --git a/config.mk b/config.mk index dfe81fa..ba42641 100644 --- a/config.mk +++ b/config.mk @@ -48,35 +48,6 @@ PLATFORM_CPPFLAGS = PLATFORM_LDFLAGS =
######################################################################### -# -# Option checker, gcc version (courtesy linux kernel) to ensure -# only supported compiler options are used -# -CC_OPTIONS_CACHE_FILE := $(OBJTREE)/include/generated/cc_options.mk -CC_TEST_OFILE := $(OBJTREE)/include/generated/cc_test_file.o - --include $(CC_OPTIONS_CACHE_FILE) - -cc-option-sys = $(shell mkdir -p $(dir $(CC_TEST_OFILE)); \ - if $(CC) $(CFLAGS) $(1) -S -xc /dev/null -o $(CC_TEST_OFILE) \ - > /dev/null 2>&1; then \ - echo 'CC_OPTIONS += $(strip $1)' >> $(CC_OPTIONS_CACHE_FILE); \ - echo "$(1)"; fi) - -ifeq ($(CONFIG_CC_OPT_CACHE_DISABLE),y) -cc-option = $(strip $(if $(call cc-option-sys,$1),$1,$2)) -else -cc-option = $(strip $(if $(findstring $1,$(CC_OPTIONS)),$1,\ - $(if $(call cc-option-sys,$1),$1,$2))) -endif - -# cc-version -# Usage gcc-ver := $(call cc-version) -cc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC)) -binutils-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS)) -dtc-version = $(shell $(CONFIG_SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC)) - -#########################################################################
# Load generated board configuration ifeq ($(CONFIG_TPL_BUILD),y) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 547e15d..ca5fd56 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -140,6 +140,10 @@ cc-fullversion = $(shell $(CONFIG_SHELL) \ # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3))
+# added for U-Boot +binutils-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/binutils-version.sh $(AS)) +dtc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/dtc-version.sh $(DTC)) + # cc-ldoption # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) cc-ldoption = $(call try-run,\ @@ -161,7 +165,9 @@ ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= # Usage: # $(Q)$(MAKE) $(build)=dir -build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj +#build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj +# temporary +build := -f $(srctree)/scripts/Makefile.build -C
### # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 1b3d77f..7789efa 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -2,6 +2,7 @@ .PHONY: all all:
+include $(srctree)/scripts/Kbuild.include include $(TOPDIR)/config.mk
# variable LIB is used in examples/standalone/Makefile diff --git a/spl/Makefile b/spl/Makefile index a3253ba..13dd616 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -24,6 +24,8 @@ else SPL_BIN := u-boot-spl endif
+include $(srctree)/scripts/Kbuild.include + include $(TOPDIR)/config.mk
# We want the final binaries in this directory @@ -123,8 +125,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.

Before this commit, most of compiler flags were defined in config.mk. But it is redundant because config.mk is included from all recursive make.
This commit moves many complier flags to the top Makefile and export them. And we use new vaiarables to store them: KBUILD_CPPFLAGS, KBUILD_CFLAGS, KBUILD_AFLAGS. This will allow us to switch more smoothly to Kbuild.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: - At version 1, nand_spl boards got broken by this commit (and fixed again in the lator commit.) Fix this problem
Makefile | 35 +++++++++++++++++++++++++++++++++++ config.mk | 41 ++++------------------------------------- 2 files changed, 39 insertions(+), 37 deletions(-)
diff --git a/Makefile b/Makefile index b166ccc..a4af4a1 100644 --- a/Makefile +++ b/Makefile @@ -226,11 +226,46 @@ CHECK = sparse CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
+KBUILD_CPPFLAGS := -D__KERNEL__ + +KBUILD_CFLAGS := -Wall -Wstrict-prototypes \ + -Wno-format-security \ + -fno-builtin -ffreestanding +KBUILD_AFLAGS := -D__ASSEMBLY__ + export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC export CPP AR NM LDR STRIP OBJCOPY OBJDUMP export MAKE AWK export DTC CHECK CHECKFLAGS
+export KBUILD_CPPFLAGS +export KBUILD_CFLAGS KBUILD_AFLAGS + +KBUILD_CFLAGS += -Os #-fomit-frame-pointer + +ifdef BUILD_TAG +KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"' +endif + +KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) + +KBUILD_CFLAGS += -g +# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format> +# option to the assembler. +KBUILD_AFLAGS += -g + +# Report stack usage if supported +KBUILD_CFLAGS += $(call cc-option,-fstack-usage) + +KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral) + +# turn jbsr into jsr for m68k +ifeq ($(ARCH),m68k) +ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4) +KBUILD_AFLAGS += -Wa,-gstabs,-S +endif +endif + # load other configuration include $(TOPDIR)/config.mk
diff --git a/config.mk b/config.mk index ba42641..04b63f6 100644 --- a/config.mk +++ b/config.mk @@ -90,19 +90,13 @@ endif
#########################################################################
-# We don't actually use $(ARFLAGS) anywhere anymore, so catch people -# who are porting old code to latest mainline but not updating $(AR). -ARFLAGS = $(error update your Makefile to use cmd_link_o_target and not AR) RELFLAGS= $(PLATFORM_RELFLAGS) -DBGFLAGS= -g # -DDEBUG -OPTFLAGS= -Os #-fomit-frame-pointer
OBJCFLAGS += --gap-fill=0xff
gccincdir := $(shell $(CC) -print-file-name=include)
-CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \ - -D__KERNEL__ +CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
# Enable garbage collection of un-used sections for SPL ifeq ($(CONFIG_SPL_BUILD),y) @@ -134,26 +128,10 @@ CPPFLAGS += -I$(OBJTREE)/include endif
CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include -CPPFLAGS += -fno-builtin -ffreestanding -nostdinc \ +CPPFLAGS += -nostdinc \ -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
-CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes - -ifdef BUILD_TAG -CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"' -endif - -CFLAGS_SSP := $(call cc-option,-fno-stack-protector) -CFLAGS += $(CFLAGS_SSP) -# Some toolchains enable security related warning flags by default, -# but they don't make much sense in the u-boot world, so disable them. -CFLAGS_WARN := $(call cc-option,-Wno-format-nonliteral) \ - $(call cc-option,-Wno-format-security) -CFLAGS += $(CFLAGS_WARN) - -# Report stack usage if supported -CFLAGS_STACK := $(call cc-option,-fstack-usage) -CFLAGS += $(CFLAGS_STACK) +CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
@@ -165,18 +143,7 @@ endif endif endif
-# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format> -# option to the assembler. -AFLAGS_DEBUG := - -# turn jbsr into jsr for m68k -ifeq ($(ARCH),m68k) -ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4) -AFLAGS_DEBUG := -Wa,-gstabs,-S -endif -endif - -AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS) +AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
LDFLAGS += $(PLATFORM_LDFLAGS) LDFLAGS_FINAL += -Bstatic

This commit merges commonly-used header include paths to UBOOTINCLUDE and NOSTDINC_FLAGS variables, which are placed at the top Makefile.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 14 +++++++++++++- config.mk | 11 ++--------- tools/Makefile | 8 +++----- tools/env/Makefile | 4 +--- 4 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/Makefile b/Makefile index a4af4a1..1523f12 100644 --- a/Makefile +++ b/Makefile @@ -226,6 +226,15 @@ CHECK = sparse CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
+# Use UBOOTINCLUDE when you must reference the include/ directory. +# Needed to be compatible with the O= option +UBOOTINCLUDE := +ifneq ($(OBJTREE),$(SRCTREE)) +UBOOTINCLUDE += -I$(OBJTREE)/include +endif +UBOOTINCLUDE += -I$(srctree)/include \ + -I$(srctree)/arch/$(ARCH)/include + KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_CFLAGS := -Wall -Wstrict-prototypes \ @@ -238,7 +247,7 @@ export CPP AR NM LDR STRIP OBJCOPY OBJDUMP export MAKE AWK export DTC CHECK CHECKFLAGS
-export KBUILD_CPPFLAGS +export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE export KBUILD_CFLAGS KBUILD_AFLAGS
KBUILD_CFLAGS += -Os #-fomit-frame-pointer @@ -254,6 +263,9 @@ KBUILD_CFLAGS += -g # option to the assembler. KBUILD_AFLAGS += -g
+NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) +CHECKFLAGS += $(NOSTDINC_FLAGS) + # Report stack usage if supported KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
diff --git a/config.mk b/config.mk index 04b63f6..f700ee1 100644 --- a/config.mk +++ b/config.mk @@ -94,8 +94,6 @@ RELFLAGS= $(PLATFORM_RELFLAGS)
OBJCFLAGS += --gap-fill=0xff
-gccincdir := $(shell $(CC) -print-file-name=include) - CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
# Enable garbage collection of un-used sections for SPL @@ -123,13 +121,8 @@ Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file) endif endif
-ifneq ($(OBJTREE),$(SRCTREE)) -CPPFLAGS += -I$(OBJTREE)/include -endif - -CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include -CPPFLAGS += -nostdinc \ - -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS) +CPPFLAGS += $(UBOOTINCLUDE) +CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
diff --git a/tools/Makefile b/tools/Makefile index 6c2a29c..3c186ba 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -173,11 +173,9 @@ HOSTSRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c)) # Define _GNU_SOURCE to obtain the getline prototype from stdio.h # HOST_EXTRACFLAGS += -include $(SRCTREE)/include/libfdt_env.h \ - -idirafter $(SRCTREE)/include \ - -idirafter $(SRCTREE)/arch/$(ARCH)/include \ - -idirafter $(OBJTREE)/include \ - -I $(SRCTREE)/lib/libfdt \ - -I $(SRCTREE)/tools \ + $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \ + -I$(SRCTREE)/lib/libfdt \ + -I$(SRCTREE)/tools \ -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \ -DUSE_HOSTCC \ -D__KERNEL_STRICT_NAMES \ diff --git a/tools/env/Makefile b/tools/env/Makefile index c303815..d47fe16 100644 --- a/tools/env/Makefile +++ b/tools/env/Makefile @@ -6,9 +6,7 @@ #
# Compile for a hosted environment on the target -HOST_EXTRACFLAGS = -idirafter $(SRCTREE)/include \ - -idirafter $(SRCTREE)/arch/$(ARCH)/include \ - -idirafter $(OBJTREE)/include \ +HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \ -idirafter $(SRCTREE)/tools/env \ -DUSE_HOSTCC \ -DTEXT_BASE=$(TEXT_BASE)

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

Some flags are used for SPL (and TPL) build only. This commit moves them from config.mk to spl/Makefile.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
config.mk | 19 ------------------- spl/Makefile | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/config.mk b/config.mk index 54d1d8b..597a566 100644 --- a/config.mk +++ b/config.mk @@ -95,20 +95,6 @@ RELFLAGS= $(PLATFORM_RELFLAGS) OBJCFLAGS += --gap-fill=0xff
CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS) - -# Enable garbage collection of un-used sections for SPL -ifeq ($(CONFIG_SPL_BUILD),y) -CPPFLAGS += -ffunction-sections -fdata-sections -LDFLAGS_FINAL += --gc-sections -endif - -ifeq ($(CONFIG_SPL_BUILD),y) -CPPFLAGS += -DCONFIG_SPL_BUILD -ifeq ($(CONFIG_TPL_BUILD),y) -CPPFLAGS += -DCONFIG_TPL_BUILD -endif -endif - CPPFLAGS += $(UBOOTINCLUDE) CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
@@ -129,11 +115,6 @@ AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS) LDFLAGS += $(PLATFORM_LDFLAGS) LDFLAGS_FINAL += -Bstatic
-LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL) -ifneq ($(CONFIG_SPL_TEXT_BASE),) -LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) -endif - #########################################################################
export PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS diff --git a/spl/Makefile b/spl/Makefile index 13dd616..798c9f3 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -17,6 +17,15 @@ CONFIG_SPL_BUILD := y export CONFIG_SPL_BUILD
+KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD +ifeq ($(CONFIG_TPL_BUILD),y) +KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD +endif + +# Enable garbage collection of un-used sections for SPL +KBUILD_CFLAGS += -ffunction-sections -fdata-sections +LDFLAGS_FINAL += --gc-sections + ifeq ($(CONFIG_TPL_BUILD),y) export CONFIG_TPL_BUILD SPL_BIN := u-boot-tpl @@ -164,6 +173,11 @@ endif $(obj)$(SPL_BIN).bin: $(obj)$(SPL_BIN) $(OBJCOPY) $(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) \

This commit moves some flags which are used under examples/ directory only.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
config.mk | 8 -------- examples/api/Makefile | 4 ++++ examples/standalone/Makefile | 4 ++++ 3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/config.mk b/config.mk index 597a566..ed1a519 100644 --- a/config.mk +++ b/config.mk @@ -102,14 +102,6 @@ CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
-ifeq ($(findstring examples/,$(BCURDIR)),) -ifeq ($(CONFIG_SPL_BUILD),) -ifdef FTRACE -CFLAGS += -finstrument-functions -DFTRACE -endif -endif -endif - AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
LDFLAGS += $(PLATFORM_LDFLAGS) diff --git a/examples/api/Makefile b/examples/api/Makefile index 52f4368..ee3c487 100644 --- a/examples/api/Makefile +++ b/examples/api/Makefile @@ -4,6 +4,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
+ifdef FTRACE +CFLAGS += -finstrument-functions -DFTRACE +endif + ifeq ($(ARCH),powerpc) LOAD_ADDR = 0x40000 endif diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile index cad4409..1f8d70c 100644 --- a/examples/standalone/Makefile +++ b/examples/standalone/Makefile @@ -5,6 +5,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
+ifdef FTRACE +CFLAGS += -finstrument-functions -DFTRACE +endif + extra-y := hello_world extra-$(CONFIG_SMC91111) += smc91111_eeprom extra-$(CONFIG_SMC911X) += smc911x_eeprom

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

We are going to switch over to Kbuild in upcoming commits.
Each makefile must have non-empty obj- or obj-y to generate built-in.o on Kbuild.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
arch/arm/cpu/armv7/tegra114/Makefile | 3 ++- arch/arm/cpu/armv7/tegra30/Makefile | 3 ++- arch/nds32/cpu/n1213/Makefile | 3 +++ board/freescale/common/Makefile | 5 ++++- board/samsung/origen/Makefile | 3 +++ board/samsung/smdkv310/Makefile | 3 +++ board/spear/common/Makefile | 5 ++++- board/spear/x600/Makefile | 5 ++++- 8 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/arch/arm/cpu/armv7/tegra114/Makefile b/arch/arm/cpu/armv7/tegra114/Makefile index 886b509..77e2319 100644 --- a/arch/arm/cpu/armv7/tegra114/Makefile +++ b/arch/arm/cpu/armv7/tegra114/Makefile @@ -17,4 +17,5 @@ # along with this program. If not, see http://www.gnu.org/licenses/. #
-obj- := +# necessary to create built-in.o +obj- := __dummy__.o diff --git a/arch/arm/cpu/armv7/tegra30/Makefile b/arch/arm/cpu/armv7/tegra30/Makefile index 518d6d1..413eba1 100644 --- a/arch/arm/cpu/armv7/tegra30/Makefile +++ b/arch/arm/cpu/armv7/tegra30/Makefile @@ -17,4 +17,5 @@ # along with this program. If not, see http://www.gnu.org/licenses/. #
-obj- := +# necessary to create built-in.o +obj- := __dummy__.o diff --git a/arch/nds32/cpu/n1213/Makefile b/arch/nds32/cpu/n1213/Makefile index bb3550e..206d304 100644 --- a/arch/nds32/cpu/n1213/Makefile +++ b/arch/nds32/cpu/n1213/Makefile @@ -9,4 +9,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
+# necessary to create built-in.o +obj- := __dummy__.o + extra-y = start.o diff --git a/board/freescale/common/Makefile b/board/freescale/common/Makefile index 25f063d..f6a0879 100644 --- a/board/freescale/common/Makefile +++ b/board/freescale/common/Makefile @@ -13,7 +13,10 @@ MINIMAL=y endif endif
-ifndef MINIMAL +ifdef MINIMAL +# necessary to create built-in.o +obj- := __dummy__.o +else obj-$(CONFIG_FSL_CADMUS) += cadmus.o obj-$(CONFIG_FSL_VIA) += cds_via.o obj-$(CONFIG_FMAN_ENET) += fman.o diff --git a/board/samsung/origen/Makefile b/board/samsung/origen/Makefile index 37acba7..1add9fe 100644 --- a/board/samsung/origen/Makefile +++ b/board/samsung/origen/Makefile @@ -5,6 +5,9 @@ #
ifdef CONFIG_SPL_BUILD +# necessary to create built-in.o +obj- := __dummy__.o + hostprogs-y := tools/mkorigenspl always := $(hostprogs-y)
diff --git a/board/samsung/smdkv310/Makefile b/board/samsung/smdkv310/Makefile index 9e37b4e..de0da16 100644 --- a/board/samsung/smdkv310/Makefile +++ b/board/samsung/smdkv310/Makefile @@ -5,6 +5,9 @@ #
ifdef CONFIG_SPL_BUILD +# necessary to create built-in.o +obj- := __dummy__.o + hostprogs-y := tools/mksmdkv310spl always := $(hostprogs-y) else diff --git a/board/spear/common/Makefile b/board/spear/common/Makefile index 08dc09f..b0ba320 100644 --- a/board/spear/common/Makefile +++ b/board/spear/common/Makefile @@ -5,7 +5,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-ifndef CONFIG_SPL_BUILD +ifdef CONFIG_SPL_BUILD +# necessary to create built-in.o +obj- := __dummy__.o +else obj-y := spr_misc.o obj-y += spr_lowlevel_init.o endif diff --git a/board/spear/x600/Makefile b/board/spear/x600/Makefile index f9053fe..18d3dd2 100644 --- a/board/spear/x600/Makefile +++ b/board/spear/x600/Makefile @@ -5,6 +5,9 @@ # SPDX-License-Identifier: GPL-2.0+ #
-ifndef CONFIG_SPL_BUILD +ifdef CONFIG_SPL_BUILD +# necessary to create built-in.o +obj- := __dummy__.o +else obj-y := fpga.o x600.o endif

Some build scripts including scripts/Makefile.build will be imported from Linux Kernel in the next commit. We need to adjust them for U-Boot in the following commits.
To make it easier for reviewers to track the modification, this commit renames scripts/Makefile.build to scripts/Makefile.build.tmp beforehand.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
scripts/Kbuild.include | 2 +- scripts/{Makefile.build => Makefile.build.tmp} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename scripts/{Makefile.build => Makefile.build.tmp} (100%)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 6113c13..30a5551 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -165,7 +165,7 @@ ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= # Usage: # $(Q)$(MAKE) $(build)=dir -build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj +build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build.tmp obj
### # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= diff --git a/scripts/Makefile.build b/scripts/Makefile.build.tmp similarity index 100% rename from scripts/Makefile.build rename to scripts/Makefile.build.tmp

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

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 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, there are ccflags-y, asflags-y, cppflags-y, CFLAGS_$(basetarget).o, CFLAGS_REMOVE_$(basetarget).o for that purpose.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
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 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 | 15 -- 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 | 19 +- fs/ubifs/Makefile | 2 +- fs/yaffs2/Makefile | 9 +- lib/Makefile | 2 +- lib/lzma/Makefile | 2 +- nand_spl/board/amcc/acadia/Makefile | 7 +- nand_spl/board/amcc/bamboo/Makefile | 7 +- nand_spl/board/amcc/canyonlands/Makefile | 7 +- nand_spl/board/amcc/kilauea/Makefile | 7 +- nand_spl/board/amcc/sequoia/Makefile | 7 +- nand_spl/board/freescale/mpc8315erdb/Makefile | 7 +- nand_spl/board/freescale/mpc8536ds/Makefile | 7 +- nand_spl/board/freescale/mpc8569mds/Makefile | 7 +- nand_spl/board/freescale/mpc8572ds/Makefile | 7 +- nand_spl/board/freescale/p1023rds/Makefile | 7 +- nand_spl/board/freescale/p1_p2_rdb/Makefile | 7 +- nand_spl/board/sheldon/simpc8313/Makefile | 7 +- net/Makefile | 2 +- post/lib_powerpc/fpu/Makefile | 30 ++-- scripts/Kbuild.include | 2 +- scripts/Makefile.build | 21 ++- scripts/Makefile.lib | 14 +- spl/Makefile | 22 +-- tools/Makefile | 23 +-- 77 files changed, 456 insertions(+), 311 deletions(-)
diff --git a/Makefile b/Makefile index 3a6f63c..199a1e5 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,78 @@ else XECHO = : endif
+# *DOCUMENTATION* +# To see a list of typical targets execute "make help" +# More info can be located in ./README +# Comments in this file are targeted only to the developer, do not +# expect to learn how to build the kernel reading this file. + +# Do not: +# o use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour); +# o print "Entering directory ..."; +MAKEFLAGS += -rR --no-print-directory + +# Avoid funny character set dependencies +unexport LC_ALL +LC_COLLATE=C +LC_NUMERIC=C +export LC_COLLATE LC_NUMERIC + +# We are using a recursive build, so we need to do a little thinking +# to get the ordering right. +# +# Most importantly: sub-Makefiles should only ever modify files in +# their own directory. If in some directory we have a dependency on +# a file in another dir (which doesn't happen often, but it's often +# unavoidable when linking the built-in.o targets which finally +# turn into vmlinux), we will call a sub make in that other dir, and +# after that we are sure that everything which is in that other dir +# is now up to date. +# +# The only cases where we need to modify files which have global +# effects are thus separated out and done before the recursive +# descending is started. They are now explicitly listed as the +# prepare rule. + +# To put more focus on warnings, be less verbose as default +# Use 'make V=1' to see the full commands + +ifeq ("$(origin V)", "command line") + KBUILD_VERBOSE = $(V) +endif +ifndef KBUILD_VERBOSE + KBUILD_VERBOSE = 0 +endif + +# Call a source code checker (by default, "sparse") as part of the +# C compilation. +# +# Use 'make C=1' to enable checking of only re-compiled files. +# Use 'make C=2' to enable checking of *all* source files, regardless +# of whether they are re-compiled or not. +# +# See the file "Documentation/sparse.txt" for more details, including +# where to get the "sparse" utility. + +ifeq ("$(origin C)", "command line") + KBUILD_CHECKSRC = $(C) +endif +ifndef KBUILD_CHECKSRC + KBUILD_CHECKSRC = 0 +endif + +# Use make M=dir to specify directory of external module to build +# Old syntax make ... SUBDIRS=$PWD is still supported +# Setting the environment variable KBUILD_EXTMOD take precedence +ifdef SUBDIRS + KBUILD_EXTMOD ?= $(SUBDIRS) +endif + +ifeq ("$(origin M)", "command line") + KBUILD_EXTMOD := $(M) +endif + # kbuild supports saving output files in a separate directory. # To locate output files in a separate directory two syntaxes are supported. # In both cases the working directory must be the root of the kernel src. @@ -107,8 +179,14 @@ endif # ifeq ($(KBUILD_SRC),) # We process the rest of the Makefile if this is the final invocation of make ifeq ($(skip-makefile),)
+# If building an external module we do not care about the all: rule +# but instead _all depend on modules PHONY += all +ifeq ($(KBUILD_EXTMOD),) _all: all +else +_all: modules +endif
srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) objtree := $(CURDIR) @@ -119,24 +197,6 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
export srctree objtree VPATH
-# Call a source code checker (by default, "sparse") as part of the -# C compilation. -# -# Use 'make C=1' to enable checking of re-compiled files. -# -# See the linux kernel file "Documentation/sparse.txt" for more details, -# including where to get the "sparse" utility. - -ifdef C -ifeq ("$(origin C)", "command line") -CHECKSRC := $(C) -endif -endif -ifndef CHECKSRC - CHECKSRC = 0 -endif -export CHECKSRC - OBJTREE := $(objtree) SPLTREE := $(OBJTREE)/spl TPLTREE := $(OBJTREE)/tpl @@ -222,6 +282,78 @@ HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp") HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress") endif
+# Decide whether to build built-in, modular, or both. +# Normally, just do built-in. + +KBUILD_MODULES := +KBUILD_BUILTIN := 1 + +# If we have only "make modules", don't compile built-in objects. +# When we're building modules with modversions, we need to consider +# the built-in objects during the descend as well, in order to +# make sure the checksums are up to date before we record them. + +ifeq ($(MAKECMDGOALS),modules) + KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) +endif + +# If we have "make <whatever> modules", compile modules +# in addition to whatever we do anyway. +# Just "make" or "make all" shall build modules as well + +# U-Boot does not need modules +#ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) +# KBUILD_MODULES := 1 +#endif + +#ifeq ($(MAKECMDGOALS),) +# KBUILD_MODULES := 1 +#endif + +export KBUILD_MODULES KBUILD_BUILTIN +export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD + +# Beautify output +# --------------------------------------------------------------------------- +# +# Normally, we echo the whole command before executing it. By making +# that echo $($(quiet)$(cmd)), we now have the possibility to set +# $(quiet) to choose other forms of output instead, e.g. +# +# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ +# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< +# +# If $(quiet) is empty, the whole command will be printed. +# If it is set to "quiet_", only the short version will be printed. +# If it is set to "silent_", nothing will be printed at 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 @@ -674,7 +835,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 @@ -682,27 +843,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 @@ -777,14 +938,14 @@ checkdtc: include/autoconf.mk.dep: include/config.h include/common.h @$(XECHO) Generating $@ ; \ : Generate the dependancies ; \ - $(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \ + $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \ -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || \ rm $@
include/autoconf.mk: include/config.h @$(XECHO) Generating $@ ; \ : Extract the config macros ; \ - $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ + $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ rm $@.tmp
@@ -792,7 +953,7 @@ include/autoconf.mk: include/config.h include/tpl-autoconf.mk: include/config.h @$(XECHO) Generating $@ ; \ : Extract the config macros ; \ - $(CPP) $(CFLAGS) -DCONFIG_TPL_BUILD -DCONFIG_SPL_BUILD\ + $(CPP) $(c_flags) -DCONFIG_TPL_BUILD -DCONFIG_SPL_BUILD\ -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ rm $@.tmp @@ -800,7 +961,7 @@ include/tpl-autoconf.mk: include/config.h include/spl-autoconf.mk: include/config.h @$(XECHO) Generating $@ ; \ : Extract the config macros ; \ - $(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ + $(CPP) $(c_flags) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ rm $@.tmp
@@ -811,7 +972,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 @@ -822,7 +983,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 $@; \ @@ -869,15 +1030,15 @@ $(TIMESTAMP_FILE): @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
easylogo env gdb: - $(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION} + $(Q)$(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION}
gdbtools: gdb
xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc - $(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) $(build)=doc/DocBook $@ + $(Q)$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) $(build)=doc/DocBook $@
tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE) - $(MAKE) $(build)=tools HOST_TOOLS_ALL=y + $(Q)$(MAKE) $(build)=tools HOST_TOOLS_ALL=y
.PHONY : CHANGELOG CHANGELOG: @@ -937,7 +1098,7 @@ clean: @$(MAKE) -f $(srctree)/doc/DocBook/Makefile cleandocs @find $(OBJTREE) -type f \ ( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \ - -o -name '*.o' -o -name '*.a' -o -name '*.exe' \ + -o -name '*.o' -o -name '*.a' -o -name '*.exe' -o -name '*.cmd' \ -o -name '*.cfgtmp' ) -print \ | xargs rm -f
diff --git a/arch/arm/imx-common/Makefile b/arch/arm/imx-common/Makefile index 2c80441..6eb05dd 100644 --- a/arch/arm/imx-common/Makefile +++ b/arch/arm/imx-common/Makefile @@ -22,7 +22,7 @@ obj-$(CONFIG_CMD_HDMIDETECT) += cmd_hdmidet.o
$(OBJTREE)/$(patsubst "%",%,$(CONFIG_IMX_CONFIG)).cfgtmp: $(OBJTREE)/%.cfgtmp : $(SRCTREE)/% mkdir -p $(dir $@) - $(CC) -E -x c $< $(CPPFLAGS) -o $@ + $(CPP) $(cpp_flags) -x c -o $@ $<
$(OBJTREE)/u-boot.imx: $(OBJTREE)/u-boot.bin $(OBJTREE)/$(patsubst "%",%,$(CONFIG_IMX_CONFIG)).cfgtmp $(OBJTREE)/tools/mkimage -n $(filter-out %.bin,$^) -T imximage \ diff --git a/arch/blackfin/cpu/Makefile b/arch/blackfin/cpu/Makefile index 369dc74..dd4d2d1 100644 --- a/arch/blackfin/cpu/Makefile +++ b/arch/blackfin/cpu/Makefile @@ -25,7 +25,7 @@ extra-y += check_initcode
# make sure our initcode (which goes into LDR) does not # have relocs or external references -$(obj)/initcode.o: CFLAGS += -fno-function-sections -fno-data-sections +CFLAGS_REMOVE_initcode.o := -ffunction-sections -fdata-sections READINIT = env LC_ALL=C $(CROSS_COMPILE)readelf -s $< $(obj)/check_initcode: $(obj)/initcode.o ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS) @@ -35,7 +35,6 @@ ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS) fi endif
-$(obj)/init.lds: $(src)/init.lds.S - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P $^ -o $@ +CPPFLAGS_init.lds := -ansi $(obj)/init.elf: $(obj)/init.lds $(obj)/init.o $(obj)/initcode.o $(LD) $(LDFLAGS) -T $^ -o $@ diff --git a/arch/blackfin/lib/Makefile b/arch/blackfin/lib/Makefile index a5c552f..4ba7bf6 100644 --- a/arch/blackfin/lib/Makefile +++ b/arch/blackfin/lib/Makefile @@ -9,7 +9,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS += -DBFIN_BOARD_NAME='"$(BOARD)"' +# Unnecessary. +# Use CONFIG_SYS_BOARD instead of BFIN_BOARD_NAME +# and delete this. +ccflags-y += -DBFIN_BOARD_NAME='"$(BOARD)"'
obj-y += ins.o obj-y += memcmp.o diff --git a/arch/m68k/cpu/mcf5227x/Makefile b/arch/m68k/cpu/mcf5227x/Makefile index a47fd56..e0c5db6 100644 --- a/arch/m68k/cpu/mcf5227x/Makefile +++ b/arch/m68k/cpu/mcf5227x/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-# CFLAGS += -DET_DEBUG +# ccflags-y += -DET_DEBUG
extra-y = start.o obj-y = cpu.o speed.o cpu_init.o interrupts.o diff --git a/arch/m68k/cpu/mcf523x/Makefile b/arch/m68k/cpu/mcf523x/Makefile index a47fd56..e0c5db6 100644 --- a/arch/m68k/cpu/mcf523x/Makefile +++ b/arch/m68k/cpu/mcf523x/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-# CFLAGS += -DET_DEBUG +# ccflags-y += -DET_DEBUG
extra-y = start.o obj-y = cpu.o speed.o cpu_init.o interrupts.o diff --git a/arch/m68k/cpu/mcf52x2/Makefile b/arch/m68k/cpu/mcf52x2/Makefile index d9bf900..b92fd86 100644 --- a/arch/m68k/cpu/mcf52x2/Makefile +++ b/arch/m68k/cpu/mcf52x2/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-# CFLAGS += -DET_DEBUG +# ccflags-y += -DET_DEBUG
extra-y = start.o obj-y = interrupts.o cpu.o speed.o cpu_init.o diff --git a/arch/m68k/cpu/mcf532x/Makefile b/arch/m68k/cpu/mcf532x/Makefile index 97aa3f1..9c53c50 100644 --- a/arch/m68k/cpu/mcf532x/Makefile +++ b/arch/m68k/cpu/mcf532x/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-# CFLAGS += -DET_DEBUG +# ccflags-y += -DET_DEBUG
extra-y := start.o obj-y = cpu.o speed.o cpu_init.o interrupts.o diff --git a/arch/m68k/cpu/mcf5445x/Makefile b/arch/m68k/cpu/mcf5445x/Makefile index b506719..9be91ed 100644 --- a/arch/m68k/cpu/mcf5445x/Makefile +++ b/arch/m68k/cpu/mcf5445x/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-# CFLAGS += -DET_DEBUG +# ccflags-y += -DET_DEBUG
extra-y = start.o obj-y = cpu.o speed.o cpu_init.o interrupts.o pci.o diff --git a/arch/m68k/cpu/mcf547x_8x/Makefile b/arch/m68k/cpu/mcf547x_8x/Makefile index 0fa50bf..4f82099 100644 --- a/arch/m68k/cpu/mcf547x_8x/Makefile +++ b/arch/m68k/cpu/mcf547x_8x/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-# CFLAGS += -DET_DEBUG +# ccflags-y += -DET_DEBUG
extra-y = start.o obj-y = cpu.o speed.o cpu_init.o pci.o interrupts.o slicetimer.o diff --git a/arch/powerpc/cpu/mpc8xx/Makefile b/arch/powerpc/cpu/mpc8xx/Makefile index d40bdab..f83fd5e 100644 --- a/arch/powerpc/cpu/mpc8xx/Makefile +++ b/arch/powerpc/cpu/mpc8xx/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-# CFLAGS += -DET_DEBUG +# ccflags-y += -DET_DEBUG
extra-y += start.o extra-y += traps.o diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index ac780d4..e6d8be5 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile @@ -54,11 +54,11 @@ ifndef CONFIG_SPL_BUILD # Workaround for local bus unaligned access problems # on MPC512x and MPC5200 ifdef CONFIG_MPC512X -$(obj)/ppcstring.o: AFLAGS += -Dmemcpy=__memcpy +AFLAGS_ppcstring.o += -Dmemcpy=__memcpy obj-y += memcpy_mpc5200.o endif ifdef CONFIG_MPC5200 -$(obj)/ppcstring.o: AFLAGS += -Dmemcpy=__memcpy +AFLAGS_ppcstring.o += -Dmemcpy=__memcpy obj-y += memcpy_mpc5200.o endif endif diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile index c5f5426..63deded 100644 --- a/arch/sandbox/cpu/Makefile +++ b/arch/sandbox/cpu/Makefile @@ -10,7 +10,10 @@ obj-y := cpu.o os.o start.o state.o
# os.c is build in the system environment, so needs standard includes -$(obj)/os.o: CFLAGS := $(filter-out -nostdinc,\ - $(patsubst -I%,-idirafter%,$(CFLAGS))) -$(obj)/.depend.os: CPPFLAGS := $(filter-out -nostdinc,\ - $(patsubst -I%,-idirafter%,$(CPPFLAGS))) +# CFLAGS_REMOVE_os.o cannot be used to drop header include path +quiet_cmd_cc_os.o = CC $(quiet_modtag) $@ +cmd_cc_os.o = $(CC) $(filter-out -nostdinc, \ + $(patsubst -I%,-idirafter%,$(c_flags))) -c -o $@ $< + +$(obj)/os.o: $(src)/os.c FORCE + $(call if_changed_dep,cc_os.o) diff --git a/board/bct-brettl2/config.mk b/board/bct-brettl2/config.mk index f1ef9bf..0d3df2d 100644 --- a/board/bct-brettl2/config.mk +++ b/board/bct-brettl2/config.mk @@ -7,6 +7,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif diff --git a/board/bf518f-ezbrd/config.mk b/board/bf518f-ezbrd/config.mk index f1ef9bf..0d3df2d 100644 --- a/board/bf518f-ezbrd/config.mk +++ b/board/bf518f-ezbrd/config.mk @@ -7,6 +7,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif diff --git a/board/bf526-ezbrd/config.mk b/board/bf526-ezbrd/config.mk index f1ef9bf..0d3df2d 100644 --- a/board/bf526-ezbrd/config.mk +++ b/board/bf526-ezbrd/config.mk @@ -7,6 +7,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif diff --git a/board/bf527-ad7160-eval/config.mk b/board/bf527-ad7160-eval/config.mk index f1ef9bf..0d3df2d 100644 --- a/board/bf527-ad7160-eval/config.mk +++ b/board/bf527-ad7160-eval/config.mk @@ -7,6 +7,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif diff --git a/board/bf527-ezkit/config.mk b/board/bf527-ezkit/config.mk index f1ef9bf..0d3df2d 100644 --- a/board/bf527-ezkit/config.mk +++ b/board/bf527-ezkit/config.mk @@ -7,6 +7,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif diff --git a/board/bf527-sdp/config.mk b/board/bf527-sdp/config.mk index 5f327a9..af299f5 100644 --- a/board/bf527-sdp/config.mk +++ b/board/bf527-sdp/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 6 diff --git a/board/bf533-ezkit/config.mk b/board/bf533-ezkit/config.mk index 973d357..97eaafe 100644 --- a/board/bf533-ezkit/config.mk +++ b/board/bf533-ezkit/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8 diff --git a/board/bf533-stamp/config.mk b/board/bf533-stamp/config.mk index 973d357..97eaafe 100644 --- a/board/bf533-stamp/config.mk +++ b/board/bf533-stamp/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8 diff --git a/board/bf537-stamp/config.mk b/board/bf537-stamp/config.mk index ae2ea0b..bc0e747 100644 --- a/board/bf537-stamp/config.mk +++ b/board/bf537-stamp/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8 diff --git a/board/bf538f-ezkit/config.mk b/board/bf538f-ezkit/config.mk index 973d357..97eaafe 100644 --- a/board/bf538f-ezkit/config.mk +++ b/board/bf538f-ezkit/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8 diff --git a/board/bf548-ezkit/config.mk b/board/bf548-ezkit/config.mk index ad3a729..8d2c60f 100644 --- a/board/bf548-ezkit/config.mk +++ b/board/bf548-ezkit/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --dma 6 diff --git a/board/bf561-acvilon/config.mk b/board/bf561-acvilon/config.mk index c33aef9..ce94715 100644 --- a/board/bf561-acvilon/config.mk +++ b/board/bf561-acvilon/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 diff --git a/board/bf561-ezkit/config.mk b/board/bf561-ezkit/config.mk index c33aef9..ce94715 100644 --- a/board/bf561-ezkit/config.mk +++ b/board/bf561-ezkit/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 diff --git a/board/br4/config.mk b/board/br4/config.mk index 5c18d5c..2436ec0 100644 --- a/board/br4/config.mk +++ b/board/br4/config.mk @@ -9,6 +9,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif diff --git a/board/cm-bf527/config.mk b/board/cm-bf527/config.mk index f1ef9bf..0d3df2d 100644 --- a/board/cm-bf527/config.mk +++ b/board/cm-bf527/config.mk @@ -7,6 +7,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif diff --git a/board/cm-bf533/config.mk b/board/cm-bf533/config.mk index 973d357..97eaafe 100644 --- a/board/cm-bf533/config.mk +++ b/board/cm-bf533/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8 diff --git a/board/cm-bf537e/config.mk b/board/cm-bf537e/config.mk index 973d357..97eaafe 100644 --- a/board/cm-bf537e/config.mk +++ b/board/cm-bf537e/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8 diff --git a/board/cm-bf537u/config.mk b/board/cm-bf537u/config.mk index 973d357..97eaafe 100644 --- a/board/cm-bf537u/config.mk +++ b/board/cm-bf537u/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8 diff --git a/board/cm-bf548/config.mk b/board/cm-bf548/config.mk index c005afb..289c8a4 100644 --- a/board/cm-bf548/config.mk +++ b/board/cm-bf548/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --dma 6 diff --git a/board/cm-bf561/config.mk b/board/cm-bf561/config.mk index c33aef9..ce94715 100644 --- a/board/cm-bf561/config.mk +++ b/board/cm-bf561/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 diff --git a/board/ip04/config.mk b/board/ip04/config.mk index ae2ea0b..bc0e747 100644 --- a/board/ip04/config.mk +++ b/board/ip04/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8 diff --git a/board/matrix_vision/mvblx/Makefile b/board/matrix_vision/mvblx/Makefile index c6c0933..c056eba 100644 --- a/board/matrix_vision/mvblx/Makefile +++ b/board/matrix_vision/mvblx/Makefile @@ -8,4 +8,4 @@ obj-y += mvblx.o fpga.o obj-$(CONFIG_ID_EEPROM) += sys_eeprom.o
-CFLAGS += -Werror +ccflags-y += -Werror diff --git a/board/pr1/config.mk b/board/pr1/config.mk index 5c18d5c..2436ec0 100644 --- a/board/pr1/config.mk +++ b/board/pr1/config.mk @@ -9,6 +9,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif diff --git a/board/sandburst/karef/Makefile b/board/sandburst/karef/Makefile index f890008..d5a9b34 100644 --- a/board/sandburst/karef/Makefile +++ b/board/sandburst/karef/Makefile @@ -13,7 +13,7 @@ BUILDUSER := $(shell whoami) FORCEBUILD := $(shell rm -f karef.o)
-CFLAGS += -DBUILDUSER='"$(BUILDUSER)"' +ccflags-y += -DBUILDUSER='"$(BUILDUSER)"' # TBS: end debugging
obj-y = karef.o ../common/flash.o ../common/sb_common.o diff --git a/board/sandburst/metrobox/Makefile b/board/sandburst/metrobox/Makefile index 37d91a5..8121cce 100644 --- a/board/sandburst/metrobox/Makefile +++ b/board/sandburst/metrobox/Makefile @@ -12,7 +12,7 @@ BUILDUSER := $(shell whoami) FORCEBUILD := $(shell rm -f metrobox.o)
-CFLAGS += -DBUILDUSER='"$(BUILDUSER)"' +ccflags-y += -DBUILDUSER='"$(BUILDUSER)"' # TBS: end debugging
obj-y = metrobox.o ../common/flash.o ../common/sb_common.o diff --git a/board/st-ericsson/snowball/Makefile b/board/st-ericsson/snowball/Makefile index 6867a70..f0605e2 100644 --- a/board/st-ericsson/snowball/Makefile +++ b/board/st-ericsson/snowball/Makefile @@ -4,6 +4,6 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS += -D__RELEASE -D__STN_8500 +ccflags-y += -D__RELEASE -D__STN_8500
obj-y := snowball.o diff --git a/board/st-ericsson/u8500/Makefile b/board/st-ericsson/u8500/Makefile index b9dfbe9..d6c4280 100644 --- a/board/st-ericsson/u8500/Makefile +++ b/board/st-ericsson/u8500/Makefile @@ -4,6 +4,6 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS += -D__RELEASE -D__STN_8500 +ccflags-y += -D__RELEASE -D__STN_8500
obj-y := u8500_href.o gpio.o diff --git a/board/tcm-bf518/config.mk b/board/tcm-bf518/config.mk index f1ef9bf..0d3df2d 100644 --- a/board/tcm-bf518/config.mk +++ b/board/tcm-bf518/config.mk @@ -7,6 +7,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif diff --git a/board/tcm-bf537/config.mk b/board/tcm-bf537/config.mk index 973d357..97eaafe 100644 --- a/board/tcm-bf537/config.mk +++ b/board/tcm-bf537/config.mk @@ -7,9 +7,10 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS_lib += -O2 -CFLAGS_lib/lzma += -O2 -CFLAGS_lib/zlib += -O2 +# FIX ME +ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),) +ccflags-y := -O2 +endif
# Set some default LDR flags based on boot mode. LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8 diff --git a/common/Makefile b/common/Makefile index cd86e4a..c6f8848 100644 --- a/common/Makefile +++ b/common/Makefile @@ -230,10 +230,6 @@ obj-$(CONFIG_FIT_SIGNATURE) += image-sig.o obj-y += memsize.o obj-y += stdio.o
-$(obj)/env_embedded.o: $(src)/env_embedded.c - $(CC) $(AFLAGS) -Wa,--no-warn \ - -DENV_CRC=$(shell tools/envcrc) -c -o $@ $< - -# SEE README.arm-unaligned-accesses -$(obj)/hush.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) -$(obj)/fdt_support.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) +CFLAGS_env_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2>/dev/null) +CFLAGS_hush.o := $(PLATFORM_NO_UNALIGNED) +CFLAGS_fdt_support.o := $(PLATFORM_NO_UNALIGNED) diff --git a/config.mk b/config.mk index 0fa3167..1336ef8 100644 --- a/config.mk +++ b/config.mk @@ -58,19 +58,10 @@ RELFLAGS= $(PLATFORM_RELFLAGS)
OBJCFLAGS += --gap-fill=0xff
-CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS) -CPPFLAGS += $(UBOOTINCLUDE) -CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS) - -CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS) +CPPFLAGS = $(RELFLAGS) +CPPFLAGS += -pipe $(PLATFORM_CPPFLAGS)
BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
-AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS) - LDFLAGS += $(PLATFORM_LDFLAGS) LDFLAGS_FINAL += -Bstatic - -######################################################################### - -export PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS diff --git a/disk/Makefile b/disk/Makefile index 48abec8..6970cec 100644 --- a/disk/Makefile +++ b/disk/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-#CFLAGS += -DET_DEBUG -DDEBUG +#ccflags-y += -DET_DEBUG -DDEBUG
obj-$(CONFIG_PARTITIONS) += part.o obj-$(CONFIG_MAC_PARTITION) += part_mac.o diff --git a/doc/DocBook/Makefile b/doc/DocBook/Makefile index 4bf0415..c1792dd 100644 --- a/doc/DocBook/Makefile +++ b/doc/DocBook/Makefile @@ -67,21 +67,6 @@ XMLTOFLAGS += --skip-validation %.xml: %.tmpl $(DOCPROC) doc $< >$@
-ifeq ($@, "cleandocs") -sinclude $(obj).depend -$(obj).depend: $(patsubst %.xml, %.tmpl, $(DOCBOOKS)) - rm -f $(obj).depend ; \ - touch $(obj).depend ; \ - for file in $^ ; do \ - xmlfile=`echo "$${file}" | \ - sed "s/tmpl$$/xml/"` ; \ - echo -n "$${xmlfile}: ">> $(obj).depend ; \ - $(DOCPROC) depend $$file >> $(obj).depend ; \ - echo -e "\n\t$(DOCPROC) doc $< >$${xmlfile} " >> \ - $(obj).depend ; \ - done -endif - ### # Changes in kernel-doc force a rebuild of all documentation $(BOOKS): $(KERNELDOC) diff --git a/drivers/bios_emulator/Makefile b/drivers/bios_emulator/Makefile index 330f36f..e56356e 100644 --- a/drivers/bios_emulator/Makefile +++ b/drivers/bios_emulator/Makefile @@ -8,8 +8,5 @@ obj-y = atibios.o biosemu.o besys.o bios.o \ $(X86DIR)/sys.o \ $(X86DIR)/debug.o
-EXTRA_CFLAGS += -I$(srctree)/$(src) -I$(srctree)/$(src)/include \ +ccflags-y := -I$(srctree)/$(src) -I$(srctree)/$(src)/include \ -D__PPC__ -D__BIG_ENDIAN__ - -CFLAGS += $(EXTRA_CFLAGS) -CPPFLAGS += $(EXTRA_CFLAGS) diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index a78a724..25b8e8a 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -8,7 +8,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-#CFLAGS += -DDEBUG +#ccflags-y += -DDEBUG
obj-$(CONFIG_DTT_ADM1021) += adm1021.o obj-$(CONFIG_DTT_ADT7460) += adt7460.o diff --git a/drivers/net/npe/Makefile b/drivers/net/npe/Makefile index 0779255..ff554cf 100644 --- a/drivers/net/npe/Makefile +++ b/drivers/net/npe/Makefile @@ -5,9 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-LOCAL_CFLAGS += -I$(TOPDIR)/drivers/net/npe/include -DCONFIG_IXP425_COMPONENT_ETHDB -D__linux -CFLAGS += $(LOCAL_CFLAGS) -CPPFLAGS += $(LOCAL_CFLAGS) # needed for depend +ccflags-y += -I$(src)/include -DCONFIG_IXP425_COMPONENT_ETHDB -D__linux
obj-y := npe.o \ miiphy.o \ diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index d5a2725..003d322 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-#CFLAGS += -DDEBUG +#ccflags-y += -DDEBUG
obj-$(CONFIG_RTC_AT91SAM9_RTT) += at91sam9_rtt.o obj-$(CONFIG_RTC_BFIN) += bfin_rtc.o diff --git a/drivers/usb/musb-new/Makefile b/drivers/usb/musb-new/Makefile index ba72348..3facf0f 100644 --- a/drivers/usb/musb-new/Makefile +++ b/drivers/usb/musb-new/Makefile @@ -9,7 +9,6 @@ obj-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o
-CFLAGS_NO_WARN := $(call cc-option,-Wno-unused-variable) \ - $(call cc-option,-Wno-unused-but-set-variable) \ - $(call cc-option,-Wno-unused-label) -CFLAGS += $(CFLAGS_NO_WARN) +ccflags-y := $(call cc-option,-Wno-unused-variable) \ + $(call cc-option,-Wno-unused-but-set-variable) \ + $(call cc-option,-Wno-unused-label) diff --git a/dts/Makefile b/dts/Makefile index d81f32d..cc6ecf6 100644 --- a/dts/Makefile +++ b/dts/Makefile @@ -36,7 +36,7 @@ process_lds = \ $(1) | sed -r -n 's/^OUTPUT_$(2)[ ("]*([^")]*).*/\1/p'
# Run the compiler and get the link script from the linker -GET_LDS = $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--verbose 2>&1 +GET_LDS = $(CC) $(c_flags) $(ld_flags) -Wl,--verbose 2>&1
$(obj)/dt.o: $(DT_BIN) # We want the output format and arch. diff --git a/examples/api/Makefile b/examples/api/Makefile index db0bb34..8b79886 100644 --- a/examples/api/Makefile +++ b/examples/api/Makefile @@ -5,7 +5,7 @@ #
ifdef FTRACE -CFLAGS += -finstrument-functions -DFTRACE +ccflags-y += -finstrument-functions -DFTRACE endif
ifeq ($(ARCH),powerpc) @@ -33,12 +33,6 @@ EXT_COBJ_FILES-y += lib/time.o EXT_COBJ_FILES-y += lib/vsprintf.o EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
-# Create a list of source files so their dependencies can be auto-generated -SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c)) -SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S)) -SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c)) -SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S)) - # Create a list of object files to be compiled OBJS += $(addprefix $(obj)/,$(SOBJ_FILES-y)) OBJS += $(addprefix $(obj)/,$(COBJ_FILES-y)) @@ -54,9 +48,10 @@ $(obj)/demo.bin: $(obj)/demo $(OBJCOPY) -O binary $< $@ 2>/dev/null
# Rule to build generic library C files -$(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c - $(CC) -g $(CFLAGS) -c -o $@ $< +$(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c FORCE + $(call cmd,force_checksrc) + $(call if_changed_rule,cc_o_c)
# Rule to build architecture-specific library assembly files $(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S - $(CC) -g $(CFLAGS) -c -o $@ $< + $(call if_changed_dep,as_o_S) diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile index a6819f7..ca62e2a 100644 --- a/examples/standalone/Makefile +++ b/examples/standalone/Makefile @@ -6,7 +6,7 @@ #
ifdef FTRACE -CFLAGS += -finstrument-functions -DFTRACE +ccflags-y += -finstrument-functions -DFTRACE endif
extra-y := hello_world @@ -41,8 +41,6 @@ LIBCOBJS = stubs.o
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 +50,22 @@ gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) # also causes the entry point of the standalone application to be # inconsistent. ifeq ($(ARCH),powerpc) -AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS)) -CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS)) -CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS)) +# FIX ME +CPPFLAGS := $(filter-out $(RELFLAGS), $(CPPFLAGS)) endif
# We don't want gcc reordering functions if possible. This ensures that an # application's entry point will be the first function in the application's # source file. -CFLAGS += $(call cc-option,-fno-toplevel-reorder) +ccflags-y += $(call cc-option,-fno-toplevel-reorder)
######################################################################### -$(LIB): $(LIBOBJS) - $(call cmd_link_o_target, $(LIBOBJS)) + +quiet_cmd_link_lib = LD $@ + cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^) + +$(LIB): $(LIBOBJS) FORCE + $(call if_changed,link_lib)
$(ELF): $(obj)/%: $(obj)/%.o $(LIB) diff --git a/fs/ubifs/Makefile b/fs/ubifs/Makefile index 5682b16..6b1a9a5 100644 --- a/fs/ubifs/Makefile +++ b/fs/ubifs/Makefile @@ -15,4 +15,4 @@ obj-y += tnc.o tnc_misc.o debug.o crc16.o budget.o obj-y += log.o orphan.o recovery.o replay.o
# SEE README.arm-unaligned-accesses -$(obj)/super.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) +CFLAGS_super.o := $(PLATFORM_NO_UNALIGNED) diff --git a/fs/yaffs2/Makefile b/fs/yaffs2/Makefile index d811287..45ff745 100644 --- a/fs/yaffs2/Makefile +++ b/fs/yaffs2/Makefile @@ -24,9 +24,6 @@ obj-y := \ yaffs_summary.o yaffs_tagscompat.o yaffs_verify.o yaffs_yaffs1.o \ yaffs_yaffs2.o yaffs_mtdif.o yaffs_mtdif2.o
-YCFLAGS = -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -YCFLAGS += -DCONFIG_YAFFS_YAFFS2 -DNO_Y_INLINE -YCFLAGS += -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES - -CFLAGS += $(YCFLAGS) -CPPFLAGS += $(YCFLAGS) +ccflags-y = -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM \ + -DCONFIG_YAFFS_YAFFS2 -DNO_Y_INLINE \ + -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES diff --git a/lib/Makefile b/lib/Makefile index 39e79dd..83c3e69 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -66,4 +66,4 @@ obj-$(CONFIG_BOOTP_RANDOM_DELAY) += rand.o obj-$(CONFIG_CMD_LINK_LOCAL) += rand.o
# SEE README.arm-unaligned-accesses -$(obj)/bzlib.o: CFLAGS += $(PLATFORM_NO_UNALIGNED) +CFLAGS_bzlib.o := $(PLATFORM_NO_UNALIGNED) diff --git a/lib/lzma/Makefile b/lib/lzma/Makefile index f8eda06..b6c8067 100644 --- a/lib/lzma/Makefile +++ b/lib/lzma/Makefile @@ -8,6 +8,6 @@ # SPDX-License-Identifier: GPL-2.0+ #
-CFLAGS += -D_LZMA_PROB32 +ccflags-y += -D_LZMA_PROB32
obj-y += LzmaDec.o LzmaTools.o diff --git a/nand_spl/board/amcc/acadia/Makefile b/nand_spl/board/amcc/acadia/Makefile index 041213f..949dce5 100644 --- a/nand_spl/board/amcc/acadia/Makefile +++ b/nand_spl/board/amcc/acadia/Makefile @@ -12,13 +12,12 @@ 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) @@ -42,7 +41,7 @@ $(nandobj)System.map: $(nandobj)u-boot-spl sort > $@
$(nandobj)u-boot.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
# create symbolic links for common files
diff --git a/nand_spl/board/amcc/bamboo/Makefile b/nand_spl/board/amcc/bamboo/Makefile index 92b604e..a7e7f4f 100644 --- a/nand_spl/board/amcc/bamboo/Makefile +++ b/nand_spl/board/amcc/bamboo/Makefile @@ -12,13 +12,12 @@ 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) @@ -36,7 +35,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
# create symbolic links for common files
diff --git a/nand_spl/board/amcc/canyonlands/Makefile b/nand_spl/board/amcc/canyonlands/Makefile index 9a730e9..2c885bf 100644 --- a/nand_spl/board/amcc/canyonlands/Makefile +++ b/nand_spl/board/amcc/canyonlands/Makefile @@ -12,8 +12,8 @@ nandobj := $(OBJTREE)/nand_spl/ LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \ $(LDFLAGS_FINAL) -AFLAGS += -DCONFIG_NAND_SPL -CFLAGS += -DCONFIG_NAND_SPL +asflags-y += -DCONFIG_NAND_SPL +ccflags-y += -DCONFIG_NAND_SPL
SOBJS := start.o SOBJS += init.o @@ -23,7 +23,6 @@ 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) @@ -41,7 +40,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
# create symbolic links for common files
diff --git a/nand_spl/board/amcc/kilauea/Makefile b/nand_spl/board/amcc/kilauea/Makefile index 1c5498c..1fc9c57 100644 --- a/nand_spl/board/amcc/kilauea/Makefile +++ b/nand_spl/board/amcc/kilauea/Makefile @@ -12,13 +12,12 @@ 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) @@ -36,7 +35,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
# create symbolic links for common files
diff --git a/nand_spl/board/amcc/sequoia/Makefile b/nand_spl/board/amcc/sequoia/Makefile index 62131ab..dd31eb5 100644 --- a/nand_spl/board/amcc/sequoia/Makefile +++ b/nand_spl/board/amcc/sequoia/Makefile @@ -12,13 +12,12 @@ 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) @@ -36,7 +35,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
# create symbolic links for common files
diff --git a/nand_spl/board/freescale/mpc8315erdb/Makefile b/nand_spl/board/freescale/mpc8315erdb/Makefile index a2054ee..e6444ca 100644 --- a/nand_spl/board/freescale/mpc8315erdb/Makefile +++ b/nand_spl/board/freescale/mpc8315erdb/Makefile @@ -13,14 +13,13 @@ 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) @@ -38,7 +37,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
# create symbolic links for common files
diff --git a/nand_spl/board/freescale/mpc8536ds/Makefile b/nand_spl/board/freescale/mpc8536ds/Makefile index f711cf3..19aa342 100644 --- a/nand_spl/board/freescale/mpc8536ds/Makefile +++ b/nand_spl/board/freescale/mpc8536ds/Makefile @@ -15,14 +15,13 @@ 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) @@ -40,7 +39,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot-nand_spl.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \ -ansi -D__ASSEMBLY__ -P - <$< >$@
# create symbolic links for common files diff --git a/nand_spl/board/freescale/mpc8569mds/Makefile b/nand_spl/board/freescale/mpc8569mds/Makefile index f711cf3..19aa342 100644 --- a/nand_spl/board/freescale/mpc8569mds/Makefile +++ b/nand_spl/board/freescale/mpc8569mds/Makefile @@ -15,14 +15,13 @@ 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) @@ -40,7 +39,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot-nand_spl.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \ -ansi -D__ASSEMBLY__ -P - <$< >$@
# create symbolic links for common files diff --git a/nand_spl/board/freescale/mpc8572ds/Makefile b/nand_spl/board/freescale/mpc8572ds/Makefile index f711cf3..19aa342 100644 --- a/nand_spl/board/freescale/mpc8572ds/Makefile +++ b/nand_spl/board/freescale/mpc8572ds/Makefile @@ -15,14 +15,13 @@ 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) @@ -40,7 +39,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot-nand_spl.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \ -ansi -D__ASSEMBLY__ -P - <$< >$@
# create symbolic links for common files diff --git a/nand_spl/board/freescale/p1023rds/Makefile b/nand_spl/board/freescale/p1023rds/Makefile index 21a6920..924d154 100644 --- a/nand_spl/board/freescale/p1023rds/Makefile +++ b/nand_spl/board/freescale/p1023rds/Makefile @@ -11,14 +11,13 @@ 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) @@ -36,7 +35,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot-nand_spl.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \ -ansi -D__ASSEMBLY__ -P - <$< >$@
# create symbolic links for common files diff --git a/nand_spl/board/freescale/p1_p2_rdb/Makefile b/nand_spl/board/freescale/p1_p2_rdb/Makefile index f711cf3..19aa342 100644 --- a/nand_spl/board/freescale/p1_p2_rdb/Makefile +++ b/nand_spl/board/freescale/p1_p2_rdb/Makefile @@ -15,14 +15,13 @@ 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) @@ -40,7 +39,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot-nand_spl.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot-nand_spl.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(nandobj)/board/$(BOARDDIR) \ -ansi -D__ASSEMBLY__ -P - <$< >$@
# create symbolic links for common files diff --git a/nand_spl/board/sheldon/simpc8313/Makefile b/nand_spl/board/sheldon/simpc8313/Makefile index ca45ecd..b7a2110 100644 --- a/nand_spl/board/sheldon/simpc8313/Makefile +++ b/nand_spl/board/sheldon/simpc8313/Makefile @@ -12,14 +12,13 @@ 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) @@ -37,7 +36,7 @@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds -Map $(nandobj)u-boot-spl.map -o $@
$(nandobj)u-boot.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
# create symbolic links for common files
diff --git a/net/Makefile b/net/Makefile index 31aadc2..9425950 100644 --- a/net/Makefile +++ b/net/Makefile @@ -5,7 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ #
-# CFLAGS += -DDEBUG +#ccflags-y += -DDEBUG
obj-$(CONFIG_CMD_NET) += arp.o obj-$(CONFIG_CMD_NET) += bootp.o diff --git a/post/lib_powerpc/fpu/Makefile b/post/lib_powerpc/fpu/Makefile index c720a26..6889c8f 100644 --- a/post/lib_powerpc/fpu/Makefile +++ b/post/lib_powerpc/fpu/Makefile @@ -5,20 +5,20 @@ # 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 +extra-y += 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
-CFLAGS := $(shell echo $(CFLAGS) | sed s/-msoft-float//) -CFLAGS += -mhard-float -fkeep-inline-functions +# remove -msoft-float flag +$(foreach m, $(extra-y), $(eval CFLAGS_REMOVE_$m := -msoft-float)) +ccflags-y := -mhard-float -fkeep-inline-functions
-$(addprefix $(obj)/,$(obj-y)): $(obj)/%.o: $(src)/%.c - $(CC) $(ALL_CFLAGS) -o $@.fp $< -c - $(OBJCOPY) -R .gnu.attributes $@.fp $@ - rm -f $@.fp +# Do not delete intermidiate files (*.o) +.SECONDARY: $(addprefix $(obj)/, $(extra-y)) + +obj-y := $(extra-y:.o=.r.o) + +quiet_cmd_remove_gnu_attributes = OBJCOPY $@ +cmd_remove_gnu_attributes = $(OBJCOPY) -R .gnu.attributes $< $@ + +$(obj)/%.r.o: $(obj)/%.o + $(call if_changed,remove_gnu_attributes) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 30a5551..6113c13 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -165,7 +165,7 @@ ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= # Usage: # $(Q)$(MAKE) $(build)=dir -build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build.tmp obj +build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
### # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= diff --git a/scripts/Makefile.build b/scripts/Makefile.build index d5d859c..921fbbf 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -2,7 +2,16 @@ # Building # ==========================================================================
-src := $(obj) +# Modified for U-Boot +ifeq ($(CONFIG_TPL_BUILD),y) + src := $(patsubst tpl/%,%,$(obj)) +else + ifeq ($(CONFIG_SPL_BUILD),y) + src := $(patsubst spl/%,%,$(obj)) + else + src := $(obj) + endif +endif
PHONY := __build __build: @@ -34,6 +43,10 @@ subdir-ccflags-y := -include include/config/auto.conf
include scripts/Kbuild.include +# Modified for U-Boot +# We must include config.mk after Kbuild.include: +# Some config.mk use cc-option +include config.mk
# For backward compatibility check that these variables do not change save-cflags := $(CFLAGS) @@ -115,14 +128,16 @@ ifneq ($(hostprogs-y)$(hostprogs-m),) include scripts/Makefile.host endif
-ifneq ($(KBUILD_SRC),) +# Uncommented for U-Boot +# We need to create output dicrectory for SPL and TPL even for in-tree build +#ifneq ($(KBUILD_SRC),) # Create output directory if not already present _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
# Create directories for object files if directory does not exist # Needed when obj-y := dir/file.o syntax is used _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) -endif +#endif
ifndef obj $(warning kbuild: Makefile.build is included improperly) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 49392ec..d4b5cb5 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -101,12 +101,13 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" modname_flags = $(if $(filter 1,$(words $(modname))),\ -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
-orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ +# U-Boot also uses $(CPPFLAGS) +orig_c_flags = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ $(ccflags-y) $(CFLAGS_$(basetarget).o) _c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) -_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \ +_a_flags = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \ $(asflags-y) $(AFLAGS_$(basetarget).o) -_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) +_cpp_flags = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
# # Enable gcov profiling flags for a file, directory or for all files depending @@ -137,14 +138,15 @@ __a_flags = $(call flags,_a_flags) __cpp_flags = $(call flags,_cpp_flags) endif
-c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ +# Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE +c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ $(__c_flags) $(modkern_cflags) \ -D"KBUILD_STR(s)=#s" $(basename_flags) $(modname_flags)
-a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ +a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ $(__a_flags) $(modkern_aflags)
-cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ +cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ $(__cpp_flags)
ld_flags = $(LDFLAGS) $(ldflags-y) diff --git a/spl/Makefile b/spl/Makefile index cce6165..fd5294b 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -102,8 +102,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)) @@ -151,7 +150,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 @@ -182,20 +181,17 @@ 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 - -# defines $(obj).depend target -include $(SRCTREE)/rules.mk +$(obj)/u-boot-spl.lds: $(LDSCRIPT) + $(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(obj). -ansi -D__ASSEMBLY__ -P - < $< > $@ diff --git a/tools/Makefile b/tools/Makefile index fe4a6c7..143bbe0 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -40,19 +40,19 @@ hostprogs-$(CONFIG_CMD_LICENSE) += bin2header$(SFX)
hostprogs-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX) hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX) -HOSTCFLAGS_bmp_logo$(SFX) := -pedantic +HOSTCFLAGS_bmp_logo$(SFX).o := -pedantic
hostprogs-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX) envcrc$(SFX)-objs := crc32.o env_embedded.o envcrc.o sha1.o
hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX) -HOSTCFLAGS_gen_eth_addr$(SFX) := -pedantic +HOSTCFLAGS_gen_eth_addr$(SFX).o := -pedantic
hostprogs-$(CONFIG_CMD_LOADS) += img2srec$(SFX) -HOSTCFLAGS_img2srec$(SFX) := -pedantic +HOSTCFLAGS_img2srec$(SFX).o := -pedantic
hostprogs-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX) -HOSTCFLAGS_xway-swap-bytes$(SFX) := -pedantic +HOSTCFLAGS_xway-swap-bytes$(SFX).o := -pedantic
hostprogs-y += mkenvimage$(SFX) mkenvimage$(SFX)-objs := crc32.o mkenvimage.o os_support.o @@ -97,7 +97,7 @@ HOSTLOADLIBES_dumpimage$(SFX) := -lssl -lcrypto HOSTLOADLIBES_mkimage$(SFX) := -lssl -lcrypto # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register # the mxsimage support within tools/mxsimage.c . -HOSTCFLAGS += -DCONFIG_MXS +HOSTCFLAGS_mxsimage.o += -DCONFIG_MXS endif
ifdef CONFIG_FIT_SIGNATURE @@ -110,11 +110,11 @@ HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE endif
hostprogs-$(CONFIG_EXYNOS5250) += 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) @@ -135,7 +135,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)
@@ -162,11 +162,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 @@ -181,7 +176,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

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

Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: - Move the line where U_BOOT_VERSION is defined
Changes in v3: None Changes in v2: None
Makefile | 65 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 32 insertions(+), 33 deletions(-)
diff --git a/Makefile b/Makefile index 199a1e5..0bd85dc 100644 --- a/Makefile +++ b/Makefile @@ -9,39 +9,6 @@ VERSION = 2014 PATCHLEVEL = 01 SUBLEVEL = EXTRAVERSION = -rc2 -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
# *DOCUMENTATION* # To see a list of typical targets execute "make help" @@ -212,6 +179,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 +398,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

We can get Kbuild-ish log style like this: GEN include/autoconf.mk GEN include/autoconf.mk.dep
We do not need XECHO any more.
And also change checkstack target like Linux Kernel.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: - Change checkstack target
Changes in v3: None Changes in v2: None
Makefile | 77 ++++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 34 deletions(-)
diff --git a/Makefile b/Makefile index 0bd85dc..393aa0b 100644 --- a/Makefile +++ b/Makefile @@ -201,12 +201,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) @@ -881,10 +875,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) \ @@ -934,52 +929,63 @@ checkdtc: # This target actually generates 2 files; autoconf.mk and autoconf.mk.dep. # the dep file is only include in this top level makefile to determine when # to regenerate the autoconf.mk file. + +quiet_cmd_autoconf_dep = GEN $@ + cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \ + -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@ + include/autoconf.mk.dep: include/config.h include/common.h - @$(XECHO) Generating $@ ; \ - : Generate the dependancies ; \ - $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \ - -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || \ - rm $@ + $(call cmd,autoconf_dep)
-include/autoconf.mk: include/config.h - @$(XECHO) Generating $@ ; \ - : Extract the config macros ; \ +quiet_cmd_autoconf = GEN $@ + cmd_autoconf = \ $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ - sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ + sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ rm $@.tmp
+include/autoconf.mk: include/config.h + $(call cmd,autoconf) + # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL) -include/tpl-autoconf.mk: include/config.h - @$(XECHO) Generating $@ ; \ - : Extract the config macros ; \ +quiet_cmd_tpl-autoconf = GEN $@ + cmd_tpl-autoconf = \ $(CPP) $(c_flags) -DCONFIG_TPL_BUILD -DCONFIG_SPL_BUILD\ -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ rm $@.tmp
-include/spl-autoconf.mk: include/config.h - @$(XECHO) Generating $@ ; \ - : Extract the config macros ; \ +include/tpl-autoconf.mk: include/config.h + $(call cmd,tpl-autoconf) + +quiet_cmd_spl-autoconf = GEN $@ + cmd_spl-autoconf = \ $(CPP) $(c_flags) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ rm $@.tmp
+include/spl-autoconf.mk: include/config.h + $(call cmd,spl-autoconf) + +quiet_cmd_offsets = GEN $@ + cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@ + include/generated/generic-asm-offsets.h: lib/asm-offsets.s - @$(XECHO) Generating $@ - $(srctree)/tools/scripts/make-asm-offsets lib/asm-offsets.s $@ + $(call cmd,offsets)
-lib/asm-offsets.s: include/config.h $(srctree)/lib/asm-offsets.c - @mkdir -p lib - $(CC) -DDO_DEPS_ONLY \ +quiet_cmd_asm-offsets.s = CC $@ + cmd_asm-offsets.s = mkdir -p lib; \ + $(CC) -DDO_DEPS_ONLY \ $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \ - -o $@ $(srctree)/lib/asm-offsets.c -c -S + -o $@ $< -c -S + +lib/asm-offsets.s: $(srctree)/lib/asm-offsets.c include/config.h + $(call cmd,asm-offsets.s)
include/generated/asm-offsets.h: $(CPUDIR)/$(SOC)/asm-offsets.s - @$(XECHO) Generating $@ - $(srctree)/tools/scripts/make-asm-offsets $(CPUDIR)/$(SOC)/asm-offsets.s $@ + $(call cmd,offsets)
-$(CPUDIR)/$(SOC)/asm-offsets.s: include/config.h - @mkdir -p $(CPUDIR)/$(SOC) +quiet_cmd_soc_asm-offsets.s = CC $@ + cmd_soc_asm-offsets.s = mkdir -p $(CPUDIR)/$(SOC); \ if [ -f $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c ];then \ $(CC) -DDO_DEPS_ONLY \ $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \ @@ -988,6 +994,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 \

This commit changes the location of include directives of board configuration files.
The purpose of this change is: - Slim down $(TOPDIR)/config.mk - Prevent $(TOPDIR)/Makefile from including the same configuration file twice - Do not include include/config.mk multiple times because ARCH, CPU, BOARD, VENDOR, SOC are exported
Before this commit:
- include/autoconf.mk was included from $(TOPDIR)/Makefile and $(TOPDIR)/config.mk (This means $(TOPDIR)/Makefile included include/autoconf.mk twice)
- include/{spl,tpl}-autoconf.mk was included from $(TOPDIR)/config.mk
- include/config.mk was included from $(TOPDIR)/Makefile and $(TOPDIR)/config.mk (This means $(TOPDIR)/Makefile included include/config.mk twice)
After this commit:
- include/autoconf.mk is included from $(TOPDIR)/Makefile and $(TOPDIR)/scripts/Makefile.build
- include/{spl,tpl}-autoconf.mk is included from $(TOPDIR)/spl/Makefile and $(TOPDIR)/scripts/Makefile.build
- include/config.mk is included from $(TOPDIR)/config.mk and $(TOPDIR)/spl/Makefile
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
config.mk | 15 --------------- scripts/Makefile.build | 11 +++++++++++ spl/Makefile | 8 ++++++++ 3 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/config.mk b/config.mk index 1336ef8..5b886aa 100644 --- a/config.mk +++ b/config.mk @@ -13,21 +13,6 @@ PLATFORM_LDFLAGS =
#########################################################################
-# Load generated board configuration -ifeq ($(CONFIG_TPL_BUILD),y) -# Include TPL autoconf -sinclude include/tpl-autoconf.mk -else -ifeq ($(CONFIG_SPL_BUILD),y) -# Include SPL autoconf -sinclude include/spl-autoconf.mk -else -# Include normal autoconf -sinclude include/autoconf.mk -endif -endif -sinclude $(OBJTREE)/include/config.mk - # Some architecture config.mk files need to know what CPUDIR is set to, # so calculate CPUDIR before including ARCH/SOC/CPU config.mk files. # Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 921fbbf..f37957f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -42,6 +42,17 @@ subdir-ccflags-y := # Read auto.conf if it exists, otherwise ignore -include include/config/auto.conf
+# Added for U-Boot: Load U-Boot configuration +ifeq ($(CONFIG_TPL_BUILD),y) + -include include/tpl-autoconf.mk +else + ifeq ($(CONFIG_SPL_BUILD),y) + -include include/spl-autoconf.mk + else + -include include/autoconf.mk + endif +endif + include scripts/Kbuild.include # Modified for U-Boot # We must include config.mk after Kbuild.include: diff --git a/spl/Makefile b/spl/Makefile index fd5294b..bf886f7 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -38,6 +38,14 @@ else SPL_BIN := u-boot-spl endif
+include include/config.mk + +ifeq ($(CONFIG_TPL_BUILD),y) + -include include/tpl-autoconf.mk +else + -include include/spl-autoconf.mk +endif + include $(srctree)/scripts/Kbuild.include
include $(TOPDIR)/config.mk

Before this commit, {spl,tpl}-autoconf.mk was always generated at the top Makefile even if SPL(TPL) build was not selected.
This commit moves the build rule of {spl,tpl}-autoconf.mk from the top Makefile to spl/Makefile. It prevents unnecessary {spl,tpl}-autoconf.mk from being generated.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 23 ----------------------- spl/Makefile | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/Makefile b/Makefile index 393aa0b..72bfb9d 100644 --- a/Makefile +++ b/Makefile @@ -862,9 +862,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
@@ -946,26 +943,6 @@ quiet_cmd_autoconf = GEN $@ include/autoconf.mk: include/config.h $(call cmd,autoconf)
-# Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL) -quiet_cmd_tpl-autoconf = GEN $@ - cmd_tpl-autoconf = \ - $(CPP) $(c_flags) -DCONFIG_TPL_BUILD -DCONFIG_SPL_BUILD\ - -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ - sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ - rm $@.tmp - -include/tpl-autoconf.mk: include/config.h - $(call cmd,tpl-autoconf) - -quiet_cmd_spl-autoconf = GEN $@ - cmd_spl-autoconf = \ - $(CPP) $(c_flags) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ - sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ - rm $@.tmp - -include/spl-autoconf.mk: include/config.h - $(call cmd,spl-autoconf) - quiet_cmd_offsets = GEN $@ cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@
diff --git a/spl/Makefile b/spl/Makefile index bf886f7..55d6824 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -50,6 +50,22 @@ include $(srctree)/scripts/Kbuild.include
include $(TOPDIR)/config.mk
+# FIX ME +c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) + +# Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL) +quiet_cmd_autoconf = GEN $@ + cmd_autoconf = \ + $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ + sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ + rm $@.tmp + +include/tpl-autoconf.mk: include/config.h + $(call cmd,autoconf) + +include/spl-autoconf.mk: include/config.h + $(call cmd,autoconf) + HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(SRCTREE)/board/$(VENDOR)/common/Makefile),y,n)
ifdef CONFIG_SPL_START_S_PATH

Before this commit, "make tidy" did "make clean" + delete "*.depend*" files.
But, we do not have "*.depend*" files any more, which means "make tidy" is the same as "make clean".
This commit removes the redandant target "tidy".
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: - Rebase on v2014.01-rc2 tag - Omit "*.depend*" from .gitignore
.gitignore | 1 - MAKEALL | 2 +- Makefile | 8 ++------ 3 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore index d18ebf3..4f51264 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,6 @@ # Generated files #
-*.depend* /LOG /errlog /reloc_off diff --git a/MAKEALL b/MAKEALL index 3c216d5..9616506 100755 --- a/MAKEALL +++ b/MAKEALL @@ -686,7 +686,7 @@ build_target() { if [ $BUILD_MANY == 1 ] ; then trap - TERM
- ${MAKE} -s tidy + ${MAKE} -s clean
if [ -s ${LOG_DIR}/${target}.ERR ] ; then cp ${LOG_DIR}/${target}.ERR ${OUTPUT_PREFIX}/ERR/${target} diff --git a/Makefile b/Makefile index 72bfb9d..6771a59 100644 --- a/Makefile +++ b/Makefile @@ -471,7 +471,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)),) @@ -1087,11 +1087,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

This commit changes the top Makefile to handle various targets nicely. Make targets are divided into four categories:
- mixed-targets We can call a configuration target and build targets at one command line like follows: $ make <board_name>_config u-boot
They are handled one by one.
- config targets <board_name>_config
- no-dot-config-targets Targets we can run without board configuration such as clean, mrproper, distclean, TAGS, %docs, etc.
- build targets The other target which need board configuration.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: - Rebase on v2014.01-rc2 tag
Makefile | 288 ++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 167 insertions(+), 121 deletions(-)
diff --git a/Makefile b/Makefile index 6771a59..64fca69 100644 --- a/Makefile +++ b/Makefile @@ -202,34 +202,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 ?= @@ -376,15 +348,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 \ @@ -395,6 +358,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 @@ -427,65 +391,108 @@ 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 \ + tools backup + +config-targets := 0 +mixed-targets := 0 +dot-config := 1 + +ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) + ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) + dot-config := 0 + endif +endif
-KBUILD_CFLAGS += -Os #-fomit-frame-pointer - -ifdef BUILD_TAG -KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"' +ifeq ($(KBUILD_EXTMOD),) + ifneq ($(filter config %config,$(MAKECMDGOALS)),) + config-targets := 1 + ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) + mixed-targets := 1 + endif + endif endif
-KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) +ifeq ($(mixed-targets),1) +# =========================================================================== +# We're called with mixed targets (*config and build targets). +# Handle them one by one.
-KBUILD_CFLAGS += -g -# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format> -# option to the assembler. -KBUILD_AFLAGS += -g +%:: FORCE + $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
-NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) -CHECKFLAGS += $(NOSTDINC_FLAGS) +else +ifeq ($(config-targets),1) +# =========================================================================== +# *config targets only - make sure prerequisites are updated, and descend +# in scripts/kconfig to make the *config target
-# Report stack usage if supported -KBUILD_CFLAGS += $(call cc-option,-fstack-usage) +# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. +# KBUILD_DEFCONFIG may point out an alternative default configuration +# used for 'make defconfig'
-KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral) +%_config:: + @$(MKCONFIG) -A $(@:_config=)
-# turn jbsr into jsr for m68k -ifeq ($(ARCH),m68k) -ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4) -KBUILD_AFLAGS += -Wa,-gstabs,-S -endif -endif +else +# =========================================================================== +# Build targets only - this includes vmlinux, arch specific targets, clean +# targets and others. In general all targets except *config targets. + +# load ARCH, BOARD, and CPU configuration +-include include/config.mk + +ifeq ($(dot-config),1) + +# Read in config +-include include/autoconf.mk +-include include/autoconf.mk.dep
# load other configuration -include $(TOPDIR)/config.mk +include $(srctree)/config.mk
-ifneq ($(CONFIG_SYS_TEXT_BASE),) -KBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) -endif +# +# Auto-generate the autoconf.mk file (which is included by all makefiles) +# +# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep. +# the dep file is only include in this top level makefile to determine when +# to regenerate the autoconf.mk file.
-export CONFIG_SYS_TEXT_BASE +quiet_cmd_autoconf_dep = GEN $@ + cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \ + -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@
-LDFLAGS_u-boot += -T u-boot.lds $(LDFLAGS_FINAL) -ifneq ($(CONFIG_SYS_TEXT_BASE),) -LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) -endif +include/autoconf.mk.dep: include/config.h include/common.h + $(call cmd,autoconf_dep)
-# Targets which don't build the source code -NON_BUILD_TARGETS = backup clean clobber distclean mrproper unconfig %_config +quiet_cmd_autoconf = GEN $@ + cmd_autoconf = \ + $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ + sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ + rm $@.tmp + +include/autoconf.mk: include/config.h + $(call cmd,autoconf) + +ifeq ($(wildcard include/config.mk),) +$(error "System not configured - see README") +endif
-# Only do the generic board check when actually building, not configuring -ifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),) ifeq ($(__HAVE_ARCH_GENERIC_BOARD),) ifneq ($(CONFIG_SYS_GENERIC_BOARD),) -CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \ +$(error Your architecture does not support generic board. \ Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file) endif endif -endif - -# FIX ME -cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) -c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use # that (or fail if absent). Otherwise, search for a linker script in a @@ -525,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)
@@ -660,6 +734,11 @@ ALL-y += u-boot-nodtb-tegra.bin 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 @@ -839,7 +918,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 @@ -920,28 +999,6 @@ checkdtc: false; \ fi
-# -# Auto-generate the autoconf.mk file (which is included by all makefiles) -# -# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep. -# the dep file is only include in this top level makefile to determine when -# to regenerate the autoconf.mk file. - -quiet_cmd_autoconf_dep = GEN $@ - cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \ - -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@ - -include/autoconf.mk.dep: include/config.h include/common.h - $(call cmd,autoconf_dep) - -quiet_cmd_autoconf = GEN $@ - cmd_autoconf = \ - $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ - sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ - rm $@.tmp - -include/autoconf.mk: include/config.h - $(call cmd,autoconf)
quiet_cmd_offsets = GEN $@ cmd_offsets = $(srctree)/tools/scripts/make-asm-offsets $< $@ @@ -975,17 +1032,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. checkarmreloc: u-boot @@ -1034,15 +1080,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=)
#########################################################################
@@ -1119,8 +1156,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 @@ -1131,6 +1174,9 @@ backup:
#########################################################################
+endif #ifeq ($(config-targets),1) +endif #ifeq ($(mixed-targets),1) + endif # skip-makefile
PHONY += FORCE

Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 5 +---- examples/Makefile | 9 +++++++++ examples/api/Makefile | 4 ---- examples/standalone/Makefile | 4 ---- 4 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 examples/Makefile
diff --git a/Makefile b/Makefile index 64fca69..a9add4a 100644 --- a/Makefile +++ b/Makefile @@ -593,11 +593,8 @@ SUBDIRS = $(SUBDIR_TOOLS)
.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
-SUBDIR_EXAMPLES-y := examples/standalone -SUBDIR_EXAMPLES-$(CONFIG_API) += examples/api -ifndef CONFIG_SANDBOX +SUBDIR_EXAMPLES-y := examples SUBDIRS += $(SUBDIR_EXAMPLES-y) -endif
######################################################################### # U-Boot objects....order is important (i.e. start must be first) diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..18d008e --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,9 @@ +ifndef CONFIG_SANDBOX + +ifdef FTRACE +subdir-ccflags-y += -finstrument-functions -DFTRACE +endif + +subdir-y += standalone +subdir-$(CONFIG_API) += api +endif diff --git a/examples/api/Makefile b/examples/api/Makefile index 8b79886..09475f8 100644 --- a/examples/api/Makefile +++ b/examples/api/Makefile @@ -4,10 +4,6 @@ # SPDX-License-Identifier: GPL-2.0+ #
-ifdef FTRACE -ccflags-y += -finstrument-functions -DFTRACE -endif - ifeq ($(ARCH),powerpc) LOAD_ADDR = 0x40000 endif diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile index ca62e2a..6a5f1ff 100644 --- a/examples/standalone/Makefile +++ b/examples/standalone/Makefile @@ -5,10 +5,6 @@ # SPDX-License-Identifier: GPL-2.0+ #
-ifdef FTRACE -ccflags-y += -finstrument-functions -DFTRACE -endif - extra-y := hello_world extra-$(CONFIG_SMC91111) += smc91111_eeprom extra-$(CONFIG_SMC911X) += smc911x_eeprom

This commit refactors rules of directory descending and defines u-boot-dirs and u-boot-all-dirs. (We will need u-boot-all-dirs when using scripts/Makefile.clean)
Additionally, rename LIBS-y to libs-y.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 163 ++++++++++++++++++++++++++++++----------------------------- spl/Makefile | 106 +++++++++++++++++++------------------- 2 files changed, 139 insertions(+), 130 deletions(-)
diff --git a/Makefile b/Makefile index a9add4a..8487e0c 100644 --- a/Makefile +++ b/Makefile @@ -584,17 +584,7 @@ CHECKFLAGS += $(NOSTDINC_FLAGS) cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
-# The "tools" are needed early, so put this first -# Don't include stuff already done in $(LIBS) -# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC -# is "yes"), so compile examples after U-Boot is compiled. -SUBDIR_TOOLS = tools -SUBDIRS = $(SUBDIR_TOOLS) - -.PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE) - -SUBDIR_EXAMPLES-y := examples -SUBDIRS += $(SUBDIR_EXAMPLES-y) +.PHONY : $(VERSION_FILE) $(TIMESTAMP_FILE)
######################################################################### # U-Boot objects....order is important (i.e. start must be first) @@ -603,70 +593,76 @@ head-y := $(CPUDIR)/start.o head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
-OBJS := $(head-y) - HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
-LIBS-y += lib/ -LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ -LIBS-y += $(CPUDIR)/ +libs-y += lib/ +libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ +libs-y += $(CPUDIR)/ ifdef SOC -LIBS-y += $(CPUDIR)/$(SOC)/ +libs-y += $(CPUDIR)/$(SOC)/ endif -LIBS-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/ -LIBS-$(CONFIG_OF_EMBED) += dts/ -LIBS-y += arch/$(ARCH)/lib/ -LIBS-y += fs/ -LIBS-y += net/ -LIBS-y += disk/ -LIBS-y += drivers/ -LIBS-y += drivers/dma/ -LIBS-y += drivers/gpio/ -LIBS-y += drivers/i2c/ -LIBS-y += drivers/input/ -LIBS-y += drivers/mmc/ -LIBS-y += drivers/mtd/ -LIBS-$(CONFIG_CMD_NAND) += drivers/mtd/nand/ -LIBS-y += drivers/mtd/onenand/ -LIBS-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/ -LIBS-y += drivers/mtd/spi/ -LIBS-y += drivers/net/ -LIBS-y += drivers/net/phy/ -LIBS-y += drivers/pci/ -LIBS-y += drivers/power/ \ +libs-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/ +libs-$(CONFIG_OF_EMBED) += dts/ +libs-y += arch/$(ARCH)/lib/ +libs-y += fs/ +libs-y += net/ +libs-y += disk/ +libs-y += drivers/ +libs-y += drivers/dma/ +libs-y += drivers/gpio/ +libs-y += drivers/i2c/ +libs-y += drivers/input/ +libs-y += drivers/mmc/ +libs-y += drivers/mtd/ +libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/ +libs-y += drivers/mtd/onenand/ +libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/ +libs-y += drivers/mtd/spi/ +libs-y += drivers/net/ +libs-y += drivers/net/phy/ +libs-y += drivers/pci/ +libs-y += drivers/power/ \ drivers/power/fuel_gauge/ \ drivers/power/mfd/ \ drivers/power/pmic/ \ drivers/power/battery/ -LIBS-y += drivers/spi/ -LIBS-$(CONFIG_FMAN_ENET) += drivers/net/fm/ -LIBS-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ -LIBS-y += drivers/serial/ -LIBS-y += drivers/usb/eth/ -LIBS-y += drivers/usb/gadget/ -LIBS-y += drivers/usb/host/ -LIBS-y += drivers/usb/musb/ -LIBS-y += drivers/usb/musb-new/ -LIBS-y += drivers/usb/phy/ -LIBS-y += drivers/usb/ulpi/ -LIBS-y += common/ -LIBS-y += lib/libfdt/ -LIBS-$(CONFIG_API) += api/ -LIBS-$(CONFIG_HAS_POST) += post/ -LIBS-y += test/ +libs-y += drivers/spi/ +libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/ +libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ +libs-y += drivers/serial/ +libs-y += drivers/usb/eth/ +libs-y += drivers/usb/gadget/ +libs-y += drivers/usb/host/ +libs-y += drivers/usb/musb/ +libs-y += drivers/usb/musb-new/ +libs-y += drivers/usb/phy/ +libs-y += drivers/usb/ulpi/ +libs-y += common/ +libs-y += lib/libfdt/ +libs-$(CONFIG_API) += api/ +libs-$(CONFIG_HAS_POST) += post/ +libs-y += test/
ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610)) -LIBS-y += arch/$(ARCH)/imx-common/ +libs-y += arch/$(ARCH)/imx-common/ endif
-LIBS-$(CONFIG_ARM) += arch/arm/cpu/ -LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/ +libs-$(CONFIG_ARM) += arch/arm/cpu/ +libs-$(CONFIG_PPC) += arch/powerpc/cpu/ + +libs-y += board/$(BOARDDIR)/ + +libs-y := $(sort $(libs-y))
-LIBS-y += board/$(BOARDDIR)/ +u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples + +u-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-)))) + +libs-y := $(patsubst %/, %/built-in.o, $(libs-y)) + +u-boot-init := $(head-y) +u-boot-main := $(libs-y)
-LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y)) -LIBS := $(sort $(LIBS-y)) -.PHONY : $(LIBS)
# Add GCC lib ifdef USE_PRIVATE_LIBGCC @@ -736,7 +732,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 @@ -889,17 +885,17 @@ u-boot-img-spl-at-end.bin: spl/u-boot-spl.bin u-boot.img 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) | \ @@ -909,16 +905,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 - <$< >$@ @@ -929,10 +936,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 @@ -941,9 +948,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 @@ -1125,7 +1130,7 @@ clobber: clean @find $(OBJTREE) -type f ( -name '*.srec' \ -o -name '*.bin' -o -name u-boot.img ) \ -print0 | xargs -0 rm -f - @rm -f $(OBJS) *.bak ctags etags TAGS \ + @rm -f *.bak ctags etags TAGS \ cscope.* *.*~ @rm -f u-boot u-boot.map u-boot.hex $(ALL-y) @rm -f u-boot.kwb diff --git a/spl/Makefile b/spl/Makefile index 55d6824..e5ab2f6 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -79,63 +79,62 @@ head-$(CONFIG_X86) += $(START_PATH)/start16.o $(START_PATH)/resetvec.o head-$(CONFIG_4xx) += $(START_PATH)/resetvec.o head-$(CONFIG_MPC85xx) += $(START_PATH)/resetvec.o
-LIBS-y += arch/$(ARCH)/lib/ +libs-y += arch/$(ARCH)/lib/
-LIBS-y += $(CPUDIR)/ +libs-y += $(CPUDIR)/
ifdef SOC -LIBS-y += $(CPUDIR)/$(SOC)/ +libs-y += $(CPUDIR)/$(SOC)/ endif -LIBS-y += board/$(BOARDDIR)/ -LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ - -LIBS-$(CONFIG_SPL_FRAMEWORK) += common/spl/ -LIBS-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ -LIBS-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/ -LIBS-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/ -LIBS-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/ -LIBS-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/ -LIBS-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/ -LIBS-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/ -LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/ -LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/ -LIBS-y += fs/ -LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/ -LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ \ +libs-y += board/$(BOARDDIR)/ +libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ + +libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/ +libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ +libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/ +libs-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/ +libs-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/ +libs-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/ +libs-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/ +libs-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/ +libs-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/ +libs-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/ +libs-y += fs/ +libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/ +libs-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ \ drivers/power/pmic/ -LIBS-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/ -LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/ -LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/ -LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/ -LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/ -LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/ -LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/ -LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/ -LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/ -LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/ -LIBS-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/ +libs-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/ +libs-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/ +libs-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/ +libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/ +libs-$(CONFIG_SPL_NET_SUPPORT) += net/ +libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/ +libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/ +libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/ +libs-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/ +libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/ +libs-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/
ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35)) -LIBS-y += arch/$(ARCH)/imx-common/ +libs-y += arch/$(ARCH)/imx-common/ endif
-LIBS-$(CONFIG_ARM) += arch/arm/cpu/ -LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/ +libs-$(CONFIG_ARM) += arch/arm/cpu/ +libs-$(CONFIG_PPC) += arch/powerpc/cpu/
-LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y)) +head-y := $(addprefix $(obj)/,$(head-y)) +libs-y := $(addprefix $(obj)/,$(libs-y)) +u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) + +libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
# Add GCC lib ifeq ("$(USE_PRIVATE_LIBGCC)", "yes") PLATFORM_LIBS := $(SPLTREE)/arch/$(ARCH)/lib/lib.a endif
-LIBS-y := $(sort $(LIBS-y)) - -__START := $(head-y) -__LIBS := $(LIBS-y) - -START := $(addprefix $(obj)/,$(head-y)) -LIBS := $(addprefix $(obj)/,$(LIBS-y)) +u-boot-spl-init := $(head-y) +u-boot-spl-main := $(libs-y)
# Linker Script ifdef CONFIG_SPL_LDSCRIPT @@ -200,22 +199,27 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),) LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) endif
-GEN_UBOOT = \ - cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $(__START) \ - --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ - -Map $(SPL_BIN).map -o $(SPL_BIN) +quiet_cmd_u-boot-spl = LD $@ + cmd_u-boot-spl = cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \ + $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \ + $(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \ + $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN)
-$(obj)/$(SPL_BIN): $(START) $(LIBS) $(obj)/u-boot-spl.lds - $(GEN_UBOOT) +$(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds + $(call cmd,u-boot-spl)
-$(START): - @: +$(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
-$(LIBS): - $(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@)) +PHONY += $(u-boot-spl-dirs) +$(u-boot-spl-dirs): + $(Q)$(MAKE) $(build)=$@
# FIX ME cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
$(obj)/u-boot-spl.lds: $(LDSCRIPT) $(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(obj). -ansi -D__ASSEMBLY__ -P - < $< > $@ + +# 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)

$(MTD_VERSION) is used in tools/env/Makefile
If you specify a variable at a command line like: $ make MTD_VERSION=old env or specify it thru an envrionment variable like: $ export MTD_VERSION=old $ make env it is inherited to the sub-make too. We do not need to pass it from the top Makefile explicitely.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile index 8487e0c..c2fd3d7 100644 --- a/Makefile +++ b/Makefile @@ -1063,7 +1063,7 @@ $(TIMESTAMP_FILE): @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
easylogo env gdb: - $(Q)$(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION} + $(Q)$(MAKE) $(build)=tools/$@
gdbtools: gdb

- Move "easylogo", "env", "gdb" tagets to tools/Makefile - Delete "gdbtools" target (same as "gdb")
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 7 +------ tools/Makefile | 6 +++++- 2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile index c2fd3d7..aec713a 100644 --- a/Makefile +++ b/Makefile @@ -1062,15 +1062,10 @@ $(TIMESTAMP_FILE): @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
-easylogo env gdb: - $(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) +tools-all: $(VERSION_FILE) $(TIMESTAMP_FILE) $(Q)$(MAKE) $(build)=tools HOST_TOOLS_ALL=y
.PHONY : CHANGELOG diff --git a/tools/Makefile b/tools/Makefile index 143bbe0..1ff8c13 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -24,6 +24,10 @@ CONFIG_NETCONSOLE = y CONFIG_SHA1_CHECK_UB_IMG = y endif
+subdir-$(HOST_TOOLS_ALL) += easylogo +subdir-$(HOST_TOOLS_ALL) += env +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 @@ -178,7 +182,7 @@ 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) > $@

On Fri, Jan 10, 2014 at 15:44 +0900, Masahiro Yamada wrote:
- Move "easylogo", "env", "gdb" tagets to tools/Makefile
- Delete "gdbtools" target (same as "gdb")
This appears to be an "incompatible" change with regards to how users can compile these tools. Please see tools/env/README and update it as well. I'm aware of external projects which grab a U-Boot source tree and 'make env' to just get the fw_printenv(1) binary.
There is another issue for those who do
make HOSTCC=${CROSS_COMPILE}gcc env (needs a HOSTSTRIP spec as well in recent mainline sources)
to get an fw_printenv(1) binary that runs on the target (in contrast to the build machine). Some yocto recipes do this, to not re-invent how to build this tool or how to read and write the environment image.
With your changes, the 'env' make target is gone, instead there is a 'tools-all' target but it has a wider scope, includes the BMP manipulation/conversion stuff and uses HOSTCC to build a bmp_logo(1) tool, which breaks in the mentioned use case (cross compiled bmp_logo(1) executable, empty bmp_logo.h header, aborted build sequence).
Can you please look into whether the sources in the tools/env/ directory can get compiled without involving other directories? I tried 'make tools/env/', but this "make dir/" syntax as known from kernel builds appears to not be supported in U-Boot (yet? or have I done something wrong?). I did a quick hack and extended the top level Makefile as outlined below (diff copied here with the clipboard, whitespace will be broken, build tested but not yet run tested, only checked file(1) output).
--- a/Makefile +++ b/Makefile @@ -1124,6 +1124,9 @@ xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc tools-all: $(VERSION_FILE) $(TIMESTAMP_FILE) $(Q)$(MAKE) $(build)=tools HOST_TOOLS_ALL=y
+tools-env: $(VERSION_FILE) $(TIMESTAMP_FILE) + $(Q)$(MAKE) $(build)=tools/env + .PHONY : CHANGELOG CHANGELOG: git log --no-merges U-Boot-1_1_5.. | \
While testing your series I noticed a probably missing dependency: Running something different from 'make all' (or make without a target spec) after 'make <board>_config' won't work since the fixdeps(1) tool is missing. It's a "byproduct" of 'make all', afterwards other targets can get built separately. Is there a "preparation" step that one needs to take if not calling 'make all' immediately after configuration?
For the record: My test was with your v4 series on top of v2014.01-rc2-43-ge7be18225fbe plus your "sandbox: Use system headers first for sandbox's os.c in a different way" change, with ELDK 5.3 and a PowerPC target.
$ . /opt/eldk-5.3-qte/powerpc/environment-setup-powerpc-linux $ env -u LDFLAGS ARCH=powerpc CROSS_COMPILE=$TARGET_PREFIX $SHELL
$ mkdir output-ac14xx && cd $_ $ make -C .. O=`pwd` ac14xx_config
$ make HOSTCC=${CROSS_COMPILE}gcc tools/env/ "Nothing to be done ..." $ make HOSTCC=${CROSS_COMPILE}gcc tools-all HOSTCC tools/easylogo/easylogo /bin/sh: 1: scripts/basic/fixdep: not found make[4]: *** [tools/easylogo/easylogo] Error 127 make[3]: *** [tools/easylogo] Error 2 make[2]: *** [tools-all] Error 2 make[1]: *** [sub-make] Error 2 make: *** [all] Error 2 $ make HOSTCC=${CROSS_COMPILE}gcc tools CC lib/asm-offsets.s GEN include/generated/generic-asm-offsets.h CC /asm-offsets.s touch: cannot touch `/asm-offsets.s': Permission denied make[2]: *** [/asm-offsets.s] Error 1 make[1]: *** [sub-make] Error 2 make: *** [all] Error 2
[ identical errors without the HOSTCC spec ]
$ time make ... HOSTCC scripts/basic/fixdep ... [ native tools/ gets built as well, but not tools/env/ it seems ]
$ make HOSTCC=${CROSS_COMPILE}gcc tools-all ... tools/bmp_logo: 1: tools/bmp_logo: ELF: not found tools/bmp_logo: 2: tools/bmp_logo: Syntax error: "(" unexpected ...
$ $EDITOR ../Makefile $ make tools-all $ make HOSTCC=${CROSS_COMPILE}gcc tools-env $ file tools/env/fw_printenv tools/env/fw_printenv: ELF 32-bit MSB executable, PowerPC or cisco 4500 [ ... ]
Let me say that I do appreciate the work that you spend to provide us all with the comfort of Kbuild and "real" out-of-source builds, and cleaned up build infrastructure for improved maintenance, and future Kconfig support. :-]
I will report back after doing run time tests.
virtually yours Gerhard Sittig

Hello Gerhard.
There is another issue for those who do
make HOSTCC=${CROSS_COMPILE}gcc env (needs a HOSTSTRIP spec as well in recent mainline sources)
to get an fw_printenv(1) binary that runs on the target (in contrast to the build machine). Some yocto recipes do this, to not re-invent how to build this tool or how to read and write the environment image.
With your changes, the 'env' make target is gone, instead there is a 'tools-all' target but it has a wider scope, includes the BMP manipulation/conversion stuff and uses HOSTCC to build a bmp_logo(1) tool, which breaks in the mentioned use case (cross compiled bmp_logo(1) executable, empty bmp_logo.h header, aborted build sequence).
I did not know how "env" target have been used. Your comments are highly appreciated!
I will revive "env" target at v5.
But whan I cannot understand is why HOSTCC must be tweaked. (I am also asking this question in "Compiling fw_printenv tool" thread)
If fw_printenv must be always compiled with cross-tools, I'd like to suggest to use $(CC) instead of $(HOSTCC) in tools/env/Makefile.
While testing your series I noticed a probably missing dependency: Running something different from 'make all' (or make without a target spec) after 'make <board>_config' won't work since the fixdeps(1) tool is missing. It's a "byproduct" of 'make all', afterwards other targets can get built separately. Is there a "preparation" step that one needs to take if not calling 'make all' immediately after configuration?
Good catch! I will fix this problem at v5.
Best Regards Masahiro Yamada

On Wed, Jan 15, 2014 at 11:23 +0900, Masahiro Yamada wrote:
I did not know how "env" target have been used. Your comments are highly appreciated!
I will revive "env" target at v5.
But whan I cannot understand is why HOSTCC must be tweaked. (I am also asking this question in "Compiling fw_printenv tool" thread)
If fw_printenv must be always compiled with cross-tools, I'd like to suggest to use $(CC) instead of $(HOSTCC) in tools/env/Makefile.
for the record: I've replied in the other thread, to not clobber the kbuild review thread and archives with env related discussion
virtually yours Gerhard Sittig

This commit refactors cleaning targets such as clean, clobber, mrpropper, distclean with scripts/Makefile.clean.
By using scripts/Makefile.clean, we can recursively descend into subdirectories and delete generated files there.
We do not need add a big list of generated files to the "clean" target.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
We can delete ugly stuff like follows:
clean: @rm -f examples/standalone/atmel_df_pow2 \ examples/standalone/hello_world \ examples/standalone/interrupt \ examples/standalone/mem_to_mem_idma2intr \ examples/standalone/sched \ $(addprefix examples/standalone/, smc91111_eeprom smc911x_eeprom) \ examples/standalone/test_burst \ examples/standalone/timer @rm -f $(addprefix examples/api/, demo demo.bin) @rm -f tools/bmp_logo tools/easylogo/easylogo \ tools/env/fw_printenv \ tools/envcrc \ $(addprefix tools/gdb/, gdbcont gdbsend) \ tools/gen_eth_addr tools/img2srec \ tools/dumpimage \ $(addprefix tools/, mkenvimage mkimage) \ tools/mpc86x_clk \ $(addprefix tools/, mk$(BOARD)spl mkexynosspl) \ tools/mxsboot \ tools/ncb tools/ubsha1 \ tools/kernel-doc/docproc \ tools/proftool @rm -f $(addprefix board/cray/L1/, bootscript.c bootscript.image) \ board/matrix_vision/*/bootscript.img \ spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl \ u-boot.lds \ $(addprefix arch/blackfin/cpu/, init.lds init.elf) $(obj)arch/blackfin/cpu/init.{lds,elf}
By the way, I am keeping "make clobber" for now. Do we need "make clobber"? If we like 3-level cleaning targets, clean, mrproper, distclean, like Linux Kernel, we can squash "clobber" to "clean".
Changes in v4: None Changes in v3: None Changes in v2: - Rebase on v2014.01-rc2 tag
Makefile | 188 +++++++++++++++++++++++++-------------------- arch/blackfin/cpu/Makefile | 1 + board/cray/L1/Makefile | 2 + dts/Makefile | 12 +-- scripts/Makefile | 2 + scripts/Makefile.clean | 4 + 6 files changed, 121 insertions(+), 88 deletions(-) create mode 100644 scripts/Makefile
diff --git a/Makefile b/Makefile index aec713a..45af43b 100644 --- a/Makefile +++ b/Makefile @@ -1077,93 +1077,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.map u-boot.hex u-boot.img $(ALL-y) \ + u-boot.kwb u-boot.pbl u-boot.imx u-boot-with-spl.imx \ + u-boot-with-nand-spl.imx 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 System.map \ + u-boot-nand_spl.lds u-boot-spl u-boot-spl.map) + +# 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' ) -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 .. ; \ @@ -1174,6 +1187,17 @@ backup: endif #ifeq ($(config-targets),1) endif #ifeq ($(mixed-targets),1)
+quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) + cmd_rmdirs = rm -rf $(rm-dirs) + +quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) + cmd_rmfiles = rm -f $(rm-files) + +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir +# Usage: +# $(Q)$(MAKE) $(clean)=dir +clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj + endif # skip-makefile
PHONY += FORCE diff --git a/arch/blackfin/cpu/Makefile b/arch/blackfin/cpu/Makefile index dd4d2d1..426292f 100644 --- a/arch/blackfin/cpu/Makefile +++ b/arch/blackfin/cpu/Makefile @@ -22,6 +22,7 @@ obj-y += reset.o obj-y += traps.o
extra-y += check_initcode +clean-files := init.lds
# make sure our initcode (which goes into LDR) does not # have relocs or external references diff --git a/board/cray/L1/Makefile b/board/cray/L1/Makefile index 6aae9fa..63f43da 100644 --- a/board/cray/L1/Makefile +++ b/board/cray/L1/Makefile @@ -14,3 +14,5 @@ $(obj)/bootscript.c: $(obj)/bootscript.image
$(obj)/bootscript.image: $(src)/bootscript.hush -$(OBJTREE)/tools/mkimage -A ppc -O linux -T script -C none -a 0 -e 0 -n bootscript -d $< $@ + +clean-files := bootscript.c bootscript.image \ No newline at end of file diff --git a/dts/Makefile b/dts/Makefile index cc6ecf6..1e7609a 100644 --- a/dts/Makefile +++ b/dts/Makefile @@ -7,12 +7,6 @@ # This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is # enabled. See doc/README.fdt-control for more details.
-ifeq ($(DEVICE_TREE),) -$(if $(CONFIG_DEFAULT_DEVICE_TREE),,\ -$(error Please define CONFIG_DEFAULT_DEVICE_TREE in your board header file)) -DEVICE_TREE = $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%) -endif - DTS_INCDIRS = $(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts DTS_INCDIRS += $(SRCTREE)/board/$(VENDOR)/dts DTS_INCDIRS += $(SRCTREE)/arch/$(ARCH)/dts @@ -28,9 +22,15 @@ DTC_FLAGS := -R 4 -p 0x1000 \ # the filename. DT_BIN := $(obj)/dt.dtb
+DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%) +ifeq ($(DEVICE_TREE),) +$(DT_BIN): FORCE + echo >&2 "Please define CONFIG_DEFAULT_DEVICE_TREE in your board header file" +else $(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts $(CPP) $(DTS_CPPFLAGS) $< -o $(DT_BIN).dts.tmp $(DTC) $(DTC_FLAGS) -O dtb -o ${DT_BIN} $(DT_BIN).dts.tmp +endif
process_lds = \ $(1) | sed -r -n 's/^OUTPUT_$(2)[ ("]*([^")]*).*/\1/p' diff --git a/scripts/Makefile b/scripts/Makefile new file mode 100644 index 0000000..ebbadc9 --- /dev/null +++ b/scripts/Makefile @@ -0,0 +1,2 @@ +# Let clean descend into subdirs +subdir- += basic diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 686cb0d..5cd0f51 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -37,6 +37,10 @@ subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-))
subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
+# Temporal work-around for U-Boot + +subdir-ymn := $(foreach f, $(subdir-ymn), $(if $(wildcard $f/Makefile),$f)) + # build a list of files to remove, usually relative to the current # directory

This commit fixes two problems:
[1] We could not do board configuration and "make all" in one command line.
For example, the following did not work as we expect: $ make sandbox_config all Configuring for sandbox board... make: Nothing to be done for `all'.
[2] mixed-target build did not work with -j option
For example, the following did not work: $ make -j8 sandbox_config u-boot Makefile:481: *** "System not configured - see README". Stop. make: *** [u-boot] Error 2 make: *** Waiting for unfinished jobs.... Configuring for sandbox board...
Going forward, we can do $ make -j8 sandbox_config all
This is the same as $ make sandbox_config $ make -j8
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: None
Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index 45af43b..06c7c5f 100644 --- a/Makefile +++ b/Makefile @@ -427,8 +427,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)

For out-of-tree build - Check if the source tree is clean - Create a Makefile in the output directory
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: None Changes in v2: - Newly added
Makefile | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile index 06c7c5f..4f65d9a 100644 --- a/Makefile +++ b/Makefile @@ -391,6 +391,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 @@ -448,7 +459,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 @@ -924,7 +935,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) @@ -935,19 +946,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 @@ -1190,7 +1238,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)

We had switched to Kbuild, so we do not need to delete sandburst board files at every build.
U-Boot conventional build system did not check the update of command line option, -DBUILDUSER.
Kbuild can handle it nicely and re-builds object files when command line options are changed. (The file ".*.cmd" stores the information how the file was generated at the previous build.)
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: None Changes in v3: - Newly added
Changes in v2: None
board/sandburst/karef/Makefile | 6 +----- board/sandburst/metrobox/Makefile | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/board/sandburst/karef/Makefile b/board/sandburst/karef/Makefile index d5a9b34..ce29b41 100644 --- a/board/sandburst/karef/Makefile +++ b/board/sandburst/karef/Makefile @@ -10,11 +10,7 @@ #
# TBS: add for debugging purposes -BUILDUSER := $(shell whoami) -FORCEBUILD := $(shell rm -f karef.o) - -ccflags-y += -DBUILDUSER='"$(BUILDUSER)"' -# TBS: end debugging +ccflags-y += -DBUILDUSER='"$(shell whoami)"'
obj-y = karef.o ../common/flash.o ../common/sb_common.o extra-y += init.o diff --git a/board/sandburst/metrobox/Makefile b/board/sandburst/metrobox/Makefile index 8121cce..2c1028b 100644 --- a/board/sandburst/metrobox/Makefile +++ b/board/sandburst/metrobox/Makefile @@ -9,11 +9,7 @@ #
# TBS: add for debugging purposes -BUILDUSER := $(shell whoami) -FORCEBUILD := $(shell rm -f metrobox.o) - -ccflags-y += -DBUILDUSER='"$(BUILDUSER)"' -# TBS: end debugging +ccflags-y += -DBUILDUSER='"$(shell whoami)"'
obj-y = metrobox.o ../common/flash.o ../common/sb_common.o extra-y += init.o

Without this workaround, you will see a lot of ".*.su" files at the top directory after building with a compiler which supports "-fstack-usage" option.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v4: - Newly added
Changes in v3: None Changes in v2: None
scripts/Kbuild.include | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 6113c13..6504571 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -85,14 +85,16 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) # Exit code chooses option. "$$TMP" is can be used as temporary file and # is automatically cleaned up. +# modifed for U-Boot: prevent cc-option from leaving .*.su files try-run = $(shell set -e; \ TMP="$(TMPOUT).$$$$.tmp"; \ TMPO="$(TMPOUT).$$$$.o"; \ + TMPSU="$(TMPOUT).$$$$.su"; \ if ($(1)) >/dev/null 2>&1; \ then echo "$(2)"; \ else echo "$(3)"; \ fi; \ - rm -f "$$TMP" "$$TMPO") + rm -f "$$TMP" "$$TMPO" "$$TMPSU")
# as-option # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
participants (2)
-
Gerhard Sittig
-
Masahiro Yamada