Skip to content

Commit

Permalink
Add support for building man pages from AsciiDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
jirutka committed Aug 3, 2021
1 parent c8a2d64 commit 5799c17
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.html
*.[1-9]
34 changes: 31 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,42 @@ prefix := /usr/local
sbindir := $(prefix)/sbin
libexecdir := $(prefix)/libexec
localstatedir := /var
mandir := $(prefix)/share/man
sysconfdir := /etc

STATE_DIR := $(localstatedir)/lib/$(PROGNAME)

MAN_FILES := $(basename $(wildcard *.[1-9].adoc))

ASCIIDOCTOR := asciidoctor
INSTALL := install
GIT := git
SED := sed

MAKEFILE_PATH = $(lastword $(MAKEFILE_LIST))


#: Print list of targets.
#: Print list of targets (the default target).
help:
@printf '%s\n\n' 'List of targets:'
@$(SED) -En '/^#:.*/{ N; s/^#: (.*)\n([A-Za-z0-9_-]+).*/\2 \1/p }' $(MAKEFILE_PATH) \
| while read label desc; do printf '%-15s %s\n' "$$label" "$$desc"; done

#: Build sources.
build: man

#: Convert man pages.
man: $(MAN_FILES)

#: Remove generated files.
clean:
rm -f ./*.[1-9]

#: Install into $DESTDIR.
install:
install: install-other install-man

#: Install everything except the man pages into $DESTDIR.
install-other:
$(INSTALL) -D -m755 akms "$(DESTDIR)$(sbindir)/$(PROGNAME)"
$(SED) -i \
-e "s|/usr/libexec/akms|$(libexecdir)/$(PROGNAME)|" \
Expand All @@ -33,6 +50,10 @@ install:
$(INSTALL) -D -m644 akms.conf "$(DESTDIR)$(sysconfdir)/$(PROGNAME).conf"
$(INSTALL) -d -m755 "$(DESTDIR)$(STATE_DIR)"

#: Install man pages into $DESTDIR/$mandir/man[1-9]/.
install-man: man
$(INSTALL) -D -m644 -t $(DESTDIR)$(mandir)/man5/ $(filter %.5,$(MAN_FILES))

#: Uninstall from $DESTDIR.
uninstall:
rm -f "$(DESTDIR)$(sbindir)/$(PROGNAME)"
Expand All @@ -58,4 +79,11 @@ release: .check-git-clean | bump-version
@test -z "$(shell $(GIT) status --porcelain)" \
|| { echo 'You have uncommitted changes!' >&2; exit 1; }

.PHONY: help install uninstall bump-version release .check-git-clean
.PHONY: help man clean install uninstall bump-version release .check-git-clean


%.1: %.1.adoc
$(ASCIIDOCTOR) -b manpage -o $@ $<

%.5: %.5.adoc
$(ASCIIDOCTOR) -b manpage -o $@ $<
5 changes: 5 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ TBD

== Requirements

.*Runtime*:
* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html[POSIX-sh] compatible shell with `pipefail` (e.g. Busybox ash, ZSH, bash, …)
* `env`, `grep`, `install`, `mount`, `umount`, `sed`, `su`, `tr` (Busybox or GNU)
* `depmod` from https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git[kmod]
* https://gitlab.alpinelinux.org/alpine/apk-tools[apk-tools]
* https://github.com/containers/bubblewrap[bubblewrap]
* Linux kernel with OverlayFS and namespaces

.*Build*:
* https://www.gnu.org/software/make/[GNU Make]
* http://asciidoctor.org/[Asciidoctor] (for building man pages)


== Usage

Expand Down

0 comments on commit 5799c17

Please sign in to comment.