1# our default target 2.PHONY: all 3all: 4 5include $(TOPDIR)/config.mk 6 7# variable LIB is used in examples/standalone/Makefile 8__LIB := $(obj)built-in.o 9LIBGCC = $(obj)libgcc.o 10SRCS := 11subdir-y := 12obj-dirs := 13 14include Makefile 15 16# Do not include host rules unless needed 17ifneq ($(hostprogs-y)$(hostprogs-m),) 18include $(SRCTREE)/scripts/Makefile.host.tmp 19endif 20 21# Going forward use the following 22obj-y := $(sort $(obj-y)) 23extra-y := $(sort $(extra-y)) 24always := $(sort $(always)) 25lib-y := $(sort $(lib-y)) 26 27subdir-y += $(patsubst %/,%,$(filter %/, $(obj-y))) 28obj-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 32SRCS += $(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)) 35 36# $(obj-dirs) is a list of directories that contain object files 37 38obj-dirs += $(dir $(OBJS)) 39 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 44LGOBJS := $(addprefix $(obj),$(sort $(lib-y))) 45 46all: $(__LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y) 47 48$(__LIB): $(obj).depend $(OBJS) 49 $(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 58ifneq ($(subdir-obj-y),) 59# Descending 60$(subdir-obj-y): $(subdir-y) 61endif 62 63ifneq ($(subdir-y),) 64$(subdir-y): FORCE 65 $(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build 66endif 67 68######################################################################### 69 70# defines $(obj).depend target 71 72include $(TOPDIR)/rules.mk 73 74sinclude $(obj).depend 75 76######################################################################### 77 78.PHONY: FORCE 79