chiark / gitweb /
[PATCH] klibc: version 1.0.3
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Thu, 10 Mar 2005 16:51:43 +0000 (17:51 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:51:00 +0000 (23:51 -0700)
klibc/MCONFIG
klibc/Makefile
klibc/include/stddef.h
klibc/klcc.in
klibc/makeklcc.pl
klibc/version

index 7a24b821adf5192d104716754f3fb43e469a21a8..1141b78d474bed1d9c2361240dd11d1e4ce1b9e0 100644 (file)
@@ -29,6 +29,10 @@ OBJROOT = $(SRCROOT)
 KRNLSRC = $(SRCROOT)/linux
 KRNLOBJ = $(SRCROOT)/linux
 
 KRNLSRC = $(SRCROOT)/linux
 KRNLOBJ = $(SRCROOT)/linux
 
+# klibc version information
+KLIBCVER = -D__KLIBC__=$(shell cut -d. -f1 < $(SRCROOT)/version) \
+          -D__KLIBC_MINOR__=$(shell cut -d. -f2 < $(SRCROOT)/version)
+
 ARCH    = $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
 CC     = $(CROSS)gcc
 LD      = $(CROSS)ld
 ARCH    = $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
 CC     = $(CROSS)gcc
 LD      = $(CROSS)ld
@@ -38,7 +42,7 @@ INCLUDE = -I$(SRCROOT)/include/arch/$(ARCH) \
          -I$(SRCROOT)/include/bits$(BITSIZE) \
          -I$(SRCROOT)/include \
          -I$(KRNLOBJ)/include -I$(KRNLOBJ)/include2 -I$(KRNLSRC)/include
          -I$(SRCROOT)/include/bits$(BITSIZE) \
          -I$(SRCROOT)/include \
          -I$(KRNLOBJ)/include -I$(KRNLOBJ)/include2 -I$(KRNLSRC)/include
-REQFLAGS = $(ARCHREQFLAGS) -nostdinc -iwithprefix include -D__KLIBC__ \
+REQFLAGS = $(ARCHREQFLAGS) $(KLIBCVER) -nostdinc -iwithprefix include \
           $(INCLUDE)
 LDFLAGS =
 AR      = $(CROSS)ar
           $(INCLUDE)
 LDFLAGS =
 AR      = $(CROSS)ar
index a512aa308aeda11c05d2f7454bc3d4d64a803ba0..7a9b92e8d61b1ed0c95bfd9b7662c5bb5d43af04 100644 (file)
@@ -27,7 +27,10 @@ $(CROSS)klibc.config: Makefile
        echo 'STRIPFLAGS=$(STRIPFLAGS)' >> $@
        echo 'EMAIN=$(EMAIN)' >> $@
        echo 'BITSIZE=$(BITSIZE)' >> $@
        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 \
 
 $(CROSS)klcc: klcc.in $(CROSS)klibc.config makeklcc.pl
        $(PERL) makeklcc.pl klcc.in $(CROSS)klibc.config \
index 125d2352ec2567af3455d997dbbc929dda429688..e96f28c446d7d21e280a92d9d756204805256fff 100644 (file)
@@ -6,7 +6,7 @@
 #define _STDDEF_H
 
 #ifndef __KLIBC__
 #define _STDDEF_H
 
 #ifndef __KLIBC__
-# define __KLIBC__ 1
+# error "__KLIBC__ not defined, compiler invocation error!"
 #endif
 
 #include <bitsize/stddef.h>
 #endif
 
 #include <bitsize/stddef.h>
index d8721c9a6bacda613cc19cff9c52dd83c0643b62..36c4d9b3eeeb6332b5a9d9fc369529a6db033e5f 100644 (file)
@@ -1,19 +1,22 @@
 # -*- perl -*-
 
 # Standard includes
 # -*- 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');
 
 
 # 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
 # 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($) {
 
 # Returns the language (-x option string) for a specific extension.
 sub filename2lang($) {
@@ -51,13 +54,15 @@ sub files_with_lang($$) {
 
     foreach $f ( @{$files} ) {
        $need = ${$flang}{$f};
 
     foreach $f ( @{$files} ) {
        $need = ${$flang}{$f};
-       $need = 'none' if ( $need eq 'obj' );
-       unless ( $xopt eq $need ||
-                ($xopt eq 'none' && filename2lang($f) eq $need) ) {
-           push(@as, '-x', $need);
-           $xopt = $need;
+
+       # Skip object files
+       if ( $need ne 'obj' ) {
+           unless ( $xopt eq $need ) {
+               push(@as, '-x', $need);
+               $xopt = $need;
+           }
+           push(@as, $f);
        }
        }
-       push(@as, $f);
     }
 
     return @as;
     }
 
     return @as;
@@ -88,6 +93,7 @@ open(NULL, '+<', '/dev/null') or die "$0: cannot open /dev/null\n";
 
 @ccopt = ();
 @ldopt = ();
 
 @ccopt = ();
 @ldopt = ();
+@libs  = ();
 
 @files = ();                   # List of files
 %flang = ();                   # Languages for files
 
 @files = ();                   # List of files
 %flang = ();                   # Languages for files
@@ -111,13 +117,26 @@ while ( defined($a = shift(@ARGV)) ) {
        # Not an option.  Must be a filename then.
        push(@files, $a);
        $flang{$a} = $lang || filename2lang($a);
        # Not an option.  Must be a filename then.
        push(@files, $a);
        $flang{$a} = $lang || filename2lang($a);
+    } elsif ( $a =~ /^-print-klibc-(.*)$/ ) {
+       # This test must precede -print
+       if ( defined($conf{$1}) ) {
+           print ${$conf{$1}}, "\n";
+           exit 0;
+       } else {
+           die "$0: unknown option: $a\n";
+       }
+    } elsif ( $a =~ /^(-print|-dump|--help|--version)/ ) {
+       # These share prefixes with some other options, so put this test early!
+       # Pseudo-operations; just pass to gcc and don't do anything else
+       push(@ccopt, $a);
+       $operation = 'c' if ( $operation eq '' );
     } elsif ( $a =~ /^-Wl,(.*)$/ ) {
        # -Wl used to pass options to the linker
        push(@ldopt, split(/,/, $1));
     } elsif ( $a =~ /^-Wl,(.*)$/ ) {
        # -Wl used to pass options to the linker
        push(@ldopt, split(/,/, $1));
-    } elsif ( $a =~ /^-([fmwWQdO]|std=|ansi|pedantic)/ ) {
+    } elsif ( $a =~ /^-([fmwWQdO]|std=|ansi|pedantic|M[GPD]|MMD)/ ) {
        # Options to gcc
        push(@ccopt, $a);
        # 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);
        # Options to gcc, which can take either a conjoined argument
        # (-DFOO) or a disjoint argument (-D FOO)
        push(@ccopt, $a);
@@ -125,10 +144,13 @@ 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 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 eq '-M' || $a eq '-MM' ) {
+       # gcc options, that force preprocessing mode
+       push(@ccopt, $a);
+       $operation = 'E';
+    } elsif ( $a =~ /^-[gp]/ || $a eq '-p' ) {
+       # Debugging options to gcc
        push(@ccopt, $a);
        push(@ccopt, $a);
-       push(@ldopt, $a);
        $debugging = 1;
     } elsif ( $a eq '-v' ) {
        push(@ccopt, $a);
        $debugging = 1;
     } elsif ( $a eq '-v' ) {
        push(@ccopt, $a);
@@ -147,13 +169,15 @@ while ( defined($a = shift(@ARGV)) ) {
        $strip = 1;
     } elsif ( $a eq '-o' ) {
        $output = shift(@ARGV);
        $strip = 1;
     } elsif ( $a eq '-o' ) {
        $output = shift(@ARGV);
+    } elsif ( $a eq '-x' ) {
+       $lang = shift(@ARGV);
     } elsif ( $a eq '-nostdinc' ) {
        push(@ccopt, $a);
        @includes = ();
     } elsif ( $a eq '-nostdinc' ) {
        push(@ccopt, $a);
        @includes = ();
-    } elsif ( $a =~ /^(-print|--help)/ ) {
-       # Pseudo-operations; just pass to gcc and don't do anything else
-       push(@ccopt, $a);
-       $operation = 'c' if ( $operation eq '' );
+    } elsif ( $a =~ /^-([lL])(.*)$/ ) {
+       # Libraries
+       push(@libs, $a);
+       push(@libs, shift(@ARGV)) if ( $2 eq '' );
     } else {
        die "$0: unknown option: $a\n";
     }
     } else {
        die "$0: unknown option: $a\n";
     }
@@ -170,6 +194,10 @@ if ( $operation ne '' ) {
     @outopt = ('-o', $output) if ( defined($output) );
     $rv = mysystem($CC, @ccopt, @outopt, files_with_lang(\@files, \%flang));
 } else {
     @outopt = ('-o', $output) if ( defined($output) );
     $rv = mysystem($CC, @ccopt, @outopt, files_with_lang(\@files, \%flang));
 } else {
+    if ( scalar(@files) == 0 ) {
+       die "$0: No input files!\n";
+    }
+
     @outopt = ('-o', $output || 'a.out');
 
     @objs = ();
     @outopt = ('-o', $output || 'a.out');
 
     @objs = ();
@@ -204,9 +232,9 @@ if ( $operation ne '' ) {
     close(LIBGCC);
 
     if ( $shared ) {
     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 {
     } 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);
     }
 
     unlink(@rmobjs);
index ea3f8a8256af09e0576bcbf0454be082bc41cf67..f8a6294db3faa72101eebf191ce78c0a074fbe64 100644 (file)
@@ -7,23 +7,16 @@
 
 ($klccin, $klibcconf, $perlpath) = @ARGV;
 
 
 ($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;
 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 = qw($s);\n";
+       print "\$conf{\'\L$n\E\'} = \\\$$n;\n";
     }
 }
 close(KLIBCCONF);
     }
 }
 close(KLIBCCONF);
index 136a629e2d96a8eae35522570bd18af677d66d7e..21e8796a09d4f26935ffc4879147879a153f0193 100644 (file)
@@ -1 +1 @@
-0.214
+1.0.3