-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
129 lines (93 loc) · 2.39 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
MAKEFLAGS += --no-print-directory -r -R
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE = $(V)
endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
ifeq ($(KBUILD_VERBOSE),1)
quiet =
Q =
else
quiet = quiet_
Q = @
endif
export KBUILD_VERBOSE quiet Q
# we do not support out-of-tree builds yet
srctree := .
objtree := .
src := $(srctree)
obj := $(objtree)
export srctree objtree
PHONY := _all
_all:
# We need some generic definitions (do not try to remake the file).
include $(srctree)/scripts/Kbuild.include
$(srctree)/scripts/Kbuild.include: ;
-include $(objtree)/config.mk
quiet_cmd_configure = GEN $@
cmd_configure = $(srctree)/configure
$(objtree)/config.mk $(objtree)/config.h: $(srctree)/configure
$(call cmd,configure)
OBJCOPY = $(CROSS_COMPILE)objcopy
AS = $(CROSS_COMPILE)as
AFLAGS = -marm -march=armv4t -mcpu=arm720t -g
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
NOSTDINC_FLAGS = -nostdinc -isystem $(shell $(CC) -print-file-name=include)
CPPFLAGS = $(NOSTDINC_FLAGS) -include config.h
CFLAGS = $(CPPFLAGS) -I include -marm -march=armv4t -mcpu=arm720t
LD = $(CROSS_COMPILE)ld
LDFLAGS = -nostdlib
ifneq ($(CONFIG_DEBUG),)
CFLAGS += -O0 -ggdb
else
CFLAGS += -O2 -g
endif
CFLAGS += -Wall -Werror
export AS AFLAGS CC CFLAGS LD LDFLAGS
obj-y += arch/
obj-y += core/
obj-y += drivers/
obj-y += lib/
obj-y += init/
obj-y += boards/
subdirs = $(patsubst %/,%,$(filter %/,$(obj-y)))
objs = $(patsubst %,%/built-in.o,$(subdirs))
targets :=
PHONY += all
_all: all
quiet_cmd_cpp_lds_S = LDS $@
cmd_cpp_lds_S = $(CPP) $(CPPFLAGS) -P -C -MD -MF [email protected] -MT $@ -o $@ $<
%.lds: %.lds.S
$(call cmd,cpp_lds_S)
targets += avp.lds
deps += avp.lds.d
quiet_cmd_link_avp = LD $@
cmd_link_avp = $(LD) $(LDFLAGS) -T avp.lds $(objs) -o $@
avp.elf: $(objs) avp.lds
$(call cmd,link_avp)
targets += avp.elf
quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) -O binary $< $@
avp.bin: avp.elf
$(call cmd,objcopy)
targets += avp.bin
all: $(targets)
%/built-in.o: FORCE
$(Q)$(MAKE) $(build)=$*
subdirs = $(patsubst %/,%,$(filter %/, $(obj-y)))
clean-dirs := $(addprefix _clean_, $(subdirs))
$(clean-dirs): _clean_%:
$(Q)$(MAKE) $(clean)=$*
quiet_cmd_rmfiles = CLEAN $(rm-files)
cmd_rmfiles = rm -f $(rm-files)
clean: rm-files = $(strip $(targets))
clean: $(clean-dirs)
$(call cmd,rmfiles)
ifneq ($(deps),)
-include $(deps)
endif
PHONY += FORCE
FORCE:
.PHONY: $(PHONY)