summaryrefslogtreecommitdiff
path: root/spl/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.m@jp.panasonic.com>2014-02-04 08:24:24 (GMT)
committerTom Rini <trini@ti.com>2014-02-19 16:07:50 (GMT)
commit9e4140329ee9a787d0f96ac2829d618d47f7973f (patch)
tree6a40432f6f6723ba9ac5309076af17aec3bc0a9b /spl/Makefile
parentd958002589cb724907e8d4360d546403d1e6b7d8 (diff)
downloadu-boot-fsl-qoriq-9e4140329ee9a787d0f96ac2829d618d47f7973f.tar.xz
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 <sub-dir>" syntax when descending into the sub-directories. On the other hand, Kbuild uses a different idea to handle out-of-tree build and directory descending. The build process of Kbuild always occurs under the output tree. When "O=dir/to/store/output/files" is given, the build system changes the current working directory to that directory and restarts the make. Kbuild uses "make -f $(srctree)/scripts/Makefile.build obj=<sub-dir>" syntax for descending into sub-directories. (We can write it like "make $(obj)=<sub-dir>" with a shorthand.) This means the current working directory is always the top of the output directory. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Tested-by: Gerhard Sittig <gsi@denx.de>
Diffstat (limited to 'spl/Makefile')
-rw-r--r--spl/Makefile49
1 files changed, 24 insertions, 25 deletions
diff --git a/spl/Makefile b/spl/Makefile
index 8d0e6c3..18606ac 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))
+
include $(srctree)/scripts/Kbuild.include
CONFIG_SPL_BUILD := y
@@ -37,14 +42,6 @@ endif
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
@@ -113,11 +110,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
@@ -148,21 +147,21 @@ LDPPFLAGS += \
$(shell $(LD) --version | \
sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
-$(OBJTREE)/MLO: $(obj)u-boot-spl.bin
+$(OBJTREE)/MLO: $(obj)/u-boot-spl.bin
$(OBJTREE)/tools/mkimage -T omapimage \
-a $(CONFIG_SPL_TEXT_BASE) -d $< $@
-$(OBJTREE)/MLO.byteswap: $(obj)u-boot-spl.bin
+$(OBJTREE)/MLO.byteswap: $(obj)/u-boot-spl.bin
$(OBJTREE)/tools/mkimage -T omapimage -n byteswap \
-a $(CONFIG_SPL_TEXT_BASE) -d $< $@
-$(OBJTREE)/SPL : $(obj)u-boot-spl.bin depend
- $(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common $@
+$(objtree)/SPL : $(obj)/u-boot-spl.bin depend
+ $(MAKE) $(build)=spl/arch/arm/imx-common $@
-ALL-y += $(obj)$(SPL_BIN).bin
+ALL-y += $(obj)/$(SPL_BIN).bin
ifdef CONFIG_SAMSUNG
-ALL-y += $(obj)$(BOARD)-spl.bin
+ALL-y += $(obj)/$(BOARD)-spl.bin
endif
all: $(ALL-y)
@@ -173,16 +172,16 @@ VAR_SIZE_PARAM = --vs
else
VAR_SIZE_PARAM =
endif
-$(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
+$(obj)/$(BOARD)-spl.bin: $(obj)/u-boot-spl.bin
$(if $(wildcard $(OBJTREE)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\
$(OBJTREE)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\
$(OBJTREE)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
endif
-$(obj)$(SPL_BIN).bin: $(obj)$(SPL_BIN)
+$(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)
$(OBJCOPY) $(OBJCFLAGS) $(SPL_OBJCFLAGS) -O binary $< $@
-LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
+LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
ifneq ($(CONFIG_SPL_TEXT_BASE),)
LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
endif
@@ -192,19 +191,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