X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=klibc%2Fmakeklcc.pl;h=74045955fdcd75db015f85e765a45ef8b7256749;hp=ea3f8a8256af09e0576bcbf0454be082bc41cf67;hb=accff726856a0b3258a413d823a534f4f437e6b2;hpb=e5f053b5312a0f8d62a2bcff8ddb095052d228bc diff --git a/klibc/makeklcc.pl b/klibc/makeklcc.pl old mode 100644 new mode 100755 index ea3f8a825..74045955f --- a/klibc/makeklcc.pl +++ b/klibc/makeklcc.pl @@ -5,15 +5,25 @@ # Usage: makeklcc klcc.in klibc.config perlpath # +use File::Spec; + ($klccin, $klibcconf, $perlpath) = @ARGV; -# This should probably handle quotes and escapes... -sub string2list($) -{ - my($s) = @_; +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 ); + } - $s =~ s/\s+/\',\'/g; - return "(\'".$s."\')"; + return undef; } print "#!${perlpath}\n"; @@ -21,9 +31,18 @@ print "#!${perlpath}\n"; open(KLIBCCONF, '<', $klibcconf) or die "$0: cannot open $klibcconf: $!\n"; while ( defined($l = ) ) { chomp $l; - if ( $l =~ /=/ ) { - print "\$$` = \"\Q$'\E\";\n"; - print "\@$` = ", string2list("$'"), ";\n"; + 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"; } } close(KLIBCCONF);