From: Soren A. <so...@wo...> - 2000-11-26 02:08:56
|
Oingo-Boingo! (I thought it excessively boring of me to constantly be writing just "Hello" ...), I like the output of running ld using '-cref' so much, I wrote a perl script to pretty it up and make it a bit more self-documenting. Can I share it with you, readers? Thanks. [Copied below and also attached as a .zip file due to the likelihood that the email will wrap things ruinously ..] soren andersen ---- code! ---- cut here -------- #!perl # "PipeFilterMake.p" # script by soren andersen, <sor...@ju...> # PLEASE freely copy and distribute and make # modifications to this software. # =============================================== # sample command line used run this: # > PipeFilterMake.p "make apps -o libjpeg_dll.a" # Your makefile $(LD) command must have '-cref' flag. # =============================================== require 5.005; # "qr//" operator use Local::TeeOutput; # look at CPAN use Date::Format; # ditto @lt = localtime(time); $template = '%C (UTC %z)'; my $stamp = time2str($template, time); my $hardcoded = ''; # HARDCODED PREFIX !!! my $prefix = quotemeta( $hardcoded = q'D:\MingW32\gcc-2.95.2\bin\..\lib\gcc-lib\i386-mingw32msvc\2.95.2\..\..\..\..\i386-mingw32msvc\lib' ); print STDERR '-' x 46 .qq(\nUsing pattern:\n$prefix\n\n). '-' x 46 .qq(\n); # tee STDOUT to a log file using a string literal openTee (*STDOUT, *STDOUT, ">linkmap_log.txt"); $match0 = qr'\A(Symbol) \s+ (File)'; $match1 = qr/\A([\w\@\_]+)\s+$prefix\\(.+)/; $match2 = qr/\A\s+$prefix\\(.+)/; # make -f makefile.mingw apps USE_DLL=yes -o libjpeg_dll.a open(MAKE, "$ARGV[0] | ") or die qq(\nWe Could not open the process pipe\n$!); my @Make = <MAKE>; close (MAKE); unshift @Make, '-' x 76 .qq(\nld linking cref map generated on $stamp\n) . '-' x 76 . qq(\n\$ ); # Symbol File my $hr= q(------).' ' x 53 .q(----); for (@Make) { # poor-man's Perl write() ;-) s@$match0 @qq(\"<prefix>\" is:\n $hardcoded\n\n$1). ' ' x 46 .qq(\t\t$2\n$hr\n\n)@xeg; # spaces! (46) s@$match1@${1}. ' ' x ($spcs=50 - length $1) .qq(\t\t<prefix>/lib/$2)@eg; s@$match2@' 'x 50 .qq(\t\t<prefix>/lib/$1)@eg; print ; } __END__ ---- end code ------ cut here ----------- |