-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.mk
More file actions
80 lines (61 loc) · 1.56 KB
/
common.mk
File metadata and controls
80 lines (61 loc) · 1.56 KB
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
#
# common.mk
# makecm
#
# Copyright (C) 2023 Jaider Angarita.
# All rights reserved.
#
# This file is part of the makecm project.
#
cross := arm-none-eabi-
cc := $(cross)gcc
cpp := $(cross)gcc -E
cxx := $(cross)g++
ld := $(cross)gcc
rm := rm -rf
vpath %.c $(srcdirs)
objects := $(addprefix $(build),$(subst .c,.o,$(sources)))
depends := $(addprefix $(build),$(subst .c,.d,$(sources)))
incpath := $(addprefix -I,$(incdirs))
mcpuflags := -mthumb -mcpu=$(mcpu) -mfloat-abi=$(mfloat)
flags := -pipe -Wall -Wextra -Werror \
$(mcpuflags) -D$(target) -D$(defines) \
$(incpath) -O$(cdebug) \
-ffunction-sections -fdata-sections \
-ffreestanding \
cflags := -std=$(cstd) $(flags)
cxxflags := -std=$(cxxstd) $(flags) \
-fno-exceptions -fno-rtti
ifeq ($(cdebug),g)
cflags += -g3 -DDEBUG
else
cflags += -g0 -flto
endif
ldflags += $(mcpuflags) $(ldlibs) -T$(ldscript) \
-pipe \
--specs=nano.specs \
-Wl,-Map=$(map) \
-Wl,--start-group \
-Wl,--end-group \
-Wl,--gc-sections \
-Wl,--print-memory-usage
# .SILENT:
.PHONY: all clean rebuild
all: $(outdirs) $(elf)
clean:
@echo 'CLEAN'
-@$(rm) $(outdirs)
rebuild: clean all
$(outdirs):
@mkdir $@
$(elf): $(objects)
@echo 'LD $(notdir $@')
$(ld) $(ldflags) $^ -o $@
$(build)%.o: %.c
$(cpp) -MM -MG -MP -MF $(subst .o,.d,$@) -D$(target) $(incpath) $<
@echo 'CC $(notdir $<)'
$(cc) $(cflags) -c $< -o $@
$(build)%.o: %.cpp
$(cpp) -MM -MG -MP -MF $(subst .o,.d,$@) -D$(target) $(incpath) $<
@echo 'CC $(notdir $<)'
$(cxx) $(cxxflags) -c $< -o $@