#!/usr/bin/perl
#   cppsyms [cppname] [ccname]
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# This produces a list of the symbols that are pre-defined by  the  C #
# preprocessor. It needs to know the name of your C preprocessor, and #
# also the name of your C compiler.  If they are in the usual places, #
# you don't need to include them on the command line, of course.      #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
$pp = $ARGV[1] || '/usr/lib/cpp';
$cc = $ARGV[2] || 'cc';
$pc = '/tmp/test.c';
$pr = '/tmp/test';
open(S,"strings $pp |")
	|| die "Can't run \"strings $pp\" [$!]\n";
open(C,">/tmp/test.c")
	|| die "Can't write to /tmp/test.c [$!]\n";
print C "main(){\n";
while (<S>) {
	chop;
	if (/^[A-Za-z0-9_]*$/) {
		print C "#ifdef $_\n";
		print C "\tprintf(\"$_\\n\");\n";
		print C "#endif\n";
}	}
print C "}\n";
close(C);
system "$cc -o $pr $pc";
system "$pr";
system "/bin/rm -f $pr $pc";
