summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-04-01 01:16:02 +0000
committerbrian m. carlson <sandals@crustytoothpaste.net>2019-04-01 01:16:02 +0000
commitd96cbbd191cf2d8704906678bf602f7dd9d84f38 (patch)
tree1d84f83ddb7893adc54135cc68bbc39a69ca5426
parenta7f9f88210593121769939ca889c0f32a04e9b2d (diff)
Revamp Makefile
Instead of using multiple makefiles with pmake, which is no longer in Debian, switch to using a single simple GNU makefile. For now, only build XHTML, although we can add PDF generation for other files later. Build a tarball for installation. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
-rw-r--r--.gitignore3
-rw-r--r--Makefile162
2 files changed, 94 insertions, 71 deletions
diff --git a/.gitignore b/.gitignore
index 49af428..61f13c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,8 +9,11 @@
*.html
*.xhtml
*.bak
+*.tar.gz
stylesheet.xml
/build
+# Don't include files for customization.
+*.mk
# Don't include files from other locations.
/writings/tech.dbx
/writings/sexism-and-sexual-orientation.dbx
diff --git a/Makefile b/Makefile
index e13572e..b7b8a9a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,71 +1,91 @@
-# We use this even though it's included below, so that only one global search
-# and replace need be used.
-.include "${HOME}/.crustytoothpaste/groups/pmakefiles/files.mk"
-
-BUILD_DIR := build
-SRC_DIR := src
-RESOURCE_DIR := rsrc
-
-BLOG_DIR := ${BUILD_DIR}/blog
-
-SERVER_NAME := castro
-
-all:
-
-ct-setup: setup
-setup: ${BUILD_DIR}
-
-update:
- [ -d .git ] && \
- (for i in ${RESOURCE_DIR}/*; do echo "Updating $$i" && \
- (cd $$i && git pull origin master); done)
-
-${BUILD_DIR}!
- [ -d ${BUILD_DIR} ] || mkdir ${BUILD_DIR}
- cp -pLR ${SRC_DIR}/* ${BUILD_DIR}
- find ${BUILD_DIR} -name .git | xargs -I%s rm -r %s
-
-clean: clean-${BUILD_DIR}
-
-clean-${BUILD_DIR}:
- rm -r ${BUILD_DIR}
-
-clean-blog:
- touch ${BUILD_DIR}/blog/entries/index.dbx
-
-NF := 2>/dev/null; echo
-
-DBX_SRC != find -P ${BUILD_DIR} -name '*.dbx' -type f -print \
- 2>/dev/null | grep -vE '${BUILD_DIR}/.*(build|writings/aoif)' ${NF}
-MX_SRC != find -P ${BUILD_DIR} -name '*.mx' -type f -print ${NF}
-ASCII_SRC != find -L ${BUILD_DIR}/me/keys -name '*.txt' -o -name '*.asc' ${NF}
-WRITINGS_SRC != find ${BUILD_DIR} -maxdepth 2 -path '${BUILD_DIR}/writings/*.dbx' ${NF}
-BLOG_SRC != find ${BLOG_DIR} -name index.dbx ${NF}
-
-DBX_SRC := ${DBX_SRC:N${BUILD_DIR}/*build}
-
-ALL_SRC += ${DBX_SRC} ${MX_SRC} ${ASCII_SRC} ${WRITINGS_SRC}
-ALL_SRC += ${BLOG_SRC}
-
-XHTML_OBJ += ${DBX_SRC:.dbx=.xhtml} ${MX_SRC:.mx=.xhtml}
-HTML_OBJ += ${DBX_SRC:.dbx=.html} ${MX_SRC:.mx=.html}
-PDF_OBJ += ${WRITINGS_SRC:.dbx=.pdf}
-ATOM_OBJ += ${BLOG_SRC:.dbx=.atom} ${BLOG_DIR}/index.atom
-ATOM_OBJ += ${BLOG_SRC:index.dbx=feed.atom} ${BLOG_DIR}/feed.atom
-ATOM_OBJ += ${BLOG_SRC:index.dbx=atom.xml} ${BLOG_DIR}/atom.xml
-RSS_OBJ +=
-EXTRA_OBJ += ${ASCII_SRC}
-
-CLEAN_OBJ += ${HTML_OBJ}
-ct_TARGET_ALL += html
-
-.include "${ct_PMAKEFILES}/personal/atom.mk"
-.include "${ct_PMAKEFILES}/personal/rss.mk"
-.include "${ct_PMAKEFILES}/troff.mk"
-.include "${ct_PMAKEFILES}/personal/website.mk"
-
-atom-def: ${ATOM_OBJ}
-atom: atom-def
-
-rss-def: ${RSS_OBJ}
-rss: rss-def
+DOCBOOK_XSL_NS ?= /usr/share/xml/docbook/stylesheet/docbook-xsl-ns
+
+-include config.mk
+
+XHTML_SHEETS ?= $(XSL_SHEETS)/docbook/xhtml5
+XHTML_PARAMS += --stringparam html.stylesheet "https://www.crustytoothpaste.net/css/bootstrap/base.css https://www.crustytoothpaste.net/css/bootstrap/default.css"
+FO_SHEETS ?= $(XSL_SHEETS)/docbook/fo
+FO_PARAMS += --param fop1.extensions 1
+FO_PARAMS += --stringparam draft.mode no
+
+FOP_CONF ?= /usr/share/doc/fop/fop.xconf
+FOP_FLAGS ?= -q $(shell [ -e $(FOP_CFG) ] && printf -- "-c $(FOP_CFG)")
+
+SRC_ADOC = $(shell find -L src -name '*.adoc' | grep -vE 'src/writings/aoif/((misc|sketches|rsrc)/)?[^/]+.adoc')
+SRC_DBX = $(shell find -L src -name '*.dbx' | grep -vE 'src/writings/aoif/((misc|sketches|rsrc)/)?[^/]+.dbx')
+SRC_OTHER = $(shell find -L src -type f ! -name '*.adoc' ! -name '*.dbx')
+TARGET_BUILD = $(patsubst src/%,build/%,$(SRC_ADOC:.adoc=.txml) $(SRC_DBX:.dbx=.txml))
+TARGET_OTHER = $(patsubst src/%,build/%,$(SRC_OTHER))
+STRIPPED_OTHER = $(patsubst src/%,%,$(SRC_OTHER))
+
+BLOG_CAT_FILES = $(patsubst src/%,build/%,$(shell find src/blog/ -mindepth 1 -type f | grep -vE '.git|entries'))
+BLOG_ENTRIES = $(patsubst src/%,build/%,$(shell find src/blog/entries -type f))
+
+ASCIIDOCTOR ?= asciidoctor
+CP ?= cp
+FOP ?= fop
+XSLTPROC ?= xsltproc
+
+ifdef V
+QUIET_ASCIIDOCTOR = $(ASCIIDOCTOR)
+QUIET_CP = $(CP)
+QUIET_FO = $(XSLTPROC)
+QUIET_FOP = $(FOP)
+QUIET_XHTML = $(XSLTPROC)
+QUIET_PSTP = $(XSLTPROC)
+else
+QUIET = @
+QUIET_ASCIIDOCTOR = $(QUIET)echo "ASCIIDOCTOR $@" && $(ASCIIDOCTOR)
+QUIET_CP = $(QUIET)echo "CP $@" && $(CP)
+QUIET_FO = $(QUIET)echo "FO $@" && $(XSLTPROC)
+QUIET_FOP = $(QUIET)echo "FOP $@" && $(FOP)
+QUIET_XHTML = $(QUIET)echo "XHTML $@" && $(XSLTPROC)
+QUIET_PSTP = $(QUIET)echo "PSTP $@" && $(XSLTPROC)
+endif
+
+all: build.tar.gz
+
+clean:
+ rm -fr build
+
+build:
+ @mkdir build
+
+other: build
+ $(QUIET)tar -C src -cf - $(STRIPPED_OTHER) | tar -C build -xf -
+
+build/%.txml: src/%.adoc
+ $(QUIET)[ -z "$$(dirname "$@")" ] || [ -d "$$(dirname "$@")" ] || mkdir -p "$$(dirname "$@")"
+ $(QUIET_ASCIIDOCTOR) -b docbook5 -o $@ $<
+
+build/writings/aoif/%.dbx: build/writings/aoif/%.txml
+ $(QUIET)[ -z "$$(dirname "$@")" ] || [ -d "$$(dirname "$@")" ] || mkdir -p "$$(dirname "$@")"
+ $(QUIET_CP) $< $@
+
+build/blog/entries/%.dbx: build/blog/entries/%.txml
+ $(QUIET)[ -z "$$(dirname "$@")" ] || [ -d "$$(dirname "$@")" ] || mkdir -p "$$(dirname "$@")"
+ $(QUIET_CP) $< $@
+
+build/%.txml: src/%.dbx
+ $(QUIET)[ -z "$$(dirname "$@")" ] || [ -d "$$(dirname "$@")" ] || mkdir -p "$$(dirname "$@")"
+ $(QUIET_CP) $< $@
+
+build/%.xhtml: build/%.txml other
+ $(QUIET_XHTML) $(XHTML_PARAMS) --xinclude -o $@+ $(XHTML_SHEETS)/style/bmc/cvt.xsl $<
+ $(QUIET_PSTP) $(XHTML_PARAMS) --xinclude -o $@ $(XHTML_SHEETS)/style/bmc/pstp.xsl $@+
+ $(QUIET)rm $@+
+
+build/%.fo: build/%.txml other
+ $(QUIET_FO) $(FO_PARAMS) --xinclude -o $@+ $(FO_SHEETS)/style/bmc/cvt.xsl $<
+ $(QUIET_PSTP) $(FO_PARAMS) --xinclude -o $@ $(FO_SHEETS)/style/bmc/pstp.xsl $@+
+ $(QUIET)rm $@+
+
+build/%.pdf: build/%.fo other
+ $(FOP) $(FOP_FLAGS) -pdf $@ $<
+
+html: $(TARGET_BUILD:.txml=.xhtml)
+
+build.tar.gz: html other
+ tar --posix -cf $@ -C build \
+ $$(cd build && \
+ find . \( -name build -o -name rsrc -o -name '.git*' -o -name '*.txml' -o -name '*.dbx' \) -prune -o -type f -print)