Update.
[glibc.git] / scripts / versions.awk
blob78ed73914b7c153d231cfeff2f6f3d08e129d6b1
1 # Combine version map fragments into version files for the generated
2 # shared object.
3 # (C) Copyright 1998, 1999 Free Software Foundation, Inc.
4 # Written by Ulrich Drepper <drepper@cygnus.com>, 1998.
6 # This script expects the following variables to be defined:
7 # defsfile name of Versions.def file
8 # buildroot name of build directory with trailing slash
9 # move_if_change move-if-change command
11 # Read definitions for the versions.
12 BEGIN {
13 nlibs=0;
14 while (getline < defsfile) {
15 if (/^[a-zA-Z0-9_.]+ \{/) {
16 libs[$1] = 1;
17 curlib = $1;
18 while (getline < defsfile && ! /^}/) {
19 versions[$1] = 1;
23 close(defsfile);
25 tmpfile = buildroot "Versions.tmp";
26 sort = "sort -n > " tmpfile;
29 # Remove comment lines.
30 /^ *#/ {
31 next;
34 # This matches the beginning of the version information for a new library.
35 /^[a-zA-Z0-9_.]+/ {
36 actlib = $1;
37 if (!libs[$1]) {
38 printf("no versions defined for %s\n", $1) > "/dev/stderr";
39 exit 1;
41 next;
44 # This matches the beginning of a new version for the current library.
45 /^ [A-Za-z_]/ {
46 actver = $1;
47 if (!versions[$1]) {
48 printf("version %s not defined\n", $1) > "/dev/stderr";
49 exit 1;
51 next;
54 # This matches lines with names to be added to the current version in the
55 # current library. This is the only place where we print something to
56 # the intermediate file.
57 /^ / {
58 printf("%s %s %s\n", actlib, actver, $0) | sort;
62 function closeversion(name, oldname) {
63 if (firstinfile) {
64 printf(" local:\n *;\n") > outfile;
65 firstinfile = 0;
67 printf("}%s;\n", oldname) > outfile;
70 function close_and_move(name, real_name) {
71 close(name);
72 system(move_if_change " " name " " real_name " >&2");
75 # Now print the accumulated information.
76 END {
77 close(sort);
78 oldlib = "";
79 oldver = "";
80 printf("version-maps =");
81 while(getline < tmpfile) {
82 if ($1 != oldlib) {
83 if (oldlib != "") {
84 closeversion(oldver, veryoldver);
85 oldver = "";
86 close_and_move(outfile, real_outfile);
88 oldlib = $1;
89 real_outfile = buildroot oldlib ".map";
90 outfile = real_outfile "T";
91 firstinfile = 1;
92 veryoldver = "";
93 printf(" %s.map", oldlib);
95 if ($2 != oldver) {
96 if (oldver != "") {
97 closeversion(oldver, veryoldver);
98 veryoldver = oldver;
100 printf("%s {\n global:\n", $2) > outfile;
101 oldver = $2;
103 printf(" ") > outfile;
104 for (n = 3; n <= NF; ++n) {
105 printf(" %s", $n) > outfile;
107 printf("\n") > outfile;
109 printf("\n");
110 closeversion(oldver, veryoldver);
111 close_and_move(outfile, real_outfile);
112 system("rm -f " tmpfile);