summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra2003-11-02 22:25:26 +0000
committerEelco Dolstra2003-11-02 22:25:26 +0000
commit549a0a807f06709b39716f819b1d27756e431359 (patch)
treeba1d7d0342279d8bfdb2801c6fc473f8bfa43b09
parent354561704620d61e28dec08bf317ce283cb23c0d (diff)
* Stdenv for Linux, i.e., with a Nix-built glibc.
svn path=/nixpkgs/trunk/; revision=461
-rwxr-xr-xpkgs-ng/devel/libs/glibc/builder.sh26
-rw-r--r--pkgs-ng/devel/libs/glibc/default.fix20
-rw-r--r--pkgs-ng/devel/libs/glibc/glibc-2.3.2-sscanf-1.patch68
-rwxr-xr-xpkgs-ng/os-specific/linux/kernel-headers/builder.sh12
-rw-r--r--pkgs-ng/os-specific/linux/kernel-headers/default.fix10
-rw-r--r--pkgs-ng/stdenv/generic/gcc-wrapper.sh4
-rw-r--r--pkgs-ng/stdenv/generic/setup.sh4
-rw-r--r--pkgs-ng/stdenv/nix-linux/boot.fix13
-rw-r--r--pkgs-ng/stdenv/nix-linux/default.fix25
-rw-r--r--pkgs-ng/stdenv/nix-linux/posthook.sh0
-rw-r--r--pkgs-ng/stdenv/nix-linux/prehook-boot.sh12
-rw-r--r--pkgs-ng/stdenv/nix-linux/prehook.sh12
-rw-r--r--pkgs-ng/system/all-packages-generic.fix14
-rw-r--r--pkgs-ng/system/all-packages.fix31
14 files changed, 237 insertions, 14 deletions
diff --git a/pkgs-ng/devel/libs/glibc/builder.sh b/pkgs-ng/devel/libs/glibc/builder.sh
new file mode 100755
index 000000000000..7503e73a171e
--- /dev/null
+++ b/pkgs-ng/devel/libs/glibc/builder.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+# glibc cannot have itself in its rpath.
+export NIX_NO_SELF_RPATH=1
+. $stdenv/setup || exit 1
+
+tar xvfj $glibcSrc || exit 1
+(cd glibc-* && tar xvfj $linuxthreadsSrc) || exit 1
+
+(cd glibc-* && patch -p1 < $vaargsPatch) || exit 1
+
+mkdir build || exit 1
+cd build || exit 1
+LDFLAGS=-Wl,-S ../glibc-*/configure --prefix=$out --enable-add-ons --disable-profile || exit 1
+
+make || exit 1
+make install || exit 1
+make localedata/install-locales || exit 1
+strip -S $out/lib/*.a $out/lib/*.so $out/lib/gconv/*.so
+strip -s $out/bin/* $out/sbin/* $out/libexec/*
+
+ln -sf /etc/ld.so.cache $out/etc/ld.so.cache || exit 1
+
+(cd $out/include && ln -s $kernelHeaders/include/* .) || exit 1
+
+exit 0
diff --git a/pkgs-ng/devel/libs/glibc/default.fix b/pkgs-ng/devel/libs/glibc/default.fix
new file mode 100644
index 000000000000..9d75bfc3140c
--- /dev/null
+++ b/pkgs-ng/devel/libs/glibc/default.fix
@@ -0,0 +1,20 @@
+{stdenv, fetchurl, kernelHeaders}: derivation
+  { name = "glibc-2.3.2"
+  , system = stdenv.system
+  , builder = ./builder.sh
+  , glibcSrc = fetchurl
+      { url = ftp://ftp.nl.net/pub/gnu/glibc/glibc-2.3.2.tar.bz2
+      , md5 = "ede969aad568f48083e413384f20753c"
+      }
+  , linuxthreadsSrc = fetchurl
+      { url = ftp://ftp.nl.net/pub/gnu/glibc/glibc-linuxthreads-2.3.2.tar.bz2
+      , md5 = "894b8969cfbdf787c73e139782167607"
+      }
+
+  # This is a patch to make glibc compile under GCC 3.3.  Presumably
+  # later releases of glibc won't need this.
+  , vaargsPatch = ./glibc-2.3.2-sscanf-1.patch
+
+  , stdenv = stdenv
+  , kernelHeaders = kernelHeaders
+  }
diff --git a/pkgs-ng/devel/libs/glibc/glibc-2.3.2-sscanf-1.patch b/pkgs-ng/devel/libs/glibc/glibc-2.3.2-sscanf-1.patch
new file mode 100644
index 000000000000..78940884cbe7
--- /dev/null
+++ b/pkgs-ng/devel/libs/glibc/glibc-2.3.2-sscanf-1.patch
@@ -0,0 +1,68 @@
+Submitted By: David Shust (www.shustring.com)
+Date: 2003-08-15
+Initial Package Version: 2.3.2
+Origin: glibc CVS changes performed by Roland McGrath
+Description: patches stdio-common/sscanf.c, libio/{swprintf.c, swscanf.c}
+
+diff -Naur glibc-2.3.2/libio/swprintf.c glibc-2.3.2-new/libio/swprintf.c
+--- glibc-2.3.2/libio/swprintf.c	2001-07-07 19:21:03.000000000 +0000
++++ glibc-2.3.2-new/libio/swprintf.c	2003-08-15 19:36:42.000000000 +0000
+@@ -1,4 +1,5 @@
+-/* Copyright (C) 1991,1995,1997,1998,1999,2000 Free Software Foundation, Inc.
++/* Copyright (C) 1991,1995,1997,1998,1999,2000,2003
++	Free Software Foundation, Inc.
+    This file is part of the GNU C Library.
+ 
+    The GNU C Library is free software; you can redistribute it and/or
+@@ -22,10 +23,7 @@
+ /* Write formatted output into S, according to the format string FORMAT.  */
+ /* VARARGS3 */
+ int
+-swprintf (s, n, format)
+-     wchar_t *s;
+-     size_t n;
+-     const wchar_t *format;
++swprintf (wchar_t *s, size_t n, const wchar_t *format, ...)
+ {
+   va_list arg;
+   int done;
+diff -Naur glibc-2.3.2/libio/swscanf.c glibc-2.3.2-new/libio/swscanf.c
+--- glibc-2.3.2/libio/swscanf.c	2001-07-07 19:21:03.000000000 +0000
++++ glibc-2.3.2-new/libio/swscanf.c	2003-08-15 19:36:42.000000000 +0000
+@@ -1,4 +1,4 @@
+-/* Copyright (C) 1991, 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
++/* Copyright (C) 1991,1995,1996,1998,1999,2003 Free Software Foundation, Inc.
+    This file is part of the GNU C Library.
+ 
+    The GNU C Library is free software; you can redistribute it and/or
+@@ -22,9 +22,7 @@
+ /* Read formatted input from S, according to the format string FORMAT.  */
+ /* VARARGS2 */
+ int
+-swscanf (s, format)
+-     const wchar_t *s;
+-     const wchar_t *format;
++swscanf (const wchar_t *s, const wchar_t *format, ...)
+ {
+   va_list arg;
+   int done;
+diff -Naur glibc-2.3.2/stdio-common/sscanf.c glibc-2.3.2-new/stdio-common/sscanf.c
+--- glibc-2.3.2/stdio-common/sscanf.c	2002-08-10 18:09:08.000000000 +0000
++++ glibc-2.3.2-new/stdio-common/sscanf.c	2003-08-15 19:36:24.000000000 +0000
+@@ -1,4 +1,4 @@
+-/* Copyright (C) 1991,95,96,98,2002 Free Software Foundation, Inc.
++/* Copyright (C) 1991,1995,1996,1998,2002,2003 Free Software Foundation, Inc.
+    This file is part of the GNU C Library.
+ 
+    The GNU C Library is free software; you can redistribute it and/or
+@@ -27,9 +27,7 @@
+ /* Read formatted input from S, according to the format string FORMAT.  */
+ /* VARARGS2 */
+ int
+-sscanf (s, format)
+-     const char *s;
+-     const char *format;
++sscanf (const char *s, const char *format, ...)
+ {
+   va_list arg;
+   int done;
diff --git a/pkgs-ng/os-specific/linux/kernel-headers/builder.sh b/pkgs-ng/os-specific/linux/kernel-headers/builder.sh
new file mode 100755
index 000000000000..3afc94f02463
--- /dev/null
+++ b/pkgs-ng/os-specific/linux/kernel-headers/builder.sh
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+. $stdenv/setup || exit 1
+
+tar xvfj $src || exit 1
+cd linux-* || exit 1
+make include/linux/version.h || exit 1
+mkdir $out || exit 1
+mkdir $out/include || exit 1
+cp -prvd include/linux include/asm-i386 $out/include || exit 1
+cd $out/include || exit 1
+ln -s asm-i386 asm || exit 1
diff --git a/pkgs-ng/os-specific/linux/kernel-headers/default.fix b/pkgs-ng/os-specific/linux/kernel-headers/default.fix
new file mode 100644
index 000000000000..bb34420aa00f
--- /dev/null
+++ b/pkgs-ng/os-specific/linux/kernel-headers/default.fix
@@ -0,0 +1,10 @@
+{stdenv, fetchurl}: derivation
+  { name = "linux-headers-2.4.22-i386"
+  , system = stdenv.system
+  , builder = ./builder.sh
+  , src = fetchurl
+      { url = ftp://ftp.nl.kernel.org/pub/linux/kernel/v2.4/linux-2.4.22.tar.bz2
+      , md5 = "75dc85149b06ac9432106b8941eb9f7b"
+      }
+  , stdenv = stdenv
+  }
diff --git a/pkgs-ng/stdenv/generic/gcc-wrapper.sh b/pkgs-ng/stdenv/generic/gcc-wrapper.sh
index f743c96ec2f0..f68612d2c1e7 100644
--- a/pkgs-ng/stdenv/generic/gcc-wrapper.sh
+++ b/pkgs-ng/stdenv/generic/gcc-wrapper.sh
@@ -24,10 +24,10 @@ extra=($NIX_CFLAGS_COMPILE)
 if test "$justcompile" != "1"; then
     extra=(${extra[@]} $NIX_CFLAGS_LINK)
     for i in $NIX_LDFLAGS; do
-	extra=(${extra[@]} "-Wl,$i")
+        extra=(${extra[@]} "-Wl,$i")
     done
     if test "$NIX_STRIP_DEBUG" == "1"; then
-	extra=(${extra[@]} -g0 -Wl,-s)
+        extra=(${extra[@]} -g0 -Wl,-s)
     fi
 fi
 
diff --git a/pkgs-ng/stdenv/generic/setup.sh b/pkgs-ng/stdenv/generic/setup.sh
index a3dc8aea11d5..25b84bb5edcc 100644
--- a/pkgs-ng/stdenv/generic/setup.sh
+++ b/pkgs-ng/stdenv/generic/setup.sh
@@ -52,7 +52,9 @@ for i in $oldbuildinputs; do
 done
 
 # Add the output as an rpath.
-export NIX_LDFLAGS="-rpath $out/lib $NIX_LDFLAGS"
+if test "$NIX_NO_SELF_RPATH" != "1"; then
+    export NIX_LDFLAGS="-rpath $out/lib $NIX_LDFLAGS"
+fi
 
 # Strip debug information by default.
 export NIX_STRIP_DEBUG=1
diff --git a/pkgs-ng/stdenv/nix-linux/boot.fix b/pkgs-ng/stdenv/nix-linux/boot.fix
new file mode 100644
index 000000000000..92098d65e0e2
--- /dev/null
+++ b/pkgs-ng/stdenv/nix-linux/boot.fix
@@ -0,0 +1,13 @@
+{system, glibc}: (import ../generic)
+  { name = "stdenv-linux-boot"
+  , system = system
+  , prehook = ./prehook-boot.sh
+  , posthook = ./posthook.sh
+  , initialPath = "/usr/local /usr /"
+  , param1 = ""
+  , param2 = ""
+  , param3 = ""
+  , param4 = glibc
+  , param5 = ""
+  , noSysDirs = true
+  }
diff --git a/pkgs-ng/stdenv/nix-linux/default.fix b/pkgs-ng/stdenv/nix-linux/default.fix
new file mode 100644
index 000000000000..aee52e90dd9f
--- /dev/null
+++ b/pkgs-ng/stdenv/nix-linux/default.fix
@@ -0,0 +1,25 @@
+{bootStdenv, pkgs, glibc}: (import ../generic)
+  { name = "stdenv-nix-linux"
+  , system = bootStdenv.system
+  , prehook = ./prehook.sh
+  , posthook = ./posthook.sh
+  , initialPath =
+      [ pkgs.coreutils
+      , pkgs.findutils
+      , pkgs.diffutils
+      , pkgs.gnused
+      , pkgs.gnugrep
+      , pkgs.gawk
+      , pkgs.gnutar
+      , pkgs.gzip
+      , pkgs.binutils
+      , pkgs.gnumake
+      , pkgs.gcc
+      ]
+  , param1 = pkgs.bash
+  , param2 = pkgs.gcc
+  , param3 = pkgs.binutils
+  , param4 = glibc
+  , param5 = ""
+  , noSysDirs = true
+  }
diff --git a/pkgs-ng/stdenv/nix-linux/posthook.sh b/pkgs-ng/stdenv/nix-linux/posthook.sh
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/pkgs-ng/stdenv/nix-linux/posthook.sh
diff --git a/pkgs-ng/stdenv/nix-linux/prehook-boot.sh b/pkgs-ng/stdenv/nix-linux/prehook-boot.sh
new file mode 100644
index 000000000000..780c5aa56532
--- /dev/null
+++ b/pkgs-ng/stdenv/nix-linux/prehook-boot.sh
@@ -0,0 +1,12 @@
+export SHELL=/bin/sh
+
+export NIX_CC=/usr/bin/gcc
+export NIX_CXX=/usr/bin/g++
+export NIX_LD=/usr/bin/ld
+
+export NIX_CFLAGS_COMPILE="-isystem $param4/include $NIX_CFLAGS_COMPILE"
+export NIX_CFLAGS_LINK="-L$param4/lib $NIX_CFLAGS_LINK"
+export NIX_LDFLAGS="-dynamic-linker $param4/lib/ld-linux.so.2 -rpath $param4/lib $NIX_LDFLAGS"
+
+export NIX_LIBC_INCLUDES="$param4/include"
+export NIX_LIBC_LIBS="$param4/lib"
diff --git a/pkgs-ng/stdenv/nix-linux/prehook.sh b/pkgs-ng/stdenv/nix-linux/prehook.sh
new file mode 100644
index 000000000000..cc38a9c174d5
--- /dev/null
+++ b/pkgs-ng/stdenv/nix-linux/prehook.sh
@@ -0,0 +1,12 @@
+export SHELL=$param1
+
+export NIX_CC=$param2/bin/gcc
+export NIX_CXX=$param2/bin/g++
+export NIX_LD=$param3/bin/ld
+
+export NIX_CFLAGS_COMPILE="-isystem $param4/include $NIX_CFLAGS_COMPILE"
+export NIX_CFLAGS_LINK="-L$param4/lib -L$param2/lib $NIX_CFLAGS_LINK"
+export NIX_LDFLAGS="-dynamic-linker $param4/lib/ld-linux.so.2 -rpath $param4/lib -rpath $param2/lib $NIX_LDFLAGS"
+
+export NIX_LIBC_INCLUDES="$param4/include"
+export NIX_LIBC_LIBS="$param4/lib"
diff --git a/pkgs-ng/system/all-packages-generic.fix b/pkgs-ng/system/all-packages-generic.fix
index d26641654e59..b8fea1bf96d5 100644
--- a/pkgs-ng/system/all-packages-generic.fix
+++ b/pkgs-ng/system/all-packages-generic.fix
@@ -87,9 +87,23 @@
       , stdenv = stdenv
       }
 
+  # devel/libs/glibc
+  , glibc = (import ../devel/libs/glibc)
+      { fetchurl = fetchurl
+      , stdenv = stdenv
+      , kernelHeaders = kernelHeaders
+      }
+
   # devel/libs/aterm
   , aterm = (import ../devel/libs/aterm)
       { fetchurl = fetchurl
       , stdenv = stdenv
       }
+
+  # os-specific/linux/kernel-headers
+  , kernelHeaders = (import ../os-specific/linux/kernel-headers)
+      { fetchurl = fetchurl
+      , stdenv = stdenv
+      }
+
   }
diff --git a/pkgs-ng/system/all-packages.fix b/pkgs-ng/system/all-packages.fix
index e38549bb01f0..4410ce7f7b96 100644
--- a/pkgs-ng/system/all-packages.fix
+++ b/pkgs-ng/system/all-packages.fix
@@ -17,25 +17,34 @@
   # be used with care, since many Nix packages will not build properly
   # with it (e.g., because they require GNU Make).
   , stdenvNative = (import ../stdenv/native) {system = system}
+  , stdenvNativePkgs = allPackages {system = system, stdenv = stdenvNative}
 
   # The Nix build environment.
-  , stdenvNixPkgs = allPackages {system = system, stdenv = stdenvNative}
   , stdenvNix = (import ../stdenv/nix)
       { bootStdenv = stdenvNative
-      , pkgs = stdenvNixPkgs
+      , pkgs = stdenvNativePkgs
       }
+  , stdenvNixPkgs = allPackages {system = system, stdenv = stdenvNix}
 
   # The Linux build environment consists of the Nix build environment
   # built against the GNU C Library.
-  , stdenvLinux = (import ../stdenv/nix-linux) {baseStdenv = stdenvNix}
-
-  # Select the right one.
-  , stdenv =
-      if system == "i686-suse-linux"
-      then stdenvNix
-      else stdenvNix
+  , stdenvLinuxGlibc = stdenvNativePkgs.glibc
+  , stdenvLinuxBoot = (import ../stdenv/nix-linux/boot.fix)
+      { system = system
+      , glibc = stdenvLinuxGlibc
+      }
+  , stdenvLinuxBootPkgs = allPackages {system = system, stdenv = stdenvLinuxBoot}
 
-  # Instantiate.
-  , body = allPackages {system = system, stdenv = stdenv}
+  , stdenvLinux = (import ../stdenv/nix-linux)
+      { bootStdenv = stdenvLinuxBoot
+      , pkgs = stdenvLinuxBootPkgs
+      , glibc = stdenvLinuxGlibc
+      }
+  , stdenvLinuxPkgs = allPackages {system = system, stdenv = stdenvLinux}
 
+  # Select the right instantiation.
+  , body =
+      if system == "i686-suse-linux"
+      then stdenvLinuxPkgs
+      else stdenvNixPkgs
   }