forked from leftwm/leftwm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
79 lines (69 loc) · 2.84 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# The flags to pass to the `cargo build` command
BUILDFLAGS := --release
# Absolute path to project directory, required for symbolic links
# or when 'make' is run from another directory.
# - credit: https://stackoverflow.com/a/23324703/2726733
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
SHARE_DIR := /usr/share/xsessions
TARGET_DIR := /usr/local/bin
# default rule is to run build/test
all: build test
# runs tests and linters
test:
cd $(ROOT_DIR) && cargo test --all-targets --all-features
cd $(ROOT_DIR) && cargo fmt -- --check
cd $(ROOT_DIR) && cargo clippy --release
test-full:
make test
cargo clippy --\
-W clippy::pedantic\
-A clippy::must_use_candidate\
-A clippy::cast_precision_loss\
-A clippy::cast_possible_truncation\
-A clippy::cast_possible_wrap\
-A clippy::cast_sign_loss\
-A clippy::mut_mut
# builds the project
build:
cd $(ROOT_DIR) && cargo build ${BUILDFLAGS}
# removes the generated binaries
clean:
cd $(ROOT_DIR) && cargo clean
@echo "build files have been cleaned"
# builds the project and installs the binaries (and .desktop)
install: build
sudo cp $(ROOT_DIR)/leftwm.desktop /usr/share/xsessions/
sudo cp $(ROOT_DIR)/leftwm/doc/leftwm.1 /usr/local/share/man/man1/leftwm.1
sudo install -s -Dm755\
$(ROOT_DIR)/target/release/leftwm\
$(ROOT_DIR)/target/release/leftwm-worker\
$(ROOT_DIR)/target/release/lefthk-worker\
$(ROOT_DIR)/target/release/leftwm-state\
$(ROOT_DIR)/target/release/leftwm-check\
$(ROOT_DIR)/target/release/leftwm-command\
-t /usr/bin
cd $(ROOT_DIR) && cargo clean
@echo "binaries, '.desktop' file and manual page have been installed"
# build the project and links the binaries, will also install the .desktop file
install-dev: build
sudo cp $(ROOT_DIR)/leftwm.desktop $(SHARE_DIR)/
sudo cp $(ROOT_DIR)/leftwm/doc/leftwm.1 /usr/local/share/man/man1/leftwm.1
sudo ln -sf $(ROOT_DIR)/target/release/leftwm $(TARGET_DIR)/leftwm
sudo ln -sf $(ROOT_DIR)/target/release/leftwm-worker $(TARGET_DIR)/leftwm-worker
sudo ln -sf $(ROOT_DIR)/target/release/lefthk-worker $(TARGET_DIR)/lefthk-worker
sudo ln -sf $(ROOT_DIR)/target/release/leftwm-state $(TARGET_DIR)/leftwm-state
sudo ln -sf $(ROOT_DIR)/target/release/leftwm-check $(TARGET_DIR)/leftwm-check
sudo ln -sf $(ROOT_DIR)/target/release/leftwm-command $(TARGET_DIR)/leftwm-command
@echo "binaries have been linked, manpage and '.desktop' file have been installed"
# uninstalls leftwm from the system, no matter if installed via 'install' or 'install-dev'
uninstall:
sudo rm -f $(SHARE_DIR)/leftwm.desktop
sudo rm /usr/local/share/man/man1/leftwm.1
sudo rm -f\
$(TARGET_DIR)/leftwm\
$(TARGET_DIR)/leftwm-worker\
$(TARGET_DIR)/lefthk-worker\
$(TARGET_DIR)/leftwm-state\
$(TARGET_DIR)/leftwm-check\
$(TARGET_DIR)/leftwm-command
@echo "binaries and manpage have been uninstalled and '.desktop' file has been removed"