Fix ynl return value with LDBL_MIN.
[platform/upstream/glibc.git] / scripts / soversions.awk
1 # awk script for shlib-versions.v -> soversions.i; see Makeconfig.
2
3 BEGIN {
4   config = cpu "-" vendor "-" os;
5   configs[config] = "DEFAULT";
6 }
7
8 { thiscf = $1 }
9
10 $2 == "ABI" {
11   if ((config ~ thiscf) && !abiname) {
12     abiname = $3;
13     sub(/@CPU@/, cpu, abiname);
14     sub(/@VENDOR@/, vendor, abiname);
15     sub(/@OS@/, os, abiname);
16   }
17   next;
18 }
19
20 # Obey the first matching DEFAULT line.
21 $2 == "DEFAULT" {
22   $1 = $2 = "";
23   default_set[++ndefault_set] = thiscf "\n" $0;
24   next
25 }
26
27 # Collect all lib lines before emitting anything, so DEFAULT
28 # can be interspersed.
29 {
30   lib = number = $2;
31   sub(/=.*$/, "", lib);
32   sub(/^.*=/, "", number);
33   if ((thiscf FS lib) in numbers) next;
34   numbers[thiscf FS lib] = number;
35   order[thiscf FS lib] = ++order_n;
36   if (NF > 2) {
37     $1 = $2 = "";
38     versions[thiscf FS lib] = $0
39   }
40 }
41
42 END {
43   for (elt in numbers) {
44     split(elt, x);
45     cf = x[1];
46     lib = x[2];
47     for (c in configs)
48       if (c ~ cf) {
49         if (elt in versions)
50           set = versions[elt];
51         else {
52           set = (c == config) ? default_setname : "";
53           for (i = 1; i <= ndefault_set; ++i) {
54             split(default_set[i], x, "\n");
55             if (c ~ x[1]) {
56               set = x[2];
57               break;
58             }
59           }
60         }
61         line = set ? (lib FS numbers[elt] FS set) : (lib FS numbers[elt]);
62         if (!((c FS lib) in lineorder) || order[elt] < lineorder[c FS lib]) {
63           lineorder[c FS lib] = order[elt];
64           lines[c FS lib] = configs[c] FS line;
65         }
66       }
67   }
68   if (abiname) {
69     print "ABI", abiname
70   }
71   for (c in lines) {
72     print lines[c]
73   }
74 }