MAKEDEV.mi revision 1.73
1define(COMM,`#')dnl
2include(MAKEDEV.sub)dnl
3dnl
4vers(a, {-$OpenBSD: MAKEDEV.mi,v 1.73 2005/02/07 06:14:18 david Exp $-})dnl
5dnl
6divert(1)dnl
7{-#-}
8{-#-} Copyright (c) 2001-2004 Todd T. Fries <todd@OpenBSD.org>
9{-#-}
10{-#-} Permission to use, copy, modify, and distribute this software for any
11{-#-} purpose with or without fee is hereby granted, provided that the above
12{-#-} copyright notice and this permission notice appear in all copies.
13{-#-}
14{-#-} THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15{-#-} WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16{-#-} MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17{-#-} ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18{-#-} WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19{-#-} ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20{-#-} OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21{-#-}
22define(quote,{-"$1" -})dnl
23include(MAKEDEV.common)dnl
24dnl
25__devtitle(make, {-Device "make" file.  Valid arguments-})dnl
26__devitem({-all-}, {-all-}, {-makes all known devices{-,-} including local devices.
27{-#-}		Tries to make the ``standard'' number of each type.-})dnl
28__devitem(std,{-std-},Standard devices)dnl
29__devitem(local,local,Configuration specific devices)dnl
30dnl
31dnl _std
32dnl
33dnl $1: tty
34dnl $2: memstuff
35dnl $3: ksyms
36dnl $4: drum
37dnl $5: klog
38dnl
39define({-_std-},{-dnl
40std)
41	M console	c 0 0 600
42	M tty		c $1 0
43	M mem		c $2 0 640 kmem
44	M kmem		c $2 1 640 kmem
45	M null		c $2 2
46	M zero		c $2 12
47	M stdin		c major_fdesc_c 0
48	M stdout	c major_fdesc_c 1
49	M stderr	c major_fdesc_c 2
50	M ksyms		c $3 0 640 kmem
51	M drum		c $4 0 640 kmem
52	M klog		c $5 0 600-})dnl
53dnl
54divert(1)dnl
55define(__mddivert,7)dnl
56include(etc.MACHINE/MAKEDEV.md)dnl
57dnl
58dnl
59divert(0)dnl
60#!/bin/sh -
61#
62# THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
63# generated from:
64#
65show_vers()dnl <-- now that all files are included, show versions
66#
67dnl
68divert(2)dnl
69PATH=/sbin:/usr/sbin:/bin:/usr/bin
70T=$0
71
72# set this to echo for Echo-Only debugging
73[ "$eo" ] || eo=
74
75hex()
76{
77	case ${--}1 in
78	[0-9]) echo -n {-$-}1;;
79	10) echo -n a;;
80	11) echo -n b;;
81	12) echo -n c;;
82	13) echo -n d;;
83	14) echo -n e;;
84	15) echo -n f;;
85	esac
86}
87
88alph2d()
89{
90	local t="$1"
91	local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
92	local sub=${p%${t}*}
93	echo ${#sub}
94}
95
96h2d()
97{
98	local s="$1"
99	local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*}
100
101	echo $(($(_h2d $f)*16+ $(_h2d $n) ))
102}
103
104_h2d()
105{
106	case $1 in
107	[0-9]) echo -n $1;;
108	a) echo -n 10;;
109	b) echo -n 11;;
110	c) echo -n 12;;
111	d) echo -n 13;;
112	e) echo -n 14;;
113	f) echo -n 15;;
114	esac
115}
116
117unt()
118{
119	# XXX pdksh can't seem to deal with locally scoped variables
120	# in ${foo#$bar} expansions
121	arg="{-$-}1"
122	tmp="${arg#[a-zA-Z]*}"
123	tmp="${tmp%*[a-zA-Z]}"
124	while [ "$tmp" != "$arg" ]
125	do
126		arg=$tmp
127		tmp="${arg#[a-zA-Z]*}"
128		tmp="${tmp%*[a-zA-Z]}"
129	done
130	echo $arg
131}
132dnl
133dnl dodisk(name, unit, blkmaj, chrmaj, unit, off[, stepping])
134dnl   arg: 1    2    3      4      5    6    7
135dnl
136
137dodisk()
138{
139	[ "$DEBUG" ] && set -x
140	n=Add(Mult(${5}, ${7:-16}), ${6}) count=0
141	RMlist="$RMlist {-$-}1{-$-}2? r{-$-}1{-$-}2?"
142	[ 0$7 -ne 8 ] && l="i j k l m n o p"
143	for d in a b c d e f g h $l
144	do
145		M {-$-}1{-$-}2$d	b {-$-}3 Add($n, $count) 640
146		M r{-$-}1{-$-}2$d	c {-$-}4 Add($n, $count) 640
147		let count=count+1
148	done
149	MKlist="$MKlist;chown root:operator {-$-}1{-$-}2? r{-$-}1{-$-}2?"
150}
151dnl
152dnl dodisk2(name, unit, blkmaj, chrmaj, unit, off[, stepping])
153dnl
154dnl 1. name    - prefix name of the device
155dnl 2. unit    - beginning unit number for block devices
156dnl 3. blkmaj  - block device major number
157dnl 4. chrmaj  - character device major number
158dnl 5. unit    - beginning unit number for character devices
159dnl 6. off     - offset from 0 for all minor numbers (see svnd for an example)
160dnl 7. step    - optional, defaults to 16, number of partitions per device
161dnl
162
163dodisk2()
164{
165	n=Add(Mult({-$-}5, ${7:-16}), {-$-}6)
166	M {-$-}1{-$-}2a b {-$-}3 $n 640 operator
167	M r{-$-}1{-$-}2a c {-$-}4 $n 640 operator
168	n=Add($n, 2)
169	M {-$-}1{-$-}2c b {-$-}3 $n 640 operator
170	M r{-$-}1{-$-}2c c {-$-}4 $n 640 operator
171}
172
173# M name b/c major minor [mode] [group]
174RMlist="rm -f"
175MKlist=":"
176
177mkl() {
178dnl
179dnl uncomment if multi mknod happens
180dnl
181ifelse(1, 0,
182[ "${mklist[{-$-}1]}" ] && mklist[{-$-}1]="${mklist[{-$-}1]} {-$-}2 {-$-}3 {-$-}4 {-$-}5" || {
183	  mklist[{-$-}1]="mknod -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5"
184	  modes="$modes {-$-}1"
185     },
186dnl
187dnl non multi mknod
188dnl
189	[ "${mklist[{-$-}1]}" ] && {
190		mklist[{-$-}1]="${mklist[{-$-}1]};mknod -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5"
191	} || {
192		mklist[{-$-}1]="mknod -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5"
193		modes="$modes {-$-}1"
194	})
195}
196
197M() {
198	RMlist="$RMlist {-$-}1"
199	mkl ${5-666} {-$-}1 {-$-}2 {-$-}3 {-$-}4
200	mklist="$mklist {-$-}1"
201	G={-$-}{6:-wheel}
202	[ "{-$-}7" ] && {
203		MKlist="$MKlist;chown {-$-}7:{-$-}G {-$-}1"
204	} || {
205		case $G in
206		wheel)g=0;;kmem)g=2;;operator)g=5;;tty)g=4;;dialer)g=117;;_lkm)g=61;;
207		esac
208		[ "${grplist[$g]}" ] && {
209			grplist[$g]="${grplist[$g]} {-$-}1"
210		} || {
211			groups="$groups $g"
212			grplist[$g]="chgrp $G {-$-}1"
213		}
214	}
215	return 0
216}
217divert(7)dnl
218dnl
219dnl there is no blank line at the end of etc.arch/MAKEDEV.md files, so add one
220dnl on the following line:
221
222show_devs()dnl
223dnl
224divert(9)dnl
225*)
226	echo $i: unknown device
227	;;
228esac
229done
230}
231_recurse "$@"
232list="$RMlist"
233for mode in $modes; do
234	list="$list;${mklist[$mode]}"
235done
236for group in $groups; do
237	list="$list;${grplist[$group]}"
238done
239list="$list;$MKlist"
240if [ "$eo" = "echo" ]; then
241	$eo "$list"
242else
243	echo "$list" | sh
244fi
245divert(3)dnl
246dnl
247
248R() {
249[ "$DEBUG" ] && set -x
250for i in "$@"
251do
252U=`unt $i`
253[ "$U" ] || U=0
254
255case $i in
256dnl
257