code: purgatorio

ref: d4f4b292ca9c8665ef938036340ff32bf5128755
dir: /emu/port/mkdevlist/

View raw version
$AWK '
BEGIN{
		var["init"] = "INIT=";
		var["ip"] = "IP=";
		var["lib"] = "LIBS=";
		var["root"] = "ROOTFILES=";
		infernoroot = ENVIRON["ROOT"];
}
/^$/{		next;
}
/^#/{		next;
}
/^env/{
		inenv = 1;
		next;
}
inenv != 0 && /^[ 	]/{
		sub("^[ 	]*", "", $0)
		printf "%s\n", $0
		next
}

/^(code|dev|init|ip|lib|link|mod|misc|port|root)/{
		inenv = 0;
		type = $1;
		next;
}
/^[^ 	]/	{
		inenv = 0;
}
type && /^[ 	]/{
		if(type == "code")
			next;
		if(type == "root"){
			if (NF > 1)
				file = $2;
			else if ($1 == "/osinit.dis")
				next;	# handled via explicit dependency
			else
				file = $1;
			if(rootfile[file] == 0){
				var[type] = var[type] " " infernoroot file;
				rootfile[file]++;
			}
			next;
		}
		if(type == "init" || type == "lib"){
			var[type] = var[type] " " $1;
			next;
		}
		file = $1 "'.$O'"
		if(type == "port")
			port[file]++;
		else if(type == "dev")
			obj["dev" file]++;
		else if(type != "mod")
			obj[file]++;
		for(i = 2; i <= NF; i++){
			if($i !~ "^[+=-].*")
				obj[$i "'.$O'"]++;
		}
		next;
}
END{
		x = ""
		for(i in obj)
			x = x " " i
		printf "DEVS=%s\n", x;
		x = ""
		for(i in port)
			x = x " " i
		printf "PORT=%s\n", x
		for(v in var)
			printf "%s\n", var[v]
}' $*