aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2022-02-22 23:21:58 +0100
committerGuilhem Moulin <guilhem@fripost.org>2022-02-22 23:58:07 +0100
commit6cf878f69e15c6414dda4fb1171db244953bf8a4 (patch)
tree5a7ec6cfdb55061be3026d24f1279ef88537c374
parent6bfc13635af817bb16b4fe5ef5a42619573c51fc (diff)
Makefile: Honor srcdir=.
Cf. https://www.gnu.org/prep/standards/html_node/Directory-Variables.html .
-rw-r--r--Makefile51
1 files changed, 26 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index 9f4702d..0324d65 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,11 @@
+srcdir ?= .
DESTDIR ?= /usr/local
-BUILD_DOCDIR ?= ./doc
+BUILD_DOCDIR ?= $(srcdir)/doc
CSS ?= /usr/share/javascript/bootstrap4/css/bootstrap.css
-HTML_TEMPLATE ?= ./doc/template.html
+HTML_TEMPLATE ?= $(srcdir)/doc/template.html
-HTML_FILES = $(addprefix $(BUILD_DOCDIR)/,$(patsubst ./doc/%.md,%.html,$(wildcard ./doc/*.md)))
-MANUAL_FILES = $(addprefix $(BUILD_DOCDIR)/,$(patsubst ./doc/%.md,%,$(wildcard ./doc/*.[1-9].md)))
+HTML_FILES = $(addprefix $(BUILD_DOCDIR)/,$(patsubst $(srcdir)/doc/%.md,%.html,$(wildcard $(srcdir)/doc/*.md)))
+MANUAL_FILES = $(addprefix $(BUILD_DOCDIR)/,$(patsubst $(srcdir)/doc/%.md,%,$(wildcard $(srcdir)/doc/*.[1-9].md)))
all: manual
@@ -12,34 +13,34 @@ manual: $(MANUAL_FILES)
html: $(HTML_FILES)
# upper case the headers and remove the links
-$(MANUAL_FILES): $(BUILD_DOCDIR)/%: ./doc/%.md
- pandoc -f markdown -t json -- "$<" | ./pandoc2man.jq | pandoc -s -f json -t man -o "$@"
+$(MANUAL_FILES): $(BUILD_DOCDIR)/%: $(srcdir)/doc/%.md
+ pandoc -f markdown -t json -- "$<" | $(srcdir)/pandoc2man.jq | pandoc -s -f json -t man -o "$@"
test:
- ./tests/certs/generate
- ./tests/run-all
+ $(srcdir)/tests/certs/generate
+ $(srcdir)/tests/run-all
release:
- @if ! git diff HEAD --quiet -- ./Changelog ./interimap ./pullimap ./lib/Net/IMAP/InterIMAP.pm; then \
+ @if ! git -C $(srcdir) diff --quiet HEAD -- Changelog interimap pullimap lib/Net/IMAP/InterIMAP.pm; then \
echo "Dirty state, refusing to release!" >&2; \
exit 1; \
fi
- VERS=$$(dpkg-parsechangelog -l Changelog -SVersion 2>/dev/null) && \
- if git rev-parse -q --verify "refs/tags/v$$VERS" >/dev/null; then echo "tag exists" 2>/dev/null; exit 1; fi && \
- sed -ri "0,/^( -- .*) .*/ s//\\1 $(shell date -R)/" ./Changelog && \
+ VERS=$$(dpkg-parsechangelog -l $(srcdir)/Changelog -SVersion 2>/dev/null) && \
+ if git -C $(srcdir) rev-parse -q --verify "refs/tags/v$$VERS" >/dev/null; then echo "tag exists" 2>/dev/null; exit 1; fi && \
+ sed -ri "0,/^( -- .*) .*/ s//\\1 $(shell date -R)/" $(srcdir)/Changelog && \
sed -ri "0,/^(our\\s+\\\$$VERSION\\s*=\\s*)'[0-9.]+'\\s*;/ s//\\1'$$VERS';/" \
- -- ./interimap ./pullimap && \
+ -- $(srcdir)/interimap $(srcdir)/pullimap && \
sed -ri "0,/^(package\\s+Net::IMAP::InterIMAP\\s+)v[0-9.]+\\s*;/ s//\\1v$$VERS;/" \
- -- ./lib/Net/IMAP/InterIMAP.pm && \
+ -- $(srcdir)/lib/Net/IMAP/InterIMAP.pm && \
sed -ri "0,/^(use\\s+Net::IMAP::InterIMAP\\s+)[0-9.]+(\\s|\\$$)/ s//\\1$$VERS\\2/" \
- -- ./interimap ./pullimap && \
- git commit -m "Prepare new release v$$VERS." \
- -- ./Changelog ./interimap ./pullimap ./lib/Net/IMAP/InterIMAP.pm && \
- git tag -sm "Release version $$VERS" "v$$VERS"
+ -- $(srcdir)/interimap $(srcdir)/pullimap && \
+ git -C $(srcdir) commit -m "Prepare new release v$$VERS." \
+ -- Changelog interimap pullimap lib/Net/IMAP/InterIMAP.pm && \
+ git -C $(srcdir) tag -sm "Release version $$VERS" "v$$VERS"
## make html CSS="https://guilhem.org/static/css/bootstrap.min.css" BUILD_DOCDIR="$XDG_RUNTIME_DIR/Downloads"
-$(HTML_FILES): $(BUILD_DOCDIR)/%.html: ./doc/%.md $(HTML_TEMPLATE)
- mtime="$$(git --no-pager log -1 --pretty="format:%ct" -- "$<" 2>/dev/null)"; \
+$(HTML_FILES): $(BUILD_DOCDIR)/%.html: $(srcdir)/doc/%.md $(HTML_TEMPLATE)
+ mtime="$$(git -C $(srcdir) --no-pager log -1 --pretty="format:%ct" -- "$<" 2>/dev/null)"; \
[ -n "$$mtime" ] || mtime="$$(date +%s -r "$<")"; \
[ "$<" = "doc/index.md" ] && parent="" || parent="./index.html"; \
pandoc -sp -f markdown -t html+smart --css=$(CSS) --template=$(HTML_TEMPLATE) \
@@ -60,12 +61,12 @@ mandir ?= $(datarootdir)/man
man1dir ?= $(mandir)/man1
install: all
- install -m0755 -vDt $(bindir) ./interimap ./pullimap
- install -m0644 -vDT ./lib/Net/IMAP/InterIMAP.pm $(datarootdir)/perl5/Net/IMAP/InterIMAP.pm
+ install -m0755 -vDt $(bindir) $(srcdir)/interimap $(srcdir)/pullimap
+ install -m0644 -vDT $(srcdir)/lib/Net/IMAP/InterIMAP.pm $(datarootdir)/perl5/Net/IMAP/InterIMAP.pm
install -m0644 -vDt $(man1dir) $(BUILD_DOCDIR)/interimap.1 $(BUILD_DOCDIR)/pullimap.1
- install -m0644 -vDt $(datarootdir)/doc/pullimap ./pullimap.sample
- install -m0644 -vDt $(datarootdir)/doc/interimap ./interimap.sample ./doc/getting-started.md ./doc/multi-account.md README
- install -m0644 -vDt $(libdir)/systemd/user ./*.service
+ install -m0644 -vDt $(datarootdir)/doc/pullimap $(srcdir)/pullimap.sample
+ install -m0644 -vDt $(datarootdir)/doc/interimap $(srcdir)/interimap.sample $(srcdir)/doc/getting-started.md $(srcdir)/doc/multi-account.md README
+ install -m0644 -vDt $(libdir)/systemd/user $(srcdir)/*.service
uninstall:
rm -vf -- $(bindir)/interimap $(man1dir)/interimap.1 $(libdir)/systemd/user/interimap*.service