summaryrefslogtreecommitdiff
path: root/klibc/makeklcc.pl
blob: ea3f8a8256af09e0576bcbf0454be082bc41cf67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl
#
# Combine klibc.config, klcc.in to produce a klcc script
#
# Usage: makeklcc klcc.in klibc.config perlpath
#

($klccin, $klibcconf, $perlpath) = @ARGV;

# This should probably handle quotes and escapes...
sub string2list($)
{
    my($s) = @_;

    $s =~ s/\s+/\',\'/g;
    return "(\'".$s."\')";
}

print "#!${perlpath}\n";

open(KLIBCCONF, '<', $klibcconf) or die "$0: cannot open $klibcconf: $!\n";
while ( defined($l = <KLIBCCONF>) ) {
    chomp $l;
    if ( $l =~ /=/ ) {
	print "\$$` = \"\Q$'\E\";\n";
	print "\@$` = ", string2list("$'"), ";\n";
    }
}
close(KLIBCCONF);

open(KLCCIN, '<', $klccin) or die "$0: cannot open $klccin: $!\n";
while ( defined($l = <KLCCIN>) ) {
    print $l;
}
close(KLCCIN);