]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - scripts/Makefile.build
kbuild: Use Kbuild.include
[karo-tx-uboot.git] / scripts / Makefile.build
1 # our default target
2 .PHONY: all
3 all:
4
5 include $(srctree)/scripts/Kbuild.include
6 include $(TOPDIR)/config.mk
7
8 # variable LIB is used in examples/standalone/Makefile
9 __LIB := $(obj)built-in.o
10 LIBGCC = $(obj)libgcc.o
11 SRCS :=
12 subdir-y :=
13 obj-dirs :=
14
15 include Makefile
16
17 # Do not include host rules unless needed
18 ifneq ($(hostprogs-y)$(hostprogs-m),)
19 include $(SRCTREE)/scripts/Makefile.host.tmp
20 endif
21
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))
27
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))
32
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))
36
37 # $(obj-dirs) is a list of directories that contain object files
38
39 obj-dirs += $(dir $(OBJS))
40
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)))
44
45 LGOBJS := $(addprefix $(obj),$(sort $(lib-y)))
46
47 all: $(__LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
48
49 $(__LIB):       $(obj).depend $(OBJS)
50         $(call cmd_link_o_target, $(OBJS))
51
52 ifneq ($(strip $(lib-y)),)
53 all: $(LIBGCC)
54
55 $(LIBGCC): $(obj).depend $(LGOBJS)
56         $(call cmd_link_o_target, $(LGOBJS))
57 endif
58
59 ifneq ($(subdir-obj-y),)
60 # Descending
61 $(subdir-obj-y): $(subdir-y)
62 endif
63
64 ifneq ($(subdir-y),)
65 $(subdir-y): FORCE
66         $(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build
67 endif
68
69 #########################################################################
70
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)
76
77 # The _DEP version uses the $< file target (for dependency generation)
78 # See rules.mk
79 EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \
80                 $(CPPFLAGS_$(BCURDIR))
81 $(obj)%.s:      %.S
82         $(CPP) $(ALL_AFLAGS) -o $@ $<
83 $(obj)%.o:      %.S
84         $(CC)  $(ALL_AFLAGS) -o $@ $< -c
85 $(obj)%.o:      %.c
86 ifneq ($(CHECKSRC),0)
87         $(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $<
88 endif
89         $(CC)  $(ALL_CFLAGS) -o $@ $< -c
90 $(obj)%.i:      %.c
91         $(CPP) $(ALL_CFLAGS) -o $@ $< -c
92 $(obj)%.s:      %.c
93         $(CC)  $(ALL_CFLAGS) -o $@ $< -c -S
94
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 $@ )
99
100 #########################################################################
101
102 # defines $(obj).depend target
103
104 include $(TOPDIR)/rules.mk
105
106 sinclude $(obj).depend
107
108 #########################################################################
109
110 .PHONY: FORCE