Update.
[glibc.git] / versions.awk
blob57660d235a589da32d01b6c0fb49980efefa989f
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.
6 # Read definitions for the versions.
7 BEGIN {
8 nlibs=0;
9 while (getline < "Versions.def") {
10 if (/^[a-zA-Z_]+ {/) {
11 libs[$1] = 1;
12 curlib = $1;
13 while (getline < "Versions.def" && ! /^}/) {
14 if (NF > 1) {
15 versions[$1] = 1;
16 derived[curlib, $1] = (" " $2);
17 for (n = 3; n <= NF; ++n) {
18 derived[curlib, $1] = sprintf("%s, %s", derived[curlib, $1], $n);
20 } else {
21 versions[$1] = 1;
26 close("Versions.def");
28 tmpfile = (buildroot "/Versions.tmp");
29 sort = ("sort -n >" tmpfile);
32 # Remove comment lines.
33 /^ *#/ {
34 next;
37 # This matches the beginning of the version information for a new library.
38 /^[a-zA-Z_]+/ {
39 actlib = $1;
40 if (libs[$1] != 1) {
41 printf("no versions defined for %s\n", $1);
42 exit 1;
44 next;
47 # This matches the beginning of a new version for the current library.
48 /^ [A-Za-z_]/ {
49 actver = $1;
50 if (versions[$1] != 1) {
51 printf("version %s not defined\n", $1);
52 exit 1;
54 next;
57 # This matches lines with names to be added to the current version in the
58 # current library. This is the only place where we print something to
59 # the intermediate file.
60 /^ / {
61 printf("%s %s %s\n", actlib, actver, $0) | sort;
65 function closeversion(name) {
66 if (firstinfile) {
67 printf(" local:\n *;\n") > outfile;
68 firstinfile = 0;
70 printf("}%s;\n", derived[oldlib, name]) > outfile;
73 # Now print the accumulated information.
74 END {
75 close(sort);
76 oldlib="";
77 oldver="";
78 while(getline < tmpfile) {
79 if ($1 != oldlib) {
80 if (oldlib != "") {
81 closeversion(oldver);
82 oldver = "";
83 close(outfile);
85 oldlib = $1;
86 outfile = (buildroot oldlib ".map");
87 firstinfile = 1;
89 if ($2 != oldver) {
90 if (oldver != "") {
91 closeversion(oldver);
93 printf("%s {\n global:\n", $2) > outfile;
94 oldver = $2;
96 printf(" ") > outfile;
97 for (n = 3; n <= NF; ++n) {
98 printf(" %s", $n) > outfile;
100 printf("\n") > outfile;
102 closeversion(oldver);
103 close(outfile);
104 rm tmpfile;