]> git.ipfire.org Git - thirdparty/glibc.git/blame - scripts/versions.awk
* scripts/firstversions.awk: Don't mess with GLIBC_PRIVATE.
[thirdparty/glibc.git] / scripts / versions.awk
CommitLineData
d3564d01
RM
1# Combine version map fragments into version scripts for our shared objects.
2# Copyright (C) 1998,99,2000 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 {
12 nlibs=0;
8eaaffde 13 while (getline < defsfile) {
8d8c6efa 14 if (/^[a-zA-Z0-9_.]+ \{/) {
b0b67c47
UD
15 libs[$1] = 1;
16 curlib = $1;
8eaaffde 17 while (getline < defsfile && ! /^}/) {
d3564d01
RM
18 if ($2 == "=") {
19 renamed[curlib "::" $1] = $3;
20 }
361742ed
RM
21 else
22 versions[$1] = 1;
b0b67c47
UD
23 }
24 }
25 }
8eaaffde 26 close(defsfile);
b0b67c47 27
4bae5567
UD
28 tmpfile = buildroot "Versions.tmp";
29 sort = "sort -n > " tmpfile;
b0b67c47
UD
30}
31
32# Remove comment lines.
33/^ *#/ {
34 next;
35}
36
37# This matches the beginning of the version information for a new library.
8d8c6efa 38/^[a-zA-Z0-9_.]+/ {
b0b67c47 39 actlib = $1;
8eaaffde
UD
40 if (!libs[$1]) {
41 printf("no versions defined for %s\n", $1) > "/dev/stderr";
b0b67c47
UD
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_]/ {
d3564d01
RM
49 if (renamed[actlib "::" $1])
50 actver = renamed[actlib "::" $1];
361742ed 51 else if (!versions[$1]) {
8eaaffde 52 printf("version %s not defined\n", $1) > "/dev/stderr";
b0b67c47
UD
53 exit 1;
54 }
361742ed
RM
55 else
56 actver = $1;
b0b67c47
UD
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/^ / {
1e06620a
UD
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;
b0b67c47
UD
68}
69
70
da6d7d38 71function closeversion(name, oldname) {
b0b67c47
UD
72 if (firstinfile) {
73 printf(" local:\n *;\n") > outfile;
74 firstinfile = 0;
75 }
da6d7d38 76 printf("}%s;\n", oldname) > outfile;
b0b67c47
UD
77}
78
4bae5567
UD
79function close_and_move(name, real_name) {
80 close(name);
81 system(move_if_change " " name " " real_name " >&2");
82}
83
b0b67c47
UD
84# Now print the accumulated information.
85END {
86 close(sort);
4bae5567
UD
87 oldlib = "";
88 oldver = "";
89 printf("version-maps =");
b0b67c47
UD
90 while(getline < tmpfile) {
91 if ($1 != oldlib) {
92 if (oldlib != "") {
da6d7d38 93 closeversion(oldver, veryoldver);
b0b67c47 94 oldver = "";
4bae5567 95 close_and_move(outfile, real_outfile);
b0b67c47
UD
96 }
97 oldlib = $1;
4bae5567
UD
98 real_outfile = buildroot oldlib ".map";
99 outfile = real_outfile "T";
b0b67c47 100 firstinfile = 1;
da6d7d38 101 veryoldver = "";
4bae5567 102 printf(" %s.map", oldlib);
b0b67c47
UD
103 }
104 if ($2 != oldver) {
105 if (oldver != "") {
da6d7d38
UD
106 closeversion(oldver, veryoldver);
107 veryoldver = oldver;
b0b67c47
UD
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 }
8eaaffde 118 printf("\n");
da6d7d38 119 closeversion(oldver, veryoldver);
4bae5567
UD
120 close_and_move(outfile, real_outfile);
121 system("rm -f " tmpfile);
b0b67c47 122}