3 # lines in input look like ARCH TYPE path/to/TYPE/ARCH/modules/foo.ver
13 # read files that look like pairs of repeating
14 # #define __ver_foo hexstring
15 # #define foo _set_ver(foo)
16 while ((getline < FILE) > 0) {
19 if ($1 != "#define" || $2 !~ /^__ver_/)
22 # this is a "#define __ver_foo somehex" line
23 SYMBOL=gensub(/^__ver_/,"","",$2)
24 VALUE=gensub(/^(smp_|2gig_|smp2gig_)/,"","",$3)
25 VALUE=gensub(/^(smp|2gig|smp2gig)/,"","",VALUE)
26 values[SYMBOL,ARCH,TYPE]=VALUE
28 # skip the "#define foo _set_ver(foo)" line
29 if ((getline < FILE) <= 0)
31 if ($1 != "#define" || $2 != SYMBOL || $3 != "_set_ver(" SYMBOL ")")
46 # (re)initialize a few arrays to have no elements
54 if (values[SYMBOL,arch,type]) {
55 VALUE = values[SYMBOL,arch,type]
56 values[SYMBOL,arch,type] = ""
57 ntype[VALUE,type] += 1
60 x[VALUE] = x[VALUE] " "
61 x[VALUE] = x[VALUE] arch ":" type
65 if (total[VALUE] == NTOTAL) {
66 # there is only one checksum for this symbol
67 printf "#define __ver_%s\t_ver_str(%s)\n", SYMBOL, VALUE
68 printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL
72 totalsum += total[VALUE]
73 if (totalsum == NTOTAL && ifstr == "#elif") {
74 # this is the last unique checksum for this symbol
75 printf "#else\n#define __ver_%s\t_ver_str(%s)\n", SYMBOL, VALUE
76 printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL
80 # there must be more than one checksum still to
81 # print for this symbol
85 if (ntype[VALUE,type] == NARCHES[type]) {
86 if (str) str = str " || "
87 str = str "defined(__module__" type ")"
94 for (arch in ARCHES) {
101 if (narch == NTYPES[arch]) {
102 if (str) str = str " || "
103 str = str "defined(__module__" arch ")"
113 if (str) str = str " || "
114 str = str "defined(__module__" z[1] "_" z[2] ")"
116 printf "%s %s\n#define __ver_%s\t_ver_str(%s)\n", ifstr, str, SYMBOL, VALUE
117 printf "#define %s _set_ver(%s)\n", SYMBOL, SYMBOL
120 if (ifstr == "#elif ")