|
Packit Service |
c5cf8c |
#! /usr/bin/env perl
|
|
Packit Service |
c5cf8c |
# -*- Mode: perl; -*-
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# Set Defaults
|
|
Packit Service |
c5cf8c |
$debug = 0;
|
|
Packit Service |
c5cf8c |
$debugDir = 0;
|
|
Packit Service |
c5cf8c |
$gDebugOther = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
$summaryOutput = 0;
|
|
Packit Service |
c5cf8c |
$terseOutput = 1;
|
|
Packit Service |
c5cf8c |
$rootSrcDir = "";
|
|
Packit Service |
c5cf8c |
# Define the known commands, along with known make noise (results of
|
|
Packit Service |
c5cf8c |
# echo)
|
|
Packit Service |
c5cf8c |
# We include /bin/rm and /bin/mv because some Makefile authors prefer
|
|
Packit Service |
c5cf8c |
# to get the full path for these routines
|
|
Packit Service |
c5cf8c |
@commands = ( "cc", "pgcc", "gcc", "icc", "acc",
|
|
Packit Service |
c5cf8c |
"rm", "mv", "cp", "ar", "ranlib", "perl", "for",
|
|
Packit Service |
c5cf8c |
"/bin/rm", "/bin/mv", "/bin/cp", "/bin/chmod",
|
|
Packit Service |
c5cf8c |
"rm", "mv", "cp", "chmod",
|
|
Packit Service |
c5cf8c |
"if", "make", "gnumake",
|
|
Packit Service |
c5cf8c |
"[A-Za-z0-9_\/\.-]*\/mpicc",
|
|
Packit Service |
c5cf8c |
"[A-Za-z0-9_\/\.-]*\/mpifort",
|
|
Packit Service |
c5cf8c |
"[A-Za-z0-9_\/\.-]*\/mpicxx",
|
|
Packit Service |
c5cf8c |
"cleaning", "sleep", "date", "g77", "f77", "f90", "f95", "pgCC",
|
|
Packit Service |
c5cf8c |
"pgf77", "pgf90", "CC", "g95", "g\\+\\+", "c\\+\\+",
|
|
Packit Service |
c5cf8c |
"acc\\+\\+", "xlc", "xlf", "xlC", "xlf90", "gfortran",
|
|
Packit Service |
c5cf8c |
"ifort", "ifc", "test",
|
|
Packit Service |
c5cf8c |
"true", "false", "/[A-Za-z0-9_\/\.-]*createshlib",
|
|
Packit Service |
c5cf8c |
"/bin/sh\\s+[A-Za-z0-9_\/\.-]*libtool\\s+\(--tag=\\w+\)*\\s+--mode=\\w+",
|
|
Packit Service |
c5cf8c |
"/bin/bash\\s+[A-Za-z0-9_\/\.-]*libtool\\s+--mode=\\w+",
|
|
Packit Service |
c5cf8c |
"/bin/sh\\s+[A-Za-z0-9_\/\.-]*libtool\\s+--finish",
|
|
Packit Service |
c5cf8c |
"/bin/bash\\s+[A-Za-z0-9_\/\.-]*libtool\\s+--finish",
|
|
Packit Service |
c5cf8c |
"libtool:\\s+compile:",
|
|
Packit Service |
c5cf8c |
"libtool:\\s+link:",
|
|
Packit Service |
c5cf8c |
"libtool:\\s+install:",
|
|
Packit Service |
c5cf8c |
"libtool:\\s+finish:",
|
|
Packit Service |
c5cf8c |
"[A-Za-z0-9_\/-]*\/icc",
|
|
Packit Service |
c5cf8c |
"[A-Za-z0-9_\/-]*\/install-sh",
|
|
Packit Service |
c5cf8c |
"/usr/bin/ar", "mkdir",
|
|
Packit Service |
c5cf8c |
"/bin/mkdir",
|
|
Packit Service |
c5cf8c |
"/.*bin/mkdir",
|
|
Packit Service |
c5cf8c |
"/usr/ucb/ld",
|
|
Packit Service |
c5cf8c |
"mpicc", "mpicxx",
|
|
Packit Service |
c5cf8c |
"compiling ROMIO in",
|
|
Packit Service |
c5cf8c |
"Make completed",
|
|
Packit Service |
c5cf8c |
"echo", "cat",
|
|
Packit Service |
c5cf8c |
"CC", "CCLD", "AR", "RANLIB", "LIBTOOL", "MV",
|
|
Packit Service |
c5cf8c |
"MOD", "GEN", "F77", "FC", "CXXLD", "CXX", "FCLD",
|
|
Packit Service |
c5cf8c |
"CP", # "terse" make versions
|
|
Packit Service |
c5cf8c |
"\\(?cd",
|
|
Packit Service |
c5cf8c |
"\\(\\s*cd",
|
|
Packit Service |
c5cf8c |
"creating\s+lib.*",
|
|
Packit Service |
c5cf8c |
"cd\\s+\&\&\\s+make",
|
|
Packit Service |
c5cf8c |
"sed -e",
|
|
Packit Service |
c5cf8c |
"PATH=\"\\\$PATH.*\\sldconfig\\s",
|
|
Packit Service |
c5cf8c |
"building profiling interface in directory",
|
|
Packit Service |
c5cf8c |
"/usr/bin/install",
|
|
Packit Service |
c5cf8c |
"/.*bin/install",
|
|
Packit Service |
c5cf8c |
".*confdb/install-sh",
|
|
Packit Service |
c5cf8c |
"Copying Upshot",
|
|
Packit Service |
c5cf8c |
"Cleaning directory",
|
|
Packit Service |
c5cf8c |
"[*][*][*][*] Making .*\.\.\.\.",
|
|
Packit Service |
c5cf8c |
"Making .* in .*",
|
|
Packit Service |
c5cf8c |
"Making upshot", "\\s*\$",
|
|
Packit Service |
c5cf8c |
"ld: warning: directory not found for option '-L\\S*src/mpl'",
|
|
Packit Service |
c5cf8c |
"ld: warning: directory not found for option '-L\\S*src/openpa/src'",
|
|
Packit Service |
c5cf8c |
);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# OtherNoise is an array of patterns that describe blocks of
|
|
Packit Service |
c5cf8c |
# text that we'd like to skip. The initial use it to handle
|
|
Packit Service |
c5cf8c |
# libtool install output.
|
|
Packit Service |
c5cf8c |
# The PG entries are work-arounds for bugs in the PG header files that have
|
|
Packit Service |
c5cf8c |
# small incompatibilities with the system header file /usr/include/unistd.h
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
@OtherNoise = ( 'Libraries have been installed in:<SEP>more information, such as the ld\(1\) and ld.so\(8\) manual pages.<SEP>20',
|
|
Packit Service |
c5cf8c |
'^\s*-+\s*$<SEP><SEP>1',
|
|
Packit Service |
c5cf8c |
'^In directory:<SEP><SEP>1',
|
|
Packit Service |
c5cf8c |
'^creating\s<SEP><SEP>1',
|
|
Packit Service |
c5cf8c |
# '^PGC-W-0114-More than one type.*/usr/include/unistd.h: 189<SEP>^PGC-W-0143-Useless typedef.*/usr/include/unistd.h: 189<SEP>2',
|
|
Packit Service |
c5cf8c |
# '^PGC-W-0114-More than one type.*/usr/include/unistd.h: 243<SEP>^PGC-W-0143-Useless typedef.*/usr/include/unistd.h: 243<SEP>2',
|
|
Packit Service |
c5cf8c |
'^PGC.*: compilation completed with warnings<SEP><SEP>1',
|
|
Packit Service |
c5cf8c |
# This next is a general version to handle all of these mistakes
|
|
Packit Service |
c5cf8c |
'^PGC-W-0114-More than one type specified.*/usr/include<SEP>^PGC-W-0143-Useless typedef declaration \(no declarators present\).*/usr/include<SEP>2',
|
|
Packit Service |
c5cf8c |
'copying python',
|
|
Packit Service |
c5cf8c |
'LOOP WAS VECTORIZED',
|
|
Packit Service |
c5cf8c |
'Using variables ',
|
|
Packit Service |
c5cf8c |
);
|
|
Packit Service |
c5cf8c |
# In the past, we also needed
|
|
Packit Service |
c5cf8c |
# WARNING 84.*not used for resolving any symbol
|
|
Packit Service |
c5cf8c |
# Info: File not optimized
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
$trimCompileLine = 1;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Create the variables that keep track of state
|
|
Packit Service |
c5cf8c |
# dirstack keeps the directory name that gnumake and similar make
|
|
Packit Service |
c5cf8c |
# implementations echo as a directory is entered or exited (this can generate
|
|
Packit Service |
c5cf8c |
# a great deal of output noise that can obscure important data. However, when
|
|
Packit Service |
c5cf8c |
# a problem *does* occur, this directory information is valuable.
|
|
Packit Service |
c5cf8c |
# dirprinted is a parallel array that indicates whether the corresponding
|
|
Packit Service |
c5cf8c |
# directory entry has been printed.
|
|
Packit Service |
c5cf8c |
@dirstack = ();
|
|
Packit Service |
c5cf8c |
@dirprinted = ();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Process arguments to select options
|
|
Packit Service |
c5cf8c |
foreach $_ (@ARGV) {
|
|
Packit Service |
c5cf8c |
if (/^--?debug/) { $debug = 1; }
|
|
Packit Service |
c5cf8c |
elsif (/^--?showdir/) { $debugDir = 1; }
|
|
Packit Service |
c5cf8c |
elsif (/^--?summary/) { $summaryOutput = 1; }
|
|
Packit Service |
c5cf8c |
elsif (/^--?notrimcompileline/) { $trimCompileLine = 0; }
|
|
Packit Service |
c5cf8c |
elsif (/^-/) {
|
|
Packit Service |
c5cf8c |
print STDERR "Unrecognized argument $_\n";
|
|
Packit Service |
c5cf8c |
print STDERR "clmake [ -debug ] [ -showdir ] [ -summary ]\n";
|
|
Packit Service |
c5cf8c |
exit(1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else { last; }
|
|
Packit Service |
c5cf8c |
shift @ARGV;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
# Read lines. Categorize lines as commands and output. This
|
|
Packit Service |
c5cf8c |
# script suppresses commands that generate no extra output.
|
|
Packit Service |
c5cf8c |
# The approach is to read a line and then read the next line.
|
|
Packit Service |
c5cf8c |
# While the line is a command and the next line is not, output the
|
|
Packit Service |
c5cf8c |
# line.
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# We use eof() (see man perlfun) so that we can accept filenames on the
|
|
Packit Service |
c5cf8c |
# commandline.
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
$cmdline = "";
|
|
Packit Service |
c5cf8c |
T:
|
|
Packit Service |
c5cf8c |
while ($line = <>) {
|
|
Packit Service |
c5cf8c |
if (eof()) { next; }
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
$line =~ s/\r//; # remove returns from line (de DOSify)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Read the next line, including handling any continuation lines
|
|
Packit Service |
c5cf8c |
while ($line =~ /\\$/) {
|
|
Packit Service |
c5cf8c |
print "Read continuation line (cmd) ... \n" if $debug;
|
|
Packit Service |
c5cf8c |
$line .= <>;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Check for noise
|
|
Packit Service |
c5cf8c |
foreach my $pat (@OtherNoise) {
|
|
Packit Service |
c5cf8c |
# maxlines is the maximum number of lines to match
|
|
Packit Service |
c5cf8c |
my ($beginpat,$endpat,$maxlines) = split( '<SEP>', $pat );
|
|
Packit Service |
c5cf8c |
print "Trying to match $beginpat\n" if $gDebugOther;
|
|
Packit Service |
c5cf8c |
if ($line =~ /$beginpat/) {
|
|
Packit Service |
c5cf8c |
$maxlines --;
|
|
Packit Service |
c5cf8c |
print "Found match to $beginpat\n" if $gDebugOther;
|
|
Packit Service |
c5cf8c |
# Found the beginning. Look for the end (if one requested)
|
|
Packit Service |
c5cf8c |
if ($endpat =~ /\S/) {
|
|
Packit Service |
c5cf8c |
print "Trying to match endpat $endpat\n" if $gDebugOther;
|
|
Packit Service |
c5cf8c |
while ($line = <>) {
|
|
Packit Service |
c5cf8c |
if (eof()) { last; }
|
|
Packit Service |
c5cf8c |
print "Trying to match to $line" if $gDebugOther;
|
|
Packit Service |
c5cf8c |
if ($line =~ /$endpat/) { last; }
|
|
Packit Service |
c5cf8c |
if ($maxlines-- <= 0) {
|
|
Packit Service |
c5cf8c |
print STDOUT "Failed to match $endpat; last line was $line";
|
|
Packit Service |
c5cf8c |
last;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
next T;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# Is the line a command (including a directory change?)
|
|
Packit Service |
c5cf8c |
# Check first for a directory change
|
|
Packit Service |
c5cf8c |
if ($line =~ /^\s*make.* Entering directory \`([^\']*)\'/) {
|
|
Packit Service |
c5cf8c |
my $dirname = $1;
|
|
Packit Service |
c5cf8c |
$dirstack[$#dirstack+1] = $dirname;
|
|
Packit Service |
c5cf8c |
$dirprinted[$#dirprinted+1] = 0;
|
|
Packit Service |
c5cf8c |
print ">>entering $dirname\n" if $debugDir;
|
|
Packit Service |
c5cf8c |
$cmdline = "";
|
|
Packit Service |
c5cf8c |
next;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
elsif ($line =~ /^\s*make.* Leaving directory \`([^\']*)\'/) {
|
|
Packit Service |
c5cf8c |
# We should check that the directory names match
|
|
Packit Service |
c5cf8c |
my $dirname = $1;
|
|
Packit Service |
c5cf8c |
print ">>leaving $dirname\n" if $debugDir;
|
|
Packit Service |
c5cf8c |
if ($dirname ne $dirstack[$#dirstack]) {
|
|
Packit Service |
c5cf8c |
print STDERR "Warning: leaving directory $dirname but expected to leave directory " . $dirstack[$#dirstack] . "\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
$#dirstack--;
|
|
Packit Service |
c5cf8c |
$#dirprinted--;
|
|
Packit Service |
c5cf8c |
$cmdline = "";
|
|
Packit Service |
c5cf8c |
next;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
$is_command = 0;
|
|
Packit Service |
c5cf8c |
foreach $cmdname (@commands) {
|
|
Packit Service |
c5cf8c |
if ($line =~ /^\s*$cmdname\W/) {
|
|
Packit Service |
c5cf8c |
$is_command = 1;
|
|
Packit Service |
c5cf8c |
$cmdline = $line;
|
|
Packit Service |
c5cf8c |
last;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if ($is_command) {
|
|
Packit Service |
c5cf8c |
if ($summaryOutput) {
|
|
Packit Service |
c5cf8c |
# FIXME: Summarize the command
|
|
Packit Service |
c5cf8c |
if ($terseOutput) {
|
|
Packit Service |
c5cf8c |
if ($rootSrcDir eq "") {
|
|
Packit Service |
c5cf8c |
if ($line =~ /\s(\/\S+\/src\/)/) {
|
|
Packit Service |
c5cf8c |
$rootSrcDir = $1;
|
|
Packit Service |
c5cf8c |
print "rootSrcDir = $rootSrcDir\n";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
else {
|
|
Packit Service |
c5cf8c |
$line =~ s/$rootSrcDir//g;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
# Compiler options to remove
|
|
Packit Service |
c5cf8c |
$line =~ s/-I\S+\s+//g;
|
|
Packit Service |
c5cf8c |
$line =~ s/-W\S+\s+//g;
|
|
Packit Service |
c5cf8c |
$line =~ s/-D\S+\s+//g;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
print $line;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
next;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
# If we got to this point, the line was not a recognized command or
|
|
Packit Service |
c5cf8c |
# ignorable output. Output the line, including the command if this
|
|
Packit Service |
c5cf8c |
# is the first time. We can then forget the command
|
|
Packit Service |
c5cf8c |
if ($#dirstack >= 0 && $dirprinted[$#dirstack] == 0) {
|
|
Packit Service |
c5cf8c |
print "In directory: ". $dirstack[$#dirstack] . "\n";
|
|
Packit Service |
c5cf8c |
$dirprinted[$#dirstack] = 1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if ($cmdline ne "") {
|
|
Packit Service |
c5cf8c |
if ($trimCompileLine) {
|
|
Packit Service |
c5cf8c |
# Simplify the command line before printing
|
|
Packit Service |
c5cf8c |
$cmdline =~ s/-I\S*\s+//g;
|
|
Packit Service |
c5cf8c |
$cmdline =~ s/-ansi//g;
|
|
Packit Service |
c5cf8c |
$cmdline =~ s/-W\S*\s+//g;
|
|
Packit Service |
c5cf8c |
$cmdline =~ s/-DHAVE_CONFIG_H//g;
|
|
Packit Service |
c5cf8c |
$cmdline =~ s/-DGCC_WALL//g;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
# We could print a newline here to separate commands
|
|
Packit Service |
c5cf8c |
print $cmdline;
|
|
Packit Service |
c5cf8c |
$cmdline = "";
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
print $line;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#
|
|
Packit Service |
c5cf8c |
# ToDo:
|
|
Packit Service |
c5cf8c |
# Handle lines containing just ----, e.g., patterns of the form
|
|
Packit Service |
c5cf8c |
# -*
|