summaryrefslogtreecommitdiff
path: root/sys/src/9/port/mkdevlist
blob: 0bdbf445a523d3d0e99a406a9f7c449e16acefa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/rc

awk -v 'objtype='$objtype '
BEGIN{
	if(ARGC < 2)
		exit;
	collect = isdev = 0;
}

/^[ \t]*$/{
	next;
}
/^#/{
	next;
}
collect && /^[^	\t]/{
	collect = isdev = 0;
}
collect && $0 ~ /[^ \t]+/{
	if(isdev)
		obj["dev" $1 "'.$O'"]++;
	else
		obj[$1 "'.$O'"]++;
	for(i = 2; i <= NF; i++){
		if($i !~ "[+=-].*")
			obj[$i "'.$O'"]++;
	}
}
$0 ~ /^[^ \t]/{
	if($1 ~ "dev"){
		isdev = 1;
		collect = 1;
	}
	else if($1 ~ "misc" || $1 ~ "link" || $1 ~ "ip")
		collect = 1;
	next;
}

END{
	x = ""
	for(i in obj)
		x = x i "\n";
	if((objtype ~ "386" || objtype ~ "amd64") && obj["pci" "'.$O'"])
		x = x "bios32'.$O' \n";
	printf x;
}' $*