* libio/bits/stdio.h (fgetc_unlocked): Add extern inline optimized
[glibc/pb-stable.git] / scripts / versions.awk
blobe642b3d16ecc8500283ad8b42e956df560f6ae23
1 # Combine version map fragments into version scripts for our shared objects.
2 # Copyright (C) 1998,99,2000,2002,2005 Free Software Foundation, Inc.
3 # Written by Ulrich Drepper <drepper@cygnus.com>, 1998.
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
10 # Read definitions for the versions.
11 BEGIN {
12 lossage = 0;
14 nlibs=0;
15 while (getline < defsfile) {
16 if (/^[a-zA-Z0-9_.]+ \{/) {
17 libs[$1] = 1;
18 curlib = $1;
19 while (getline < defsfile && ! /^}/) {
20 if ($2 == "=") {
21 renamed[curlib "::" $1] = $3;
23 else
24 versions[curlib "::" $1] = 1;
28 close(defsfile);
30 tmpfile = buildroot "Versions.tmp";
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;
37 # Remove comment lines.
38 /^ *#/ {
39 next;
42 # This matches the beginning of the version information for a new library.
43 /^[a-zA-Z0-9_.]+/ {
44 actlib = $1;
45 if (!libs[$1]) {
46 printf("no versions defined for %s\n", $1) > "/dev/stderr";
47 ++lossage;
49 next;
52 # This matches the beginning of a new version for the current library.
53 /^ [A-Za-z_]/ {
54 if (renamed[actlib "::" $1])
55 actver = renamed[actlib "::" $1];
56 else if (!versions[actlib "::" $1] && $1 != "GLIBC_PRIVATE") {
57 printf("version %s not defined for %s\n", $1, actlib) > "/dev/stderr";
58 ++lossage;
60 else
61 actver = $1;
62 next;
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 /^ / {
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;
76 function closeversion(name, oldname) {
77 if (firstinfile) {
78 printf(" local:\n *;\n") > outfile;
79 firstinfile = 0;
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;
90 function close_and_move(name, real_name) {
91 close(name);
92 system(move_if_change " " name " " real_name " >&2");
95 # Now print the accumulated information.
96 END {
97 close(sort);
99 if (lossage) {
100 system("rm -f " tmpfile);
101 exit 1;
104 oldlib = "";
105 oldver = "";
106 printf("version-maps =");
107 while (getline < tmpfile) {
108 if ($1 != oldlib) {
109 if (oldlib != "") {
110 closeversion(oldver, veryoldver);
111 oldver = "";
112 close_and_move(outfile, real_outfile);
114 oldlib = $1;
115 real_outfile = buildroot oldlib ".map";
116 outfile = real_outfile "T";
117 firstinfile = 1;
118 veryoldver = "";
119 printf(" %s.map", oldlib);
121 if ($2 != oldver) {
122 if (oldver != "") {
123 closeversion(oldver, veryoldver);
124 veryoldver = oldver;
126 printf("%s {\n global:\n", $2) > outfile;
127 oldver = $2;
129 printf(" ") > outfile;
130 for (n = 3; n <= NF; ++n) {
131 printf(" %s", $n) > outfile;
133 printf("\n") > outfile;
135 printf("\n");
136 closeversion(oldver, veryoldver);
137 close_and_move(outfile, real_outfile);
138 system("rm -f " tmpfile);