blob: e3354aaa3ff31f4d509342c7fa6fa046135379c7 [file] [log] [blame]
Masahiro Yamadace28d7a2013-10-17 17:34:47 +09001# our default target
2.PHONY: all
3all:
4
5include $(TOPDIR)/config.mk
6
7LIB := $(obj)built-in.o
8LIBGCC = $(obj)libgcc.o
9SRCS :=
10
11include Makefile
12
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090013# Going forward use the following
14obj-y := $(sort $(obj-y))
15extra-y := $(sort $(extra-y))
16lib-y := $(sort $(lib-y))
17
Masahiro Yamadaac7e7352013-10-17 20:38:51 +090018subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
19obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
20subdir-obj-y := $(filter %/built-in.o, $(obj-y))
21subdir-obj-y := $(addprefix $(obj),$(subdir-obj-y))
22
Masahiro Yamada3fdf5c82013-11-11 14:35:49 +090023SRCS += $(wildcard $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) \
24 $(lib-y:.o=.S) $(extra-y:.o=.c) $(extra-y:.o=.S))
25OBJS := $(addprefix $(obj),$(obj-y))
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090026
Masahiro Yamadae5c53012013-11-11 14:35:54 +090027# $(obj-dirs) is a list of directories that contain object files
28obj-dirs := $(dir $(OBJS))
29
30# Create directories for object files if directory does not exist
31# Needed when obj-y := dir/file.o syntax is used
32_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
33
Masahiro Yamada3fdf5c82013-11-11 14:35:49 +090034LGOBJS := $(addprefix $(obj),$(sort $(lib-y)))
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090035
36all: $(LIB) $(addprefix $(obj),$(extra-y))
37
38$(LIB): $(obj).depend $(OBJS)
39 $(call cmd_link_o_target, $(OBJS))
40
41ifneq ($(strip $(lib-y)),)
42all: $(LIBGCC)
43
44$(LIBGCC): $(obj).depend $(LGOBJS)
45 $(call cmd_link_o_target, $(LGOBJS))
46endif
47
Masahiro Yamadaac7e7352013-10-17 20:38:51 +090048ifneq ($(subdir-obj-y),)
49# Descending
50$(subdir-obj-y): $(subdir-y)
51
52$(subdir-y): FORCE
53 $(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build
54endif
55
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090056#########################################################################
57
58# defines $(obj).depend target
59
60include $(TOPDIR)/rules.mk
61
62sinclude $(obj).depend
63
64#########################################################################
Masahiro Yamadaac7e7352013-10-17 20:38:51 +090065
66.PHONY: FORCE