ab73e296b5
Signed-off-by: Thomas Klaehn <thomas.klaehn@perinet.io>
57 lines
1.1 KiB
Makefile
57 lines
1.1 KiB
Makefile
PROJECT_NAME := saunaservice
|
|
|
|
PREFIX ?= /usr/bin
|
|
|
|
CONFIG_DIR := /etc/$(PROJECT_NAME)
|
|
SYSTEM_DIR := /usr/lib/systemd/system
|
|
|
|
CONFIG_FILE := config/config.json
|
|
BIN_FILE := bin/$(PROJECT_NAME)
|
|
UNIT_FILE := $(PROJECT_NAME).service
|
|
README_FILE := README.md
|
|
|
|
.PHONY: all
|
|
all:service
|
|
|
|
.PHONY: service
|
|
service:
|
|
mkdir -p bin
|
|
go clean
|
|
go mod tidy
|
|
go build -o $(BIN_FILE)
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
go clean
|
|
rm -rf bin
|
|
|
|
.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)
|
|
|
|
.PHONY: package
|
|
package: all
|
|
tar cvzf $(PROJECT_NAME).tar.gz $(CONFIG_FILE) $(BIN_FILE) $(UNIT_FILE) $(README_FILE)
|