blob: 247f061bc37b2a859aa0b2964baf0028c079730b [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# awk script for shlib-versions.v -> soversions.i; see Makeconfig.
2
3# Obey the first matching DEFAULT line.
4$1 == "DEFAULT" {
5 $1 = "";
6 default_set[++ndefault_set] = $0;
7 next
8}
9
10# Collect all lib lines before emitting anything, so DEFAULT
11# can be interspersed.
12{
13 lib = number = $1;
14 sub(/=.*$/, "", lib);
15 sub(/^.*=/, "", number);
16 if (lib in numbers) next;
17 numbers[lib] = number;
18 order[lib] = ++order_n;
19 if (NF > 1) {
20 $1 = "";
21 versions[lib] = $0
22 }
23}
24
25END {
26 for (lib in numbers) {
27 if (lib in versions)
28 set = versions[lib];
29 else {
30 set = "";
31 if (ndefault_set >= 1)
32 set = default_set[1];
33 }
34 line = set ? (lib FS numbers[lib] FS set) : (lib FS numbers[lib]);
35 if (!(lib in lineorder) || order[lib] < lineorder[lib]) {
36 lineorder[lib] = order[lib];
37 lines[lib] = "DEFAULT" FS line;
38 }
39 }
40 for (c in lines) {
41 print lines[c]
42 }
43}