man pages: Split out the common preamble and insert it at build time.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 23 Jun 2020 09:08:50 +0000 (10:08 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 23 Jun 2020 09:09:46 +0000 (10:09 +0100)
This machinery is taken from the TrIPE project.

12 files changed:
Makefile.am
common/Makefile.am [new file with mode: 0644]
common/defs.man [new file with mode: 0644]
configure.ac
lib/Makefile.am
lib/keyword.3.in [moved from lib/keyword.3 with 98% similarity]
lib/sod-structs.3.in [moved from lib/sod-structs.3 with 98% similarity]
lib/sod.3.in [moved from lib/sod.3 with 97% similarity]
src/Makefile.am
src/sod-module.5.in [moved from src/sod-module.5 with 94% similarity]
src/sod.1.in [moved from src/sod.1 with 93% similarity]
vars.am

index 6bfe89b..d2b7e96 100644 (file)
@@ -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 (file)
index 0000000..b8246e4
--- /dev/null
@@ -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 (file)
index 0000000..8b14ee3
--- /dev/null
@@ -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 --------------------------------------------------
index 765924a..44f061c 100644 (file)
@@ -211,6 +211,7 @@ dnl Output.
 
 AC_CONFIG_FILES(
   [Makefile]
+  [common/Makefile]
   [src/Makefile]
   [lib/Makefile]
   [doc/Makefile]
index af62357..a0b727c 100644 (file)
@@ -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 --------------------------------------------------
similarity index 98%
rename from lib/keyword.3
rename to lib/keyword.3.in
index 7847733..dc2aa5f 100644 (file)
 .\" 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"
similarity index 98%
rename from lib/sod-structs.3
rename to lib/sod-structs.3.in
index 161fc4e..5cdff33 100644 (file)
 .\" 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"
similarity index 97%
rename from lib/sod.3
rename to lib/sod.3.in
index c49378a..975e7c7 100644 (file)
--- a/lib/sod.3
 .\" 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"
index b8f0e85..0dfb320 100644 (file)
@@ -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.
similarity index 94%
rename from src/sod-module.5
rename to src/sod-module.5.in
index 8e21b5d..f391668 100644 (file)
 .\" 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"
similarity index 93%
rename from src/sod.1
rename to src/sod.1.in
index 5474bda..5010ea3 100644 (file)
--- a/src/sod.1
 .\" 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 (file)
--- 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 --------------------------------------------------