#Usage for #define format is `perl MakeSysTraps.pl -d /path/to/systrap.h'. use strict; if (@ARGV == 0) { print < Produces output suitable for the build-prc data file. -s Produces an asm include file. -d Produces a bunch of #defines. -c Produces a list of Perl constants. EOF exit; } my ($format, $forConst); $forConst = 0; if ($ARGV[0] eq "-s") { shift; $format = "\t.equ %s,%s\n"; print <) { s"//.*$""; # eat C++-style comments s"/\*[^/]*\*/""g; # eat simple C-style comments (just in case) if (/define\W+sysTrapBase\W+((0[xX][\da-fA-F]+)|(\d+))/) { $num = $1; $num = oct $num if $num =~ /^0/; } next unless /=.*sysTrapBase.*,/ .. /}.*SysTrapNumber.*;/; printf $format, $1, sprintf("\"%lX\"", $num++) if /sysTrap(\w+)\b/; } if ($forConst != 0) { print "\n", "1;", "\n"; }