blob: 1d61824254a16f754f650c370a3023f6733ecd50 [file] [log] [blame]
Mike Frysinger9171fc82008-03-30 15:46:13 -04001#!/usr/bin/gawk -f
2BEGIN {
3 print "/* DO NOT EDIT: AUTOMATICALLY GENERATED"
4 print " * Input files: bootrom-asm-offsets.awk bootrom-asm-offsets.c.in"
5 print " * DO NOT EDIT: AUTOMATICALLY GENERATED"
6 print " */"
7 print ""
8 system("cat bootrom-asm-offsets.c.in")
9 print "{"
10}
11
12{
13 /* find a structure definition */
14 if ($0 ~ /typedef struct .* {/) {
15 delete members;
16 i = 0;
17
18 /* extract each member of the structure */
19 while (1) {
20 getline
21 if ($1 == "}")
22 break;
23 gsub(/[*;]/, "");
24 members[i++] = $NF;
25 }
26
27 /* grab the structure's name */
28 struct = $NF;
29 sub(/;$/, "", struct);
30
31 /* output the DEFINE() macros */
32 while (i-- > 0)
33 print "\tDEFINE(" struct ", " members[i] ");"
34 print ""
35 }
36}
37
38END {
39 print "\treturn 0;"
40 print "}"
41}