lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | # 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 | |
| 25 | END { |
| 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 | } |