]> git.ipfire.org Git - thirdparty/glibc.git/blame - scripts/versions.awk
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / scripts / versions.awk
CommitLineData
d3564d01 1# Combine version map fragments into version scripts for our shared objects.
d4697bc9 2# Copyright (C) 1998-2014 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";
8680179f
UD
31 # POSIX sort needed.
32 sort = "sort -t. -k 1,1 -k 2n,2n -k 3 > " tmpfile;
b0b67c47
UD
33}
34
35# Remove comment lines.
36/^ *#/ {
37 next;
38}
39
40# This matches the beginning of the version information for a new library.
8d8c6efa 41/^[a-zA-Z0-9_.]+/ {
b0b67c47 42 actlib = $1;
8eaaffde
UD
43 if (!libs[$1]) {
44 printf("no versions defined for %s\n", $1) > "/dev/stderr";
2fb9a65c 45 ++lossage;
b0b67c47
UD
46 }
47 next;
48}
49
50# This matches the beginning of a new version for the current library.
51/^ [A-Za-z_]/ {
d3564d01
RM
52 if (renamed[actlib "::" $1])
53 actver = renamed[actlib "::" $1];
8ac78e60 54 else if (!versions[actlib "::" $1] && $1 != "GLIBC_PRIVATE") {
48a5e010 55 printf("version %s not defined for %s\n", $1, actlib) > "/dev/stderr";
2fb9a65c 56 ++lossage;
b0b67c47 57 }
361742ed
RM
58 else
59 actver = $1;
b0b67c47
UD
60 next;
61}
62
63# This matches lines with names to be added to the current version in the
64# current library. This is the only place where we print something to
65# the intermediate file.
66/^ / {
1e06620a
UD
67 sortver=actver
68 # Ensure GLIBC_ versions come always first
69 sub(/^GLIBC_/," GLIBC_",sortver)
70 printf("%s %s %s\n", actlib, sortver, $0) | sort;
b0b67c47
UD
71}
72
73
da6d7d38 74function closeversion(name, oldname) {
b0b67c47
UD
75 if (firstinfile) {
76 printf(" local:\n *;\n") > outfile;
77 firstinfile = 0;
78 }
48a5e010
RM
79 # This version inherits from the last one only if they
80 # have the same nonnumeric prefix, i.e. GLIBC_x.y and GLIBC_x.z
81 # or FOO_x and FOO_y but not GLIBC_x and FOO_y.
82 pfx = oldname;
83 sub(/[0-9.]+/,".+",pfx);
84 if (oldname == "" || name !~ pfx) print "};" > outfile;
85 else printf("} %s;\n", oldname) > outfile;
b0b67c47
UD
86}
87
4bae5567
UD
88function close_and_move(name, real_name) {
89 close(name);
90 system(move_if_change " " name " " real_name " >&2");
91}
92
b0b67c47
UD
93# Now print the accumulated information.
94END {
95 close(sort);
2fb9a65c
RM
96
97 if (lossage) {
98 system("rm -f " tmpfile);
99 exit 1;
100 }
101
4bae5567
UD
102 oldlib = "";
103 oldver = "";
104 printf("version-maps =");
48a5e010 105 while (getline < tmpfile) {
b0b67c47
UD
106 if ($1 != oldlib) {
107 if (oldlib != "") {
da6d7d38 108 closeversion(oldver, veryoldver);
b0b67c47 109 oldver = "";
4bae5567 110 close_and_move(outfile, real_outfile);
b0b67c47
UD
111 }
112 oldlib = $1;
4bae5567
UD
113 real_outfile = buildroot oldlib ".map";
114 outfile = real_outfile "T";
b0b67c47 115 firstinfile = 1;
da6d7d38 116 veryoldver = "";
4bae5567 117 printf(" %s.map", oldlib);
b0b67c47
UD
118 }
119 if ($2 != oldver) {
120 if (oldver != "") {
da6d7d38
UD
121 closeversion(oldver, veryoldver);
122 veryoldver = oldver;
b0b67c47
UD
123 }
124 printf("%s {\n global:\n", $2) > outfile;
125 oldver = $2;
126 }
127 printf(" ") > outfile;
128 for (n = 3; n <= NF; ++n) {
129 printf(" %s", $n) > outfile;
130 }
131 printf("\n") > outfile;
132 }
8eaaffde 133 printf("\n");
da6d7d38 134 closeversion(oldver, veryoldver);
4bae5567 135 close_and_move(outfile, real_outfile);
8680179f 136 #system("rm -f " tmpfile);
b0b67c47 137}