-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rules.make
211 lines (163 loc) · 3.96 KB
/
Rules.make
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#
# Mcube Kernel
#
# Hiroyuki Chishiro
#
include $(TOP_DIR)/.kconfig
include $(TOP_DIR)/arch/$(ARCH_NAME)/$(ARCH_NAME).make
vpath %.h $(TOP_DIR)/include
vpath %.c $(TOP_DIR)/arch/$(ARCH_NAME) \
$(TOP_DIR)/arch/aarch64/raspi3 \
$(TOP_DIR)/kernel \
$(TOP_DIR)/kernel/queue \
$(TOP_DIR)/lib \
$(TOP_DIR)/fs \
$(TOP_DIR)/fs/ext2 \
$(TOP_DIR)/fs/fat \
$(TOP_DIR)/user \
$(TOP_DIR)/user/$(ARCH_NAME)/ \
$(TOP_DIR)/user/test/ \
vpath %.S $(TOP_DIR)/arch/$(ARCH_NAME)
vpath %.asm $(TOP_DIR)/arch/$(ARCH_NAME)
ifeq ($(ARCH_NAME), x86_64)
IMG_TARGET = $(TOP_DIR)/build/mcube.img
endif
TARGET = $(TOP_DIR)/build/mcube
DMPFILE = $(TARGET).dmp
MAP = $(TARGET).map
BIN = $(TARGET).bin
CCACHE = $(shell which ccache)
JOBS=$(shell grep processor /proc/cpuinfo | wc -l)
ifeq ($(CC), $(CCACHE) clang)
CLANG = $(shell which clang)
CC = $(CCACHE) $(CLANG)
endif
CFLAGS += -Iinclude -Wall
#CFLAGS += -O3
#CFLAGS += -O2
#CFLAGS += -O0
#CFLAGS += -std=gnu11
ifeq ($(findstring clang++, $(CC)), clang++)
CFLAGS += -std=gnu++11
else
ifeq ($(findstring g++, $(CC)), g++)
CFLAGS += -std=gnu++11
else
CFLAGS += -std=gnu11
CFLAGS += -Wstrict-prototypes \
-Wmissing-prototypes
endif
endif
CFLAGS += -fno-strict-aliasing
CFLAGS += -fPIC
#
# GCC C dialect flags:
#
# We're a freestanding environment by ISO C99 definition:
# - Code get executed without benefit of an OS (it's a kernel).
# - Program startup and termination is implementation-defined.
# - Any library facilities outside C99 'strict conformance'
# options are also implementation defined.
#
# Poking GCC with the 'freestanding' flag assures it won't
# presume availability of any 'hosted' facilities like libc.
#
# After using -nostdinc, we add compiler's specific includes
# back (stdarg.h, etc) using the -iwithprefix flag.
#
CDIALECT_FLAGS = \
-ffreestanding \
-fno-stack-protector \
-fno-builtin \
-iwithprefix include
ifneq ($(ARCH_NAME), sim)
CDIALECT_FLAGS += \
-fno-pie \
-nostdlib \
#CDIALECT_FLAGS += \
-nostdinc
endif
# -std=gnu99 \
#-I ../../include/
#
# C Optimization flags:
#
# Use -O3 to catch any weird bugs early on
#
# Note-1! Fallback to -O2 at official releases
# Note-2! Shouldn't we disable strict aliasing?
#
COPT_FLAGS = \
-O2 \
-pipe
#
# Warnings request and dismissal flags:
#
# - We've previously caught 2 bugs causeed by an implicit cast
# to a smaller-width type: carefully inspect warnings reported
# by the '-Wconversion' flag.
#
# - We may like to warn about aggregate returns cause we don't
# want to explode the stack if the structure type returned got
# _innocently_ bigger over time. Check '-Waggregate-return'.
#
# Options are printed in GCC HTML documentation order.
#
CWARN_FLAGS = \
-Wall \
CWARN_FLAGS += -Wextra \
-Wchar-subscripts \
-Wformat=2 \
-Wmissing-include-dirs \
-Wparentheses \
-Wtrigraphs \
-Wunused \
-Wstrict-aliasing=2 \
-Wpointer-arith \
-Wwrite-strings \
-Waddress \
-Wmissing-declarations \
-Wredundant-decls \
-Wdisabled-optimization \
-Wno-type-limits \
-Wno-missing-field-initializers \
-Wundef \
-Wno-int-to-pointer-cast \
# -Wmissing-noreturn \
# -Wvla \
# -Wcast-qual \
ifeq ($(CC), gcc)
CWARN_FLAGS += \
-Wlogical-op \
-Wnormalized=nfc \
endif
CFLAGS += \
$(CMACH_FLAGS) \
$(CDIALECT_FLAGS) \
$(COPT_FLAGS) \
$(CWARN_FLAGS)
ASTYLE = astyle
SIZE = $(CROSS_PREFIX)size
DOXYGEN = doxygen
PYTHON = python3
DUMPARG = eb
RM = rm -f
FIND = find
CAT = cat
CLEANFILES = *.o *~ *.o.* *.log *.pyc *.tmp *.orig __pycache__
DUMP = $(TOP_DIR)/scripts/misc/dump.py
RUN_AXIS = $(TOP_DIR)/scripts/misc/run_axis.sh
RUN_AXIS_CLUSTER = $(TOP_DIR)/scripts/misc/run_axis_cluster.sh
MAKEFLAGS += --no-print-directory -rR
MAKE = make
ROM_FILE = rom.txt
TEE = tee
UART_FILE = uart.log
ARGS =
DOC_DIR = docs
BUILD_DIR = $(TOP_DIR)/build
OBJS = $(SRCS:%.c=$(BUILD_DIR)/%.o)
ASM_OBJS = $(ASMS:%.S=$(BUILD_DIR)/%.o)
ASM_DEPS = $(ASMS:%.S=$(BUILD_DIR)/%.d)
DEPS = $(SRCS:%.c=$(BUILD_DIR)/%.d)
BOOTSECT_OBJS = $(BOOTSECT_ASMS:%.S=$(BUILD_DIR)/%.o)