.PHONY: all release dev manpages install deb-pkg clean uninstall run run-dialog DESTDIR ?= = PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin LIBEXECDIR ?= $(PREFIX)/libexec DATADIR ?= $(PREFIX)/share MANDIR ?= $(DATADIR)/man APPLICATIONS_DIR = $(DATADIR)/applications DOC_DIR = $(DATADIR)/doc/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_OUT)/bscreensaver-settings.desktop release: $(RELEASE_TARGETS) dev: $(DEV_TARGETS) manpages: $(RELEASE_MANPAGES) install: all $(INSTALL) -m 0755 -d $(addprefix $(DESTDIR),$(BINDIR) $(HELPER_DIR) $(DOC_DIR) $(APPLICATIONS_DIR) $(MANDIR)/man1) $(INSTALL) -m 0755 $(addprefix $(RELEASE_OUT)/,$(BINARIES)) $(DESTDIR)$(BINDIR) $(INSTALL) -m 0755 $(addprefix $(RELEASE_OUT)/,$(HELPERS)) $(DESTDIR)$(HELPER_DIR) $(INSTALL) -m 0644 bscreensaver.toml.example $(DESTDIR)$(DOC_DIR) $(INSTALL) -m 0644 $(RELEASE_OUT)/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 mkdir -p $(dir $@) gzip -c -k $< > $@ $(RELEASE_OUT)/%.1: $(RELEASE_TARGETS) mkdir -p $(dir $@) $(HELP2MAN) --no-info $(subst .1,,$@) > $@ $(RELEASE_OUT)/bscreensaver-settings.desktop: settings/bscreensaver-settings.desktop.in mkdir -p $(dir $@) sed -e 's:@BINDIR@:$(BINDIR):g' $< > $@ deb-pkg: @[ "$(RELEASE_VERSION)" ] || { echo "RELEASE_VERSION not set >&2"; exit 1; } docker build -t bscreensaver-build:latest . sudo rm -rf docker-out mkdir docker-out docker run --rm -v $(shell pwd)/docker-out:/build:rw bscreensaver-build:latest bash -c '\ cp -a /bscreensaver /build/bscreensaver-$(RELEASE_VERSION) && \ cd /build && \ tar cvzf bscreensaver_$(RELEASE_VERSION).orig.tar.gz bscreensaver-$(RELEASE_VERSION) && \ cd bscreensaver-$(RELEASE_VERSION) && \ debuild --prepend-path=/root/.cargo/bin -uc -us && \ rm -rf /build/bscreensaver' 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)) rm -f $(DESTDIR)$(APPLICATIONS_DIR)/bscreensaver-settings.desktop rm -f $(DESTDIR)$(DOC_DIR)/bscreensaver.toml.example rmdir -p $(addprefix $(DESTDIR),$(BINDIR) $(HELPER_DIR) $(APPLICATIONS_DIR) $(DOC_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 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