genmoddep.awk 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /usr/bin/awk -f
  2. #
  3. # Copyright (C) 2006 Free Software Foundation, Inc.
  4. #
  5. # This genmoddep.awk is free software; the author
  6. # gives unlimited permission to copy and/or distribute it,
  7. # with or without modifications, as long as this notice is preserved.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  11. # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  12. # PARTICULAR PURPOSE.
  13. # Read defined symbols from stdin.
  14. BEGIN {
  15. while (getline <"/dev/stdin") {
  16. symtab[$1] = $2
  17. }
  18. }
  19. # The first line contains a module name.
  20. FNR == 1 {
  21. module = $1
  22. next
  23. };
  24. # The rest is undefined symbols.
  25. {
  26. if ($1 in symtab) {
  27. modtab[module] = modtab[module] " " symtab[$1];
  28. }
  29. else if ($1 != "__gnu_local_gp") {
  30. printf "%s in %s is not defined\n", $1, module >"/dev/stderr";
  31. error++;
  32. }
  33. }
  34. # Output the result.
  35. END {
  36. if (error >= 1)
  37. exit 1;
  38. for (mod in modtab) {
  39. # Remove duplications.
  40. split(modtab[mod], depmods, " ");
  41. for (depmod in uniqmods) {
  42. delete uniqmods[depmod];
  43. }
  44. for (i in depmods) {
  45. depmod = depmods[i];
  46. # Ignore kernel, as always loaded.
  47. if (depmod != "kernel" && depmod != mod)
  48. uniqmods[depmod] = 1;
  49. }
  50. modlist = ""
  51. for (depmod in uniqmods) {
  52. modlist = modlist " " depmod;
  53. }
  54. printf "%s:%s\n", mod, modlist;
  55. }
  56. }