Merge branch 'master' of ssh://sourceware.org/git/glibc
[glibc.git] / scripts / soversions.awk
blob55577ccc7e2b7bc3fd19f224432b661c6fcce810
1 # awk script for shlib-versions.v -> soversions.i; see Makeconfig.
3 BEGIN {
4 config = cpu "-" vendor "-" os;
5 configs[config] = "DEFAULT";
8 { thiscf = $1 }
10 $2 ~ /WORDSIZE[3264]/ {
11 if ((config ~ thiscf) && !othercf) {
12 othercf = $3;
13 sub(/@CPU@/, cpu, othercf);
14 sub(/@VENDOR@/, vendor, othercf);
15 sub(/@OS@/, os, othercf);
16 configs[othercf] = $2;
18 next;
21 $2 == "ABI" {
22 if ((config ~ thiscf) && !abiname) {
23 abiname = $3;
24 sub(/@CPU@/, cpu, abiname);
25 sub(/@VENDOR@/, vendor, abiname);
26 sub(/@OS@/, os, abiname);
28 next;
31 # Obey the first matching DEFAULT line.
32 $2 == "DEFAULT" {
33 $1 = $2 = "";
34 default_set[++ndefault_set] = thiscf "\n" $0;
35 next
38 # Collect all lib lines before emitting anything, so DEFAULT
39 # can be interspersed.
41 lib = number = $2;
42 sub(/=.*$/, "", lib);
43 sub(/^.*=/, "", number);
44 if ((thiscf FS lib) in numbers) next;
45 numbers[thiscf FS lib] = number;
46 order[thiscf FS lib] = ++order_n;
47 if (NF > 2) {
48 $1 = $2 = "";
49 versions[thiscf FS lib] = $0
53 END {
54 for (elt in numbers) {
55 split(elt, x);
56 cf = x[1];
57 lib = x[2];
58 for (c in configs)
59 if (c ~ cf) {
60 if (elt in versions)
61 set = versions[elt];
62 else {
63 set = (c == config) ? default_setname : "";
64 for (i = 1; i <= ndefault_set; ++i) {
65 split(default_set[i], x, "\n");
66 if (c ~ x[1]) {
67 set = x[2];
68 break;
72 line = set ? (lib FS numbers[elt] FS set) : (lib FS numbers[elt]);
73 if (!((c FS lib) in lineorder) || order[elt] < lineorder[c FS lib]) {
74 lineorder[c FS lib] = order[elt];
75 lines[c FS lib] = configs[c] FS line;
79 if (abiname) {
80 print "ABI", abiname
82 for (c in lines) {
83 print lines[c]