ref: dd16eef8365cb0b9e4805c23291aadcaa596dd87
dir: /os/port/mkdevlist/
$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); }' $*