Magellan Linux

Contents of /tags/mkinitrd-6_3_1/klibc/klcc/makeklcc.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1143 - (show annotations) (download)
Thu Aug 19 12:44:27 2010 UTC (13 years, 9 months ago) by niro
File MIME type: text/plain
File size: 1256 byte(s)
tagged 'mkinitrd-6_3_1'
1 #!/usr/bin/perl
2 #
3 # Combine klibc.config, klcc.in to produce a klcc script
4 #
5 # Usage: makeklcc klcc.in klibc.config perlpath
6 #
7
8 use File::Spec;
9
10 ($klccin, $klibcconf, $perlpath) = @ARGV;
11
12 sub pathsearch($) {
13 my($file) = @_;
14 my(@path);
15 my($p,$pp);
16
17 if ( $file =~ /\// ) {
18 return File::Spec->rel2abs($file);
19 }
20
21 foreach $p ( split(/\:/, $ENV{'PATH'}) ) {
22 $pp = File::Spec->rel2abs(File::Spec->catpath(undef, $p, $file));
23 return $pp if ( -x $pp );
24 }
25
26 return undef;
27 }
28
29 print "#!${perlpath}\n";
30
31 open(KLIBCCONF, "< $klibcconf\0")
32 or die "$0: cannot open $klibcconf: $!\n";
33 while ( defined($l = <KLIBCCONF>) ) {
34 chomp $l;
35 if ( $l =~ /^([^=]+)\=\s*(.*)$/ ) {
36 $n = $1; $s = $2;
37
38 if ( $n eq 'CC' || $n eq 'LD' || $n eq 'STRIP' ) {
39 $s1 = pathsearch($s);
40 die "$0: Cannot find $n: $s\n" unless ( defined($s1) );
41 $s = $s1;
42 }
43
44 print "\$$n = \"\Q$s\E\";\n";
45 print "\$conf{\'\L$n\E\'} = \\\$$n;\n";
46
47 print "\@$n = ("; $sep = '';
48 while ( $s =~ /^\s*(\S+)/ ) {
49 print $sep, "\"\Q$1\E\"";
50 $sep = ', ';
51 $s = "$'";
52 }
53 print ");\n";
54 }
55 }
56 close(KLIBCCONF);
57
58 open(KLCCIN, "< $klccin\0")
59 or die "$0: cannot open $klccin: $!\n";
60 while ( defined($l = <KLCCIN>) ) {
61 print $l;
62 }
63 close(KLCCIN);