-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (64 loc) · 1.97 KB
/
Makefile
File metadata and controls
86 lines (64 loc) · 1.97 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
81
82
83
84
85
binary = altos_rust
static_lib = lib$(binary).a
linker_script = cortex_m0.ld
target = thumbv6m-none-eabi
core_lib = altos_core
build_path = build/
debug_static_lib = target/$(target)/debug/$(static_lib)
debug_build_path = $(build_path)debug/
debug_build = $(debug_build_path)$(binary)
release_static_lib = target/$(target)/release/$(static_lib)
release_build_path = $(build_path)release/
release_build = $(release_build_path)$(binary)
### CARGO ###
cargo = xargo
cargo_args = --target $(target)
### TEST ###
test_dependencies = altos_core \
arm \
volatile \
cm0_atomic \
bump_allocator \
# --lib flag only runs the unit test suite, doc tests are currently and issue for cross-compiled
# platforms. See: https://github.com/rust-lang/cargo/issues/1789
test_args = $(foreach dep, $(test_dependencies),-p $(dep)) --lib
### LINKER ###
linker = arm-none-eabi-ld
linker_args = -n --gc-sections -T $(linker_script)
### SIZE ###
size = arm-none-eabi-size
size_flags = -t
### GDB ###
gdb = arm-none-eabi-gdb
gdb_flags =
st_port = 4242
ocd_port = 3333
st_gdb_flags = $(gdb_flags) -eval-command="target remote :$(st_port)"
ocd_gdb_flags = $(gdb_flags) -eval-command="target remote :$(ocd_port)"
### Make targets ###
.PHONY: debug release clean
all: debug
clean:
@$(cargo) clean
@rm -rf $(build_path)
debug: $(linker_script)
@mkdir -p $(debug_build_path)
@$(cargo) build $(cargo_args)
@$(linker) $(linker_args) -o $(debug_build) $(debug_static_lib)
@$(size) $(size_flags) $(debug_build)
release: $(linker_script)
@mkdir -p $(release_build_path)
@$(cargo) build $(cargo_args) --release
@$(linker) $(linker_args) -o $(release_build) $(release_static_lib)
@$(size) $(size_flags) $(release_build)
gdb: debug
@$(gdb) $(gdb_flags) $(debug_build)
gdb-st: debug
@$(gdb) $(st_gdb_flags) $(debug_build)
gdb-ocd: debug
@$(gdb) $(ocd_gdb_flags) $(debug_build)
test:
@$(cargo) test $(test_args)
test_verbose:
@$(cargo) test $(test_args) -- --nocapture
size: debug