From 6bed6ea3e51d812189d2ef2d5f9418632079db71 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Tue, 23 Jun 2020 10:08:50 +0100 Subject: [PATCH] man pages: Split out the common preamble and insert it at build time. This machinery is taken from the TrIPE project. --- Makefile.am | 3 + common/Makefile.am | 34 ++++++++++ common/defs.man | 111 ++++++++++++++++++++++++++++++++ configure.ac | 1 + lib/Makefile.am | 12 +++- lib/{keyword.3 => keyword.3.in} | 26 +------- lib/{sod-structs.3 => sod-structs.3.in} | 19 +----- lib/{sod.3 => sod.3.in} | 19 +----- src/Makefile.am | 5 +- src/{sod-module.5 => sod-module.5.in} | 52 +-------------- src/{sod.1 => sod.1.in} | 19 +----- vars.am | 24 ++++++- 12 files changed, 194 insertions(+), 131 deletions(-) create mode 100644 common/Makefile.am create mode 100644 common/defs.man rename lib/{keyword.3 => keyword.3.in} (98%) rename lib/{sod-structs.3 => sod-structs.3.in} (98%) rename lib/{sod.3 => sod.3.in} (97%) rename src/{sod-module.5 => sod-module.5.in} (94%) rename src/{sod.1 => sod.1.in} (93%) diff --git a/Makefile.am b/Makefile.am index 6bfe89b..d2b7e96 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,9 @@ SUBDIRS = ###-------------------------------------------------------------------------- ### Subdirectories to build +## Common infrastructure. +SUBDIRS += common + ## The SOD translator. SUBDIRS += src diff --git a/common/Makefile.am b/common/Makefile.am new file mode 100644 index 0000000..b8246e4 --- /dev/null +++ b/common/Makefile.am @@ -0,0 +1,34 @@ +### -*-makefile-*- +### +### Makefile for Sod common source files +### +### (c) 2020 Straylight/Edgeware +### + +###----- Licensing notice --------------------------------------------------- +### +### This file is part of the Sensible Object Design, an object system for C. +### +### SOD is free software: you can redistribute it and/or modify it under +### the terms of the GNU General Public License as published by the Free +### Software Foundation; either version 2 of the License, or (at your +### option) any later version. +### +### SOD is distributed in the hope that it will be useful, but WITHOUT ANY +### WARRANTY; without even the implied warranty of MERCHANTABILITY or +### FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +### for more details. +### +### You should have received a copy of the GNU General Public License +### along with SOD. If not, write to the Free Software Foundation, Inc., +### 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +include $(top_srcdir)/vars.am + +###-------------------------------------------------------------------------- +### Documentation. + +## Standard manpage preamble. +EXTRA_DIST += defs.man + +###----- That's all, folks -------------------------------------------------- diff --git a/common/defs.man b/common/defs.man new file mode 100644 index 0000000..8b14ee3 --- /dev/null +++ b/common/defs.man @@ -0,0 +1,111 @@ +.\" -*-nroff-*- +.\" +.\" Common definitions for Sod manpages +.\" +.\" (c) 2008 Straylight/Edgeware +.\" +. +.\"----- Licensing notice --------------------------------------------------- +.\" +.\" This file is part of the Sensible Object Design, an object system for C. +.\" +.\" SOD is free software; you can redistribute it and/or modify +.\" it under the terms of the GNU Library General Public License as +.\" published by the Free Software Foundation; either version 2 of the +.\" License, or (at your option) any later version. +.\" +.\" SOD is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU Library General Public License for more details. +.\" +.\" You should have received a copy of the GNU Library General Public +.\" License along with SOD; if not, write to the Free +.\" Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +.\" MA 02111-1307, USA. +. +.\"-------------------------------------------------------------------------- +.\" Preliminary definitions. +. +.\" Font selection. +.ie t \{\ +. if \n(.g \{\ +. fam P +. ev an-1 +. fam P +. ev +. \} +.\} +. +.\" Character definitions. +.ie t \{\ +. ds o \(bu \" bullet for lists +. ds e \(*e \" empty nonterminal +. ds ^ \v'-.3m'\s'\\n(.s*7/10' \" begin superscript +. ds ^e \s0\v'.3m' \" end superscript +. ds _ \v'.3m'\s'\\n(.s*7/10' \" begin subscript +. ds _e \s0\v'-.3m' \" end subscript +.\} +.el \{\ +. ds o o \" bullet for lists +. ds e \fIe\fR \" empty nonterminal +. ds ^ ^ \" begin superscript +. ds ^e \" end superscript +. ds _ _ \" begin subscript +. ds _e \" end subscript +.\} +.ds * \*^\(**\*(^e \" superscript `*' (zero or more) +.ds + \*^+\*(^e \" superscript `+' (one or more) +. +.\" .hP TEXT -- start an indented paragraph with TEXT hanging off to the left +.de hP +.IP +\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c +.. +. +.\" .SP -- equivalent to .TP, but indicates item should be summarized +.de SP +.TP +.. +. +.\" .VS ... .VE -- present a code example +.de VS +.sp 1 +.RS +.nf +.ft B +.. +.de VE +.ft R +.fi +.RE +.sp 1 +.. +. +.\" .t( ... .t) -- tabbing: align contents at current horizontal position +.de t( +'in +\\n(.ku +.. +.de t) +.in +.. +. +.\" .| -- syntax alternative on a new line +.de | +.br +\h'4n'| +.. +. +.\" .< -- newline and indent only in nroff mode (for shorter lines) +.ie t \{\ +. de < +.. +.\} +.el \{ +. de < +. br +\h'4n' +.. +.\} +. +.\"----- That's all, folks -------------------------------------------------- diff --git a/configure.ac b/configure.ac index 765924a..44f061c 100644 --- a/configure.ac +++ b/configure.ac @@ -211,6 +211,7 @@ dnl Output. AC_CONFIG_FILES( [Makefile] + [common/Makefile] [src/Makefile] [lib/Makefile] [doc/Makefile] diff --git a/lib/Makefile.am b/lib/Makefile.am index af62357..a0b727c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -42,11 +42,15 @@ nodist_pkginclude_HEADERS = pkginclude_HEADERS += keyword.h libsod_la_SOURCES += keyword.c keyword-hosted.c -dist_man_MANS += keyword.3 +man_MANS += keyword.3 +CLEANFILES += keyword.3 +EXTRA_DIST += keyword.3.in pkginclude_HEADERS += sod.h libsod_la_SOURCES += sod.c sod-hosted.c -dist_man_MANS += sod.3 +man_MANS += sod.3 +CLEANFILES += sod.3 +EXTRA_DIST += sod.3.in ###-------------------------------------------------------------------------- ### Generated builtin module. @@ -79,6 +83,8 @@ dist_aclocal_DATA = sod.m4 ###-------------------------------------------------------------------------- ### Other manual pages. -dist_man_MANS += sod-structs.3 +man_MANS += sod-structs.3 +CLEANFILES += sod-structs.3 +EXTRA_DIST += sod-structs.3.in ###----- That's all, folks -------------------------------------------------- diff --git a/lib/keyword.3 b/lib/keyword.3.in similarity index 98% rename from lib/keyword.3 rename to lib/keyword.3.in index 7847733..dc2aa5f 100644 --- a/lib/keyword.3 +++ b/lib/keyword.3.in @@ -24,30 +24,8 @@ .\" Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, .\" MA 02111-1307, USA. . -.\" Highlight using terminal escapes, rather than overstriking. -.\"\X'tty: sgr 1' -. -.\" String definitions and font selection. -.ie t \{\ -. ds o \(bu -. if \n(.g .fam P -.\} -.el \{\ -. ds o o -.\} -. -.\" .hP TEXT -- start an indented paragraph with TEXT hanging off to the left -.de hP -.IP -\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c -.. -. -.de t( -'in +\\n(.ku -.. -.de t) -.in -.. +.\"-------------------------------------------------------------------------- +.so ../common/defs.man \" @@@PRE@@@ . .\"-------------------------------------------------------------------------- .TH keyword 3 "16 December 2015" "Straylight/Edgeware" "Sensible Object Design" diff --git a/lib/sod-structs.3 b/lib/sod-structs.3.in similarity index 98% rename from lib/sod-structs.3 rename to lib/sod-structs.3.in index 161fc4e..5cdff33 100644 --- a/lib/sod-structs.3 +++ b/lib/sod-structs.3.in @@ -24,23 +24,8 @@ .\" Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, .\" MA 02111-1307, USA. . -.\" Highlight using terminal escapes, rather than overstriking. -.\"\X'tty: sgr 1' -. -.\" String definitions and font selection. -.ie t \{\ -. ds o \(bu -. if \n(.g .fam P -.\} -.el \{\ -. ds o o -.\} -. -.\" .hP TEXT -- start an indented paragraph with TEXT hanging off to the left -.de hP -.IP -\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c -.. +.\"-------------------------------------------------------------------------- +.so ../common/defs.man \" @@@PRE@@@ . .\"-------------------------------------------------------------------------- .TH sod-structs 3 "8 September 2015" "Straylight/Edgeware" "Sensible Object Design" diff --git a/lib/sod.3 b/lib/sod.3.in similarity index 97% rename from lib/sod.3 rename to lib/sod.3.in index c49378a..975e7c7 100644 --- a/lib/sod.3 +++ b/lib/sod.3.in @@ -24,23 +24,8 @@ .\" Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, .\" MA 02111-1307, USA. . -.\" Highlight using terminal escapes, rather than overstriking. -.\"\X'tty: sgr 1' -. -.\" String definitions and font selection. -.ie t \{\ -. ds o \(bu -. if \n(.g .fam P -.\} -.el \{\ -. ds o o -.\} -. -.\" .hP TEXT -- start an indented paragraph with TEXT hanging off to the left -.de hP -.IP -\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c -.. +.\"-------------------------------------------------------------------------- +.so ../common/defs.man \" @@@PRE@@@ . .\"-------------------------------------------------------------------------- .TH sod 3 "8 September 2015" "Straylight/Edgeware" "Sensible Object Design" diff --git a/src/Makefile.am b/src/Makefile.am index b8f0e85..0dfb320 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -170,8 +170,9 @@ check-local: sod sod-test.asd ###-------------------------------------------------------------------------- ### Manual pages. -dist_man_MANS += sod.1 -dist_man_MANS += sod-module.5 +man_MANS += sod.1 sod-module.5 +CLEANFILES += sod.1 sod-module.5 +EXTRA_DIST += sod.1.in sod-module.5.in ###-------------------------------------------------------------------------- ### Installation. diff --git a/src/sod-module.5 b/src/sod-module.5.in similarity index 94% rename from src/sod-module.5 rename to src/sod-module.5.in index 8e21b5d..f391668 100644 --- a/src/sod-module.5 +++ b/src/sod-module.5.in @@ -23,56 +23,8 @@ .\" along with SOD; if not, write to the Free Software Foundation, .\" Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. . -.\" Highlight using terminal escapes, rather than overstriking. -.\"\X'tty: sgr 1' -. -.\" String definitions and font selection. -.ie t \{\ -. ds o \(bu -. if \n(.g .fam P -.\} -.el \{\ -. ds o o -.\} -. -.\" .hP TEXT -- start an indented paragraph with TEXT hanging off to the left -.de hP -.IP -\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c -.. -. -.\" An epsilon, or e. -.ie t \{\ -. ds e \(*e -. ds ^ \v'-.3m'\s'\\n(.s*7/10' -. ds ^e \s0\v'.3m' -. ds _ \v'.3m'\s'\\n(.s*7/10' -. ds _e \s0\v'-.3m' -.\} -.el \{ -. ds e \fIe\fR -. ds ^ ^ -. ds ^e -. ds _ _ -. ds _e -.\} -.ds * \*^\(**\*(^e -.ds + \*^+\*(^e -. -.de | -.br -\h'4n'| -.. -.ie t \{\ -. de < -.. -.\} -.el -. de < -. br -\h'4n' -.. -.\} +.\"-------------------------------------------------------------------------- +.so ../common/defs.man \" @@@PRE@@@ . .\"-------------------------------------------------------------------------- .TH sod 5 "11 October 2015" "Straylight/Edgeware" "Sensible Object Design" diff --git a/src/sod.1 b/src/sod.1.in similarity index 93% rename from src/sod.1 rename to src/sod.1.in index 5474bda..5010ea3 100644 --- a/src/sod.1 +++ b/src/sod.1.in @@ -23,23 +23,8 @@ .\" along with SOD; if not, write to the Free Software Foundation, .\" Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. . -.\" Highlight using terminal escapes, rather than overstriking. -.\"\X'tty: sgr 1' -. -.\" String definitions and font selection. -.ie t \{\ -. ds o \(bu -. if \n(.g .fam P -.\} -.el \{\ -. ds o o -.\} -. -.\" .hP TEXT -- start an indented paragraph with TEXT hanging off to the left -.de hP -.IP -\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c -.. +.\"-------------------------------------------------------------------------- +.so ../common/defs.man \" @@@PRE@@@ . .\"-------------------------------------------------------------------------- .TH sod 1 "11 October 2015" "Straylight/Edgeware" "Sensible Object Design" diff --git a/vars.am b/vars.am index af6c14e..1409100 100644 --- a/vars.am +++ b/vars.am @@ -45,7 +45,7 @@ pkginclude_HEADERS = noinst_DATA = TESTS = -dist_man_MANS = +man_MANS = CLEANFILES += $(BUILT_SOURCES) @@ -110,4 +110,26 @@ V_TEST = $(V_TEST_@AM_V@) V_TEST_ = $(V_TEST_@AM_DEFAULT_V@) V_TEST_0 = @echo " TEST $@"; +###-------------------------------------------------------------------------- +### Manpage substitutions. + +SUFFIXES += .1.in .1 +SUFFIXES += .3.in .3 +SUFFIXES += .5.in .5 + +mandefs = $(top_srcdir)/common/defs.man + +V_MAN = $(V_MAN_@AM_V@) +V_MAN_ = $(V_MAN_@AM_DEFAULT_V@) +V_MAN_0 = @echo " MAN $@"; + +.1.in.1 .3.in.3 .5.in.5: + $(V_MAN) + $(AM_V_at)sed '/^\.$$/ d; /^\.\\"/ d' $(mandefs) >$@.defs + $(AM_V_at)sed -e '/@@@PRE@@@/ {' -e 'r$@.defs' -e 'd' -e '}' \ + $< >$@.merge + $(AM_V_at)$(confsubst) $@.merge >$@.subst $(SUBSTITUTIONS) + $(AM_V_at)rm -f $@.merge && mv $@.subst $@ + + ###----- That's all, folks -------------------------------------------------- -- 2.11.0