powercollect/Makefile
Thomas Klaehn 6d9b0da10a Initial commit
Signed-off-by: Thomas Klaehn <thomas.klaehn@perinet.io>
2022-11-09 09:32:41 +01:00

49 lines
1.1 KiB
Makefile

PROJECT_NAME := powercollect
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 := powercollect.service
README_FILE := README.md
.PHONY: all
all:
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
@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
install -d $(PREFIX)
install -m 0755 $(BIN_FILE) $(PREFIX)
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)