From 733ed91162b02cd0fa5d7d1c443c780d3d4405e9 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 23 Feb 2022 01:23:25 +0100 Subject: Makefile: Honor builddir=. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Defaulting to ‘build’. Also, remove BUILD_DOCDIR= (replaced with ‘$(builddir)/doc’). --- Makefile | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3f0df98..b91dce3 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ srcdir ?= . -BUILD_DOCDIR ?= $(srcdir)/doc +builddir ?= build CSS ?= /usr/share/javascript/bootstrap4/css/bootstrap.css HTML_TEMPLATE ?= $(srcdir)/doc/template.html -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))) +HTML_FILES = $(patsubst $(srcdir)/doc/%.md,$(builddir)/doc/%.html,$(wildcard $(srcdir)/doc/*.md)) +MANUAL_FILES = $(patsubst $(srcdir)/doc/%.md,$(builddir)/doc/%,$(wildcard $(srcdir)/doc/*.[1-9].md)) all: manual @@ -12,7 +12,8 @@ manual: $(MANUAL_FILES) html: $(HTML_FILES) # upper case the headers and remove the links -$(MANUAL_FILES): $(BUILD_DOCDIR)/%: $(srcdir)/doc/%.md +$(MANUAL_FILES): $(builddir)/doc/%: $(srcdir)/doc/%.md + @mkdir -vp $(dir $@) pandoc -f markdown -t json -- "$<" | $(srcdir)/pandoc2man.jq | pandoc -s -f json -t man -o "$@" test: @@ -37,8 +38,9 @@ release: -- 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: $(srcdir)/doc/%.md $(HTML_TEMPLATE) +## `make html CSS="https://guilhem.org/static/css/bootstrap.min.css" builddir="$XDG_RUNTIME_DIR/Downloads/interimap"` +$(HTML_FILES): $(builddir)/doc/%.html: $(srcdir)/doc/%.md $(HTML_TEMPLATE) + @mkdir -vp $(dir $@) 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"; \ @@ -66,7 +68,7 @@ man1dir ?= $(mandir)/man1 install: all $(INSTALL_PROGRAM) -vDt $(DESTDIR)$(bindir) $(srcdir)/interimap $(srcdir)/pullimap $(INSTALL_DATA) -vDT $(srcdir)/lib/Net/IMAP/InterIMAP.pm $(DESTDIR)$(datarootdir)/perl5/Net/IMAP/InterIMAP.pm - -$(INSTALL_DATA) -vDt $(DESTDIR)$(man1dir) $(BUILD_DOCDIR)/interimap.1 $(BUILD_DOCDIR)/pullimap.1 + -$(INSTALL_DATA) -vDt $(DESTDIR)$(man1dir) $(builddir)/doc/interimap.1 $(builddir)/doc/pullimap.1 $(INSTALL_DATA) -vDt $(DESTDIR)$(datarootdir)/doc/pullimap $(srcdir)/pullimap.sample $(INSTALL_DATA) -vDt $(DESTDIR)$(datarootdir)/doc/interimap $(srcdir)/interimap.sample \ $(srcdir)/doc/getting-started.md $(srcdir)/doc/multi-account.md $(srcdir)/README @@ -80,5 +82,6 @@ uninstall: clean: rm -vf -- $(MANUAL_FILES) $(HTML_FILES) + -rmdir -vp --ignore-fail-on-non-empty -- $(builddir)/doc .PHONY: all manual html doc test release install uninstall clean -- cgit v1.2.3