bscreensaver/Makefile

108 lines
3.0 KiB
Makefile
Raw Normal View History

.PHONY: all release dev manpages install clean uninstall run run-dialog
2022-05-05 20:38:21 +00:00
DESTDIR ?= =
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
LIBEXECDIR ?= $(PREFIX)/libexec
2022-05-04 07:27:18 +00:00
SYSCONFDIR ?= $(PREFIX)/etc
2022-05-05 08:14:53 +00:00
DATADIR ?= $(PREFIX)/share
MANDIR ?= $(DATADIR)/man
2022-05-05 08:14:53 +00:00
APPLICATIONS_DIR = $(DATADIR)/applications
2022-05-04 07:27:18 +00:00
CONFIG_DIR = $(SYSCONFDIR)/xdg/bscreensaver
HELPER_DIR = $(LIBEXECDIR)/bscreensaver
HELPERS := \
bscreensaver-dbus-service \
bscreensaver-systemd \
bscreensaver-dialog-gtk3 \
$(NULL)
BINARIES := \
bscreensaver \
bscreensaver-command \
bscreensaver-settings \
$(NULL)
TARGETS := \
$(BINARIES) \
$(HELPERS) \
$(NULL)
DEV_OUT = target/debug
RELEASE_OUT = target/release
SOURCES := $(find . -name '*.rs') $(find . -name Cargo.toml) Cargo.lock
DEV_TARGETS := $(addprefix $(DEV_OUT),$(TARGETS))
RELEASE_TARGETS := $(addprefix $(RELEASE_OUT),$(TARGETS))
MANPAGES := \
bscreensaver.1.gz \
bscreensaver-command.1.gz \
$(NULL)
RELEASE_MANPAGES := $(addprefix $(RELEASE_OUT)/,$(MANPAGES))
INSTALL ?= install
HELP2MAN ?= help2man
RUST_RELEASE_CHANNEL = nightly
ifeq ($(RUST_RELEASE_CHANNEL),nightly)
RUST_RELEASE_CHANNEL_ARG = +nightly
else
FEATURES_ARGS = --no-default-features
endif
DEV_LOG_LEVEL = debug
all: release manpages
release: $(RELEASE_TARGETS)
dev: $(DEV_TARGETS)
manpages: $(RELEASE_MANPAGES)
install: release manpages
$(INSTALL) -m 0755 -d $(addprefix $(DESTDIR),$(BINDIR) $(HELPER_DIR) $(CONFIG_DIR) $(APPLICATIONS_DIR) $(MANDIR)/man1)
$(INSTALL) -m 0755 $(addprefix $(RELEASE_OUT)/,$(BINARIES)) $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 $(addprefix $(RELEASE_OUT)/,$(HELPERS)) $(DESTDIR)$(HELPER_DIR)
2022-05-05 20:38:21 +00:00
$(INSTALL) -m 0644 bscreensaver.toml.example $(DESTDIR)$(CONFIG_DIR)
$(INSTALL) -m 0644 settings/bscreensaver-settings.desktop $(DESTDIR)$(APPLICATIONS_DIR)
$(INSTALL) -m 0644 $(RELEASE_MANPAGES) $(DESTDIR)$(MANDIR)/man1
$(DEV_TARGETS): $(SOURCES)
HELPER_DIR=target/debug cargo $(RUST_RELEASE_CHANNEL_ARG) build $(FEATURES_ARGS)
$(RELEASE_TARGETS): $(SOURCES)
HELPER_DIR=$(HELPER_DIR) cargo $(RUST_RELEASE_CHANNEL_ARG) build $(FEATURES_ARGS) --release
$(RELEASE_OUT)/%.1.gz: $(RELEASE_OUT)/%.1
gzip -c -k $< > $@
$(RELEASE_OUT)/%.1: $(RELEASE_TARGETS)
$(HELP2MAN) --no-info $(subst .1,,$@) > $@
clean:
cargo $(RUST_RELEASE_CHANNEL_ARG) clean
uninstall:
rm -f $(addprefix $(DESTDIR)$(BINDIR),$(BINARIES)) $(addprefix $(HELPER_DIR)/,$(HELPERS))) || true
rm -f $(addprefix $(DESTDIR)$(MANDIR)/man1/,$(MANPAGES))
rmdir -p $(addprefix $(DESTDIR),$(BINDIR) $(HELPER_DIR) $(APPLICATIONS_DIR) $(MANDIR)/man1) || true
run: $(DEV_TARGETS)
BSCREENSAVER_LOCAL_DEV=1 \
RUST_BACKTRACE=1 \
BSCREENSAVER_LOG=$(DEV_LOG_LEVEL) \
BSCREENSAVER_DBUS_SERVICE_LOG=$(DEV_LOG_LEVEL) \
BSCREENSAVER_SYSTEMD_LOG=$(DEV_LOG_LEVEL) \
BSCREENSAVER_DIALOG_GTK3_LOG=$(DEV_LOG_LEVEL) \
HELPER_DIR=target/debug \
cargo $(RUST_RELEASE_CHANNEL_ARG) run $(FEATURES_ARGS) --bin bscreensaver
2022-05-04 06:47:06 +00:00
run-dialog:
RUST_BACKTRACE=1 \
BSCREENSAVER_DIALOG_GTK3_LOG=$(DEV_LOG_LEVEL) \
BSCREENSAVER_DIALOG_STANDALONE=1 \
cargo $(RUST_RELEASE_CHANNEL_ARG) run $(FEATURES_ARGS) --bin bscreensaver-dialog-gtk3