ref: efd1615c5741a6898853fefc24b1cbcb734e5477
dir: /emu/port/mkdevlist/
$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] }' $*