-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
144 lines (103 loc) · 3.1 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
T := $(dir $(lastword $(MAKEFILE_LIST)))
UNAME_S := $(shell uname -s)
-include local.mk
PLATFORM ?= lm3s811evb
O ?= build.${PLATFORM}
.DEFAULT_GOAL := ${O}/build.elf
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/mk/$(shell uname).mk
GLOBALDEPS += ${T}Makefile
SRC := ${T}src
MOS := ${O}/${T}src
#
# Include platform- (which in turn include CPU-) specific things
#
include ${SRC}/platform/${PLATFORM}/${PLATFORM}.mk
OPTLEVEL ?= 2
CFLAGS += -Wframe-larger-than=192
CFLAGS += ${CFLAGS-yes}
CFLAGS += -g3 -O${OPTLEVEL} -nostdinc -Wall -Werror -D__mios__
CPPFLAGS += -I${T}include -I${SRC} -I${O} -I${O}/include -include ${O}/include/config.h
LDFLAGS += -nostartfiles -nodefaultlibs ${CFLAGS} -lgcc
CFLAGS += -ffunction-sections -fdata-sections -Wno-attributes
LDFLAGS += -Wl,--gc-sections -Wl,--build-id=sha1
# Needed for linker script includes
LDFLAGS += -L${SRC}
#
# Set defaults for all variables
#
ENABLE_SYSTIM ?= no
ENABLE_MATH ?= yes
ENABLE_TASK_WCHAN ?= yes
ENABLE_TASK_DEBUG ?= no
ENABLE_TASK_ACCOUNTING ?= yes
ENABLE_NET_IPV4 ?= no
ENABLE_NET_MBUS ?= no
ENABLE_NET_MBUS_GW ?= no
ENABLE_NET_BLE ?= no
ENABLE_NET_CAN ?= no
ENABLE_NET_FPU_USAGE ?= no
ENABLE_METRIC ?= no
ENABLE_BUILTIN_BOOTLOADER ?= no
CONFIG_H := ${O}/include/config.h
#
# Core
#
include ${SRC}/kernel/kernel.mk
include ${SRC}/shell/shell.mk
include ${SRC}/lib/crypto/crypto.mk
include ${SRC}/lib/libc/libc.mk
include ${SRC}/lib/math/math.mk
include ${SRC}/lib/fixmath.mk
include ${SRC}/lib/littlefs.mk
include ${SRC}/lib/usb/usb.mk
include ${SRC}/lib/gui/gui.mk
include ${SRC}/lib/tig/tig.mk
include ${SRC}/lib/metric/metric.mk
include ${SRC}/lib/rpc/rpc.mk
include ${SRC}/drivers/drivers.mk
include ${SRC}/net/net.mk
include ${SRC}/util/util.mk
include ${T}/support/version/gitver.mk
ALL_ENABLE_VARS := $(filter ENABLE_%, $(.VARIABLES))
SRCS += ${SRC}/version.c
SRCS += ${SRCS-yes}
SRCS += ${SRCS-yes-yes}
SRCS := $(sort $(SRCS))
OBJS += ${SRCS:%.c=${O}/%.o}
OBJS := ${OBJS:%.s=${O}/%.o}
DEPS += ${OBJS:%.o=%.d}
${O}/build.elf: ${OBJS} ${GLOBALDEPS} ${LDSCRIPT} ${MIOSVER} ${APPVER}
@mkdir -p $(dir $@)
@echo "\tLINK\t$@"
${TOOLCHAIN}gcc -Wl,-T${LDSCRIPT} ${OBJS} -o $@ ${LDFLAGS}
${TOOLCHAIN}objcopy --update-section .miosversion=${MIOSVER} $@
ifdef APPNAME
${TOOLCHAIN}objcopy --update-section .appversion=${APPVER} $@
endif
${O}/build.bin: ${O}/build.elf
@echo "\tBIN\t$@"
${TOOLCHAIN}objcopy -O binary $< $@
${O}/%.o: %.c ${GLOBALDEPS} ${CONFIG_H} ${CDEPS}
@mkdir -p $(dir $@)
@echo "\tCC\t$<"
${TOOLCHAIN}gcc -MD -MP ${CPPFLAGS} ${CFLAGS} -c $< -o $@
${O}/%.o: %.S ${GLOBALDEPS} ${CONFIG_H}
@mkdir -p $(dir $@)
@echo "\tASM\t$<"
${TOOLCHAIN}gcc -MD -MP -DASM ${CPPFLAGS} ${CFLAGS} -c $< -o $@
HASH := \#
CONFIG_H_CONTENTS := $(foreach K,$(ALL_ENABLE_VARS), \
$(if $(subst no,,${${K}}),"${HASH}define ${K}\n",""))
${CONFIG_H}: ${GLOBALDEPS}
@mkdir -p $(dir $@)
@echo "\tGEN\t$@"
@echo >$@ ${CONFIG_H_CONTENTS}
@echo >>$@ "#define APPNAME \"${APPNAME}\""
clean::
rm -rf "${O}"
bin: ${O}/build.bin
builtindefs:
${TOOLCHAIN}gcc ${CFLAGS} -dM -E - < /dev/null
include ${SRC}/platform/platforms.mk
-include ${DEPS}
$(V).SILENT: