2020-02-06 08:03:29 +01:00
|
|
|
PLUGINS ?= df cpu if_ if_err_ load memory processes swap netstat uptime interrupts irqstats ntpdate plugindir_
|
2020-02-07 11:30:36 +01:00
|
|
|
CONFIGURATION_FILE ?= muninlite.conf
|
|
|
|
INPUT_FILE ?= muninlite.in
|
|
|
|
TARGET_FILE ?= muninlite
|
2020-02-06 07:45:48 +01:00
|
|
|
PLUGIN_DIRECTORY ?= plugins
|
|
|
|
PLUGIN_FILES = $(patsubst %,$(PLUGIN_DIRECTORY)/%,$(PLUGINS))
|
2019-07-23 04:43:46 +02:00
|
|
|
VERSION ?= $(shell cat VERSION)
|
|
|
|
DIST_DIR = releases
|
2020-02-06 08:10:10 +01:00
|
|
|
DESTDIR ?= /usr/local/bin
|
2019-07-23 04:43:46 +02:00
|
|
|
TGZ_FILE ?= $(DIST_DIR)/muninlite-$(VERSION).tar.gz
|
2020-02-09 00:44:21 +01:00
|
|
|
TGZ_FILE_CHECKSUM ?= $(TGZ_FILE).sha256sum
|
|
|
|
TGZ_FILE_SIGNATURE ?= $(TGZ_FILE).asc
|
2007-06-11 17:45:16 +02:00
|
|
|
|
|
|
|
|
2020-02-06 07:45:48 +01:00
|
|
|
$(TARGET_FILE): $(INPUT_FILE) $(PLUGIN_FILES) $(CONFIGURATION_FILE)
|
2020-02-07 11:30:36 +01:00
|
|
|
@echo "Making muninlite version $$VERSION"
|
2020-02-06 07:59:03 +01:00
|
|
|
@for plugin_filename in $(PLUGIN_FILES); do \
|
|
|
|
echo "Adding plugin $$(basename "$$plugin_filename")"; done
|
2019-07-23 04:43:46 +02:00
|
|
|
@export VERSION="$(VERSION)"; \
|
2020-02-06 07:59:27 +01:00
|
|
|
export "PLUGINS=$(PLUGINS)"; \
|
|
|
|
export CONF=$$(grep -v '^#' "$(CONFIGURATION_FILE)"); \
|
2020-02-08 23:41:48 +01:00
|
|
|
export PLSTR="$$(grep -vh '^[ \t]*#' $(PLUGIN_FILES))"; \
|
2020-02-06 07:59:27 +01:00
|
|
|
perl -p -e '\
|
|
|
|
s/\@\@VERSION\@\@/$$ENV{"VERSION"}/; \
|
|
|
|
s/\@\@CONF\@\@/$$ENV{"CONF"}/; \
|
|
|
|
s/\@\@PLUGINS\@\@/$$ENV{"PLUGINS"}/; \
|
|
|
|
s/\@\@PLSTR\@\@/$$ENV{"PLSTR"}/;' \
|
|
|
|
"$(INPUT_FILE)" >"$(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)))
|
2020-02-09 00:44:21 +01:00
|
|
|
@$(info dist - create release archive)
|
2020-02-06 08:10:10 +01:00
|
|
|
@$(info install - install the standalone shell script)
|
2019-07-23 05:04:30 +02:00
|
|
|
@$(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)
|
2020-02-06 07:28:08 +01:00
|
|
|
@$(info test - run tests)
|
2019-07-23 05:04:30 +02:00
|
|
|
|
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
|
|
|
|
2020-02-09 00:44:21 +01:00
|
|
|
.PHONY: clean-dist
|
|
|
|
clean-dist:
|
2019-07-23 04:32:57 +02:00
|
|
|
@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
|
2020-02-09 00:44:21 +01:00
|
|
|
clean-all: clean-node clean-dist
|
2019-07-23 04:43:46 +02:00
|
|
|
|
|
|
|
$(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
|
|
|
|
2020-02-09 00:44:21 +01:00
|
|
|
$(TGZ_FILE_CHECKSUM): $(TGZ_FILE)
|
|
|
|
sha256sum "$<" >"$@"
|
|
|
|
|
|
|
|
$(TGZ_FILE_SIGNATURE): $(TGZ_FILE_CHECKSUM)
|
|
|
|
gpg --armor --detach-sign --sign "$<"
|
|
|
|
|
|
|
|
.PHONY: dist
|
|
|
|
dist: $(TGZ_FILE_SIGNATURE)
|
|
|
|
|
2020-02-06 08:10:10 +01:00
|
|
|
.PHONY: install
|
|
|
|
install: $(TARGET_FILE)
|
|
|
|
mkdir -p "$(dir $(DESTDIR))"
|
|
|
|
cp "$(TARGET_FILE)" "$(DESTDIR)/"
|
|
|
|
|
|
|
|
|
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:
|
2020-02-09 02:08:24 +01:00
|
|
|
@find -name .git -prune -or -name $(DIST_DIR) -prune -or -type f -print | xargs codespell
|
2020-02-06 07:28:08 +01:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test: $(TARGET_FILE)
|
|
|
|
@# verify that the assembled shell script can be interpreted by the local shell
|
|
|
|
@if echo "list" | "$(abspath $(TARGET_FILE))" | grep -qw "uptime"; then \
|
|
|
|
echo "Test OK"; else echo "Test FAILED"; false; fi
|