diff options
author | H. Peter Anvin <hpa@zytor.com> | 2005-03-06 19:38:38 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2005-03-06 19:38:38 +0000 |
commit | 359b03755262459481eb796502b8155ad24febfe (patch) | |
tree | 9d4793ad42a3c748ac491ecc291b04b65a5328eb | |
parent | d79fa90921dca3428c89d28b18ea9a1019a69d6a (diff) | |
download | klibc-359b03755262459481eb796502b8155ad24febfe.tar.gz |
Support -l/-L, -M*, and -print-klibc-* options in klccklibc-0.215
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | klcc.in | 42 | ||||
-rwxr-xr-x | makeklcc.pl | 8 |
3 files changed, 37 insertions, 18 deletions
diff --git a/Makefile b/Makefile index a512aa308aeda..7a9b92e8d61b1 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,10 @@ $(CROSS)klibc.config: Makefile echo 'STRIPFLAGS=$(STRIPFLAGS)' >> $@ echo 'EMAIN=$(EMAIN)' >> $@ echo 'BITSIZE=$(BITSIZE)' >> $@ - echo 'INSTALLDIR=$(INSTALLDIR)' >> $@ + echo 'prefix=$(INSTALLDIR)' >> $@ + echo 'bindir=$(INSTALLDIR)/$(KCROSS)bin' >> $@ + echo 'libdir=$(INSTALLDIR)/$(KCROSS)lib' >> $@ + echo 'includedir=$(INSTALLDIR)/$(KCROSS)include' >> $@ $(CROSS)klcc: klcc.in $(CROSS)klibc.config makeklcc.pl $(PERL) makeklcc.pl klcc.in $(CROSS)klibc.config \ @@ -1,19 +1,22 @@ # -*- perl -*- # Standard includes -@includes = ("-I${INSTALLDIR}/${KCROSS}include/arch/${ARCH}", - "-I${INSTALLDIR}/${KCROSS}include/bits${BITSIZE}", - "-I${INSTALLDIR}/${KCROSS}include"); +@includes = ("-I${prefix}/${KCROSS}include/arch/${ARCH}", + "-I${prefix}/${KCROSS}include/bits${BITSIZE}", + "-I${prefix}/${KCROSS}include"); # Default optimization options (for compiles without -g) @optopt = @OPTFLAGS; @goptopt = ('-O'); +# Standard library directories +@stdlibpath = ("-L${prefix}/${KCROSS}lib"); + # Options and libraries to pass to ld; shared versus static -@staticopt = ("$INSTALLDIR/${KCROSS}lib/crt0.o"); -@staticlib = ("$INSTALLDIR/${KCROSS}lib/libc.a"); -@sharedopt = (@EMAIN, "$INSTALLDIR/${KCROSS}lib/interp.o"); -@sharedlib = ('-R', "$INSTALLDIR/${KCROSS}lib/libc.so"); +@staticopt = ("${prefix}/${KCROSS}lib/crt0.o"); +@staticlib = ("${prefix}/${KCROSS}lib/libc.a"); +@sharedopt = (@EMAIN, "${prefix}/${KCROSS}lib/interp.o"); +@sharedlib = ('-R', "${prefix}/${KCROSS}lib/libc.so"); # Returns the language (-x option string) for a specific extension. sub filename2lang($) { @@ -88,6 +91,7 @@ open(NULL, '+<', '/dev/null') or die "$0: cannot open /dev/null\n"; @ccopt = (); @ldopt = (); +@libs = (); @files = (); # List of files %flang = (); # Languages for files @@ -117,7 +121,7 @@ while ( defined($a = shift(@ARGV)) ) { } elsif ( $a =~ /^-([fmwWQdO]|std=|ansi|pedantic)/ ) { # Options to gcc push(@ccopt, $a); - } elsif ( $a =~ /^-([DUI])(.*)$/ ) { + } elsif ( $a =~ /^-([DUI]|M[FQT])(.*)$/ ) { # Options to gcc, which can take either a conjoined argument # (-DFOO) or a disjoint argument (-D FOO) push(@ccopt, $a); @@ -125,10 +129,9 @@ while ( defined($a = shift(@ARGV)) ) { } elsif ( $a eq '-include' ) { # Options to gcc which always take a disjoint argument push(@ccopt, $a, shift(@ARGV)); - } elsif ( $a =~ /^-[gp]/ ) { - # Debugging options to gcc *and* ld + } elsif ( $a =~ /^-(g|pg)/ || $a eq '-p' ) { + # Debugging options to gcc push(@ccopt, $a); - push(@ldopt, $a); $debugging = 1; } elsif ( $a eq '-v' ) { push(@ccopt, $a); @@ -150,7 +153,18 @@ while ( defined($a = shift(@ARGV)) ) { } elsif ( $a eq '-nostdinc' ) { push(@ccopt, $a); @includes = (); - } elsif ( $a =~ /^(-print|--help)/ ) { + } elsif ( $a =~ /^-([lL])(.*)$/ ) { + # Libraries + push(@libs, $a); + push(@libs, shift(@ARGV)) if ( $2 eq '' ); + } elsif ( $a =~ /^-print-klibc-(.*)$/ ) { + if ( defined($conf{$1}) ) { + print ${$conf{$1}}, "\n"; + exit 0; + } else { + die "$0: unknown option: $a\n"; + } + } elsif ( $a =~ /^(-print|-dump|--help)/ ) { # Pseudo-operations; just pass to gcc and don't do anything else push(@ccopt, $a); $operation = 'c' if ( $operation eq '' ); @@ -204,9 +218,9 @@ if ( $operation ne '' ) { close(LIBGCC); if ( $shared ) { - $rv = mysystem($LD, @LDFLAGS, @sharedopt, @ldopt, @outopt, @objs, @sharedlib, $libgcc); + $rv = mysystem($LD, @LDFLAGS, @sharedopt, @ldopt, @outopt, @objs, @libs, @stdlibpath, @sharedlib, $libgcc); } else { - $rv = mysystem($LD, @LDFLAGS, @staticopt, @ldopt, @outopt, @objs, @staticlib, $libgcc); + $rv = mysystem($LD, @LDFLAGS, @staticopt, @ldopt, @outopt, @objs, @libs, @stdlibpath, @staticlib, $libgcc); } unlink(@rmobjs); diff --git a/makeklcc.pl b/makeklcc.pl index ea3f8a8256af0..ba851ae93bfd3 100755 --- a/makeklcc.pl +++ b/makeklcc.pl @@ -21,9 +21,11 @@ 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"; + if ( $l =~ /^([^=]+)\=(.*)$/ ) { + $n = $1; $s = $2; + print "\$$n = \"\Q$s\E\";\n"; + print "\@$n = ", string2list($s), ";\n"; + print "\$conf{\'\L$n\E\'} = \\\$$n;\n"; } } close(KLIBCCONF); |