#!/usr/bin/perl

# extract all defines from STCP 'system' files.  I will prefix
# these with _sam_.  This script makes a list of all possible
# labels (irrespective of #if directives).

while(<>) {
    @fields = split(/[\b\s\(\)\[\]\{\}]/);;
    do {
	$cfield = shift(@fields);
    } while(($cfield !~ /#define/) && (scalar(@fields)));
    if ($label = shift(@fields)) {
	# Got a label
	# don't extract it if it already has the sam_ prefix.
	if ($label !~ /sam_/) {
	    print "s/\\([][(){} 	*/><&+-]\\)\\(",$label,
		  "\\)/\\1_sam_",$label,"/g\n";
	}
    }
}
