xref: /plan9/sys/src/9/port/mkdevlist (revision 4fafed5d7536a51c1efde8b967cebb8d45be19ba)
1#!/bin/rc
2
3awk -v 'objtype='$objtype '
4BEGIN{
5	if(ARGC < 2)
6		exit;
7	collect = isdev = 0;
8}
9
10/^[ \t]*$/{
11	next;
12}
13/^#/{
14	next;
15}
16collect && /^[^	\t]/{
17	collect = isdev = 0;
18}
19collect && $0 ~ /[^ \t]+/{
20	if(isdev)
21		obj["dev" $1 "'.$O'"]++;
22	else
23		obj[$1 "'.$O'"]++;
24	for(i = 2; i <= NF; i++){
25		if($i !~ "[+=-].*")
26			obj[$i "'.$O'"]++;
27	}
28}
29$0 ~ /^[^ \t]/{
30	if($1 ~ "dev"){
31		isdev = 1;
32		collect = 1;
33	}
34	else if($1 ~ "misc" || $1 ~ "link" || $1 ~ "ip")
35		collect = 1;
36	next;
37}
38
39END{
40	x = ""
41	for(i in obj)
42		x = x i "\n";
43	if(objtype ~ "386" && obj["pci" "'.$O'"])
44		x = x "bios32'.$O' \n";
45	printf x;
46}' $*
47