about summary refs log tree commit diff
path: root/scripts/soversions.awk
blob: 6207088514a9878b5a3b6cd6b8ab035c89d0cec7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# awk script for shlib-versions.v.i -> soversions.i; see Makeconfig.

# Only lines matching `config' (set with -v) are relevant to us.
config !~ $1 { next }

# Obey the first matching DEFAULT line.
$2 == "DEFAULT" {
  if (!matched_default) {
    matched_default = 1;
    $1 = $2 = "";
    default_setname = $0;
  }
  next
}

# Collect all lib lines before emitting anything, so DEFAULT
# can be interspersed.
{
  lib = number = $2;
  sub(/=.*$/, "", lib);
  sub(/^.*=/, "", number);
  if (lib in numbers) next;
  numbers[lib] = number;
  if (NF > 2) {
    $1 = $2 = "";
    versions[lib] = $0
  }
}

END {
  for (lib in numbers) {
    set = (lib in versions) ? versions[lib] : default_setname;
    if (set)
      print lib, numbers[lib], set;
    else
      print lib, numbers[lib];
  }
}