Rust syntax update in README.
[anymap] / Makefile
1 RUSTC ?= rustc
2 RUSTDOC ?= rustdoc
3 RUSTFLAGS ?= -O
4 RUST_REPOSITORY ?= ../rust
5 RUST_CTAGS ?= $(RUST_REPOSITORY)/src/etc/ctags.rust
6
7 all: anymap docs test
8
9 # Recursive wildcard function
10 # http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
11 rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
12 $(filter $(subst *,%,$2),$d))
13
14 SRC := $(call rwildcard,src/,*.rs)
15 LIB := target/$(shell rustc --print-file-name src/lib.rs)
16 ifeq ($(LIB),target/)
17 # We may not have rustc or the lib.rs file may be broken.
18 # But don't break the rules on that account.
19 LIB := target/libanymap.dummy
20 endif
21
22 anymap: $(LIB)
23
24 $(LIB): $(SRC)
25 @mkdir -p target/
26 $(RUSTC) $(RUSTFLAGS) src/lib.rs --out-dir=target -L target
27
28 doc/anymap/index.html: $(SRC)
29 $(RUSTDOC) src/lib.rs -L target
30
31 target/test: $(SRC)
32 $(RUSTC) $(RUSTFLAGS) --test -o target/test src/lib.rs -L target
33
34 target/quicktest: $(SRC)
35 $(RUSTC) --test -o target/quicktest src/lib.rs -L target
36
37 # There are no tests to run this way at present. It’s all doctests.
38 # test: anymap doctest target/test
39 # target/test --test
40 test: anymap doctest
41
42 bench: anymap target/test
43 target/test --bench
44
45 doctest: $(SRC) $(LIB)
46 $(RUSTDOC) -L target --test src/lib.rs
47
48 # Can't wait for everything to target, optimised too? OK, you can save some time here.
49 quicktest: target/quicktest
50 target/quicktest --test
51
52 docs: doc/anymap/index.html
53
54 clean:
55 rm -rf target/ doc/
56
57 TAGS: $(SRC)
58 ctags -f TAGS --options="$(RUST_CTAGS)" --language=rust -R src/
59
60 .PHONY: all docs clean test doctest quicktest anymap