Update.
[glibc.git] / scripts / versions.awk
blobd6571fd039514c95df1830d08aa19df90f712c7b
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 # 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-Z_]+ {/) {
16 libs[$1] = 1;
17 curlib = $1;
18 while (getline < defsfile && ! /^}/) {
19 versions[$1] = 1;
20 if (NF > 1) {
21 derived[curlib, $1] = " " $2;
22 for (n = 3; n <= NF; ++n) {
23 derived[curlib, $1] = derived[curlib, $1] ", " $n;
29 close(defsfile);
31 tmpfile = buildroot "Versions.tmp";
32 sort = "sort -n > " tmpfile;
35 # Remove comment lines.
36 /^ *#/ {
37 next;
40 # This matches the beginning of the version information for a new library.
41 /^[a-zA-Z_]+/ {
42 actlib = $1;
43 if (!libs[$1]) {
44 printf("no versions defined for %s\n", $1) > "/dev/stderr";
45 exit 1;
47 next;
50 # This matches the beginning of a new version for the current library.
51 /^ [A-Za-z_]/ {
52 actver = $1;
53 if (!versions[$1]) {
54 printf("version %s not defined\n", $1) > "/dev/stderr";
55 exit 1;
57 next;
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 /^ / {
64 printf("%s %s %s\n", actlib, actver, $0) | sort;
68 function closeversion(name) {
69 if (firstinfile) {
70 printf(" local:\n *;\n") > outfile;
71 firstinfile = 0;
73 printf("}%s;\n", derived[oldlib, name]) > outfile;
76 function close_and_move(name, real_name) {
77 close(name);
78 system(move_if_change " " name " " real_name " >&2");
81 # Now print the accumulated information.
82 END {
83 close(sort);
84 oldlib = "";
85 oldver = "";
86 printf("version-maps =");
87 while(getline < tmpfile) {
88 if ($1 != oldlib) {
89 if (oldlib != "") {
90 closeversion(oldver);
91 oldver = "";
92 close_and_move(outfile, real_outfile);
94 oldlib = $1;
95 real_outfile = buildroot oldlib ".map";
96 outfile = real_outfile "T";
97 firstinfile = 1;
98 printf(" %s.map", oldlib);
100 if ($2 != oldver) {
101 if (oldver != "") {
102 closeversion(oldver);
104 printf("%s {\n global:\n", $2) > outfile;
105 oldver = $2;
107 printf(" ") > outfile;
108 for (n = 3; n <= NF; ++n) {
109 printf(" %s", $n) > outfile;
111 printf("\n") > outfile;
113 printf("\n");
114 closeversion(oldver);
115 close_and_move(outfile, real_outfile);
116 system("rm -f " tmpfile);