2010-05-18 Justus Winter <4winter@informatik.uni-hamburg.de>
[grub.git] / genmoddep.awk
blob48419a091eeec504bc2a055462552cdeafb628a0
1 #! /usr/bin/awk -f
3 # Copyright (C) 2006 Free Software Foundation, Inc.
5 # This genmoddep.awk is free software; the author
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
14 # Read defined symbols from stdin.
15 BEGIN {
16 while (getline <"/dev/stdin") {
17 symtab[$1] = $2
21 # The first line contains a module name.
22 FNR == 1 {
23 module = $1
24 next
27 # The rest is undefined symbols.
29 if ($1 in symtab) {
30 modtab[module] = modtab[module] " " symtab[$1];
32 else if ($1 != "__gnu_local_gp") {
33 printf "%s in %s is not defined\n", $1, module >"/dev/stderr";
34 error++;
38 # Output the result.
39 END {
40 if (error >= 1)
41 exit 1;
43 for (mod in modtab) {
44 # Remove duplications.
45 split(modtab[mod], depmods, " ");
46 for (depmod in uniqmods) {
47 delete uniqmods[depmod];
49 for (i in depmods) {
50 depmod = depmods[i];
51 # Ignore kernel, as always loaded.
52 if (depmod != "kernel" && depmod != mod)
53 uniqmods[depmod] = 1;
55 modlist = ""
56 for (depmod in uniqmods) {
57 modlist = modlist " " depmod;
59 printf "%s:%s\n", mod, modlist;