]> git.ipfire.org Git - thirdparty/glibc.git/blob - scripts/versions.awk
Update.
[thirdparty/glibc.git] / scripts / versions.awk
1 # Combine version map fragments into version scripts for our shared objects.
2 # Copyright (C) 1998,99,2000 Free Software Foundation, Inc.
3 # Written by Ulrich Drepper <drepper@cygnus.com>, 1998.
4
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
10 # Read definitions for the versions.
11 BEGIN {
12 nlibs=0;
13 while (getline < defsfile) {
14 if (/^[a-zA-Z0-9_.]+ \{/) {
15 libs[$1] = 1;
16 curlib = $1;
17 while (getline < defsfile && ! /^}/) {
18 if ($2 == "=") {
19 renamed[curlib "::" $1] = $3;
20 }
21 else
22 versions[$1] = 1;
23 }
24 }
25 }
26 close(defsfile);
27
28 tmpfile = buildroot "Versions.tmp";
29 sort = "sort -n > " tmpfile;
30 }
31
32 # Remove comment lines.
33 /^ *#/ {
34 next;
35 }
36
37 # This matches the beginning of the version information for a new library.
38 /^[a-zA-Z0-9_.]+/ {
39 actlib = $1;
40 if (!libs[$1]) {
41 printf("no versions defined for %s\n", $1) > "/dev/stderr";
42 exit 1;
43 }
44 next;
45 }
46
47 # This matches the beginning of a new version for the current library.
48 /^ [A-Za-z_]/ {
49 if (renamed[actlib "::" $1])
50 actver = renamed[actlib "::" $1];
51 else if (!versions[$1]) {
52 printf("version %s not defined\n", $1) > "/dev/stderr";
53 exit 1;
54 }
55 else
56 actver = $1;
57 next;
58 }
59
60 # This matches lines with names to be added to the current version in the
61 # current library. This is the only place where we print something to
62 # the intermediate file.
63 /^ / {
64 sortver=actver
65 # Ensure GLIBC_ versions come always first
66 sub(/^GLIBC_/," GLIBC_",sortver)
67 printf("%s %s %s\n", actlib, sortver, $0) | sort;
68 }
69
70
71 function closeversion(name, oldname) {
72 if (firstinfile) {
73 printf(" local:\n *;\n") > outfile;
74 firstinfile = 0;
75 }
76 printf("}%s;\n", oldname) > outfile;
77 }
78
79 function close_and_move(name, real_name) {
80 close(name);
81 system(move_if_change " " name " " real_name " >&2");
82 }
83
84 # Now print the accumulated information.
85 END {
86 close(sort);
87 oldlib = "";
88 oldver = "";
89 printf("version-maps =");
90 while(getline < tmpfile) {
91 if ($1 != oldlib) {
92 if (oldlib != "") {
93 closeversion(oldver, veryoldver);
94 oldver = "";
95 close_and_move(outfile, real_outfile);
96 }
97 oldlib = $1;
98 real_outfile = buildroot oldlib ".map";
99 outfile = real_outfile "T";
100 firstinfile = 1;
101 veryoldver = "";
102 printf(" %s.map", oldlib);
103 }
104 if ($2 != oldver) {
105 if (oldver != "") {
106 closeversion(oldver, veryoldver);
107 veryoldver = oldver;
108 }
109 printf("%s {\n global:\n", $2) > outfile;
110 oldver = $2;
111 }
112 printf(" ") > outfile;
113 for (n = 3; n <= NF; ++n) {
114 printf(" %s", $n) > outfile;
115 }
116 printf("\n") > outfile;
117 }
118 printf("\n");
119 closeversion(oldver, veryoldver);
120 close_and_move(outfile, real_outfile);
121 system("rm -f " tmpfile);
122 }