~ubuntu-branches/ubuntu/hardy/klibc/hardy-updates

« back to all changes in this revision

Viewing changes to klcc/makeklcc.pl

  • Committer: Bazaar Package Importer
  • Author(s): Jeff Bailey
  • Date: 2006-01-04 20:24:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060104202452-ec4v3n829rymukuv
Tags: 1.1.15-0ubuntu1
* New upstream version.

* Patch to fix compilation on parisc64 kernels.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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) or die "$0: cannot open $klibcconf: $!\n";
 
32
while ( defined($l = <KLIBCCONF>) ) {
 
33
    chomp $l;
 
34
    if ( $l =~ /^([^=]+)\=\s*(.*)$/ ) {
 
35
        $n = $1;  $s = $2;
 
36
 
 
37
        if ( $n eq 'CC' || $n eq 'LD' || $n eq 'STRIP' ) {
 
38
            $s1 = pathsearch($s);
 
39
            die "$0: Cannot find $n: $s\n" unless ( defined($s1) );
 
40
            $s = $s1;
 
41
        }
 
42
 
 
43
        print "\$$n = \"\Q$s\E\";\n";
 
44
        print "\$conf{\'\L$n\E\'} = \\\$$n;\n";
 
45
 
 
46
        print "\@$n = ("; $sep = '';
 
47
        while ( $s =~ /^\s*(\S+)/ ) {
 
48
            print $sep, "\"\Q$1\E\"";
 
49
            $sep = ', ';
 
50
            $s = $';
 
51
        }
 
52
        print ");\n";
 
53
    }
 
54
}
 
55
close(KLIBCCONF);
 
56
 
 
57
open(KLCCIN, '<', $klccin) or die "$0: cannot open $klccin: $!\n";
 
58
while ( defined($l = <KLCCIN>) ) {
 
59
    print $l;
 
60
}
 
61
close(KLCCIN);
 
62