summaryrefslogtreecommitdiff
path: root/os/port/mkdevlist
blob: 6fdc68669a67f07883537a9bfee20ad0637be1ae (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
$AWK '
BEGIN{
		var["dev"] = "DEVS=";
		var["vga"] = "VGAS=";
		var["ether"] = "ETHERS=";
		var["init"] = "INIT=";
		var["ip"] = "IP=";
		var["port"] = "PORT=";
		var["misc"] = "MISC=";
		var["lib"] = "LIBS=";
		var["link"] = "LINKS=";
		var["root"] = "ROOTFILES=";
		infernoroot = ENVIRON["ROOT"];
}
/^$/{		next;
}
/^#/{		next;
}
/^env/{
		inenv = 1;
		next;
}
inenv != 0 && /^[ 	]/{
		sub("^[ 	]*", "", $0)
		printf "%s\n", $0
		next
}
/^(code|dev|ether|init|ip|lib|link|mod|misc|port|root|vga)/{
		inenv = 0;
		if(current != "")
			print current;
		current = var[$1];
		type = $1;
		next;
}
/^[^ 	]/	{
		inenv = 0;
		if(current != "")
			print current;
		current = "";
}
current && /^[ 	]/{
		if(type == "dev")
			file = "dev" $1;
		else if(type == "root"){
			if (NF > 1)
				file = $2;
			else if ($1 == "/osinit.dis")
				next;	# handled via explicit dependency
			else
				file = $1;
			if(have[file] == 0){
				current = current " " infernoroot file;
				have[file]++;
			}
			next;
		}
		else
			file = $1;
		if(type == "init" || type == "lib")
			current = current " " file;
		else if(have[file] == 0){
			if(type == "lib")
				current = current " " file;
			else
				current = current " " file "'.$O'";
			have[file]++;
		}
		for(i = 2; i <= NF; i++){
			if($i !~ "^[+=-].*"){
				if(have[$i] == 0){
					others[++nothers] = $i;
					have[$i]++;
				}
			}
		}
		next;
}
END{
		if(current != "")
			print current;
		for(i = 1; i <= nothers; i++)
			x = x " " others[i] "'.$O' ";
		if(x)
			printf("OTHERS=%s\n", x);
}' $*