2019-07-23 04:32:57 +02:00
|
|
|
PLUGINS = df cpu if_ if_err_ load memory processes swap netstat uptime interrupts irqstats ntpdate plugindir_
|
2019-07-23 04:43:46 +02:00
|
|
|
CONFIGURATION_FILE ?= munin-node.conf
|
|
|
|
TARGET_FILE ?= munin-node
|
|
|
|
VERSION ?= $(shell cat VERSION)
|
|
|
|
DIST_DIR = releases
|
|
|
|
TGZ_FILE ?= $(DIST_DIR)/muninlite-$(VERSION).tar.gz
|
2007-06-11 17:45:16 +02:00
|
|
|
|
|
|
|
|
2019-07-23 04:43:46 +02:00
|
|
|
$(TARGET_FILE): plugins/* $(CONFIGURATION_FILE)
|
|
|
|
@export VERSION="$(VERSION)"; \
|
|
|
|
export CONF=$$(grep -v '^#' "$(CONFIGURATION_FILE)"); \
|
2019-07-19 06:08:23 +02:00
|
|
|
export "PLUGINS=$(PLUGINS)"; \
|
2007-06-11 17:45:16 +02:00
|
|
|
echo "Making munin-node for muninlite version $$VERSION"; \
|
2019-07-19 06:08:23 +02:00
|
|
|
export PLSTR=""; \
|
|
|
|
for PLGIN in $$PLUGINS; \
|
2007-06-11 17:45:16 +02:00
|
|
|
do \
|
|
|
|
echo "Adding plugin $$PLGIN"; \
|
2019-07-19 06:08:23 +02:00
|
|
|
PLSTR=$$(printf "%s\n" "$$PLSTR"; grep -v '^#' plugins/$$PLGIN); \
|
2007-06-11 17:45:16 +02:00
|
|
|
done; \
|
2019-07-19 06:08:23 +02:00
|
|
|
perl -p -e '\
|
|
|
|
s/\@\@VERSION\@\@/$$ENV{"VERSION"}/; \
|
|
|
|
s/\@\@CONF\@\@/$$ENV{"CONF"}/; \
|
|
|
|
s/\@\@PLUGINS\@\@/$$ENV{"PLUGINS"}/; \
|
|
|
|
s/\@\@PLSTR\@\@/$$ENV{"PLSTR"}/;' \
|
2019-07-23 04:44:44 +02:00
|
|
|
munin-node.in >"$(TARGET_FILE).tmp"
|
|
|
|
@chmod +x "$(TARGET_FILE).tmp"
|
|
|
|
@mv "$(TARGET_FILE).tmp" "$(TARGET_FILE)"
|
2007-06-11 17:45:16 +02:00
|
|
|
|
2019-07-23 05:04:30 +02:00
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@$(info Available targets:)
|
|
|
|
@$(info all - assemble 'TARGET_FILE' ($(TARGET_FILE)))
|
|
|
|
@$(info clean - remove assembled 'TARGET_FILE' ($(TARGET_FILE)))
|
|
|
|
@$(info clean-all - remove old releases from 'DIST_DIR' ($(DIST_DIR)))
|
|
|
|
@$(info help - show this overview)
|
2019-07-23 05:23:03 +02:00
|
|
|
@$(info lint - code style checks)
|
2020-02-06 07:13:58 +01:00
|
|
|
@$(info spelling - check spelling)
|
2019-07-23 05:04:30 +02:00
|
|
|
@$(info tgz - create release archive)
|
|
|
|
|
2019-07-23 04:45:58 +02:00
|
|
|
.PHONY: all
|
2019-07-23 04:43:46 +02:00
|
|
|
all: $(TARGET_FILE)
|
2019-07-23 04:32:57 +02:00
|
|
|
|
2019-07-23 04:45:58 +02:00
|
|
|
.PHONY: clean-node
|
2007-06-11 17:45:16 +02:00
|
|
|
clean-node:
|
2019-07-23 04:43:46 +02:00
|
|
|
@echo "Removing $(TARGET_FILE)"
|
|
|
|
@rm -f "$(TARGET_FILE)"
|
2007-06-11 17:45:16 +02:00
|
|
|
|
2019-07-23 04:45:58 +02:00
|
|
|
.PHONY: clean-tgz
|
2019-07-23 04:32:57 +02:00
|
|
|
clean-tgz:
|
|
|
|
@echo "Removing old releases"
|
2019-07-23 04:43:46 +02:00
|
|
|
@rm -rf "$(DIST_DIR)"
|
2007-06-11 17:45:16 +02:00
|
|
|
|
2019-07-23 04:45:58 +02:00
|
|
|
.PHONY: clean
|
2007-06-11 17:45:16 +02:00
|
|
|
clean: clean-node
|
2019-07-23 04:32:57 +02:00
|
|
|
|
2019-07-23 04:45:58 +02:00
|
|
|
.PHONY: clean-all
|
2007-06-11 17:45:16 +02:00
|
|
|
clean-all: clean-node clean-tgz
|
|
|
|
|
2019-07-23 04:45:58 +02:00
|
|
|
.PHONY: tgz
|
2019-07-23 04:43:46 +02:00
|
|
|
tgz: $(TGZ_FILE)
|
|
|
|
|
|
|
|
$(TGZ_FILE):
|
2019-07-23 05:13:39 +02:00
|
|
|
@echo "Building $@ ..."
|
|
|
|
@mkdir -p "$(dir $(@))"
|
|
|
|
git archive --prefix=muninlite-$(VERSION)/ --format=tar --output "$@.tmp" HEAD
|
|
|
|
mv "$@.tmp" "$@"
|
2019-07-23 05:23:03 +02:00
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
|
|
|
shellcheck -s dash --exclude=SC2230 $(PLUGIN_FILES) "$(INPUT_FILE)"
|
2020-02-06 07:13:58 +01:00
|
|
|
|
|
|
|
.PHONY: spelling
|
|
|
|
spelling:
|
|
|
|
find -name .git -prune -or -name $(DIST_DIR) -prune -or -type f | xargs codespell
|