xref: /openbmc/u-boot/scripts/Makefile.build (revision 940db16d)
1# our default target
2.PHONY: all
3all:
4
5include $(TOPDIR)/config.mk
6
7LIB := $(obj)built-in.o
8LIBGCC = $(obj)libgcc.o
9SRCS :=
10subdir-y :=
11obj-dirs :=
12
13include Makefile
14
15# Do not include host rules unless needed
16ifneq ($(hostprogs-y)$(hostprogs-m),)
17include $(SRCTREE)/scripts/Makefile.host.tmp
18endif
19
20# Going forward use the following
21obj-y := $(sort $(obj-y))
22extra-y := $(sort $(extra-y))
23always := $(sort $(always))
24lib-y := $(sort $(lib-y))
25
26subdir-y 	+= $(patsubst %/,%,$(filter %/, $(obj-y)))
27obj-y		:= $(patsubst %/, %/built-in.o, $(obj-y))
28subdir-obj-y	:= $(filter %/built-in.o, $(obj-y))
29subdir-obj-y	:= $(addprefix $(obj),$(subdir-obj-y))
30
31SRCS	+= $(wildcard $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) \
32	$(lib-y:.o=.S) $(extra-y:.o=.c) $(extra-y:.o=.S))
33OBJS	:= $(addprefix $(obj),$(obj-y))
34
35# $(obj-dirs) is a list of directories that contain object files
36
37obj-dirs += $(dir $(OBJS))
38
39# Create directories for object files if directory does not exist
40# Needed when obj-y := dir/file.o syntax is used
41_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
42
43LGOBJS := $(addprefix $(obj),$(sort $(lib-y)))
44
45all: $(LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
46
47$(LIB):	$(obj).depend $(OBJS)
48	$(call cmd_link_o_target, $(OBJS))
49
50ifneq ($(strip $(lib-y)),)
51all: $(LIBGCC)
52
53$(LIBGCC): $(obj).depend $(LGOBJS)
54	$(call cmd_link_o_target, $(LGOBJS))
55endif
56
57ifneq ($(subdir-obj-y),)
58# Descending
59$(subdir-obj-y): $(subdir-y)
60endif
61
62ifneq ($(subdir-y),)
63$(subdir-y): FORCE
64	$(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build
65endif
66
67#########################################################################
68
69# defines $(obj).depend target
70
71include $(TOPDIR)/rules.mk
72
73sinclude $(obj).depend
74
75#########################################################################
76
77.PHONY: FORCE
78