versionlist.awk 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Extract ordered list of version sets from Versions files.
  2. # Copyright (C) 2014-2019 Free Software Foundation, Inc.
  3. BEGIN { in_lib = ""; in_version = 0 }
  4. !in_lib && NF == 2 && $2 == "{" {
  5. in_lib = $1;
  6. all_libs[in_lib] = 1;
  7. next
  8. }
  9. !in_lib { next }
  10. NF == 2 && $2 == "{" {
  11. in_version = 1;
  12. lib_versions[in_lib, $1] = 1;
  13. # Partition the version sets into GLIBC_* and others.
  14. if ($1 ~ /GLIBC_/) {
  15. libs[in_lib] = libs[in_lib] " " $1 "\n";
  16. all_versions[$1] = 1;
  17. }
  18. else {
  19. others_libs[in_lib] = others_libs[in_lib] " " $1 "\n";
  20. others_all_versions[$1] = 1;
  21. }
  22. next
  23. }
  24. in_version && $1 == "}" { in_version = 0; next }
  25. in_version { next }
  26. $1 == "}" { in_lib = ""; next }
  27. END {
  28. nlibs = asorti(all_libs, libs_order);
  29. for (i = 1; i <= nlibs; ++i) {
  30. lib = libs_order[i];
  31. for (v in all_versions) {
  32. if (!((lib, v) in lib_versions)) {
  33. libs[lib] = libs[lib] " " v "\n";
  34. }
  35. }
  36. for (v in others_all_versions) {
  37. if (!((lib, v) in lib_versions)) {
  38. others_libs[lib] = others_libs[lib] " " v "\n";
  39. }
  40. }
  41. print lib, "{";
  42. # Sort and print all the GLIBC_* sets first, then all the others.
  43. # This is not really generically right, but it suffices
  44. # for the cases we have so far. e.g. GCC_3.0 is "later than"
  45. # all GLIBC_* sets that matter for purposes of Versions files.
  46. sort = "sort -u -t. -k 1,1 -k 2n,2n -k 3";
  47. printf "%s", libs[lib] | sort;
  48. close(sort);
  49. sort = "sort -u -t. -k 1,1 -k 2n,2n -k 3";
  50. printf "%s", others_libs[lib] | sort;
  51. close(sort);
  52. print "}";
  53. }
  54. }