From 1dda526c6679827f272ff4895c41781e999cceb2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 24 Jul 2003 15:15:48 +0000 Subject: [PATCH] * Added the GNU C Library (glibc), a big step towards full Nixification of the build and execution environment. This is very useful. For example, it allows packages built on a SuSE 8.2 system to run on a SuSE 8.1 system (this is because 8.2 has a newer glibc; packages built against it cannot be dynamically linked against older glibcs). Of course, Fix packages should not directly import glibc since that is very system-specific. Rather, they should import stdenv/stdenv.fix and in their build scripts source in $stdenv/setup, which will setup the right environment variables. The idea is that stdenv.fix provides the basic C/Unix build environment (C compiler, POSIX utilities, etc.). Note that only the ATerm package currently uses this. svn path=/nixpkgs/trunk/; revision=203 --- pkgs/aterm/aterm-build.sh | 5 +++-- pkgs/aterm/aterm.fix | 3 +++ pkgs/glibc/glibc-build.sh | 13 +++++++++++++ pkgs/glibc/glibc.fix | 16 ++++++++++++++++ pkgs/stdenv/gcc-wrapper.sh | 18 ++++++++++++++++++ pkgs/stdenv/stdenv-build.sh | 22 ++++++++++++++++++++++ pkgs/stdenv/stdenv.fix | 9 +++++++++ 7 files changed, 84 insertions(+), 2 deletions(-) create mode 100755 pkgs/glibc/glibc-build.sh create mode 100644 pkgs/glibc/glibc.fix create mode 100644 pkgs/stdenv/gcc-wrapper.sh create mode 100755 pkgs/stdenv/stdenv-build.sh create mode 100644 pkgs/stdenv/stdenv.fix diff --git a/pkgs/aterm/aterm-build.sh b/pkgs/aterm/aterm-build.sh index f92097b1d554..9ca15e18b1c5 100755 --- a/pkgs/aterm/aterm-build.sh +++ b/pkgs/aterm/aterm-build.sh @@ -1,9 +1,10 @@ #! /bin/sh -export PATH=/bin:/usr/bin +. $stdenv/setup || exit 1 tar xvfz $src || exit 1 cd aterm-* || exit 1 -LDFLAGS=-s ./configure --prefix=$out --with-gcc || exit 1 +./configure --prefix=$out || exit 1 make || exit 1 make install || exit 1 +(cd $out/lib && ln -s libATerm.a libATerm-gcc.a) || exit 1 diff --git a/pkgs/aterm/aterm.fix b/pkgs/aterm/aterm.fix index 7bb76b33ca65..a10e7579f428 100644 --- a/pkgs/aterm/aterm.fix +++ b/pkgs/aterm/aterm.fix @@ -1,9 +1,12 @@ Package( [ ("name", "aterm-2.0") , ("build", Relative("aterm/aterm-build.sh")) + , ("src", App(IncludeFix("fetchurl/fetchurl.fix"), [ ("url", "http://www.cwi.nl/projects/MetaEnv/aterm/aterm-2.0.tar.gz") , ("md5", "853474e4bcf4a85f7d38a0676b36bded") ])) + + , ("stdenv", IncludeFix("stdenv/stdenv.fix")) ] ) diff --git a/pkgs/glibc/glibc-build.sh b/pkgs/glibc/glibc-build.sh new file mode 100755 index 000000000000..79863998d249 --- /dev/null +++ b/pkgs/glibc/glibc-build.sh @@ -0,0 +1,13 @@ +#! /bin/sh + +export PATH=/bin:/usr/bin + +tar xvfj $glibcSrc || exit 1 +(cd glibc-* && tar xvfj $linuxthreadsSrc) || exit 1 + +mkdir build || exit 1 +cd build || exit 1 +../glibc-*/configure --prefix=$out --enable-add-ons || exit 1 + +make || exit 1 +make install || exit 1 diff --git a/pkgs/glibc/glibc.fix b/pkgs/glibc/glibc.fix new file mode 100644 index 000000000000..7d26b9d3442a --- /dev/null +++ b/pkgs/glibc/glibc.fix @@ -0,0 +1,16 @@ +Package( + [ ("name", "glibc-2.3.2") + + , ("build", Relative("glibc/glibc-build.sh")) + + , ("glibcSrc", App(IncludeFix("fetchurl/fetchurl.fix"), + [ ("url", "ftp://ftp.nl.net/pub/gnu/glibc/glibc-2.3.2.tar.bz2") + , ("md5", "ede969aad568f48083e413384f20753c") + ])) + + , ("linuxthreadsSrc", App(IncludeFix("fetchurl/fetchurl.fix"), + [ ("url", "ftp://ftp.nl.net/pub/gnu/glibc/glibc-linuxthreads-2.3.2.tar.bz2") + , ("md5", "894b8969cfbdf787c73e139782167607") + ])) + ] +) diff --git a/pkgs/stdenv/gcc-wrapper.sh b/pkgs/stdenv/gcc-wrapper.sh new file mode 100644 index 000000000000..fdeefe8493cf --- /dev/null +++ b/pkgs/stdenv/gcc-wrapper.sh @@ -0,0 +1,18 @@ +#! /bin/sh + +realgcc=@GCC@ +libc=@LIBC@ + +justcompile=0 +for i in $*; do + if test "$i" == "-c"; then + justcompile=1 + fi +done + +extra="-isystem $libc/include" +if test "$justcompile" != "1"; then + extra="$extra -L $libc/lib -Wl,-dynamic-linker,$libc/lib/ld-linux.so.2,-rpath,$libc/lib" +fi + +exec $realgcc $* $extra diff --git a/pkgs/stdenv/stdenv-build.sh b/pkgs/stdenv/stdenv-build.sh new file mode 100755 index 000000000000..a266e1ff445d --- /dev/null +++ b/pkgs/stdenv/stdenv-build.sh @@ -0,0 +1,22 @@ +#! /bin/sh + +export PATH=/bin:/usr/bin + +mkdir $out || exit 1 +mkdir $out/bin || exit 1 + +echo "export PATH=$out/bin:/bin:/usr/bin" >> $out/setup || exit 1 + +gcc=/usr/bin/gcc + +sed \ + -e s^@GCC\@^$gcc^g \ + -e s^@LIBC\@^$glibc^g \ + < $gccwrapper > $out/bin/gcc || exit 1 +chmod +x $out/bin/gcc || exit 1 + +sed \ + -e s^@GCC\@^$g++^g \ + -e s^@LIBC\@^$glibc^g \ + < $gccwrapper > $out/bin/g++ || exit 1 +chmod +x $out/bin/g++ || exit 1 diff --git a/pkgs/stdenv/stdenv.fix b/pkgs/stdenv/stdenv.fix new file mode 100644 index 000000000000..375b7a01d84d --- /dev/null +++ b/pkgs/stdenv/stdenv.fix @@ -0,0 +1,9 @@ +Package( + [ ("name", "stdenv-linux") + , ("build", Relative("stdenv/stdenv-build.sh")) + + , ("gccwrapper", Relative("stdenv/gcc-wrapper.sh")) + + , ("glibc", IncludeFix("glibc/glibc.fix")) + ] +)