From 0801eec3c7bd9301c54d2aa96db3a96ab946842c Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Thu, 26 Jul 2018 20:34:07 +0100 Subject: [PATCH] Small refactoring of Makefile plus add documentation installation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makefile’s install target now copies documentation (AUTHORS, LICENSE and HTML files) to /usr/share/doc/urxvt-tabbedex (in addition to all the other things the target did). This can be disabled by making DOCDIR variable empty, e.g.: make DESTDIR=/tmp/urxvt-tabbedex-package DOCDIR= install Similarly, installing man pages can now be disabled by setting MANDIR to empty value. Apart from the two, there’s now also LIBDIR variable (but this one has to always be non-empty). All of the variables are relative to PREFIX. Makefile has also been refactored slightly such that there’s less renaming going on and templates can be used more efficiently. --- .gitignore | 4 ++- Makefile | 95 ++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 66 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index ee2ff37..49bf44c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -urxvt-tabbedex.* +*.1 +*.1.gz +*.html diff --git a/Makefile b/Makefile index d8a7665..e6990d5 100644 --- a/Makefile +++ b/Makefile @@ -1,56 +1,87 @@ DESTDIR = PREFIX = /usr -p = $(DESTDIR)$(PREFIX) -MANPAGES := urxvt-tabbedex.1.gz command-runner.1.gz -DIST := tabbedex command-runner.sample $(MANPAGES) +LIBDIR = lib +# Set to empty value to prevent man pages from being installed: +MANDIR = share/man +# Set to empty value to prevent documentation from being installed: +DOCDIR = share/doc/urxvt-tabbedex -all: $(MANPAGES) +L = $(DESTDIR)/$(PREFIX)/$(LIBDIR)/urxvt +M = $(DESTDIR)/$(PREFIX)/$(MANDIR)/man1 +D = $(DESTDIR)/$(PREFIX)/$(DOCDIR) -.INTERMEDIATE: urxvt-tabbedex.1 command-runner.1 +DIST = tabbedex command-runner.sample + + +all: man html +man: tabbedex.1.gz command-runner.sample.1.gz +html: tabbedex.html command-runner.sample.html -urxvt-tabbedex.1: tabbedex - if ! pod2man $< >$@; then rm -- $@; exit 1; fi -command-runner.1: command-runner.sample +%.1: % if ! pod2man $< >$@; then rm -- $@; exit 1; fi %.1.gz: %.1 if ! gzip -9 <$< >$@; then rm -- $@; exit 1; fi -urxvt-tabbedex.html: tabbedex +%.html: % if ! pod2html $< >$@; then rm -- $@; exit 1; fi @rm -f -- pod2htmd.tmp -install: $(DIST) - install -D -m 644 tabbedex '$p/lib/urxvt/perl/tabbedex' - install -D -m 644 command-runner.sample '$p/lib/urxvt/perl/tabbedex-command-runner.sample' - install -D -m 644 urxvt-tabbedex.1.gz '$p/share/man/man1/urxvt-tabbedex.1.gz' - install -D -m 644 command-runner.1.gz '$p/share/man/man1/tabbedex-command-runner.1.gz' + +clean: + rm -f -- *.1 *.1.gz *.html + + +install: AUTHORS LICENSE $(DIST) man html + install -D -m 644 tabbedex $L/perl/tabbedex + install -D -m 644 command-runner.sample $L/tabbedex-command-runner.sample +ifneq ($(MANDIR),) + install -D -m 644 tabbedex.1.gz $M/urxvt-tabbedex.1.gz + install -D -m 644 command-runner.sample.1.gz $M/tabbedex-command-runner.1.gz +endif +ifneq ($(DOCDIR),) + install -D -m 644 AUTHORS $D/AUTHORS + install -D -m 644 LICENSE $D/LICENSE + install -D -m 644 tabbedex.html $D/tabbedex.html + install -D -m 644 command-runner.sample.html $D/command-runner.html +endif uninstall: - rm -f -- '$p/lib/urxvt/perl/tabbedex' \ - '$p/lib/urxvt/perl/tabbedex-command-runner.sample' \ - '$p/share/man/man1/urxvt-tabbedex.1.gz' \ - '$p/share/man/man1/tabbedex-command-runner.1.gz' - -install-local: $(DIST) - install -D -m 644 tabbedex ~/.urxvt/ext/tabbedex - install -D -m 644 command-runner.sample ~/.urxvt/tabbedex-command-runner.sample + rm -f -- $L/perl/tabbedex $L/tabbedex-command-runner.sample +ifneq ($(MANDIR),) + rm -f -- $M/urxvt-tabbedex.1.gz $M/tabbedex-command-runner.1.gz +endif +ifneq ($(DOCDIR),) + rm -rf -- $D +endif + + +install-local: $(DIST) man + install -D -m 644 tabbedex ~/.urxvt/ext/tabbedex + install -D -m 644 command-runner.sample ~/.urxvt/tabbedex-command-runner.sample +ifneq ($(MANDIR),) # TODO: This assumes user has ~/bin in their PATH: - install -D -m 644 urxvt-tabbedex.1.gz ~/man/man1/urxvt-tabbedex.1.gz - install -D -m 644 command-runner.1.gz ~/man/man1/tabbedex-command-runner.1.gz + install -D -m 644 tabbedex.1.gz ~/man/man1/urxvt-tabbedex.1.gz + install -D -m 644 command-runner.sample.1.gz ~/man/man1/tabbedex-command-runner.1.gz +endif -install-local-symlink: $(DIST) +install-local-symlink: $(DIST) man mkdir -m 755 -p ~/.urxvt/ext ~/man/man1/ - ln -sf -- "$$(realpath tabbedex)" ~/.urxvt/ext - ln -sf -- "$$(realpath command-runner.sample)" ~/.urxvt/tabbedex-command-runner.sample - ln -sf -- "$$(realpath urxvt-tabbedex.1.gz)" ~/man/man1/ - ln -sf -- "$$(realpath command-runner.1.gz)" ~/man/man1/ + ln -sf -- "$$(realpath tabbedex)" ~/.urxvt/ext + ln -sf -- "$$(realpath command-runner.sample)" ~/.urxvt/tabbedex-command-runner.sample +ifneq ($(MANDIR),) + ln -sf -- "$$(realpath tabbedex.1.gz)" ~/man/man1/urxvt-tabbedex.1.gz + ln -sf -- "$$(realpath command-runner.sample.1.gz)" ~/man/man1/tabbedex-command-runner.1.gz +endif uninstall-local: - rm -f -- ~/.urxvt/ext/tabbedex \ - ~/.urxvt/tabbedex-command-runner.sample \ - ~/man/man1/urxvt-tabbedex.1.gz \ + rm -f -- ~/.urxvt/ext/tabbedex ~/.urxvt/tabbedex-command-runner.sample +ifneq ($(MANDIR),) + rm -f -- ~/man/man1/urxvt-tabbedex.1.gz \ ~/man/man1/tabbedex-command-runner.1.gz +endif + +.PHONY: all man html clean .PHONY: install uninstall install-local install-local-symlink uninstall-local