NPTL is no longer an add-on!
[platform/upstream/glibc.git] / scripts / versionlist.awk
1 # Extract ordered list of version sets from Versions files.
2 # Copyright (C) 2014 Free Software Foundation, Inc.
3
4 BEGIN { in_lib = ""; in_version = 0 }
5
6 !in_lib && NF == 2 && $2 == "{" {
7   in_lib = $1;
8   all_libs[in_lib] = 1;
9   next
10 }
11 !in_lib { next }
12
13 NF == 2 && $2 == "{" {
14   in_version = 1;
15   lib_versions[in_lib, $1] = 1;
16   # Partition the version sets into GLIBC_* and others.
17   if ($1 ~ /GLIBC_/) {
18     libs[in_lib] = libs[in_lib] "  " $1 "\n";
19     all_versions[$1] = 1;
20   }
21   else {
22     others_libs[in_lib] = others_libs[in_lib] "  " $1 "\n";
23     others_all_versions[$1] = 1;
24   }
25   next
26 }
27
28 in_version && $1 == "}" { in_version = 0; next }
29 in_version { next }
30
31 $1 == "}" { in_lib = ""; next }
32
33 END {
34   nlibs = asorti(all_libs, libs_order);
35   for (i = 1; i <= nlibs; ++i) {
36     lib = libs_order[i];
37
38     for (v in all_versions) {
39       if (!((lib, v) in lib_versions)) {
40         libs[lib] = libs[lib] "  " v "\n";
41       }
42     }
43
44     for (v in others_all_versions) {
45       if (!((lib, v) in lib_versions)) {
46         others_libs[lib] = others_libs[lib] "  " v "\n";
47       }
48     }
49
50     print lib, "{";
51
52     # Sort and print all the GLIBC_* sets first, then all the others.
53     # This is not really generically right, but it suffices
54     # for the cases we have so far.  e.g. GCC_3.0 is "later than"
55     # all GLIBC_* sets that matter for purposes of Versions files.
56
57     sort = "sort -u -t. -k 1,1 -k 2n,2n -k 3";
58     printf "%s", libs[lib] | sort;
59     close(sort);
60
61     sort = "sort -u -t. -k 1,1 -k 2n,2n -k 3";
62     printf "%s", others_libs[lib] | sort;
63     close(sort);
64
65     print "}";
66   }
67 }