summaryrefslogtreecommitdiffstats
path: root/klcc/makeklcc.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:06:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:06:04 +0000
commit2f0649f6fe411d7e07c8d56cf8ea56db53536da8 (patch)
tree778611fb52176dce1ad06c68e87b2cb348ca0f7b /klcc/makeklcc.pl
parentInitial commit. (diff)
downloadklibc-2f0649f6fe411d7e07c8d56cf8ea56db53536da8.tar.xz
klibc-2f0649f6fe411d7e07c8d56cf8ea56db53536da8.zip
Adding upstream version 2.0.13.upstream/2.0.13upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--klcc/makeklcc.pl63
1 files changed, 63 insertions, 0 deletions
diff --git a/klcc/makeklcc.pl b/klcc/makeklcc.pl
new file mode 100644
index 0000000..41c5cf4
--- /dev/null
+++ b/klcc/makeklcc.pl
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+#
+# Combine klibc.config, klcc.in to produce a klcc script
+#
+# Usage: makeklcc klcc.in klibc.config perlpath
+#
+
+use File::Spec;
+
+($klccin, $klibcconf, $perlpath) = @ARGV;
+
+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 );
+ }
+
+ return undef;
+}
+
+print "#!${perlpath}\n";
+
+open(KLIBCCONF, "< $klibcconf\0")
+ or die "$0: cannot open $klibcconf: $!\n";
+while ( defined($l = <KLIBCCONF>) ) {
+ chomp $l;
+ if ( $l =~ /^([^=]+)\=\s*(.*)$/ ) {
+ $n = $1; $s = $2;
+ my @s = split(/\s+/, $s);
+
+ if ( $n eq 'CC' || $n eq 'LD' || $n eq 'STRIP' ) {
+ $s1 = pathsearch($s[0]);
+ die "$0: Cannot find $n: $s\n" unless ( defined($s1) );
+ $s[0] = $s1;
+ }
+
+ print "\$$n = \"\Q$s\E\";\n";
+ print "\$conf{\'\L$n\E\'} = \\\$$n;\n";
+
+ print "\@$n = ("; $sep = '';
+ for (@s) {
+ print $sep, "\"\Q$_\E\"";
+ $sep = ', ';
+ }
+ print ");\n";
+ }
+}
+close(KLIBCCONF);
+
+open(KLCCIN, "< $klccin\0")
+or die "$0: cannot open $klccin: $!\n";
+while ( defined($l = <KLCCIN>) ) {
+ print $l;
+}
+close(KLCCIN);