mkdevlist 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. $AWK '
  2. BEGIN{
  3. var["init"] = "INIT=";
  4. var["ip"] = "IP=";
  5. var["lib"] = "LIBS=";
  6. var["root"] = "ROOTFILES=";
  7. infernoroot = ENVIRON["ROOT"];
  8. }
  9. /^$/{ next;
  10. }
  11. /^#/{ next;
  12. }
  13. /^env/{
  14. inenv = 1;
  15. next;
  16. }
  17. inenv != 0 && /^[ ]/{
  18. sub("^[ ]*", "", $0)
  19. printf "%s\n", $0
  20. next
  21. }
  22. /^(code|dev|init|ip|lib|link|mod|misc|port|root)/{
  23. inenv = 0;
  24. type = $1;
  25. next;
  26. }
  27. /^[^ ]/ {
  28. inenv = 0;
  29. }
  30. type && /^[ ]/{
  31. if(type == "code")
  32. next;
  33. if(type == "root"){
  34. if (NF > 1)
  35. file = $2;
  36. else if ($1 == "/osinit.dis")
  37. next; # handled via explicit dependency
  38. else
  39. file = $1;
  40. if(rootfile[file] == 0){
  41. var[type] = var[type] " " infernoroot file;
  42. rootfile[file]++;
  43. }
  44. next;
  45. }
  46. if(type == "init" || type == "lib"){
  47. var[type] = var[type] " " $1;
  48. next;
  49. }
  50. file = $1 "'.$O'"
  51. if(type == "port")
  52. port[file]++;
  53. else if(type == "dev")
  54. obj["dev" file]++;
  55. else if(type != "mod")
  56. obj[file]++;
  57. for(i = 2; i <= NF; i++){
  58. if($i !~ "^[+=-].*")
  59. obj[$i "'.$O'"]++;
  60. }
  61. next;
  62. }
  63. END{
  64. x = ""
  65. for(i in obj)
  66. x = x " " i
  67. printf "DEVS=%s\n", x;
  68. x = ""
  69. for(i in port)
  70. x = x " " i
  71. printf "PORT=%s\n", x
  72. for(v in var)
  73. printf "%s\n", var[v]
  74. }' $*