summaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.build
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-07-25 15:22:08 +0800
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-08-03 17:17:05 +0800
commitd4c42fb33deb6c061e4410520a6601fb2d072a60 (patch)
tree43defbd17d334dc331908397dbe85772d00c1a2f /scripts/Makefile.build
parent789fad984a11f63ad0728cd6eabad97b185dceea (diff)
downloadbarebox-d4c42fb33deb6c061e4410520a6601fb2d072a60.tar.gz
barebox-d4c42fb33deb6c061e4410520a6601fb2d072a60.tar.xz
kbuild: add pre-bootloader (pbl) target
This will allow to link compiled object to the built-in-pbl.o across the source tree that will be finally link to the pbl. Now we compile the source %.c in pbl-%.o and provide -D__PBL__ so we can known in the source when it's compile for barebox or the pbl. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'scripts/Makefile.build')
-rw-r--r--scripts/Makefile.build48
1 files changed, 45 insertions, 3 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 1a82c44bd4..e5b77792e3 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -14,6 +14,7 @@ obj-y :=
obj-m :=
lib-y :=
lib-m :=
+pbl-y :=
always :=
targets :=
subdir-y :=
@@ -97,13 +98,19 @@ ifneq ($(strip $(lib-y) $(lib-m) $(lib-n) $(lib-)),)
lib-target := $(obj)/lib.a
endif
-ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target)),)
+ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target) $(pbl-y)),)
builtin-target := $(obj)/built-in.o
endif
+ifeq ($(CONFIG_PBL_IMAGE), y)
+ifneq ($(strip $(pbl-y) $(builtin-target)),)
+pbl-target := $(obj)/built-in-pbl.o
+endif
+endif
+
# We keep a list of all modules in $(MODVERDIR)
-__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
+__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(pbl-target) $(extra-y)) \
$(if $(KBUILD_MODULES),$(obj-m)) \
$(subdir-ym) $(always)
@:
@@ -177,9 +184,11 @@ cmd_cc_symtypes_c = \
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
+quiet_cmd_pbl_cc_o_c = PBLCC $@
ifndef CONFIG_MODVERSIONS
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
+cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) -c -o $@ $<
else
# When module versioning is enabled the following steps are executed:
@@ -220,8 +229,22 @@ define rule_cc_o_c
mv -f $(dot-target).tmp $(dot-target).cmd
endef
+define rule_pbl_cc_o_c
+ $(call echo-cmd,checksrc) $(cmd_checksrc) \
+ $(call echo-cmd,pbl_cc_o_c) $(cmd_pbl_cc_o_c); \
+ $(cmd_modversions) \
+ scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,pbl_cc__o_c)' > \
+ $(dot-target).tmp; \
+ rm -f $(depfile); \
+ mv -f $(dot-target).tmp $(dot-target).cmd
+endef
+
# Built-in and composite module parts
+pbl-%.o: %.c
+ $(call cmd,force_checksrc)
+ $(call if_changed_rule,pbl_cc_o_c)
+
%.o: %.c FORCE
$(call cmd,force_checksrc)
$(call if_changed_rule,cc_o_c)
@@ -258,10 +281,16 @@ cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
quiet_cmd_as_o_S = AS $(quiet_modtag) $@
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
+quiet_cmd_pbl_as_o_S = PBLAS $@
+cmd_pbl_as_o_S = $(CC) -D__PBL__ $(a_flags) -c -o $@ $<
+
+pbl-%.o: %.S
+ $(call if_changed_dep,pbl_as_o_S)
+
%.o: %.S FORCE
$(call if_changed_dep,as_o_S)
-targets += $(real-objs-y) $(real-objs-m) $(lib-y)
+targets += $(real-objs-y) $(real-objs-m) $(lib-y) $(pbl-y)
targets += $(extra-y) $(MAKECMDGOALS) $(always)
# Linker scripts preprocessor (.lds.S -> .lds)
@@ -294,6 +323,19 @@ $(builtin-target): $(obj-y) FORCE
targets += $(builtin-target)
endif # builtin-target
+ifdef pbl-target
+quiet_cmd_pbl_link_o_target = PBLLD $@
+# If the list of objects to link is empty, just create an empty built-in-pbl.o
+cmd_pbl_link_o_target = $(if $(strip $(pbl-y)),\
+ $(LD) $(ld_flags) -r -o $@ $(filter $(pbl-y), $^),\
+ rm -f $@; $(AR) rcs $@)
+
+$(pbl-target): $(pbl-y) FORCE
+ $(call if_changed,pbl_link_o_target)
+
+targets += $(pbl-target)
+endif # pbl-target
+
#
# Rule to compile a set of .o files into one .a file
#