-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (45 loc) · 1.62 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
# https://tech.davis-hansson.com/p/make/
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >
APP := sessionizer
DESTDIR ?=
PREFIX ?= /usr/local
CARGOFLAGS ?=
# generate release build
all: build
build: target/release/$(APP)
# install release build to local cargo bin directory
install: $(DESTDIR)$(PREFIX)/bin/$(APP)
# Remove installed binary
uninstall:
> -rm -- "$(DESTDIR)$(PREFIX)/bin/$(APP)"
# development builds
check: target/debug/$(APP)
test: .cargoinstalled
> cargo test --all --all-targets --all-features
# clean build output
clean: .cargoinstalled
> cargo clean
.PHONY: all build clean install uninstall check test
### build targets
target/debug/$(APP): .cargoinstalled Cargo.toml Cargo.lock $(shell find . \( -path './src*' \) -type f)
> cargo build --bin $(APP)
target/release/$(APP): .cargoinstalled Cargo.toml Cargo.lock $(shell find . \( -path './src*' \) -type f)
> RUSTFLAGS="-C link-arg=-s -C target-cpu=native" cargo build $(CARGOFLAGS) --package $(APP) --release
$(DESTDIR)$(PREFIX)/bin/$(APP): target/release/$(APP)
> install -m755 -- target/release/$(APP) "$(DESTDIR)$(PREFIX)/bin/"
.cargoinstalled:
> @if ! command -v cargo 2> /dev/null
> @then
> @echo "Cargo is not installed. Please visit 'https://rustup.rs/' and follow their instructions, or try to run 'curl --proto \"=https\" --tlsv1.2 -sSf https://sh.rustup.rs | sh'"
> @exit 1
> @fi
> touch .cargoinstalled