-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (42 loc) · 1.67 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
# Settings that might need to be adjusted for a different project
AVR_TARGET=atmega32
export AVR_CPU_FREQUENCY_HZ=8000000
# Other variables
CARGO_OPTS=--release
ELF_PATH=target/$(AVR_TARGET)/release/examples
ELF_FILES=$(subst .rs,.elf,$(subst examples/,$(ELF_PATH)/,$(wildcard examples/*.rs)))
HEX_PATH=target
HEX_FILES=$(subst .rs,.hex,$(subst examples/,$(HEX_PATH)/,$(wildcard examples/*.rs)))
ROBOTLOADER_PATH=robotloader
# Target definitions
all: hex doc
elfs: $(ELF_FILES)
$(ELF_PATH)/%.elf: examples/%.rs
@echo "Building example $< for the $(AVR_TARGET) architecture with cargo:"
cargo build $(CARGO_OPTS) --example $(basename $(notdir $<))
examples:
cargo build $(CARGO_OPTS) --examples
hex: examples $(HEX_FILES)
$(HEX_PATH)/%.hex: $(ELF_PATH)/%.elf
@echo ""
@avr-size --format=avr --mcu=$(AVR_TARGET) $<
@echo "Rebuilding $@:"
avr-objcopy -O ihex -R .eeprom $< $@
@echo ""
%: $(HEX_PATH)/%.hex
doc:
@echo "Building rust docs for the $(AVR_TARGET) architecture with cargo:"
cargo doc $(CARGO_OPTS) --document-private-items --workspace
doc-deploy:
@echo "Building rust docs for the $(AVR_TARGET) architecture with cargo:"
cargo doc $(CARGO_OPTS) --document-private-items --workspace --no-deps
@echo "Updating ./docs rust docs for the $(AVR_TARGET) architecture with cargo:"
@rm -rf docs/
@cp -r target/$(AVR_TARGET)/doc/ docs/
@echo "<meta http-equiv=\"refresh\" content=\"0; url=rp6\">" > docs/index.html
@echo "Please open these docs in [GitHub pages](https://pr0gm4n.github.io/rust-rp6lib/rp6/)!" > docs/Readme.md
clean:
@cargo clean
robotloader: hex
cd $(ROBOTLOADER_PATH)/ && sudo ./robotloader_linux_x64.sh
.PHONY: all elfs hex doc doc-deploy clean robotloader