chiark / gitweb /
[PATCH] unmap db-file after use
[elogind.git] / klibc / makeklcc.pl
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 ($klccin, $klibcconf, $perlpath) = @ARGV;
9
10 # This should probably handle quotes and escapes...
11 sub string2list($)
12 {
13     my($s) = @_;
14
15     $s =~ s/\s+/\',\'/g;
16     return "(\'".$s."\')";
17 }
18
19 print "#!${perlpath}\n";
20
21 open(KLIBCCONF, '<', $klibcconf) or die "$0: cannot open $klibcconf: $!\n";
22 while ( defined($l = <KLIBCCONF>) ) {
23     chomp $l;
24     if ( $l =~ /=/ ) {
25         print "\$$` = \"\Q$'\E\";\n";
26         print "\@$` = ", string2list("$'"), ";\n";
27     }
28 }
29 close(KLIBCCONF);
30
31 open(KLCCIN, '<', $klccin) or die "$0: cannot open $klccin: $!\n";
32 while ( defined($l = <KLCCIN>) ) {
33     print $l;
34 }
35 close(KLCCIN);
36