Do pathname canonicalization in Perl instead of relying on invoking bash.
diff --git a/Makefile b/Makefile
index 661e64f..5071e60 100644
--- a/Makefile
+++ b/Makefile
@@ -18,12 +18,12 @@
echo 'ARCH=$(ARCH)' >> $@
echo 'CROSS=$(CROSS)' >> $@
echo 'KCROSS=$(KCROSS)' >> $@
- echo "CC=$(shell bash -c 'type -p $(CC)')" >> $@
- echo "LD=$(shell bash -c 'type -p $(LD)')" >> $@
+ echo 'CC=$(CC)' >> $@
+ echo 'LD=$(LD)' >> $@
echo 'REQFLAGS=$(filter-out -I%,$(REQFLAGS))' >> $@
echo 'OPTFLAGS=$(OPTFLAGS)' >> $@
echo 'LDFLAGS=$(LDFLAGS)' >> $@
- echo "STRIP=$(shell bash -c 'type -p $(STRIP)')" >> $@
+ echo 'STRIP=$(STRIP)' >> $@
echo 'STRIPFLAGS=$(STRIPFLAGS)' >> $@
echo 'EMAIN=$(EMAIN)' >> $@
echo 'BITSIZE=$(BITSIZE)' >> $@
diff --git a/makeklcc.pl b/makeklcc.pl
index f8a6294..7404595 100755
--- a/makeklcc.pl
+++ b/makeklcc.pl
@@ -5,8 +5,27 @@
# Usage: makeklcc klcc.in klibc.config perlpath
#
+use File::Spec;
+
($klccin, $klibcconf, $perlpath) = @ARGV;
+sub pathsearch($) {
+ my($file) = @_;
+ my(@path);
+ my($p,$pp);
+
+ if ( $file =~ /\// ) {
+ return File::Spec->rel2abs($file);
+ }
+
+ foreach $p ( split(/\:/, $ENV{'PATH'}) ) {
+ $pp = File::Spec->rel2abs(File::Spec->catpath(undef, $p, $file));
+ return $pp if ( -x $pp );
+ }
+
+ return undef;
+}
+
print "#!${perlpath}\n";
open(KLIBCCONF, '<', $klibcconf) or die "$0: cannot open $klibcconf: $!\n";
@@ -14,6 +33,13 @@
chomp $l;
if ( $l =~ /^([^=]+)\=(.*)$/ ) {
$n = $1; $s = $2;
+
+ if ( $n eq 'CC' || $n eq 'LD' || $n eq 'STRIP' ) {
+ $s1 = pathsearch($s);
+ die "$0: Cannot find $n: $s\n" unless ( defined($s1) );
+ $s = $s1;
+ }
+
print "\$$n = \"\Q$s\E\";\n";
print "\@$n = qw($s);\n";
print "\$conf{\'\L$n\E\'} = \\\$$n;\n";