about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/abi-versions.awk39
-rw-r--r--scripts/firstversions.awk27
-rw-r--r--scripts/versions.awk13
3 files changed, 76 insertions, 3 deletions
diff --git a/scripts/abi-versions.awk b/scripts/abi-versions.awk
new file mode 100644
index 0000000000..0cceaad66a
--- /dev/null
+++ b/scripts/abi-versions.awk
@@ -0,0 +1,39 @@
+# Script to generate <abi-versions.h> header file from Versions.all list.
+# See include/shlib-compat.h comments for explanation.
+
+BEGIN {
+  print "/* This file is automatically generated by abi-versions.awk.";
+  print "   It defines symbols used by shlib-compat.h, which see.  */";
+  print "\n#ifndef _ABI_VERSIONS_H\n#define _ABI_VERSIONS_H";
+}
+
+NF == 2 && $2 == "{" {
+  thislib = $1;
+  gsub(/[^A-Za-z0-9_ 	]/, "_"); libid = $1;
+  printf "\n/* start %s */\n", thislib;
+  next;
+}
+$1 == "}" {
+  printf "/* end %s */\n", thislib;
+  next;
+}
+
+$2 == "=" {
+  new = $3;
+  gsub(/[^A-Za-z0-9_ 	]/, "_"); id = $1;
+  printf "#define ABI_%s_%s\t0\t/* earliest supported %s */\n", libid, id, new;
+  printf "#define VERSION_%s_%s\t%s\n", libid, id, new;
+  next;
+}
+
+{
+  vers = $1;
+  gsub(/[^A-Za-z0-9_ 	]/, "_"); id = $1;
+  printf "#define ABI_%s_%s\t1\t/* support %s */\n", libid, id, vers;
+  printf "#define VERSION_%s_%s\t%s\n", libid, id, vers;
+  next;
+}
+
+END {
+  print "\n#endif /* abi-versions.h */";
+}
diff --git a/scripts/firstversions.awk b/scripts/firstversions.awk
new file mode 100644
index 0000000000..236d90ec97
--- /dev/null
+++ b/scripts/firstversions.awk
@@ -0,0 +1,27 @@
+# Script to preprocess Versions.all lists based on "earliest version"
+# specifications in the shlib-versions file.
+
+NF == 3 && $2 == ":" { firstversion[$1] = $3; next }
+
+NF == 2 && $2 == "{" { thislib = $1; print; next }
+
+$1 == "}" {
+  if (firstversion[thislib]) {
+    # We haven't seen the stated version, but have produced
+    # others pointing to it, so we synthesize it now.
+    printf "  %s\n", firstversion[thislib];
+  }
+  print;
+  next;
+}
+
+{
+  if (! firstversion[thislib])
+    print;
+  else if ($1 == firstversion[thislib]) {
+    print;
+    firstversion[thislib] = 0;
+  }
+  else
+    print $1, "=", firstversion[thislib];
+}
diff --git a/scripts/versions.awk b/scripts/versions.awk
index 78ed73914b..086a963b25 100644
--- a/scripts/versions.awk
+++ b/scripts/versions.awk
@@ -16,7 +16,10 @@ BEGIN {
       libs[$1] = 1;
       curlib = $1;
       while (getline < defsfile && ! /^}/) {
-	versions[$1] = 1;
+        if ($2 == "=")
+	  renamed[$1] = $3;
+	else
+	  versions[$1] = 1;
       }
     }
   }
@@ -33,6 +36,7 @@ BEGIN {
 
 # This matches the beginning of the version information for a new library.
 /^[a-zA-Z0-9_.]+/ {
+  delete renamed;
   actlib = $1;
   if (!libs[$1]) {
     printf("no versions defined for %s\n", $1) > "/dev/stderr";
@@ -43,11 +47,14 @@ BEGIN {
 
 # This matches the beginning of a new version for the current library.
 /^  [A-Za-z_]/ {
-  actver = $1;
-  if (!versions[$1]) {
+  if (renamed[$1])
+    actver = renamed[$1];
+  else if (!versions[$1]) {
     printf("version %s not defined\n", $1) > "/dev/stderr";
     exit 1;
   }
+  else
+    actver = $1;
   next;
 }