-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (47 loc) · 1.37 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
# quick n dirty makefile to build rust binary
# based off the output of `cargo build --release --verbose` and `cargo build --verbose`
SHELL := /bin/bash
PROJECT := linlexico
ROOT := $(shell realpath .)
COMMON_FLAGS = main.rs --edition=2018 --crate-type bin
#COMMON_FLAGS = simple.rs --edition=2018 --crate-type bin
RUSTC = rustc $(COMMON_FLAGS) --emit=dep-info,link
# release build
$(PROJECT):
$(RUSTC) --crate-name $@ -C opt-level=3
-include $(PROJECT).d
# debug build
$(PROJECT)_dbg:
$(RUSTC) --crate-name $@ -C debuginfo=2
-include $(PROJECT)_dbg.d
# Generate Documentation
# (Try opening doc/$(PROJECT)/index.html in a browser)
.PHONY: doc
doc:
rustdoc $(COMMON_FLAGS) --crate-name $(PROJECT) --document-private-items
# Benchmark
# (Prefer hyperfine if it is present, but fall back to time)
.PHONY: bench
ifeq (, $(shell which hyperfine))
bench: $(PROJECT)
time ./$(PROJECT)
else
bench: $(PROJECT)
@# Hyperfine needs the command to be in quotes
hyperfine './$(PROJECT)'
endif
# build everything
all: $(PROJECT) $(PROJECT)_dbg doc
# professor-proofing the makefile by adding aliases
.PHONY: docs build ball build_dbg debug dbg benchmark
docs: doc
build: $(PROJECT)
ball: $(PROJECT)
build_dbg: $(PROJECT)_dbg
debug: $(PROJECT)_dbg
dbg: $(PROJECT)_dbg
benchmark: bench
# Clean build dir
.PHONY: clean
clean:
rm -rf $(PROJECT) $(PROJECT).d $(PROJECT)_dbg $(PROJECT)_dbg.d doc $(PROJECT)*.o