-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
54 lines (43 loc) · 1.81 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
PROJECT_NAME := $(shell grep -m 1 name Cargo.toml | cut -d '"' -f 2)
RELEASE_BIN := $(CARGO_TARGET_DIR)/release/$(PROJECT_NAME)
VERSION := $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
RSRCS += $(wildcard src/*.rs src/**/*.rs)
CARGO_TARGET_DIR ?= target
DOCS = doc/_$(PROJECT_NAME) doc/$(PROJECT_NAME).1 doc/$(PROJECT_NAME).bash doc/cyme_example_config.json
OS := $(shell uname)
ifeq ($(OS), Darwin)
PREFIX ?= /usr/local
else
PREFIX ?= /usr
endif
BIN_PATH ?= $(PREFIX)/bin
BASH_COMPLETION_PATH ?= $(PREFIX)/share/bash-completion/completions
ZSH_COMPLETION_PATH ?= $(PREFIX)/share/zsh/site-functions
MAN_PAGE_PATH ?= $(PREFIX)/share/man/man1
.PHONY: release install generated enter_version new_version
release: $(RELEASE_BIN)
install: release
@echo "Installing $(PROJECT_NAME) $(VERSION)"
install -Dm755 "$(RELEASE_BIN)" "$(DESTDIR)$(BIN_PATH)/$(PROJECT_NAME)"
install -Dm644 ./doc/$(PROJECT_NAME).1 "$(DESTDIR)$(MAN_PAGE_PATH)/$(PROJECT_NAME).1"
@if [ -d "$(DESTDIR)$(BASH_COMPLETION_PATH)" ]; then \
install -vDm0644 ./doc/$(PROJECT_NAME).bash "$(DESTDIR)$(BASH_COMPLETION_PATH)/$(PROJECT_NAME).bash"; \
fi
@if [ -d "$(DESTDIR)$(ZSH_COMPLETION_PATH)" ]; then \
install -vDm0644 ./doc/_$(PROJECT_NAME) "$(DESTDIR)$(ZSH_COMPLETION_PATH)/_$(PROJECT_NAME)"; \
fi
generated: $(DOCS)
enter_version:
@echo "Current version: $(VERSION)"
@echo "Enter new version: "
@read new_version; \
sed -i "s/^version = .*/version = \"$$new_version\"/" Cargo.toml
# update because Cargo.lock references self for tests
cargo update
new_version: enter_version generated
$(RELEASE_BIN): Cargo.lock $(RSRCS)
@echo "Building version $(PROJECT_NAME) $(VERSION)"
cargo build --locked --release
$(DOCS): Cargo.toml $(RSRCS)
@echo "Generating docs for $(PROJECT_NAME) $(VERSION)"
cargo run -F=cli_generate -- --gen