5 include $(srctree)/scripts/Kbuild.include
6 include $(TOPDIR)/config.mk
8 # variable LIB is used in examples/standalone/Makefile
9 __LIB := $(obj)built-in.o
10 LIBGCC = $(obj)libgcc.o
17 # Do not include host rules unless needed
18 ifneq ($(hostprogs-y)$(hostprogs-m),)
19 include $(SRCTREE)/scripts/Makefile.host.tmp
22 # Going forward use the following
23 obj-y := $(sort $(obj-y))
24 extra-y := $(sort $(extra-y))
25 always := $(sort $(always))
26 lib-y := $(sort $(lib-y))
28 subdir-y += $(patsubst %/,%,$(filter %/, $(obj-y)))
29 obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
30 subdir-obj-y := $(filter %/built-in.o, $(obj-y))
31 subdir-obj-y := $(addprefix $(obj),$(subdir-obj-y))
33 SRCS += $(wildcard $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) \
34 $(lib-y:.o=.S) $(extra-y:.o=.c) $(extra-y:.o=.S))
35 OBJS := $(addprefix $(obj),$(obj-y))
37 # $(obj-dirs) is a list of directories that contain object files
39 obj-dirs += $(dir $(OBJS))
41 # Create directories for object files if directory does not exist
42 # Needed when obj-y := dir/file.o syntax is used
43 _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
45 LGOBJS := $(addprefix $(obj),$(sort $(lib-y)))
47 all: $(__LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
49 $(__LIB): $(obj).depend $(OBJS)
50 $(call cmd_link_o_target, $(OBJS))
52 ifneq ($(strip $(lib-y)),)
55 $(LIBGCC): $(obj).depend $(LGOBJS)
56 $(call cmd_link_o_target, $(LGOBJS))
59 ifneq ($(subdir-obj-y),)
61 $(subdir-obj-y): $(subdir-y)
66 $(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build
69 #########################################################################
71 # Allow boards to use custom optimize flags on a per dir/file basis
72 ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
73 ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
74 EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR))
75 ALL_CFLAGS += $(EXTRA_CPPFLAGS)
77 # The _DEP version uses the $< file target (for dependency generation)
79 EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \
80 $(CPPFLAGS_$(BCURDIR))
82 $(CPP) $(ALL_AFLAGS) -o $@ $<
84 $(CC) $(ALL_AFLAGS) -o $@ $< -c
87 $(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $<
89 $(CC) $(ALL_CFLAGS) -o $@ $< -c
91 $(CPP) $(ALL_CFLAGS) -o $@ $< -c
93 $(CC) $(ALL_CFLAGS) -o $@ $< -c -S
95 # If the list of objects to link is empty, just create an empty built-in.o
96 cmd_link_o_target = $(if $(strip $1),\
97 $(LD) $(LDFLAGS) -r -o $@ $1,\
98 rm -f $@; $(AR) rcs $@ )
100 #########################################################################
102 # defines $(obj).depend target
104 include $(TOPDIR)/rules.mk
106 sinclude $(obj).depend
108 #########################################################################