1# Based on apr's make_export.awk, which is 2# based on Ryan Bloom's make_export.pl 3 4/^#[ \t]*if(def)? (AP[RUI]?_|!?defined).*/ { 5 if (old_filename != FILENAME) { 6 if (old_filename != "") printf("%s", line) 7 macro_no = 0 8 found = 0 9 count = 0 10 old_filename = FILENAME 11 line = "" 12 } 13 macro_stack[macro_no++] = macro 14 macro = substr($0, length($1)+2) 15 count++ 16 line = line "#ifdef " macro "\n" 17 next 18} 19 20/^#[ \t]*endif/ { 21 if (count > 0) { 22 count-- 23 line = line "#endif /* " macro " */\n" 24 macro = macro_stack[--macro_no] 25 } 26 if (count == 0) { 27 if (found != 0) { 28 printf("%s", line) 29 } 30 line = "" 31 } 32 next 33} 34 35function add_symbol (sym_name) { 36 if (count) { 37 found++ 38 } 39 for (i = 0; i < count; i++) { 40 line = line "\t" 41 } 42 line = line sym_name "\n" 43 44 if (count == 0) { 45 printf("%s", line) 46 line = "" 47 } 48} 49 50/^[ \t]*(extern[ \t]+)?AP[RUI]?_DECLARE_DATA .*;$/ { 51 varname = $NF; 52 gsub( /[*;]/, "", varname); 53 gsub( /\[.*\]/, "", varname); 54 add_symbol(varname); 55} 56 57END { 58 printf("%s", line) 59} 60