summary refs log tree commit diff
path: root/doc/rfc
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-03-06 01:44:20 -0500
committerJune McEnroe <june@causal.agency>2021-03-06 01:54:07 -0500
commit9d1dcf1b3ac31b3cfe4f44c0d74a8decae0c333a (patch)
tree113263230d1e8c8061b7fd5f138f47ceca2da4d5 /doc/rfc
parentRemove rfc.vim (diff)
downloadsrc-9d1dcf1b3ac31b3cfe4f44c0d74a8decae0c333a.tar.gz
src-9d1dcf1b3ac31b3cfe4f44c0d74a8decae0c333a.zip
Optionally compress RFCs, decompress in rfc(1)
Diffstat (limited to 'doc/rfc')
-rw-r--r--doc/rfc/Makefile20
-rw-r--r--doc/rfc/rfc.in13
2 files changed, 25 insertions, 8 deletions
diff --git a/doc/rfc/Makefile b/doc/rfc/Makefile
index e185dd97..31e238a0 100644
--- a/doc/rfc/Makefile
+++ b/doc/rfc/Makefile
@@ -1,11 +1,10 @@
 PREFIX ?= ~/.local
 MANDIR ?= ${PREFIX}/share/man
 
-BINS = rfc rfctags
 MODULE = ftp.rfc-editor.org::rfcs-text-only
 RFCS = ${MODULE}/rfc-index.txt ${MODULE}/'rfc[1-9]*.txt'
 
-all: ${BINS}
+all: rfc rfctags
 
 .SUFFIXES: .in .pl
 
@@ -18,15 +17,22 @@ all: ${BINS}
 	chmod a+x $@
 
 clean:
-	rm -f ${BINS}
+	rm -f rfc rfctags
 
-install: ${BINS} rfc.1
-	install -d ${PREFIX}/bin ${MANDIR}/man1 ${PREFIX}/share
-	install ${BINS} ${PREFIX}/bin
+install: rfc rfctags rfc.1
+	install -d ${PREFIX}/bin ${MANDIR}/man1
+	install rfc rfctags ${PREFIX}/bin
 	install -m 644 rfc.1 ${MANDIR}/man1
 	ln -fs rfc.1 ${MANDIR}/man1/rfctags.1
+
+sync:
+	install -d ${PREFIX}/share
 	rsync -ptz ${RFCS} ${PREFIX}/share/rfc
 
+compress:
+	find ${PREFIX}/share/rfc -name '*.txt' | xargs gzip -9f
+
 uninstall:
-	rm -f ${BINS:%=${PREFIX}/bin/%} ${BINS:%=${MANDIR}/man1/%.1}
+	rm -f ${PREFIX}/bin/rfc ${PREFIX}/bin/rfctags
+	rm -f ${MANDIR}/man1/rfc.1 ${MANDIR}/man1/rfctags.1
 	rm -fr ${PREFIX}/share/rfc
diff --git a/doc/rfc/rfc.in b/doc/rfc/rfc.in
index 958b09da..16081c83 100644
--- a/doc/rfc/rfc.in
+++ b/doc/rfc/rfc.in
@@ -1,8 +1,19 @@
 #!/bin/sh
 set -eu
 
+mktemp='mktemp -t rfc'
+[ "$(uname)" = 'OpenBSD' ] && mktemp="${mktemp}.XXXXXXXXXX"
+
 rfc=%%PREFIX%%/share/rfc/"rfc${1:--index}.txt"
-tags=$(mktemp -t rfc.XXXXXXXXXX)
+tags=$($mktemp)
 trap 'rm "${tags}"' EXIT
+
+if test -f "${rfc}.gz"; then
+	txt=$($mktemp)
+	trap 'rm "${txt}" "${tags}"' EXIT
+	gunzip -c "${rfc}.gz" >"${txt}"
+	rfc=$txt
+fi
+
 %%PREFIX%%/bin/rfctags "${rfc}" >"${tags}"
 ${PAGER:-less} -T "${tags}" "${rfc}"