From ce28d7ac6d64c8a730334c8584742cf7255ad318 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 17 Oct 2013 17:34:47 +0900 Subject: Makefile: prepare for using Kbuild-style Makefile Every makefile in sub directories has common lines at the top and the bottom. This commit pushes the common parts into script/Makefile.build. Going forward sub-makefiles only need to describe this part: COBJS := ... COBJS += ... SOBJS := ... But using obj-y is preferable to prepare for switching to Kbuild. The conventional (non-Kbuild) Makefile style is still supported. This is achieved by greping the Makefile before entering into it. U-Boot conventional sub makefiles always include some other makefiles. So the build system searches a line beginning with "include" keyword in the makefile in order to distinguish which style it is. If the Makefile include a "include" line, we assume it is a conventional U-Boot style. Otherwise, it is treated as a Kbuild-style makefile. With this tweak, we can switch sub-makefiles from U-Boot style to Kbuild style little by little. obj-y := foo/ syntax (descending into the sub directory) is not supportd yet. It will be implemented in the upcomming commit. Signed-off-by: Masahiro Yamada Cc: Simon Glass Cc: Tom Rini --- scripts/Makefile.build | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 scripts/Makefile.build (limited to 'scripts/Makefile.build') diff --git a/scripts/Makefile.build b/scripts/Makefile.build new file mode 100644 index 0000000000..f969ec55bd --- /dev/null +++ b/scripts/Makefile.build @@ -0,0 +1,48 @@ +# our default target +.PHONY: all +all: + +include $(TOPDIR)/config.mk + +LIB := $(obj)built-in.o +LIBGCC = $(obj)libgcc.o +SRCS := + +include Makefile + +# Backward compatible: obj-y is preferable +COBJS := $(sort $(COBJS) $(COBJS-y)) +SOBJS := $(sort $(SOBJS) $(SOBJS-y)) + +# Going forward use the following +obj-y := $(sort $(obj-y)) +extra-y := $(sort $(extra-y)) +lib-y := $(sort $(lib-y)) + +SRCS += $(COBJS:.o=.c) $(SOBJS:.o=.S) \ + $(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),$(COBJS) $(SOBJS) $(obj-y)) + +LGOBJS := $(addprefix $(obj),$(sort $(GLSOBJS) $(GLCOBJS)) $(lib-y)) + +all: $(LIB) $(addprefix $(obj),$(extra-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 + +######################################################################### + +# defines $(obj).depend target + +include $(TOPDIR)/rules.mk + +sinclude $(obj).depend + +######################################################################### -- cgit v1.2.1