d16bd7e7f8
Signed-off-by: Thomas Klaehn <thomas.klaehn@perinet.io>
49 lines
991 B
Makefile
49 lines
991 B
Makefile
PROJECT_NAME := cvs-monitor
|
|
|
|
PREFIX ?= /usr/bin
|
|
|
|
CONFIG_DIR := /etc/$(PROJECT_NAME)
|
|
SYSTEM_DIR := /usr/lib/systemd/system
|
|
|
|
CONFIG_FILE := config/config.json
|
|
BIN_FILE := target/release/$(PROJECT_NAME)
|
|
UNIT_FILE := $(PROJECT_NAME).service
|
|
|
|
.PHONY: all
|
|
all: service
|
|
|
|
.PHONY: service
|
|
service:
|
|
cargo build -r
|
|
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
cargo clean
|
|
|
|
.PHONY: install
|
|
install: all
|
|
# Config file
|
|
@if [ -f $(CONFIG_DIR)/$(notdir $(CONFIG_FILE)) ]; then \
|
|
echo "$(CONFIG_DIR)/$(notdir $(CONFIG_FILE)) already exists - skipping..."; \
|
|
else \
|
|
install -d $(CONFIG_DIR); \
|
|
install -m 0644 $(CONFIG_FILE) $(CONFIG_DIR); \
|
|
echo "install -d $(CONFIG_DIR)"; \
|
|
echo "install -m 0644 $(CONFIG_FILE) $(CONFIG_DIR)"; \
|
|
fi
|
|
|
|
# Binary
|
|
install -d $(PREFIX)
|
|
install -m 0755 $(BIN_FILE) $(PREFIX)
|
|
|
|
# System unit
|
|
install -d $(SYSTEM_DIR)
|
|
install -m 0644 $(UNIT_FILE) $(SYSTEM_DIR)
|
|
|
|
.PHONY: uninstall
|
|
uninstall:
|
|
rm -rf $(CONFIG_DIR)
|
|
rm -rf $(SYSTEM_DIR)/$(UNIT_FILE)
|
|
rm -rf $(PREFIX)/$(PROJECT_NAME)
|