Makefile: use make variables for filenames

This commit is contained in:
Lars Kruse 2019-07-23 04:43:46 +02:00
parent 519a1c2ef9
commit 6dcd179e56
1 changed files with 23 additions and 16 deletions

View File

@ -1,9 +1,14 @@
PLUGINS = df cpu if_ if_err_ load memory processes swap netstat uptime interrupts irqstats ntpdate plugindir_
CONFIGURATION_FILE ?= munin-node.conf
TARGET_FILE ?= munin-node
VERSION ?= $(shell cat VERSION)
DIST_DIR = releases
TGZ_FILE ?= $(DIST_DIR)/muninlite-$(VERSION).tar.gz
munin-node: plugins/* munin-node.conf
@export VERSION=$$(cat VERSION); \
export CONF=$$(grep -v '^#' munin-node.conf); \
$(TARGET_FILE): plugins/* $(CONFIGURATION_FILE)
@export VERSION="$(VERSION)"; \
export CONF=$$(grep -v '^#' "$(CONFIGURATION_FILE)"); \
export "PLUGINS=$(PLUGINS)"; \
echo "Making munin-node for muninlite version $$VERSION"; \
export PLSTR=""; \
@ -17,30 +22,32 @@ munin-node: plugins/* munin-node.conf
s/\@\@CONF\@\@/$$ENV{"CONF"}/; \
s/\@\@PLUGINS\@\@/$$ENV{"PLUGINS"}/; \
s/\@\@PLSTR\@\@/$$ENV{"PLSTR"}/;' \
munin-node.in > munin-node
@chmod +x munin-node
munin-node.in >"$(TARGET_FILE)"
@chmod +x "$(TARGET_FILE)"
all: munin-node
all: $(TARGET_FILE)
clean-node:
@echo "Removing munin-node"
@rm -f munin-node
@echo "Removing $(TARGET_FILE)"
@rm -f "$(TARGET_FILE)"
clean-tgz:
@echo "Removing old releases"
@rm -rf releases
@rm -rf "$(DIST_DIR)"
clean: clean-node
clean-all: clean-node clean-tgz
tgz: clean-node
@VERSION=$$(cat VERSION); \
echo "Building release/muninlite-$$VERSION.tar.gz"; \
mkdir -p releases; \
cp -ra . releases/muninlite-$$VERSION 2>/dev/null || true; \
cd releases; \
rm -rf muninlite-$$VERSION/releases; \
tgz: $(TGZ_FILE)
$(TGZ_FILE):
@VERSION="$(VERSION)"; \
echo "Building "$(DIST_DIR)"/muninlite-$$VERSION.tar.gz"; \
mkdir -p "$(DIST_DIR)"; \
cp -ra . "$(DIST_DIR)"/muninlite-$$VERSION 2>/dev/null || true; \
cd "$(DIST_DIR)"; \
rm -rf muninlite-$$VERSION/"$(DIST_DIR)"; \
rm -rf muninlite-$$VERSION/.svn; \
tar zcvf muninlite-$$VERSION.tar.gz muninlite-$$VERSION >/dev/null; \
rm -rf muninlite-$$VERSION;