-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
64 lines (47 loc) · 1.75 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
# define showerrs on the command-line to see what errors are generated by
# the xxx-err.rs programs
pi?=192.168.1.35
rust_exe_src:=$(wildcard src/*.rs)
rust_lib_src:=$(shell find src/ -path 'src/*/*.rs')
rust_src:=$(rust_exe_src) $(rust_lib_src)
rust_exes:=$(patsubst src/%.rs,out/%,$(filter-out %-err.rs,$(rust_exe_src)))
rust_compile_errors:=$(patsubst src/%-err.rs,out/compile-output/%-err.compile-output,$(rust_exe_src))
book_src:=$(wildcard doc/*.asciidoc)
book_images:=$(wildcard doc/*.svg doc/*.jpg doc/*.png)
version:=$(shell git describe --tags --always --dirty=-local --match='v*' | sed -e 's/^v//')
rust_version:=$(shell rustc --version | cut -c 7-)
asciidoc_icondir=/usr/share/asciidoc/icons
asciidoc_icons:=$(shell find $(asciidoc_icondir) -type f -name '*.*')
linker=../tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi-g++
rustflags=-L . --target arm-unknown-linux-gnueabihf -C linker=$(linker)
all: pdf exes
exes: $(rust_exes)
pdf: out/pdf/book.pdf
out/pdf/book.pdf: out/docbook/book.xml
@mkdir -p $(dir $@)
dblatex -o $@ --fig-path=doc -P latex.encoding=utf8 $<
out/docbook/book.xml: $(book_src) $(rust_src) $(rust_compile_errors)
@mkdir -p $(dir $@)
asciidoc \
-a icons \
-a version="$(version)" \
-a rust_version="$(rust_version)" \
-b docbook45 \
-o $@ doc/book.asciidoc
out/%: src/%.rs $(rust_lib_src)
@mkdir -p $(dir $@)
rustc $(rustflags) -o $@ $<
out/compile-output/%.compile-output: src/%.rs
@mkdir -p $(dir $@)
ifdef showerrs
-rustc $(rustflags) -o $(dir $@)/$* $< 2>&1 | tee $@
else
-rustc $(rustflags) -o $(dir $@)/$* $< > $@ 2>&1
endif
diff $@ doc/$*.compile-output
deployed: $(rust_exes)
rsync $^ $(pi):
clean:
rm -rf out/
again: clean deployed
.PHONY: all pdf exes deployed clean again tmp