-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
44 lines (31 loc) · 898 Bytes
/
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
RUSTC := rustc # rust compiler
RUSTDOC := rustdoc # rust doc generator
# compiler flags
RUSTCFLAGS := -O --color auto
RUSTDOCFLAGS := -v
# default target
RUSTTARGET := x86_64-unknown-linux-gnu
RUSTCFLAGS := $(RUSTCFLAGS) --target $(RUSTTARGET)
ifeq ($(DEBUG), 1) # use debug info
RUSTCFLAGS := $(RUSTCFLAGS) -g -v
endif
# outputs
OUTPUTS := libsnappy.a libsnappy.rlib test docs snappy
# begin rules
all: snappy
snappy: main.c libsnappy.a
$(CC) $(CFLAGS) $? -o $@
test: test.rs
$(RUSTC) $(RUSTCFLAGS) $? --test -o $@
run-test: test
@ ./test
clean:
$(RM) -r $(OUTPUTS)
docs: main.rs snappy.rs
@ mkdir docs
for i in $?; do $(RUSTDOC) $(RUSTDOCFLAGS) $$i -o $@; done
libsnappy.a: main.rs
$(RUSTC) $(RUSTCFLAGS) $? --crate-type staticlib --crate-name snappy
libsnappy.rlib: snappy.rs
$(RUSTC) $(RUSTCFLAGS) $? --crate-type rlib --crate-name snappy
.PHONY: all run-test clean