From 9e4140329ee9a787d0f96ac2829d618d47f7973f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Feb 2014 17:24:24 +0900 Subject: kbuild: change out-of-tree build 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 " 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=" syntax for descending into sub-directories. (We can write it like "make $(obj)=" with a shorthand.) This means the current working directory is always the top of the output directory. Signed-off-by: Masahiro Yamada Tested-by: Gerhard Sittig --- arch/blackfin/cpu/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'arch/blackfin/cpu/Makefile') 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 '\.*\' ; 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 $@ -- cgit v1.1 From 6825a95b0ba72c4e5667d02d8b31986e2e9abd5a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Feb 2014 17:24:28 +0900 Subject: kbuild: use Linux Kernel build scripts Now we are ready to switch over to real Kbuild. This commit disables temporary scripts: scripts/{Makefile.build.tmp, Makefile.host.tmp} and enables real Kbuild scripts: scripts/{Makefile.build,Makefile.host,Makefile.lib}. This switch is triggered by the line in scripts/Kbuild.include -build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build.tmp obj +build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj We need to adjust some build scripts for U-Boot. But smaller amount of modification is preferable. Additionally, we need to fix compiler flags which are locally added or removed. In Kbuild, it is not allowed to change CFLAGS locally. Instead, ccflags-y, asflags-y, cppflags-y, CFLAGS_$(basetarget).o, CFLAGS_REMOVE_$(basetarget).o are prepared for that purpose. Signed-off-by: Masahiro Yamada Tested-by: Gerhard Sittig --- arch/blackfin/cpu/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'arch/blackfin/cpu/Makefile') 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 $@ -- cgit v1.1 From efcf861931f987d82b11caed75b8c2ad9d709274 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Feb 2014 17:24:40 +0900 Subject: kbuild: use scripts/Makefile.clean 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 --- arch/blackfin/cpu/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'arch/blackfin/cpu/Makefile') 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 -- cgit v1.1