#! /usr/bin/env perl
#
# Scan a make logfile for errors.  Eliminate informational messages and
# innocuous warnings.
# Reduce multiple (identical or related) warnings to a single instance, 
# with a count.
$no_tar     = 0;
$no_varwarn = 0;
$is_loose   = 0;
foreach $_ (@ARGV) {
    if (/^-nowarn/) {
        $MPICH_WARNING_SEP = 'MPICH Warning' ;
    }
    elsif (/^-echo/) {
	$debug = 1;
    }
    elsif (/^-notar/) {
	# special command to skip any step that extracts and builds the mpich
	# tar file.
	$no_tar = 1;
    }
    elsif (/^-novarwarn/) {
	# Special command to skip "The variable ... is set but never used"
	$no_varwarn = 1;
    }
    elsif (/^-loose/) {
	$is_loose = 1;
    }
    elsif (/^-/) {
	print STDERR "Unrecognized argument $_\n";
	exit(1);
    }
    else {
	$filename = $_;
	last;
    }
}

#
# Set up the default exclusion strings
#
# Ranges.  All text between the range begins and range ends are skipped
# These are pairs
# They are:
#   1. Testing logs from MPICH tests
#   2. Informational output specially marked
#   3. More such data
#   4. An error in some Linux header files that redefines RLIM_INFINITY
#   5. Noise from libtool
#
@Ranges = ( '^Making testing', '\*\*\* Checking for diff', 
	    '^--->', '^---<', 
	    '^\*# --->', '^\*# ---<',
	    'In file included from \/usr\/include\/sys', 
 	    '^\/usr\/include\/asm\/resource\.h:26',
	    '^The path for wish, ', '^\(Some systems limit the length',
	    '^-- No differences found', '^End of testing in ',
	    '^Libraries have been installed in','^more information, such as',
	   );
if ( $MPICH_WARNING_SEP ne "" ) {
    @Ranges = ( @Ranges, ">$MPICH_WARNING_SEP", "<$MPICH_WARNING_SEP" );
}
#
# Various classes of messages to exclude
@CompilerMsgs = ( '^\s*cc\s', '^\s*gcc\s', '^\s*xlc\s', '^\s*xlC\s', 
		 '^\s*(pg)?f77\s', '^\s*(pg)?f90\s', '^\s*g77\s', 
		 '^\s*F90:\s',
		 '^\s*(pg)?cc\s', '^\s*f95\s', '^\s*icc\s',
		 '^\s*ecc\s', '^\s*efc\s', '^\s*ifc\s',
		 '^\s*(mp)?xlf(90)?\s', '^\s*mpicc\s',
		 '^\s*mpiCC\s', '^\s*mpcc\s', '^\s*mpCC\s',
		 '^\s*mpif77\s', '\s*mpif90\s', '^\s*javac\s', '^\s*jar\s', 
		 '^\s*[-0-9A-Za-z_\./]*/cc\s',  # For things like /usr/ucb/cc
		 '^\s*[-0-9A-Za-z_\./]*/mpicc\s',
		 '^\s*[-0-9A-Za-z_\./]*/mpiCC\s',
		 '^\s*[-0-9A-Za-z_\./]*/mpicxx\s',
		 '^\s*[-0-9A-Za-z_\./]*/mpcc\s',
		 '^\s*[-0-9A-Za-z_\./]*/mpCC\s',
		 '^\s*[-0-9A-Za-z_\./]*/mpif77\s',
		 '^\s*[-0-9A-Za-z_\./]*/mpif90\s',
		 '^\s*[-0-9A-Za-z_\./]*/mpich-globus2-cc\s',
		 '^\s*[-0-9A-Za-z_\./]*/mpich-globus2-f90\s',
		 '^\s*[-0-9A-Za-z_\./]*/javac\s',
		 '^\s*[-0-9A-Za-z_\./]*/jar\s',
		 '^\s*[-0-9A-Za-z_\./]*/rmic\s*-classpath\s',
		 '^\s*/bin/sh\s+\.\./libtool\s+--mode=compile\s',
		 '^\s*/bin/sh\s+\.\./libtool\s+--mode=link\s',
		 '^\s*/bin/sh\s+\.\./libtool\s+--mode=install\s',
		 '^\s*/bin/sh\s+\.\./libtool\s+--mode=finish\s',
	         'install -c .libs',
		 '^\s*echo\s+timestamp',
		 '^\s*mpir_[a-z_]*:\s*$', 
                 '^\s*external function [A-Za-z0-9_]*\s*$',
		 '^\s*external subroutine [A-Za-z0-9_]*\s*$',
                  '^\s*C\+\+ prelinker: executing:'
		  ); 
@LinkerMsgs = ( '^Linking:\s*$' );
# ^adding: is from Java
# Emacs perl mode breaks on this expression by not handling the \s*$' in
# the last expression correctly
@CompilerWarns = ( 'Compilation successful', '^adding: ',
                   'PGC\/x86.*:\scompilation completed with warnings',
                   'FORTRAN 77 Compiler.*Absoft Corp\.',
                   '^added manifest', # java message
		   'Note: Some input files use', # java message
		   'Note: Recompile with -deprecation', # java message
		   'Warning: JIT compiler', # java message
		   '^[-\/A-Za-z0-9\._]*:\s*$', # icc echos file name!
 );
# pgCC echos file name!
# Intel ifc echos module name
# Intel ifc tells you how many lines
# Intel ifc also echos module
@CompilerNoise = ('\s*[-0-9A-Za-z_\./]*\.cc:\s*$',
                  '^\s*module\s*subroutine\s*[A-Za-z0-9_]*$',
                  '^\s*[0-9]* Lines Compiled\s*$',
		  '^\s*module\s*[A-Za-z0-9_]*\s*$'
	       );
@CompilerWarnCombine = ( 'use of \`tmpnam\' is dangerous',
               );

# These are only for SGI (?)
@LinkerWarns = ( 'WARNING\s85\s*: definition of', 
		 'WARNING\s134\s*: weak definition of ',
		 'WARNING\s84\s*: .* is not used for resolving any symbol' );
@LinkerWarns = ( @LinkerWarns, 'libsun\.a is not used for ',
		 'libpmpich\.a is not used for resolving', 
		 'libmpich\.a is not used for resolving' );
@LinkerWarnCombine = ( 'Multiply defined:\(nxbuff_',
                       'Multiply defined:\(globus_',
                       'Multiply defined:\(utils_fprintf\)',
                       'Multiply defined:\(utils_strlen\)', 
                       'Multiply defined:\(utils_sprintf\)',
                       'Multiply defined:\(utils_streq\)',
                       'Multiply defined:\(utils_debug\)',
                       'Multiply defined:\(utils_strdup\)',
                       'Multiply defined:\(utils_streq_ci\)',
                       'Multiply defined:\(s_add_subrequest',
                       'Duplicate symbol: .piofsioctl',
                       'Duplicate symbol: piofsioctl',
                     );
@LinkerNoise = ('Use the -bloadmap');

@ArMsgs = ('^\s*ar: creating', '\s*ar: writing', '^a - ',
           '^\s*ar: [Ww]arning: creating',
           '^1501-51[-0]\s*ar cr' );

@X11Warns = ( '/X11/Xlib.h:.*function declaration.*a prototype' ,
	       '/X11/Xlib.h:.*type defaults to',
	       '/X11/Xutil\.h:.*type defaults to',
	       '/X11R./.*/Xlib.h:.*function declaration.*a prototype' );
@BogusCompilerMsgs = ( 
	'/usr/local/gcc-2\.7\.2.*termios.h.* warning: .* redefined', 
	'/usr/include/sys/ioctl.h.*this is the location',
        '/usr/include/sys/termios\.h.*/usr/ucbinclude/sys/ttychars\.h',
        '/usr/include/sys/termios\.h.*/usr/ucbinclude/sys/ioctl\.h',
        'Useless typedef declaration .*/usr/include/sys/select.h',
        'More than one type specified .*/usr/include/sys/select.h',
        'Useless typedef .*/usr/include/rpc/types\.h',
        'More than one type specified .*/usr/include/rpc/types\.h',
        'RLIM_INFINITY'
		       );

# ": filename" is sometimes used where ranlib filename is not required
@ProgramMsgs = ( '^\s*rm ', '^\s*cp ', '^\s*ar ', '^\s*mv ', 
		 '^\s*ranlib ', '^\s*chmod ', '^\s*cat ', '^\s*mkdir ',
		 '^\s*true ', '^\s*make\s', '^\s*gnumake\s',
                 '^\s*:\s+[-A-za-z0-9/\._]*\.a',
                 '^\s*\./bin/mpiinstall\s+;',
                );
@ConfigureNoise = ( '^[Cc]hecking ',
		    '^[Cc]reating ', 
		    '^[Cc]leaning ', 
                    'loading cache',
                    '^\s*Fortran interface will not',
                    '^\s*Don\'t build the tests',
		    '^updating cache ',
                    'Errors while trying to run true',
                    '=== End of Compilation . ===',
		    '^[-A-Za-z0-9_/\+\.]* is unchanged'
                   );
# The '^-*$' is for lines generated by libtool around usage messages.
# The usage messages are removed by using the range feature (see @Range).
@MakeNoise = ( 'Target .* is up to date',
	       'Nothing to be done for', '^\s*make ', '^\s*Making ',
               'sleep 1',
	       'Clock skew detected\.',
               'modification time in the future',
               '^-*$' );

if ($is_loose) { 
    @ConfigureNoise = ( @ConfigureNoise,
                     'Put JAVA', 'Cannot locate JAVA',
                     '^no$' );
    @ProgramMsgs = ( @ProgramMsgs, '^\s*/bin/rm ', '^\+\s*/bin/rm ',
		     '^\+\s*rm\s',
		     '^running /bin/sh ', '^\+\s*rmdir ',
		     '^\+ \[ -d', '^\+ make ', '^\+ cd ',
                     '^\+\s*\'\[\'\s* -d',
                     '^\s*\+\s*gnumake .* clean',
                     '^\s*\./bin/mpiinstall -prefix=',
                     '^building profiling interface',
                     '^Done installing documentation',
                     '^Send bug reports',
		     '^\s*ln -s ' );
    @MakeNoise   = ( @MakeNoise, '^making ', '^[Cc]ompiling ',
		     '^\s*test -z ', '^Copying ',
		     '^\*\* C application', 
		     '^\*\* Testing if .* linked',
		     '^\*\* Fortran77 application',
		     '^\*\* Testing if C application',
		     '^Testing that MPI appli',
		     '^Installed ',
		     '^installed ',
		     '^Fortran externals are',
		     'may be used to remove the',
                     'Rename xxx\.po to _xxx',
		     '^About to run ',
		     '^Installing ',
		     '^\s*\(cd \./p4;',
		     '^\s*\(cd lib;',
		     'MPILIBNAME=[a-zA-Z0-9]* p4inmpi',
		     '^\s*\(cd alog;',
		     '^\s*\(cd usc;',
		     '^\s*cd src\s*;',
		     '^Note: .*debug.java uses a deprecated',
		     '^\s*-DMPICH_INFODLL',
		     '^\s*-DMANAGER',
		     '^\s*else ',
		     '^\s*fi$',
                     'cd src/infoexport ; make def',
                     '^\s*if test ',
                     '^\s*if \[ ! -d ',
		     '^\s*if \[ \"',
                     'deflated [0-9]*%',
                     '^Current working',
                     'makesharedlib -lib=',
		     '^Done installing manuals',
                     '-kind=.* -local -suffix',
                     '^\s*\(\s*CC=\"',
                     '^\s*cd .* && true',
                     'CONFIG_FILES=contrib',
                     '^\s*cd\s\.\./\.\.\s*\\\\',
                     '\.\/runtests\s+-check',
		     );    
    @ConfigureNoise = ( @ConfigureNoise, '^\s*[Ss]etting ', 
			'^\s*[Cc]onfiguring ',
			'^Finished ',
			'^IRIX-specific',
			'^Running device-',
			'^Messages about long doubles',
			'^C integer type for ',
			'^Done configuring ',
                        'have been configured$',
			'^This MPE build ',
			'^Fortran externals have ',
			'^Types are ',
			'^About to do p4.* device',
			'^Include C\+\+ bindings',
			'^defining MPI_Offset',
			'^ROMIO home directory is ',
			'^Configure of SLOG-API succeeded',
			'^Configuration completed',
                        '^configure: warning: java full version',
                        '^configure: warning:\s*Jumpshot-2 is',
                        '^Note: [0-9]* files use or override a deprecated API',
                        'shot.*have been configured',
                        '^The OSF V3 make',
                        '^Using this make may cause',
                        '^You should consider using gnumake',
                        'Your make does not allow comments in target'
			);
    &setp4syms;
    @SymWarns = ( @p4globsyms );
}

if ($filename) {
    open( $INFD, "<$filename" ) || die "Could not open $filename\n";
}
else {
    $INFD = STDIN;
}

$cur_line = 0;
$nextlinepat = "";
LINE: while (<$INFD>) {
    $cur_line++;
    $last_line = $cur_line;
    $cur_line = $_;
    if (/^\s*$/) { next LINE; }
    if ($nextlinepat ne "" && /$nextlinepat/) { $nextlinepat = ""; next LINE; }
    $nextlinepat = "";
    # Special case for non-communative arithmetic
    if ($is_loose) {
        if (/^\*#    \*\*\*/) {
             $saveline = $_;
             $_ = <$INFD>;  $cur_line++;
             if (/HAS NON-COMMUTATIVE ARITHMETIC/) {
                 # skip the message
                 while (<$INFD>) {
                     $cur_line++;
                     if (/x\*y-y\*x =/) { next LINE; }
                 }
             }
             else {
                 print $saveline;
                 # continue on with the current line
             }
        }
    }
    # Try to match against range
    for ($i=0; $i<$#Ranges; $i += 2) {
	if (/$Ranges[$i]/) {
	    while (<$INFD>) {
		$cur_line++;
		if (/$Ranges[$i+1]/) { next LINE; }
	    }
	}
    }
    # Fortran compiler messages:
    if (/^[-A-Za-z0-9\/_\.]*\.f:$/) {
        #print "In fortran with $_";
	while (<$INFD>) {
	    $cur_line++;
	    if (/^\s*[A-Za-z0-9_]*:$/) { next; }
	    if (/^\s*MAIN\s*[A-Za-z0-9_]*:\s*$/) { next; }
	    last;
	}
        #print "Exiting fortran at $_";
    }
    # Multiline C compiler messages
    if (/cc-1171\s*cc: WARNING/) {
        $save_line = $_;
        $_ = <$INFD>;
        $cur_line++;
        if (/The indicated expression has no effect/) {
           while (<$INFD>) {
               $cur_line++;
               if (/\s*\^/) { next LINE; }
           }
        }
        else { $_ = $save_line . $_ ; }
    }
    if (/\"[a-zA-Z0-9_]*\.c\".* use of \"=\" where \"==\" may/) {
        # Intel compiler doesn't recognize the (a = b) idiom for 
	# assignments within an if.
        $_ = <$INFD>;
        $cur_line++;
	while (<$INFD>) {
	    $cur_line++;
	    if (/\s*\^/) { next LINE; }
	}
    }
    if (/^([^:]*):.*\s([^\s]*)\snot found in import\./) {
        # Summarize java errors
	$file = $1;
	$missing_package = $2;
	$_ = <$INFD>;
	$cur_line++;
	$java_missing{$file} .= $missing_package;
	while (<$INFD>) {
	    $cur_line++;
	    if (/\s*\^/) { next LINE; }
	}
    }
    # ---


    # Skip the various classes
    foreach $pat (@CompilerMsgs) {
	if (/$pat/) { next LINE; }
    }
    foreach $pat (@CompilerWarns) {
	if (/$pat/) { next LINE; }
    }
    foreach $pat (@CompilerNoise) {
	if (/$pat/) { next LINE; }
    }
    foreach $pat (@CompilerWarnCombine) {
        if (/$pat/) { 
            if ($compilerwarns{$pat} eq "") {
                $compilerwarnsline{$pat} = $_;
                $compilerwarns{$pat} = 0;
            }
            $compilerwarns{$pat} += 1;
            next LINE;
        }
    }
    foreach $pat (@LinkerMsgs) {
	if (/$pat/) { next LINE; }
    }
    foreach $pat (@LinkerWarns) {
	if (/$pat/) { next LINE; }
    }
    foreach $pat (@LinkerWarnCombine) {
        if (/$pat/) { 
            if ($linkerwarns{$pat} eq "") {
                $linkerwarnsline{$pat} = $_;
                $linkerwarns{$pat} = 0;
            }
            $linkerwarns{$pat} += 1;
            next LINE;
        }
    }
    foreach $pat (@LinkerNoise) {
	if (/$pat/) { next LINE; }
    }
    foreach $pat (@X11Warns) {
	#print "Testing $pat with $_";
	if (/$pat/) { next LINE; }
    }
    foreach $pat (@BogusCompilerMsgs) {
	if (/$pat/) { next LINE; }
    }

    foreach $pat (@ArMsgs) {
	if (/$pat/) { next LINE; }
    }
    foreach $pat (@ProgramMsgs) {
        #if (/\/bin\/rm/) { print "pat = $pat and line = $_"; }
	if (/$pat/) { 
	    # Remove any continuation lines
	    while (/^\s*[^#].*\\$/) {
		 $_ = <$INFD>; 
		 $cur_line++;
		 $last_line = $cur_line;
		 $cur_line = $_;
	    }
	    next LINE; }
    }
    foreach $pat (@MakeNoise) {
	if (/modification time in the future/) {
	    $nextlinepat = "Failed to remake makefile";
	}
	if (/$pat/) { next LINE; }
    }
    foreach $pat (@ConfigureNoise) {
	if (/Errors while trying to run true/) {
	    $nextlinepat = 'poll: protocol failure|connection failed|Connection refused'; 
	}
	if (/$pat/) { next LINE; }
    }
    foreach $pat (@SymWarns) {
	if (/$pat/) { next LINE; }
    }
    # Special case for excluding the tar build
    if ( $no_tar ) {
	if (/^\*# Buildtar/) {
	    while (<$INFD>) {
		$cur_line++;
		if (/^Full distribution/) { next LINE; }
	    }
	}
    }
    # Special case for broken x11 header files
    # In file included from <path>/basex11.h:15,
    if (/.*\/basex11\.h:1.,/) {
	$cur_line++;
	<$INFD>; next LINE; 
    }
    if ( $no_varwarn ) {
	if (/^\s*The variable .* is set but never used/) {
	    while (<$INFD>) {
		$cur_line++;
		if (/^\s*^/) { next LINE; }
	    }
	}
	if (/^\s*The variable .* was declared never/) {
	    while (<$INFD>) {
		$cur_line++;
		if (/^\s*^/) { next LINE; }
	    }
	}
    }

    print $_;
    # Keep the previous unprinted (good) line as the current line
    $cur_line = $last_line;
}

# For lines that are combined, print the summary:

$found_multiple = 0;
foreach $pat (@LinkerWarnCombine) {
    if ($linkerwarns{$pat} > 0) { 
        if (!$found_multiple) {
             $found_multiple = 1;
             print "\nFound multiple warning messages; summarizing:\n";
        }
        print "Found $pat $linkerwarns{$pat} times\n";
        print "Typical line: $linkerwarnsline{$pat}";
        print "\n";   # Add a blank line to make the messages clearer
    }
}
foreach $pat (@CompilerWarnCombine) {
    if ($compilerwarns{$pat} > 0) { 
        if (!$found_multiple) {
             $found_multiple = 1;
             print "\nFound multiple warning messages; summarizing:\n";
        }
        print "Found $pat $compilerwarns{$pat} times\n";
        print "Typical line: $compilerwarnsline{$pat}";
        print "\n";   # Add a blank line to make the messages clearer
    }
}

$header = 0;
foreach $file (keys(java_missing)) {
    if (!$header) { print "Missing Java imports:\n"; $header = 1; }
    print "$file $java_missing{$file}\n";
}

exit 0;

# Leave in /bin/rm because we should change it to rm.

# I'd like to remove most of these from the *normal* output, rather than
# continue to filter them
#

#  egrep -v '^[ 	]*\(cd .* clean\)|^[ 	]*\(cd [/\.a-zA-Z0-9]*[;] ' | \
#  egrep -v 'if \[ .* \] ; then ln -s .* fi' |\
#  egrep -v '^U |^Making |^for file' | \
#  egrep -v '^ *if \[' | \
#  egrep -v '^making|^ *$|^[	 ]*ln -s|^ *done$' | \
#  egrep -v '^s - ' | \
#  egrep -v '^[0-9-]*[ 	]*ar ' | \
#  egrep -v '^building pro|^compiling ROMIO|^(gnu)?make ' | \
#  egrep -v '^C integer' | \
#  egrep -v 'Warning .*declared EXTERNAL but never used' | \
#  egrep -v '^Fortran linker needs|^Fortran externals ' | \
#  egrep -v '^About to|^Finished |^Generating message' |\
#  egrep -v '^[ 	]*mpir_[ig][a-z_]*:$' |\
#  egrep -v '^[a-z]*\.f:$' |\
#  egrep -v '^[ 	]*done[ 	]*$' .tmp |\
#  egrep -v '^[	 ]*for file|.*make clean\)' |\
#  egrep -v '[ 	]*(gnu)?make[ ]*[a-zA-Z0-9\./]*[ 	]*$' |\
#  egrep -v '^Testing if |^Application can be linked|^Fortran application can' |\
#  egrep -v 'Attempting to|Adding a symbolic' |\
#  egrep -v '^[ 	]*\./makelinks|making adjlogs|not making server' > .tmp2 2>&1
#  egrep -v 'cd lib;|cd alog;|cd usc' .tmp2 |\
#  egrep -v 'MPILIBNAME=.* p4inmpi' |\
#  egrep -v 'preparing mpif.h for ROMIO' |\
#  egrep -v '^[ 	]*-DMPIRUN_' |\
#  egrep -v '^[ 	]*if \[ "[01]" = "[01]" .* \] ; then' |\
#  egrep -v 'mpir_.*=== End of Compilation ? ===' |\
#  egrep -v 'for dir in contrib|contrib/test test|^[	 ]*if test -s' |\
#  egrep -v '^[ 	]*fi[ ]*;\\$' > .tmp 2>&1
#  #
#  /bin/rm -f .tmp2
#  egrep -v 'Configuration completed' .tmp |\
#  egrep -v '\(cd \./p4;|cd \.\./\.\./include' |\
#  egrep -v 'if test -n ".*" -a ".*" != "ignore"' |\
#  egrep -v '^[ 	]*-DMPICH_INFODLL|^[ 	]*msgqdllloc.c ; \\$' |\
#  egrep -v 'cd src/infoexport|^[ 	]*fi$|^[ 	]*else[ ]*\\$' |\
#  egrep -v 'mpe/profiling/nupshot has|use it on another|You must have java' |\
#  egrep -v 'cd contrib/test; make linktest|Application can use both' |\
#  egrep -v 'defining MPI_Offset|ROMIO home directory is|configuring for file' |\
#  egrep -v 'Compiling C\+\+|Include C\+\+ bindings' |\
#  egrep -v 'it should be defined in a file called ' |\
#  egrep -v 'When building multiple|include instead of bin/ and ' >.tmp2 2>&1
#  #
#  /bin/rm -f .tmp
#  egrep -v 'if test ".*" != "ignore"' .tmp2 |\
#  egrep -v 'export CC|util/makesharedlib -lib'  |\
#  egrep -v '^[ 	]*-kind=.* -local|^[ 	]*MAIN main:$|^pi3.f:$' |\
#  egrep -v 'Testing that MPI applications' |\
#  egrep -v 'may be used to remove the ' |\
#  egrep -v 'Created util/machines|You may want to edit|These hosts are used' |\
#  egrep -v '^[ 	]*if test "." = 1 ; then|Installing MPE'  |\
#  egrep -v '^[ 	]*if \[ ["!]|mpeconf.h is unchanged|^[ 	]*if \[ -n' |\
#  egrep -v '^[ 	]*mpif.h[ 	]*$' |\
#  egrep -v 'End of Compilation|Trying GETARG' |\
#  egrep -v 'solaris/doctext|^[ ]*[a-zA-Z0-9/\._]*cc |^\*\* Testing|^\*\* C app' .tmp |\
#  egrep -v '^\*\* Fortran77 app|^[ 	]*touch ' |\
#  egrep -v '^\+ /bin/rm|^\+ rmdir|^\+ \[ -d' |\
#  egrep -v '^Trying to|^Java is|^added manifest' |\
#  egrep -v '^[a-z]*conf.h is unchanged|^if test |^\+ make clean' |\
#  egrep -v '^[ 	]*make [a-zA-Z0-9/]|^[ 	]*cd ' |\
#  egrep -v '^[ 	]: [a-zA-Z0-9/]*\.a|^[ 	]*test -z' |\
#  egrep -v '^[ 	]*if \[ -x|^Linking:$' |\
#  egrep -v '^[a-z0-9A-Z_/]*mkdirs |^[a-z0-9A-Z_/]*CreateChoiceSrc |^Types are' |\
#  egrep -v '; make clean|^Installed ' |\
#  egrep -v '^adding: |^Done configuring|^loading cache' |\
#  egrep -v '^[ 	]*[-\.A-Za-z0-9/]*/jar |^running /bin/sh|^configuring ' |\
#  egrep -v '^.*CreateModuleSrc -exc|libm\.so is not used' .tmp2 |\
#  egrep -v '^.*CreateChoiceSrc -kind|^FORTRAN 77 Compiler.*Copyright' |\
#  egrep -v '^[/A-Za-z0-9]*\.f:[ 	]*$' |\
#  egrep -v '^[ 	]*mpi_constants\.o[ 	]*$' |\
#  #
#  #
#  # Try for ld messages
#  sed -n -e '/Unresolved:/,/^[ ]*$/p' $filename
#  /bin/rm -f .tmp .tmp2

# [59]	|       280|       4|OBJT |GLOB |0    |3      |event_count


sub setp4syms {
@p4globsyms = ('\s*\|bm_outfile',
	       '\s*\|globmemsize',
	       '\s*\|hand_start_remotes',
	       '\s*\|listener_info',
	       '\s*\|local_domain',
	       '\s*\|logging_flag',
	       '\s*\|procgroup_file',
	       '\s*\|rm_outfile_head',
	       '\s*\|sserver_port',
	       '\s*\|whoami_p4',
	       '\s*\|data_representation',
	       '\s*\|trap_sig_errs',
	       '\s*\|process_args',
	       '\s*\|alloc_global',
	       '\s*\|alloc_listener_info',
	       '\s*\|alloc_local_bm',
	       '\s*\|alloc_local_listener',
	       '\s*\|alloc_local_rm',
	       '\s*\|alloc_local_slave',
	       '\s*\|alloc_p4_msg',
	       '\s*\|free_avail_buffs',
	       '\s*\|free_p4_msg',
	       '\s*\|init_avail_buffs',
	       '\s*\|dump_conntab',
	       '\s*\|dump_global',
	       '\s*\|dump_listener',
	       '\s*\|dump_local',
	       '\s*\|dump_procgroup',
	       '\s*\|dump_tmsg',
	       '\s*\|print_conn_type',
	       '\s*\|install_in_proctable',
	       '\s*\|read_procgroup',
	       '\s*\|alloc_quel',
	       '\s*\|free_avail_quels',
	       '\s*\|free_quel',
	       '\s*\|get_tmsg',
	       '\s*\|initialize_msg_queue',
	       '\s*\|queue_p4_message',
	       '\s*\|recv_message',
	       '\s*\|search_p4_queue',
	       '\s*\|send_message',
	       '\s*\|num_in_mon_queue',
	       '\s*\|subtree_broadcast_p4',
	       '\s*\|fork_p4',
	       '\s*\|get_execer_port',
	       '\s*\|get_pipe',
	       '\s*\|get_qualified_hostname',
	       '\s*\|getswport',
	       '\s*\|in_same_cluster',
	       '\s*\|init_usclock',
	       '\s*\|put_execer_port',
	       '\s*\|same_data_representation',
	       '\s*\|setup_conntab',
	       '\s*\|zap_p4_processes',
	       '\s*\|zap_remote_p4_processes',
	       '\s*\|bm_start',
	       '\s*\|create_bm_processes',
	       '\s*\|procgroup_to_proctable',
	       '\s*\|send_proc_table',
	       '\s*\|sync_with_remotes',
	       '\s*\|create_rm_processes',
	       '\s*\|receive_proc_table',
	       '\s*\|rm_start',
	       '\s*\|dump_sockaddr',
	       '\s*\|dump_sockinfo',
	       '\s*\|get_inet_addr',
	       '\s*\|get_inet_addr_str',
	       '\s*\|get_sock_info_by_hostname',
	       '\s*\|gethostbyname_p4',
	       '\s*\|net_accept',
	       '\s*\|net_conn_to_listener',
	       '\s*\|net_recv',
	       '\s*\|net_send',
	       '\s*\|net_set_sockbuf_size',
	       '\s*\|net_setup_anon_listener',
	       '\s*\|net_setup_listener',
	       '\s*\|create_remote_processes',
	       '\s*\|net_create_slave',
	       '\s*\|net_slave_info',
	       '\s*\|establish_connection',
	       '\s*\|handle_connection_interrupt',
	       '\s*\|request_connection',
	       '\s*\|send_ack',
	       '\s*\|shutdown_p4_socks',
	       '\s*\|sock_msg_avail_on_fd',
	       '\s*\|socket_close_conn',
	       '\s*\|socket_msgs_available',
	       '\s*\|socket_recv',
	       '\s*\|socket_recv_on_fd',
	       '\s*\|socket_send',
	       '\s*\|wait_for_ack',
	       '\s*\|xdr_recv',
	       '\s*\|xdr_send',
	       '\s*\|listener',
	       '\s*\|net_recv_timeout',
	       '\s*\|process_connect_request',
	       '\s*\|process_slave_message',
	       '\s*\|getpw_ss',
	       '\s*\|start_prog_error',
	       '\s*\|start_slave',
	       '\s*\|tty_orig',
	       '\s*\|shmem_msgs_available',
	       '\s*\|shmem_recv',
	       '\s*\|shmem_send',
	       '\s*\|ch_debug_buf',
	       '\s*\|expect_ack',
	       '\s*\|total_pack_unacked',
	       '\s*\|TR_stack_init',
	       '\s*\|expect_cancel_ack' );
}
