-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
98 lines (81 loc) · 1.78 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
TARGET_NAME ?= libcpp
VERBOSE ?=
DEBUG ?=
LIBCDIR =../libc
EXCEPTIONS ?=
RTTI ?=
THREADING ?=
ifeq ($(VERBOSE),1)
Q =
else
Q = @
endif
CXXSRC += $(wildcard src/exception/*.cpp)
CXXSRC += $(wildcard src/memory/*.cpp)
CXXSRC += $(wildcard src/new/*.cpp)
CXXSRC += $(wildcard src/typeinfo/*.cpp)
OBJECTS = $(CSRC:.c=.o)
OBJECTS += $(CXXSRC:.cpp=.o)
CC = arm-none-eabi-
GCC = $(Q)$(CC)gcc
GXX = $(Q)$(CC)g++
CPP = $(Q)$(CC)gcc -E
AR = $(Q)$(CC)ar
AS = $(Q)$(CC)as
ECHO = @echo -e
ifeq ($(VERBOSE),1)
RM = rm -v
else
RM = @rm
endif
ifeq ($(DEBUG),1)
DBGFLAGS = -g
else
DBGFLAGS =
endif
DFLAGS =
OPTFLAGS = -O2 -ffunction-sections -fdata-sections $(DBGFLAGS)
IFLAGS = -Iinclude -I$(LIBCDIR)/include
WFLAGS = -Wall -Wextra -Wpedantic -Wduplicated-cond -Wduplicated-branches
WFLAGS += -Wlogical-op -Wnull-dereference -Wshadow
WFLAGS += -Wdouble-promotion -Winit-self -Wswitch-default -Wswitch-enum
WFLAGS += -Wunsafe-loop-optimizations -Wundef -Wconversion -Winline
WFLAGS += -Waddress
CWFLAGS = -Wjump-misses-init
COMFLAGS = $(WFLAGS) -static -mthumb -mcpu=$(CPU) $(FPU) -nostartfiles -nostdlib
COMFLAGS += $(OPTFLAGS) $(IFLAGS) $(DFLAGS)
GCCFLAGS = $(COMFLAGS) -c $(CWFLAGS)
CXXFLAGS = $(COMFLAGS) -c -std=c++17
CPPFLAGS =
ARFLAGS =
ASFLAGS =
ifeq ($(EXCEPTIONS), 1)
CXXFLAGS +=
else
CXXFLAGS += -fno-exceptions
endif
ifeq ($(RTTI), 1)
CXXFLAGS +=
else
CXXFLAGS += -fno-rtti
endif
ifeq ($(THREADING), 1)
CXXFLAGS +=
else
CXXFLAGS += -fno-threadsafe-statics
endif
all: $(TARGET_NAME).a
%.o: %.c
$(ECHO) "GCC\t$@"
$(GCC) $(GCCFLAGS) $< -o $@
%.o: %.cpp
$(ECHO) "G++\t$@"
$(GXX) $(CXXFLAGS) $< -o $@
$(TARGET_NAME).a: $(OBJECTS)
$(RM) -f $@
$(ECHO) "AR\t$@"
$(AR) $(ARFLAGS) rcs $@ $^
.PHONY: clean
clean:
$(RM) -f $(OBJECTS)
$(RM) -f $(TARGET_NAME).a