blob: 50c0394d5f98de359326ea7d4d7e7c4b49ecc661 [file] [log] [blame]
Masahiro Yamadace28d7a2013-10-17 17:34:47 +09001# our default target
2.PHONY: all
3all:
4
5include $(TOPDIR)/config.mk
6
Masahiro Yamada4a20df32014-02-04 17:24:12 +09007# variable LIB is used in examples/standalone/Makefile
8__LIB := $(obj)built-in.o
Masahiro Yamadace28d7a2013-10-17 17:34:47 +09009LIBGCC = $(obj)libgcc.o
10SRCS :=
Masahiro Yamadaad71fa92014-02-04 17:24:09 +090011subdir-y :=
12obj-dirs :=
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090013
14include Makefile
15
Masahiro Yamadaad71fa92014-02-04 17:24:09 +090016# Do not include host rules unless needed
17ifneq ($(hostprogs-y)$(hostprogs-m),)
18include $(SRCTREE)/scripts/Makefile.host.tmp
19endif
20
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090021# Going forward use the following
22obj-y := $(sort $(obj-y))
23extra-y := $(sort $(extra-y))
Masahiro Yamadaad71fa92014-02-04 17:24:09 +090024always := $(sort $(always))
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090025lib-y := $(sort $(lib-y))
26
Masahiro Yamadaad71fa92014-02-04 17:24:09 +090027subdir-y += $(patsubst %/,%,$(filter %/, $(obj-y)))
Masahiro Yamadaac7e7352013-10-17 20:38:51 +090028obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
29subdir-obj-y := $(filter %/built-in.o, $(obj-y))
30subdir-obj-y := $(addprefix $(obj),$(subdir-obj-y))
31
Masahiro Yamada3fdf5c82013-11-11 14:35:49 +090032SRCS += $(wildcard $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) \
33 $(lib-y:.o=.S) $(extra-y:.o=.c) $(extra-y:.o=.S))
34OBJS := $(addprefix $(obj),$(obj-y))
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090035
Masahiro Yamadae5c53012013-11-11 14:35:54 +090036# $(obj-dirs) is a list of directories that contain object files
Masahiro Yamadaad71fa92014-02-04 17:24:09 +090037
38obj-dirs += $(dir $(OBJS))
Masahiro Yamadae5c53012013-11-11 14:35:54 +090039
40# Create directories for object files if directory does not exist
41# Needed when obj-y := dir/file.o syntax is used
42_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
43
Masahiro Yamada3fdf5c82013-11-11 14:35:49 +090044LGOBJS := $(addprefix $(obj),$(sort $(lib-y)))
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090045
Masahiro Yamada4a20df32014-02-04 17:24:12 +090046all: $(__LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090047
Masahiro Yamada4a20df32014-02-04 17:24:12 +090048$(__LIB): $(obj).depend $(OBJS)
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090049 $(call cmd_link_o_target, $(OBJS))
50
51ifneq ($(strip $(lib-y)),)
52all: $(LIBGCC)
53
54$(LIBGCC): $(obj).depend $(LGOBJS)
55 $(call cmd_link_o_target, $(LGOBJS))
56endif
57
Masahiro Yamadaac7e7352013-10-17 20:38:51 +090058ifneq ($(subdir-obj-y),)
59# Descending
60$(subdir-obj-y): $(subdir-y)
Masahiro Yamadaad71fa92014-02-04 17:24:09 +090061endif
Masahiro Yamadaac7e7352013-10-17 20:38:51 +090062
Masahiro Yamadaad71fa92014-02-04 17:24:09 +090063ifneq ($(subdir-y),)
Masahiro Yamadaac7e7352013-10-17 20:38:51 +090064$(subdir-y): FORCE
65 $(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build
66endif
67
Masahiro Yamadace28d7a2013-10-17 17:34:47 +090068#########################################################################
69
70# defines $(obj).depend target
71
72include $(TOPDIR)/rules.mk
73
74sinclude $(obj).depend
75
76#########################################################################
Masahiro Yamadaac7e7352013-10-17 20:38:51 +090077
78.PHONY: FORCE