Support DESTDIR in makefile

This commit is contained in:
Brian Tarricone 2022-05-05 13:38:21 -07:00
parent 23fef4d9e3
commit 858cd2750c

View File

@ -1,5 +1,6 @@
.PHONY: all release dev install clean uninstall run run-dialog .PHONY: all release dev install clean uninstall run run-dialog
DESTDIR ?= =
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin BINDIR ?= $(PREFIX)/bin
LIBEXECDIR ?= $(PREFIX)/libexec LIBEXECDIR ?= $(PREFIX)/libexec
@ -35,19 +36,18 @@ dev:
HELPER_DIR=target/debug cargo $(RUST_RELEASE_CHANNEL_ARG) build $(FEATURES_ARGS) HELPER_DIR=target/debug cargo $(RUST_RELEASE_CHANNEL_ARG) build $(FEATURES_ARGS)
install: release install: release
$(INSTALL) -m 0755 -d $(BINDIR) $(HELPER_DIR) $(CONFIG_DIR) $(APPLICATIONS_DIR) $(INSTALL) -m 0755 -d $(addprefix $(DESTDIR),$(BINDIR) $(HELPER_DIR) $(CONFIG_DIR) $(APPLICATIONS_DIR))
$(INSTALL) -m 0755 target/release/bscreensaver target/release/bscreensaver-command target/release/bscreensaver-settings $(BINDIR) $(INSTALL) -m 0755 target/release/bscreensaver target/release/bscreensaver-command target/release/bscreensaver-settings $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 $(addprefix target/release/,$(HELPERS)) $(HELPER_DIR) $(INSTALL) -m 0755 $(addprefix target/release/,$(HELPERS)) $(DESTDIR)$(HELPER_DIR)
$(INSTALL) -m 0644 bscreensaver.toml.example $(CONFIG_DIR) $(INSTALL) -m 0644 bscreensaver.toml.example $(DESTDIR)$(CONFIG_DIR)
$(INSTALL) -m 0644 settings/bscreensaver-settings.desktop $(APPLICATIONS_DIR) $(INSTALL) -m 0644 settings/bscreensaver-settings.desktop $(DESTDIR)$(APPLICATIONS_DIR)
clean: clean:
cargo $(RUST_RELEASE_CHANNEL_ARG) clean cargo $(RUST_RELEASE_CHANNEL_ARG) clean
uninstall: uninstall:
rm -f $(BINDIR)/bscreensaver $(BINDIR)/bscreensaver-command $(BINDIR)/bscreensaver-settings $(addprefix $(HELPER_DIR)/,$(HELPERS)) || true rm -f $(addprefix $(DESTDIR),$(BINDIR)/bscreensaver $(BINDIR)/bscreensaver-command $(BINDIR)/bscreensaver-settings $(addprefix $(HELPER_DIR)/,$(HELPERS))) || true
rmdir -p $(BINDIR) $(HELPER_DIR) || true rmdir -p $(addprefix $(DESTDIR),$(BINDIR) $(HELPER_DIR) $(APPLICATIONS_DIR)) || true
rmdir -p $(PREFIX) || true
run: dev run: dev
BSCREENSAVER_LOCAL_DEV=1 \ BSCREENSAVER_LOCAL_DEV=1 \