#/usr/bin/perl # Usage: lfix cc -L ... -l ... # lfix ld -L ... -l ... while (@ARGV) { $_ = shift; if (/^-L(.*)/) { push(@liblist, $1); next; } elsif (/^-l(.*)/) { $libname = $1; foreach $dir (@liblist) { if (-f "$dir/lib$libname.a") { $_ = "$dir/lib$libname.a"; last; } elsif (-f "$dir/llib-l$libname.ln") { $_ = "$dir/llib-l$libname.ln"; last; } } } push(@newargv, $_); } # Now do the new command. exec @newargv;