]> git.ipfire.org Git - thirdparty/glibc.git/blame - scripts/versions.awk
* Versions.def (libdl, librt): Add GLIBC_2.3.4 version.
[thirdparty/glibc.git] / scripts / versions.awk
CommitLineData
d3564d01 1# Combine version map fragments into version scripts for our shared objects.
2fb9a65c 2# Copyright (C) 1998,99,2000,2002,2005 Free Software Foundation, Inc.
b0b67c47
UD
3# Written by Ulrich Drepper <drepper@cygnus.com>, 1998.
4
4bae5567
UD
5# This script expects the following variables to be defined:
6# defsfile name of Versions.def file
7# buildroot name of build directory with trailing slash
8# move_if_change move-if-change command
9
b0b67c47
UD
10# Read definitions for the versions.
11BEGIN {
2fb9a65c
RM
12 lossage = 0;
13
b0b67c47 14 nlibs=0;
8eaaffde 15 while (getline < defsfile) {
8d8c6efa 16 if (/^[a-zA-Z0-9_.]+ \{/) {
b0b67c47
UD
17 libs[$1] = 1;
18 curlib = $1;
8eaaffde 19 while (getline < defsfile && ! /^}/) {
2fb9a65c 20 if ($2 == "=") {
d3564d01 21 renamed[curlib "::" $1] = $3;
2fb9a65c 22 }
361742ed 23 else
2fb9a65c 24 versions[curlib "::" $1] = 1;
b0b67c47
UD
25 }
26 }
27 }
8eaaffde 28 close(defsfile);
b0b67c47 29
4bae5567 30 tmpfile = buildroot "Versions.tmp";
720efe00
RM
31 # Note this sorting presumes only single digits between dots for proper
32 # numeric ordering. sort -n doesn't do quite the right thing either,
33 # and in some non-GNU sort implementations does not sort at all.
34 sort = "sort > " tmpfile;
b0b67c47
UD
35}
36
37# Remove comment lines.
38/^ *#/ {
39 next;
40}
41
42# This matches the beginning of the version information for a new library.
8d8c6efa 43/^[a-zA-Z0-9_.]+/ {
b0b67c47 44 actlib = $1;
8eaaffde
UD
45 if (!libs[$1]) {
46 printf("no versions defined for %s\n", $1) > "/dev/stderr";
2fb9a65c 47 ++lossage;
b0b67c47
UD
48 }
49 next;
50}
51
52# This matches the beginning of a new version for the current library.
53/^ [A-Za-z_]/ {
d3564d01
RM
54 if (renamed[actlib "::" $1])
55 actver = renamed[actlib "::" $1];
2fb9a65c 56 else if (!versions[actlib "::" $1]) {
48a5e010 57 printf("version %s not defined for %s\n", $1, actlib) > "/dev/stderr";
2fb9a65c 58 ++lossage;
b0b67c47 59 }
361742ed
RM
60 else
61 actver = $1;
b0b67c47
UD
62 next;
63}
64
65# This matches lines with names to be added to the current version in the
66# current library. This is the only place where we print something to
67# the intermediate file.
68/^ / {
1e06620a
UD
69 sortver=actver
70 # Ensure GLIBC_ versions come always first
71 sub(/^GLIBC_/," GLIBC_",sortver)
72 printf("%s %s %s\n", actlib, sortver, $0) | sort;
b0b67c47
UD
73}
74
75
da6d7d38 76function closeversion(name, oldname) {
b0b67c47
UD
77 if (firstinfile) {
78 printf(" local:\n *;\n") > outfile;
79 firstinfile = 0;
80 }
48a5e010
RM
81 # This version inherits from the last one only if they
82 # have the same nonnumeric prefix, i.e. GLIBC_x.y and GLIBC_x.z
83 # or FOO_x and FOO_y but not GLIBC_x and FOO_y.
84 pfx = oldname;
85 sub(/[0-9.]+/,".+",pfx);
86 if (oldname == "" || name !~ pfx) print "};" > outfile;
87 else printf("} %s;\n", oldname) > outfile;
b0b67c47
UD
88}
89
4bae5567
UD
90function close_and_move(name, real_name) {
91 close(name);
92 system(move_if_change " " name " " real_name " >&2");
93}
94
b0b67c47
UD
95# Now print the accumulated information.
96END {
97 close(sort);
2fb9a65c
RM
98
99 if (lossage) {
100 system("rm -f " tmpfile);
101 exit 1;
102 }
103
4bae5567
UD
104 oldlib = "";
105 oldver = "";
106 printf("version-maps =");
48a5e010 107 while (getline < tmpfile) {
b0b67c47
UD
108 if ($1 != oldlib) {
109 if (oldlib != "") {
da6d7d38 110 closeversion(oldver, veryoldver);
b0b67c47 111 oldver = "";
4bae5567 112 close_and_move(outfile, real_outfile);
b0b67c47
UD
113 }
114 oldlib = $1;
4bae5567
UD
115 real_outfile = buildroot oldlib ".map";
116 outfile = real_outfile "T";
b0b67c47 117 firstinfile = 1;
da6d7d38 118 veryoldver = "";
4bae5567 119 printf(" %s.map", oldlib);
b0b67c47
UD
120 }
121 if ($2 != oldver) {
122 if (oldver != "") {
da6d7d38
UD
123 closeversion(oldver, veryoldver);
124 veryoldver = oldver;
b0b67c47
UD
125 }
126 printf("%s {\n global:\n", $2) > outfile;
127 oldver = $2;
128 }
129 printf(" ") > outfile;
130 for (n = 3; n <= NF; ++n) {
131 printf(" %s", $n) > outfile;
132 }
133 printf("\n") > outfile;
134 }
8eaaffde 135 printf("\n");
da6d7d38 136 closeversion(oldver, veryoldver);
4bae5567
UD
137 close_and_move(outfile, real_outfile);
138 system("rm -f " tmpfile);
b0b67c47 139}