Blame scripts/soversions.awk

Packit 6c4009
# awk script for shlib-versions.v -> soversions.i; see Makeconfig.
Packit 6c4009
Packit 6c4009
# Obey the first matching DEFAULT line.
Packit 6c4009
$1 == "DEFAULT" {
Packit 6c4009
  $1 = "";
Packit 6c4009
  default_set[++ndefault_set] = $0;
Packit 6c4009
  next
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
# Collect all lib lines before emitting anything, so DEFAULT
Packit 6c4009
# can be interspersed.
Packit 6c4009
{
Packit 6c4009
  lib = number = $1;
Packit 6c4009
  sub(/=.*$/, "", lib);
Packit 6c4009
  sub(/^.*=/, "", number);
Packit 6c4009
  if (lib in numbers) next;
Packit 6c4009
  numbers[lib] = number;
Packit 6c4009
  order[lib] = ++order_n;
Packit 6c4009
  if (NF > 1) {
Packit 6c4009
    $1 = "";
Packit 6c4009
    versions[lib] = $0
Packit 6c4009
  }
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
END {
Packit 6c4009
  for (lib in numbers) {
Packit 6c4009
    if (lib in versions)
Packit 6c4009
      set = versions[lib];
Packit 6c4009
    else {
Packit 6c4009
      set = "";
Packit 6c4009
      if (ndefault_set >= 1)
Packit 6c4009
	set = default_set[1];
Packit 6c4009
    }
Packit 6c4009
    line = set ? (lib FS numbers[lib] FS set) : (lib FS numbers[lib]);
Packit 6c4009
    if (!(lib in lineorder) || order[lib] < lineorder[lib]) {
Packit 6c4009
      lineorder[lib] = order[lib];
Packit 6c4009
      lines[lib] = "DEFAULT" FS line;
Packit 6c4009
    }
Packit 6c4009
  }
Packit 6c4009
  for (c in lines) {
Packit 6c4009
    print lines[c]
Packit 6c4009
  }
Packit 6c4009
}