]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
Makefile, etc/groff/tmac/deadly.tmac: Add lint and lint-groff targets
authorAlejandro Colomar <alx.manpages@gmail.com>
Fri, 18 Mar 2022 00:50:25 +0000 (01:50 +0100)
committerAlejandro Colomar <alx.manpages@gmail.com>
Fri, 18 Mar 2022 01:31:24 +0000 (02:31 +0100)
'lint' is a metatarget that triggers all lint-* targets (currently
that is just 'lint-groff').
'lint-groff' is a target that runs groff -rCHECKSTYLE to check
manual pages' groff(7) correctness.

etc/groff/tmac/deadly.tmac is a file written by Branden, to make
groff(1) abort when it finds a style problem, which then causes
make(1) to also abort.

CC: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Makefile
etc/groff/tmac/deadly.tmac [new file with mode: 0644]

index f68066becaee9f686895d796b3dc9bd6af1b0707..68b6205299ace9a6bd1998bf22a67ee368875677 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -29,15 +29,19 @@ MAKEFLAGS += --no-print-directory
 MAKEFLAGS += --warn-undefined-variables
 
 
+srcdir := .
 builddir := tmp
+LINTDIR := $(builddir)/lint
 htmlbuilddir := $(builddir)/html
 HTOPTS :=
 
 DESTDIR :=
 prefix := /usr/local
+SYSCONFDIR := $(srcdir)/etc
+TMACDIR := $(SYSCONFDIR)/groff/tmac
 datarootdir := $(prefix)/share
 docdir := $(datarootdir)/doc
-MANDIR := $(CURDIR)
+MANDIR := $(srcdir)
 mandir := $(datarootdir)/man
 MAN0DIR := $(MANDIR)/man0
 MAN1DIR := $(MANDIR)/man1
@@ -71,12 +75,23 @@ htmldir := $(docdir)
 htmldir_ := $(htmldir)/man
 htmlext := .html
 
-INSTALL := install
+TMACFILES            := $(sort $(shell find $(TMACDIR) -not -type d))
+TMACNAMES            := $(basename $(notdir $(TMACFILES)))
+GROFF_CHECKSTYLE_LVL := 3
+DEFAULT_GROFFFLAGS   := -man
+DEFAULT_GROFFFLAGS   += -M $(TMACDIR)
+DEFAULT_GROFFFLAGS   += $(foreach x,$(TMACNAMES),-m $(x))
+DEFAULT_GROFFFLAGS   += -rCHECKSTYLE=$(GROFF_CHECKSTYLE_LVL)
+EXTRA_GROFFFLAGS     :=
+GROFFFLAGS           := $(DEFAULT_GROFFFLAGS) $(EXTRA_GROFFFLAGS)
+
+INSTALL      := install
 INSTALL_DATA := $(INSTALL) -m 644
-INSTALL_DIR := $(INSTALL) -m 755 -d
-RM := rm
-RMDIR := rmdir --ignore-fail-on-non-empty
-MAN2HTML := man2html
+INSTALL_DIR  := $(INSTALL) -m 755 -d
+RM           := rm
+RMDIR        := rmdir --ignore-fail-on-non-empty
+GROFF        := groff
+MAN2HTML     := man2html
 
 MAN_SECTIONS := 0 1 2 3 4 5 6 7 8
 
@@ -132,9 +147,11 @@ _man5pages := $(filter %$(man5ext),$(_manpages))
 _man6pages := $(filter %$(man6ext),$(_manpages))
 _man7pages := $(filter %$(man7ext),$(_manpages))
 _man8pages := $(filter %$(man8ext),$(_manpages))
+LINT_groff := $(patsubst $(MANDIR)/%,$(LINTDIR)/%.lint.groff.touch,$(MANPAGES))
 
 MANDIRS   := $(sort $(shell find $(MANDIR)/man? -type d))
 HTMLDIRS  := $(patsubst $(MANDIR)/%,$(htmlbuilddir)/%/.,$(MANDIRS))
+LINTDIRS  := $(patsubst $(MANDIR)/%,$(LINTDIR)/%/.,$(MANDIRS))
 _htmldirs := $(patsubst $(htmlbuilddir)/%,$(DESTDIR)$(htmldir_)/%,$(HTMLDIRS))
 _mandirs  := $(patsubst $(MANDIR)/%,$(DESTDIR)$(mandir)/%/.,$(MANDIRS))
 _man0dir  := $(filter %man0/.,$(_mandirs))
@@ -216,6 +233,32 @@ uninstall-man: $(_mandir_rmdir) $(uninstall_manX)
        @:
 
 
+########################################################################
+# lint
+
+linters := groff
+lint    := $(foreach x,$(linters),lint-$(x))
+
+$(LINT_groff): $(LINTDIR)/%.lint.groff.touch: $(MANDIR)/% | $$(@D)/.
+       $(info LINT (groff)     $@)
+       $(GROFF) $(GROFFFLAGS) -z $<
+       touch $@
+
+$(LINTDIRS): %/.: | $$(dir %). $(LINTDIR)/.
+
+.PHONY: lint-groff
+lint-groff: $(LINT_groff) | lintdirs
+       @:
+
+.PHONY: lintdirs
+lintdirs: $(LINTDIRS)
+       @:
+
+.PHONY: lint
+lint: $(lint)
+       @:
+
+
 ########################################################################
 # html
 
diff --git a/etc/groff/tmac/deadly.tmac b/etc/groff/tmac/deadly.tmac
new file mode 100644 (file)
index 0000000..b87cb6a
--- /dev/null
@@ -0,0 +1,7 @@
+.am an-style-warn
+.      ds LANDMINE\"
+..
+.de end-of-input-macro
+.      if d LANDMINE .ab found style problems; aborting
+..
+.em end-of-input-macro