/scripts/lib-names.awk

https://github.com/nitinkamble/glibc · AWK · 66 lines · 56 code · 6 blank · 4 comment · 10 complexity · 9c79dbe5688d15aa8ab56a67263508dc MD5 · raw file

  1. # awk script for soversions.i -> gnu/lib-names.h; see Makeconfig.
  2. $1 != "DEFAULT" { multi = 1 }
  3. #
  4. {
  5. lib = $2;
  6. version = $3;
  7. if ($3 !~ /^[0-9]/) {
  8. soname = $3;
  9. extra = $3;
  10. sub(/\.so.*$/, "", extra);
  11. }
  12. else {
  13. soname = lib ".so." $3;
  14. extra = "";
  15. }
  16. soname = "\"" soname "\"";
  17. lib = toupper(lib);
  18. extra = toupper(extra);
  19. gsub(/-/, "_", lib);
  20. gsub(/-/, "_", extra);
  21. macros[$1 FS lib "_SO"] = soname;
  22. if (extra)
  23. macros[$1 FS extra "_SO"] = soname;
  24. }
  25. END {
  26. print "/* This file is automatically generated.";
  27. print " It defines macros to allow user program to find the shared";
  28. print " library files which come as part of GNU libc. */";
  29. print "#ifndef __GNU_LIB_NAMES_H";
  30. print "#define __GNU_LIB_NAMES_H 1";
  31. print "";
  32. pfx = multi ? "# define " : "#define ";
  33. for (elt in macros) {
  34. split(elt, x);
  35. line = sprintf("%-40s%s", pfx x[2], macros[elt]);
  36. if (x[1] in lines)
  37. lines[x[1]] = lines[x[1]] "\n" line;
  38. else
  39. lines[x[1]] = line;
  40. }
  41. if (multi) {
  42. # Print these in a fixed order so the result is identical
  43. # on both sides of the coin.
  44. if (!("WORDSIZE32" in lines))
  45. lines["WORDSIZE32"] = lines["DEFAULT"];
  46. if (!("WORDSIZE64" in lines))
  47. lines["WORDSIZE64"] = lines["DEFAULT"];
  48. print "#include <bits/wordsize.h>\n";
  49. print "#if __WORDSIZE == 32";
  50. cmd = "LC_ALL=C sort"; print lines["WORDSIZE32"] | cmd; close(cmd);
  51. print "#else"
  52. cmd = "LC_ALL=C sort"; print lines["WORDSIZE64"] | cmd; close(cmd);
  53. print "#endif";
  54. }
  55. else {
  56. cmd = "LC_ALL=C sort"; print lines["DEFAULT"] | cmd; close(cmd);
  57. }
  58. print "";
  59. print "#endif /* gnu/lib-names.h */"
  60. }