#!/usr/local/bin/perl # list-irules # Syntax: list-irules input-file # Given an Imake.rules file as input, pull out the names of all the # rules defined in it. Try to, anyway. Dumps output in format used # to list the rules inside of a C comment near the beginning of the file. # Intent of the script is for generating a replacement list of rules to # put in the comment after modifying the rule definitions. # Installation instructions: # - make sure the path to perl in the first line is correct for your system # - make sure the script is executable: chmod +x list-irules # 19 Feb 1996 Paul DuBois, dubois@primate.wisc.edu @rule = (); @arglist = (); $seekifndef = 1; # 1 = seeking #ifndef line, 0 = not while (<>) { if ($seekifndef) { $seekifndef = 0 if /^#\s*ifndef/; next; } next unless /^#\s*define/; if (/^#\s*define\s+([^(]+)(\([^)]*\))/) { push (@rule, $1); push (@arglist, $2); } elsif (/^#\s*define\s+(\S+)/) { push (@rule, $1); push (@arglist, ""); } $seekifndef = 1; } while ($rule = shift (@rule)) { $arglist = shift (@arglist); $tabs = "\t" x (int ((31 - length (" * $rule")) / 8) + 1); print " * $rule$tabs$arglist\n" if $arglist; print " * $rule\n" if !$arglist; } exit (0);