Improve makefile, add autogenerated manpages

This commit is contained in:
Brian Tarricone 2022-05-11 22:37:04 -07:00
parent 050bf5cbac
commit 712467f433
2 changed files with 56 additions and 15 deletions

View File

@ -1,4 +1,4 @@
.PHONY: all release dev install clean uninstall run run-dialog .PHONY: all release dev manpages install clean uninstall run run-dialog
DESTDIR ?= = DESTDIR ?= =
PREFIX ?= /usr/local PREFIX ?= /usr/local
@ -6,17 +6,44 @@ BINDIR ?= $(PREFIX)/bin
LIBEXECDIR ?= $(PREFIX)/libexec LIBEXECDIR ?= $(PREFIX)/libexec
SYSCONFDIR ?= $(PREFIX)/etc SYSCONFDIR ?= $(PREFIX)/etc
DATADIR ?= $(PREFIX)/share DATADIR ?= $(PREFIX)/share
MANDIR ?= $(DATADIR)/man
APPLICATIONS_DIR = $(DATADIR)/applications APPLICATIONS_DIR = $(DATADIR)/applications
CONFIG_DIR = $(SYSCONFDIR)/xdg/bscreensaver CONFIG_DIR = $(SYSCONFDIR)/xdg/bscreensaver
HELPER_DIR = $(LIBEXECDIR)/bscreensaver HELPER_DIR = $(LIBEXECDIR)/bscreensaver
HELPERS = \
HELPERS := \
bscreensaver-dbus-service \ bscreensaver-dbus-service \
bscreensaver-systemd \ bscreensaver-systemd \
bscreensaver-dialog-gtk3 \ bscreensaver-dialog-gtk3 \
$(NULL) $(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 INSTALL ?= install
HELP2MAN ?= help2man
RUST_RELEASE_CHANNEL = nightly RUST_RELEASE_CHANNEL = nightly
ifeq ($(RUST_RELEASE_CHANNEL),nightly) ifeq ($(RUST_RELEASE_CHANNEL),nightly)
@ -27,29 +54,43 @@ endif
DEV_LOG_LEVEL = debug DEV_LOG_LEVEL = debug
all: release all: release manpages
release: release: $(RELEASE_TARGETS)
HELPER_DIR=$(HELPER_DIR) cargo $(RUST_RELEASE_CHANNEL_ARG) build $(FEATURES_ARGS) --release
dev: dev: $(DEV_TARGETS)
HELPER_DIR=target/debug cargo $(RUST_RELEASE_CHANNEL_ARG) build $(FEATURES_ARGS)
install: release manpages: $(RELEASE_MANPAGES)
$(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 $(DESTDIR)$(BINDIR) install: release manpages
$(INSTALL) -m 0755 $(addprefix target/release/,$(HELPERS)) $(DESTDIR)$(HELPER_DIR) $(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)
$(INSTALL) -m 0644 bscreensaver.toml.example $(DESTDIR)$(CONFIG_DIR) $(INSTALL) -m 0644 bscreensaver.toml.example $(DESTDIR)$(CONFIG_DIR)
$(INSTALL) -m 0644 settings/bscreensaver-settings.desktop $(DESTDIR)$(APPLICATIONS_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: clean:
cargo $(RUST_RELEASE_CHANNEL_ARG) clean cargo $(RUST_RELEASE_CHANNEL_ARG) clean
uninstall: uninstall:
rm -f $(addprefix $(DESTDIR),$(BINDIR)/bscreensaver $(BINDIR)/bscreensaver-command $(BINDIR)/bscreensaver-settings $(addprefix $(HELPER_DIR)/,$(HELPERS))) || true rm -f $(addprefix $(DESTDIR)$(BINDIR),$(BINARIES)) $(addprefix $(HELPER_DIR)/,$(HELPERS))) || true
rmdir -p $(addprefix $(DESTDIR),$(BINDIR) $(HELPER_DIR) $(APPLICATIONS_DIR)) || true rm -f $(addprefix $(DESTDIR)$(MANDIR)/man1/,$(MANPAGES))
rmdir -p $(addprefix $(DESTDIR),$(BINDIR) $(HELPER_DIR) $(APPLICATIONS_DIR) $(MANDIR)/man1) || true
run: dev run: $(DEV_TARGETS)
BSCREENSAVER_LOCAL_DEV=1 \ BSCREENSAVER_LOCAL_DEV=1 \
RUST_BACKTRACE=1 \ RUST_BACKTRACE=1 \
BSCREENSAVER_LOG=$(DEV_LOG_LEVEL) \ BSCREENSAVER_LOG=$(DEV_LOG_LEVEL) \

View File

@ -2,7 +2,7 @@
Version=1.0 Version=1.0
Name=Screensaver Settings Name=Screensaver Settings
Comment=Customize screensaver settings Comment=Customize screensaver settings
Exec=bscreensaver-settings Exec=@BINDIR@/bscreensaver-settings
Icon=screensaver Icon=screensaver
Terminal=false Terminal=false
StartupNotify=true StartupNotify=true