SUDO ?= sudo LIB ?= /usr/lib/battery-status SYSTEMD_PATH ?= /usr/lib/systemd/system LIB_FILES := battery-common-lib.sh battery-low-alert.sh battery-status-toggle.sh LIB_TARGETS := $(addprefix $(LIB)/,$(LIB_FILES)) SYSTEMD_FILES := battery-status-toggle.service battery-status-toggle.path SYSTEMD_TARGETS := $(addprefix $(SYSTEMD_PATH)/,$(SYSTEMD_FILES)) $(LIB): mkdir $@ $(LIB)/battery-common-lib.sh: $(SUDO) cp ./battery-common-lib.sh $@ $(LIB)/battery-low-alert.sh: $(SUDO) cp ./battery-low-alert.sh $@ $(LIB)/battery-status-toggle.sh: $(SUDO) cp ./battery-status-toggle.sh $@ ./battery-status-toggle.service: PREFIX=$(SYSTEMD_PATH) ./battery-status-toggle.service.template $(SYSTEMD_PATH)/battery-status-toggle.service: ./battery-status-toggle.service $(SUDO) cp ./battery-status-toggle.service $@ $(SYSTEMD_PATH)/battery-status-toggle.path: $(SUDO) cp ./battery-status-toggle.path $@ install: $(LIB_TARGETS) $(SYSTEMD_TARGETS) $(SUDO) systemctl daemon-reload enable: install $(SUDO) systemctl enable --now battery-status-toggle.path clean: $(SUDO) rm -f $(SYSTEMD_TARGETS) $(LIB_TARGETS) rm -f ./battery-status-toggle.service .PHONY: install enable clean