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