xref: /openbsd/etc/MAKEDEV.mansub (revision 6d09f9df)
1dnl	$OpenBSD: MAKEDEV.mansub,v 1.2 2004/02/20 19:13:01 miod Exp $
2dnl
3dnl Copyright (c) 2004, Miodrag Vallat
4dnl Copyright (c) 2001-2004 Todd T. Fries <todd@OpenBSD.org>
5dnl
6dnl Permission to use, copy, modify, and distribute this software for any
7dnl purpose with or without fee is hereby granted, provided that the above
8dnl copyright notice and this permission notice appear in all copies.
9dnl
10dnl THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11dnl WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12dnl MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13dnl ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17dnl
18dnl This file is an m4 file, really. It's a clone of MAKEDEV.sub, then
19dnl adapted to mdoc output. This means, mostly removed from any non-trivial
20dnl content...
21dnl
22dnl o First, a change of quote to make shell statements like: `command`
23dnl   possible
24dnl
25changequote(`{-', `-}')dnl
26dnl
27dnl o version info must be stripped of $ so we can say 'generated from' below
28dnl
29dnl  If we just use the version string how are we going to know what arch
30dnl  'MAKEDEV.md,v' came from?
31dnl
32dnl  Thus, I have used the below to create a version string looking like
33dnl  'OpenBSD: etc.sparc/MAKEDEV.inc,v...' which works, although requires
34dnl  some attention if ported to another Id string setup.
35dnl
36dnl
37dnl Initialize the stacks stored in _m4_*
38dnl
39undefine({-_m4_cvs_ver-})dnl
40pushdef({-_m4_cvs_ver-}, {-done-})dnl
41dnl
42undefine({-_m4_devs-})dnl
43pushdef({-_m4_devs-}, {-done-})dnl
44dnl
45undefine({-_m4_disks-})dnl
46undefine({-_m4_disks2-})dnl
47pushdef({-_m4_disks-}, {-done-})dnl
48pushdef({-_m4_disks2-}, {-done-})dnl
49dnl
50dnl define stack 'add to' functions, only unique names queued
51dnl
52define({-ver_q-}, {-ifelse(index($1_ver, y), 0, ,
53{-pushdef({-_m4_cvs_ver-}, {-$2-})define({-$1_ver-}, {-y-})-})-})dnl ver_q
54dnl
55define({-dev_q-}, {-ifelse(index(_q_$1_dev, :), 0,
56{-errprint({-duplicated dev id: $1 at -}__file__{-:-}__line__ originally at _q_$1_dev)-},
57{-pushdef({-_m4_devs-}, {-$1-})dnl
58define({-_q_$1_dev-}, {-:-}__file__{-:-}__line__)-})-})dnl dev_q
59dnl
60define({-disk_q-}, {-ifelse(index(_q_$1_disk, :), 0,
61{-errprint({-duplicated disk id: $1 at -}__file__{-:-}__line__ originally at _q_$1_disk)-}, {-pushdef({-_m4_disks-}, {-$1-})dnl
62pushdef({-_m4_disks2-}, {-$1-})dnl
63define({-_q_$1_disks-}, {-:-}__file__{-:-}__line__)-})-})dnl disk_q
64dnl
65dnl store a version string for 'this' file
66dnl
67dnl vers ( uniqueidstring, versionstring, subdir )
68dnl
69dnl example1: vers(__file__, {-$OpenBSD: MAKEDEV.mansub,v 1.2 2004/02/20 19:13:01 miod Exp $-})
70dnl example2: vers(__file__, {-$OpenBSD: MAKEDEV.mansub,v 1.2 2004/02/20 19:13:01 miod Exp $-}, etc.MACHINE)
71dnl
72dnl if subdir is defined, prepend it to the filename in the version string
73dnl
74define({-vers-},
75{-ifelse({-$3-}, {--},
76{-ver_q(hstcl({-$1-}), {-translit({-{-$2-}-}, {-$-}, {--})-})-},
77{-ver_q(hstcl({-$1-}), {-_addsubdir({-{-$2-}-}, $3)-})-})-})dnl
78dnl
79dnl Version info for this file:
80dnl
81vers(__file__, {-$OpenBSD: MAKEDEV.mansub,v 1.2 2004/02/20 19:13:01 miod Exp $-})dnl
82dnl
83dnl
84define({-_addsubdir-},
85{-patsubst({-$1-}, {-\$(OpenBSD:) ([^\$]*)\$-}, {-\1 $2/\2-})-})dnl
86dnl
87dnl do the 'showing' of the version info
88dnl
89define({-do_vers-}, {-COMM	$1-})dnl
90dnl
91dnl show version function, to be called at the place when all versions are
92dnl   queued, and it is time to show all of them
93dnl
94define({-show_vers-},
95{-ifelse(_m4_cvs_ver, {-done-}, {--},
96{-do_vers(_m4_cvs_ver)
97popdef({-_m4_cvs_ver-})dnl
98show_vers()dnl
99-})-})dnl
100dnl
101dnl _devxr(name,optional different xr name)
102dnl
103define({-_devxr-},{-.Xr $1 ifelse(index($1,{- -}),-1,{-4 -})-})dnl
104dnl
105dnl _devitem(pattern, description)
106dnl
107define({-_devitem-},{-.It Ar $2
108$3{--}ifelse($4,nothing,,{-, see
109_devxr({-ifelse($4,,$1,$4)-})-})dnl
110.-})dnl
111dnl
112dnl _devtitle(name,description)
113dnl
114define({-_devtitle-},{-ifelse($1,make,,{-.El
115-}).Pp
116.Sy $2
117.Bl -tag -width tenletters -compact-})dnl
118dnl
119dnl _DEV(name, [character major], [block major])
120dnl
121define({-_DEV-}, {-$1_dev{--}dnl
122define({-$1__DEV-}, {-Y-})-})dnl
123dnl
124define({-_MKDEV-}, {-$1_mkdev-})dnl
125define({-_TITLE-}, {-$1_title-})dnl
126dnl
127define({-__devitem-}, {-define($1_dev, {-_devitem($1,$2,$3,$4)-})-})dnl
128dnl
129define({-__devtitle-}, {-define($1_title, {-_devtitle($1,$2)-})-})dnl
130define({-_mkdev-})dnl
131define({-_mcdev-})dnl
132define({-_cdev-})dnl
133define({-__mkdev-})dnl
134define({-target-})dnl
135define({-twrget-})dnl
136