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