forked from mdaffin/teensy-3-rust
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
45 lines (35 loc) · 1.2 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
.PHONY = all rebuild build clean examples prerequisites
# e.g. examples/foo.rs
EXAMPLES_RS = $(wildcard examples/*.rs)
# e.g. examples/foo
EXAMPLES = $(EXAMPLES_RS:.rs=)
TARGET_ROOT = target/thumbv7em-none-eabihf
DEBUG_ROOT = $(TARGET_ROOT)/debug
RELEASE_ROOT = $(TARGET_ROOT)/release
# e.g. target/thumbv7em-none-eabihf/debug/examples/foo
DEBUG_ELF = $(EXAMPLES:%=$(DEBUG_ROOT)/%)
# e.g. target/thumbv7em-none-eabihf/release/examples/foo
RELEASE_ELF = $(EXAMPLES:%=$(RELEASE_ROOT)/%)
# e.g. target/thumbv7em-none-eabihf/debug/examples/foo.bin
DEBUG_BIN = $(DEBUG_ELF:%=%.bin)
# e.g. target/thumbv7em-none-eabihf/release/examples/foo.bin
RELEASE_BIN = $(RELEASE_ELF:%=%.bin)
# e.g. stable
TOOLCHAIN = stable
all: build
rebuild: clean build
build: $(DEBUG_BIN) $(RELEASE_BIN)
clean:
cargo clean
$(DEBUG_BIN) $(RELEASE_BIN): %.bin: %
arm-none-eabi-size -x $<
arm-none-eabi-objcopy -O binary $< $@
$(TARGET_ROOT)/debug/%: FORCE
cargo +$(TOOLCHAIN) build --example $(basename $(notdir $@))
$(TARGET_ROOT)/release/%: FORCE
cargo +$(TOOLCHAIN) build --release --example $(basename $(notdir $@))
prerequisites:
rustup install $(TOOLCHAIN)
rustup component add rust-src
rustup target add thumbv7em-none-eabihf
FORCE: