fix the patching monkeys
[rust-101.git] / Makefile
1 FILES=$(wildcard src/*.rs)
2 DOCFILES=$(addsuffix .html,$(addprefix docs/,$(notdir $(basename $(FILES)))))
3 WORKSPACEFILES=$(addprefix workspace/,$(FILES))
4
5 all: docs workspace crates
6 .PHONY: docs workspace crates
7
8 ## Documentation
9 docs: $(DOCFILES)
10
11 .tmp/docs/%.rs: src/%.rs Makefile dup-unimpl.sed
12         @mkdir -p .tmp/docs
13         @echo "$< -> $@"
14         @# sed-fu: remove the "@" from "//@", and remove trailing "/*@*/", replace lines ending in  "/*@@*/" by "unimplemented!()".
15         @# Also coalesce multiple adjacent such lines to one.
16         @sed 's|^\(\s*//\)@|\1|;s|\s*/\*@\*/$$||;s|\(\s*\)\S.*/\*@@\*/|\1unimplemented!()|' $< | sed -f dup-unimpl.sed > $@
17
18 docs/%.html: .tmp/docs/%.rs
19         @./pycco-rs $<
20
21 ## Workspace
22 # The generated files are shipped only for the benefit of Windows users, who
23 # typically don't have the necessary tools for generating the workspace
24 # available.
25 workspace: $(WORKSPACEFILES)
26
27 workspace/src/%.rs: src/%.rs Makefile dup-unimpl.sed
28         @mkdir -p .tmp/docs
29         @echo "$< -> $@"
30         @# sed-fu: remove lines starting with "//@", and replace those ending in "/*@*/" by "unimplemented!()".
31         @# Also coalesce multiple adjacent such lines to one.
32         @sed '/^\s*\/\/@/d;s|\(\s*\)\S.*/\*@@\?\*/|\1unimplemented!()|' $< | sed -f dup-unimpl.sed > $@
33
34 workspace/src/main.rs:
35         # Don't touch this file
36
37 ## Crates
38 crates: $(WORKSPACEFILES)
39         @cargo build
40         @cd workspace && cargo build
41         @cd solutions && cargo build && cargo test