summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/compilers/gcc/4.2/default.nix6
-rw-r--r--pkgs/development/compilers/gcc/4.2/siginfo_t.patch15
-rw-r--r--pkgs/development/compilers/gcc/4.3/default.nix16
-rw-r--r--pkgs/development/compilers/gcc/4.4/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/4.4/sources.nix14
-rwxr-xr-xpkgs/development/compilers/gcc/4.4/update-gcc.sh4
-rw-r--r--pkgs/development/compilers/gcc/4.7/builder.sh5
-rw-r--r--pkgs/development/compilers/gcc/4.7/default.nix40
-rw-r--r--pkgs/development/compilers/gcc/4.8/arm-eabi.patch230
-rw-r--r--pkgs/development/compilers/gcc/4.8/builder.sh245
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix525
-rw-r--r--pkgs/development/compilers/gcc/4.8/gfortran-driving.patch20
-rw-r--r--pkgs/development/compilers/gcc/4.8/gnat-cflags.patch33
-rw-r--r--pkgs/development/compilers/gcc/4.8/java-jvgenmain-link.patch17
-rw-r--r--pkgs/development/compilers/gcc/4.8/libstdc++-target.patch32
-rw-r--r--pkgs/development/compilers/gcc/4.8/no-sys-dirs.patch41
-rwxr-xr-xpkgs/development/compilers/ghc/ghc-get-packages.sh21
-rw-r--r--pkgs/development/compilers/llvm/default.nix7
-rw-r--r--pkgs/development/compilers/openjdk/default.nix1
-rw-r--r--pkgs/development/interpreters/perl/5.14/default.nix3
-rw-r--r--pkgs/development/interpreters/perl/5.14/ld-shared.patch11
-rw-r--r--pkgs/development/interpreters/perl/5.16/default.nix35
-rw-r--r--pkgs/development/interpreters/perl/5.16/ld-shared.patch11
-rw-r--r--pkgs/development/interpreters/perl/5.16/no-sys-dirs.patch113
-rw-r--r--pkgs/development/interpreters/python/2.6/default.nix2
-rw-r--r--pkgs/development/interpreters/python/2.7/default.nix2
-rw-r--r--pkgs/development/libraries/acl/default.nix4
-rw-r--r--pkgs/development/libraries/attr/default.nix4
-rw-r--r--pkgs/development/libraries/cloog/default.nix4
-rw-r--r--pkgs/development/libraries/coin3d/default.nix9
-rw-r--r--pkgs/development/libraries/coin3d/gcc-4.8.patch38
-rw-r--r--pkgs/development/libraries/ctl/default.nix8
-rw-r--r--pkgs/development/libraries/ctl/gcc47.patch15
-rw-r--r--pkgs/development/libraries/dbus-cplusplus/default.nix6
-rw-r--r--pkgs/development/libraries/gettext/default.nix22
-rw-r--r--pkgs/development/libraries/gettext/no-gets.patch42
-rw-r--r--pkgs/development/libraries/glib/default.nix5
-rw-r--r--pkgs/development/libraries/glibc/2.17/common.nix5
-rw-r--r--pkgs/development/libraries/glibc/2.17/fix_path_attribute_in_getconf.patch6
-rw-r--r--pkgs/development/libraries/gmp/4.3.2.nix4
-rw-r--r--pkgs/development/libraries/gmp/5.1.x.nix (renamed from pkgs/development/libraries/gmp/5.1.1.nix)9
-rw-r--r--pkgs/development/libraries/gsl/default.nix4
-rw-r--r--pkgs/development/libraries/gsl/disable-fma.patch32
-rw-r--r--pkgs/development/libraries/icu/default.nix4
-rw-r--r--pkgs/development/libraries/isl/default.nix10
-rw-r--r--pkgs/development/libraries/isl/fix-gcc-build.diff12
-rw-r--r--pkgs/development/libraries/kerberos/krb5.nix8
-rw-r--r--pkgs/development/libraries/libarchive/default.nix8
-rw-r--r--pkgs/development/libraries/libofa/curl-types.patch13
-rw-r--r--pkgs/development/libraries/libofa/default.nix17
-rw-r--r--pkgs/development/libraries/libofa/gcc-4.x.patch12
-rw-r--r--pkgs/development/libraries/libofa/libofa-0.9.3-gcc-4.3.patch36
-rw-r--r--pkgs/development/libraries/libofa/libofa-0.9.3-gcc-4.patch39
-rw-r--r--pkgs/development/libraries/libproxy/default.nix8
-rw-r--r--pkgs/development/libraries/libssh/default.nix6
-rw-r--r--pkgs/development/libraries/libxslt/default.nix30
-rw-r--r--pkgs/development/libraries/libxslt/patch-ah.patch69
-rw-r--r--pkgs/development/libraries/mpc/default.nix4
-rw-r--r--pkgs/development/libraries/mpfr/3.1.2.nix51
-rw-r--r--pkgs/development/libraries/mpfr/default.nix28
-rw-r--r--pkgs/development/libraries/ncurses/5_4.nix6
-rw-r--r--pkgs/development/libraries/ncurses/default.nix11
-rw-r--r--pkgs/development/libraries/ncurses/patch-ac40
-rw-r--r--pkgs/development/libraries/ois/default.nix13
-rw-r--r--pkgs/development/libraries/openssl/default.nix4
-rw-r--r--pkgs/development/libraries/pcre/default.nix9
-rw-r--r--pkgs/development/libraries/ppl/default.nix8
-rw-r--r--pkgs/development/libraries/ppl/upstream-based.patch42
-rw-r--r--pkgs/development/libraries/qca2/default.nix2
-rw-r--r--pkgs/development/libraries/qca2/gcc47.patch12
-rw-r--r--pkgs/development/libraries/strigi/default.nix2
-rw-r--r--pkgs/development/libraries/strigi/export_bufferedstream.patch12
-rw-r--r--pkgs/development/libraries/sword/default.nix2
-rw-r--r--pkgs/development/libraries/sword/gcc47.patch35
-rw-r--r--pkgs/development/libraries/v8/default.nix5
-rw-r--r--pkgs/development/libraries/vigra/default.nix4
-rw-r--r--pkgs/development/libraries/xbase/default.nix8
-rw-r--r--pkgs/development/libraries/zlib/default.nix6
-rw-r--r--pkgs/development/lisp-modules/stumpwm/default.nix8
-rw-r--r--pkgs/development/tools/build-managers/cmake/762-13887.patch17
-rw-r--r--pkgs/development/tools/build-managers/cmake/default.nix14
-rw-r--r--pkgs/development/tools/build-managers/cmake/search-path.patch72
-rwxr-xr-xpkgs/development/tools/build-managers/cmake/setup-hook.sh17
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix28
-rw-r--r--pkgs/development/tools/misc/elfutils/default.nix12
-rw-r--r--pkgs/development/tools/misc/gnum4/default.nix10
-rw-r--r--pkgs/development/tools/misc/gnum4/no-gets.patch26
-rw-r--r--pkgs/development/tools/misc/gnum4/readlink-EINVAL.patch18
-rw-r--r--pkgs/development/tools/misc/texinfo/4.9.nix10
-rw-r--r--pkgs/development/tools/misc/texinfo/5.2.nix (renamed from pkgs/development/tools/misc/texinfo/5.1.nix)8
-rw-r--r--pkgs/development/tools/parsing/alex/2.3.1.nix1
-rw-r--r--pkgs/development/tools/parsing/alex/2.3.2.nix1
-rw-r--r--pkgs/development/tools/parsing/alex/2.3.3.nix1
-rw-r--r--pkgs/development/tools/parsing/alex/2.3.5.nix1
-rw-r--r--pkgs/development/tools/parsing/alex/adapt-crazy-perl-regex-for-cpp-4.8.0.patch12
-rw-r--r--pkgs/development/tools/parsing/bison/2.x.nix6
-rw-r--r--pkgs/development/tools/parsing/bison/3.x.nix8
-rw-r--r--pkgs/development/tools/parsing/flex/default.nix (renamed from pkgs/development/tools/parsing/flex/flex-2.5.35.nix)0
-rw-r--r--pkgs/development/tools/parsing/flex/flex-2.5.33.nix20
-rw-r--r--pkgs/development/tools/parsing/flex/flex-2.5.34.nix19
-rw-r--r--pkgs/development/tools/parsing/flex/flex-2.5.4a.nix12
-rw-r--r--pkgs/development/tools/parsing/happy/1.18.4.nix1
-rw-r--r--pkgs/development/tools/parsing/happy/1.18.5.nix1
-rw-r--r--pkgs/development/tools/parsing/happy/1.18.6.nix1
-rw-r--r--pkgs/development/tools/parsing/happy/1.18.8.nix1
-rw-r--r--pkgs/development/tools/parsing/happy/adapt-crazy-perl-regex-for-cpp-4.8.0.patch12
106 files changed, 2019 insertions, 562 deletions
diff --git a/pkgs/development/compilers/gcc/4.2/default.nix b/pkgs/development/compilers/gcc/4.2/default.nix
index 68a174cc5797..69cac159d4a5 100644
--- a/pkgs/development/compilers/gcc/4.2/default.nix
+++ b/pkgs/development/compilers/gcc/4.2/default.nix
@@ -30,11 +30,11 @@ stdenv.mkDerivation {
       url = "mirror://gnu/gcc/gcc-${version}/gcc-fortran-${version}.tar.bz2";
       sha256 = "013yqiqhdavgxzjryvylgf3lcnknmw89fx41jf2v4899srn0bhkg";
     });
-    
+
   patches =
-    [./pass-cxxcpp.patch]
+    [./pass-cxxcpp.patch ./siginfo_t.patch]
     ++ optional noSysDirs [./no-sys-dirs.patch];
-    
+
   inherit noSysDirs profiledCompiler staticCompiler;
 
   buildInputs = [gmp mpfr texinfo];
diff --git a/pkgs/development/compilers/gcc/4.2/siginfo_t.patch b/pkgs/development/compilers/gcc/4.2/siginfo_t.patch
new file mode 100644
index 000000000000..bfb9f9753728
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.2/siginfo_t.patch
@@ -0,0 +1,15 @@
+https://bbs.archlinux.org/viewtopic.php?id=144949
+--- a/gcc/config/i386/linux-unwind.h	2011-01-03 20:52:22.000000000 +0000
++++ b/gcc/config/i386/linux-unwind.h	2012-07-06 12:23:51.562859470 +0100
+@@ -133,9 +133,9 @@
+     {
+       struct rt_sigframe {
+ 	int sig;
+-	struct siginfo *pinfo;
++	siginfo_t *pinfo;
+ 	void *puc;
+-	struct siginfo info;
++	siginfo_t info;
+ 	struct ucontext uc;
+       } *rt_ = context->cfa;
+       /* The void * cast is necessary to avoid an aliasing warning.
diff --git a/pkgs/development/compilers/gcc/4.3/default.nix b/pkgs/development/compilers/gcc/4.3/default.nix
index 7dd5be781859..4446876ab1f8 100644
--- a/pkgs/development/compilers/gcc/4.3/default.nix
+++ b/pkgs/development/compilers/gcc/4.3/default.nix
@@ -29,7 +29,7 @@ assert langVhdl -> gnat != null;
 with stdenv.lib;
 
 let
-  version = "4.3.4";
+  version = "4.3.6";
 
   crossConfigureFlags =
     "--target=${cross.config}" +
@@ -54,27 +54,27 @@ in
 
 stdenv.mkDerivation ({
   name = "${name}-${version}" + crossNameAddon;
-  
+
   builder = ./builder.sh;
-  
+
   src =
     optional /*langC*/ true (fetchurl {
       url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
-      sha256 = "1yk80nwyw8vkpw8d3x7lkg3zrv3ngjqlvj0i8zslzgj7a27q729i";
+      sha256 = "0ygrfw3hgp48hkqipbl9lw38f27npigc2sm6f01g9iswpq1igbw6";
     }) ++
     optional langCC (fetchurl {
       url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
-      sha256 = "0d8pyk5c9zmph25f4fl63vd8vhljj6ildbxpz2hr594g5i6pplpq";
+      sha256 = "105xz3991b57zx3146xwlpchdb2sjmlknclvi1iac2gawm4mhxhf";
     }) ++
     optional langFortran (fetchurl {
       url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2";
-      sha256 = "1xf2njykv1qcgxiqwj693dxjf77ss1rcxirylvnsp5hs89mdlj12";
+      sha256 = "12bqvf53hvhrwjnh101vn9frb5g8cr98cra4f11dzhzs4ppydpi1";
     }) ++
     optional langJava (fetchurl {
       url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2";
-      sha256 = "1v3krhxi3zyaqfj0x8dbxvg67fjp29cr1psyf71r9zf757p3vqsw";
+      sha256 = "03w6jln9gmdv149s774rlw4rzi2zhbqna54r86cd6mql8flmy7fs";
     });
-    
+
   patches =
     [ ./pass-cxxcpp.patch ./libmudflap-cpp.patch ./siginfo_t_fix.patch ]
     ++ optional noSysDirs ./no-sys-dirs.patch
diff --git a/pkgs/development/compilers/gcc/4.4/default.nix b/pkgs/development/compilers/gcc/4.4/default.nix
index 60e7baa77812..4d896a14e8f7 100644
--- a/pkgs/development/compilers/gcc/4.4/default.nix
+++ b/pkgs/development/compilers/gcc/4.4/default.nix
@@ -31,7 +31,7 @@ assert langVhdl     -> gnat != null;
 
 with stdenv.lib;
 
-let version = "4.4.6";
+let version = "4.4.7";
     javaEcj = fetchurl {
       # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
       # `configure' time.
diff --git a/pkgs/development/compilers/gcc/4.4/sources.nix b/pkgs/development/compilers/gcc/4.4/sources.nix
index 357cc2634edc..5517e7c3b922 100644
--- a/pkgs/development/compilers/gcc/4.4/sources.nix
+++ b/pkgs/development/compilers/gcc/4.4/sources.nix
@@ -1,26 +1,26 @@
 /* Automatically generated by `update-gcc.sh', do not edit.
-   For GCC 4.4.6.  */
+   For GCC 4.4.7.  */
 { fetchurl, optional, version, langC, langCC, langFortran, langJava, langAda }:
 
-assert version == "4.4.6";
+assert version == "4.4.7";
 optional /* langC */ true (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
-  sha256 = "c2959820de3e42eee6b1d381586992f26430f0083b9a51db31d706080fc9b44a";
+  sha256 = "c4663b7023909a4a075d3c2b2e17f6e082a9625aebfd0ce7f1d7817e44bf5542";
 }) ++
 optional langCC (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
-  sha256 = "6d5d2dacab9569472e4caa291abe94017a9b19574b9b0d866de7b04702634ddf";
+  sha256 = "1882ff29be51eeb3fb349cbcda9df200a5c3cd20c97dd1d593101e0998b3c469";
 }) ++
 optional langFortran (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2";
-  sha256 = "2b9998716a16b80f4cf843ce81da1cf58ce116e0b85422e3004ce4454e8ff923";
+  sha256 = "545a1e8e97d9364de4408c6a91830f9051ce24b4fbfbfdc56e72c7b4be17ebdd";
 }) ++
 optional langJava (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2";
-  sha256 = "7c8c12eac21d2a5c605ea4d9b7aa52e482354205b801bc93d62603b6f0956b35";
+  sha256 = "3c31ddd80f945b797d8d4ed7761426c26343781c361ec1b33bcea9874cc4c6c0";
 }) ++
 optional langAda (fetchurl {
   url = "mirror://gcc/releases/gcc-${version}/gcc-ada-${version}.tar.bz2";
-  sha256 = "771ef0e90abf61208ce84689bed15391ad249287e36a28e816d6a044035af0c6";
+  sha256 = "fb9f30b85d48838390554b948d137487f0db09ad5f8ba73ca4d7ca35765c6ed8";
 }) ++
 []
diff --git a/pkgs/development/compilers/gcc/4.4/update-gcc.sh b/pkgs/development/compilers/gcc/4.4/update-gcc.sh
index 6b0bbb993309..03297fbadd64 100755
--- a/pkgs/development/compilers/gcc/4.4/update-gcc.sh
+++ b/pkgs/development/compilers/gcc/4.4/update-gcc.sh
@@ -21,7 +21,7 @@ options["g++"]="langCC"
 options["fortran"]="langFortran"
 options["java"]="langJava"
 options["ada"]="langAda"
-options["go"]="langGo"
+#options["go"]="langGo"
 
 cat > "$out"<<EOF
 /* Automatically generated by \`$(basename $0)', do not edit.
@@ -32,7 +32,7 @@ cat > "$out"<<EOF
 assert version == "${version}";
 EOF
 
-for component in core g++ fortran java ada go
+for component in core g++ fortran java ada #go
 do
     dir="ftp.gnu.org/gnu/gcc/gcc-${version}"
     file="gcc-${component}-${version}.tar.bz2"
diff --git a/pkgs/development/compilers/gcc/4.7/builder.sh b/pkgs/development/compilers/gcc/4.7/builder.sh
index 37400fba5bf5..dc6fdd935613 100644
--- a/pkgs/development/compilers/gcc/4.7/builder.sh
+++ b/pkgs/development/compilers/gcc/4.7/builder.sh
@@ -155,7 +155,7 @@ if test -n "$targetConfig"; then
     dontStrip=1
 fi
 
-
+providedPreConfigure="$preConfigure";
 preConfigure() {
     if test -n "$newlibSrc"; then
         tar xvf "$newlibSrc" -C ..
@@ -188,6 +188,9 @@ preConfigure() {
         configureFlags="$configureFlags --with-build-sysroot=`pwd`/.."
     fi
 
+    # Eval the preConfigure script from nix expression.
+    eval $providedPreConfigure;
+    env;
     # Perform the build in a different directory.
     mkdir ../build
     cd ../build
diff --git a/pkgs/development/compilers/gcc/4.7/default.nix b/pkgs/development/compilers/gcc/4.7/default.nix
index 4f260d75afcc..951288dc0244 100644
--- a/pkgs/development/compilers/gcc/4.7/default.nix
+++ b/pkgs/development/compilers/gcc/4.7/default.nix
@@ -278,21 +278,42 @@ stdenv.mkDerivation ({
     ++ (optional stdenv.isDarwin gnused)
     ;
 
-  configureFlagsArray = stdenv.lib.optionals
-    (ppl != null && ppl ? dontDisableStatic && ppl.dontDisableStatic)
-        [ "--with-host-libstdcxx=-lstdc++ -lgcc_s" ];
+  NIX_LDFLAGS = stdenv.lib.optionalString  stdenv.isSunOS "-lm -ldl";
+
+  preConfigure = ''
+    configureFlagsArray=(
+      ${stdenv.lib.optionalString (ppl != null && ppl ? dontDisableStatic && ppl.dontDisableStatic)
+        "'--with-host-libstdcxx=-lstdc++ -lgcc_s'"}
+      ${stdenv.lib.optionalString (ppl != null && stdenv.isSunOS)
+        "\"--with-host-libstdcxx=-Wl,-rpath,\$prefix/lib/amd64 -lstdc++\"
+         \"--with-boot-ldflags=-L../prev-x86_64-pc-solaris2.11/libstdc++-v3/src/.libs\""}
+    );
+    ${stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit)
+      ''
+        export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
+        export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
+        export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
+        export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
+      ''}
+    '';
 
   # 'iant' at #go-nuts@freenode, gccgo maintainer, said that
   # they have a bug in 4.7.1 if adding "--disable-static"
-  dontDisableStatic = langGo;
+  dontDisableStatic = langGo || staticCompiler;
 
   configureFlags = "
+    ${if stdenv.isSunOS then
+      " --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " +
+      # On Illumos/Solaris GNU as is preferred
+      " --with-gnu-as --without-gnu-ld "
+      else ""}
+    --enable-lto
     ${if enableMultilib then "" else "--disable-multilib"}
     ${if enableShared then "" else "--disable-shared"}
-    ${if enablePlugin then "--enable-plugin" else ""}
-    ${if ppl != null then "--with-ppl=${ppl}" else ""}
+    ${if enablePlugin then "--enable-plugin" else "--disable-plugin"}
+    ${if ppl != null then "--with-ppl=${ppl} --disable-ppl-version-check" else ""}
     ${if cloog != null then
-      "--with-cloog=${cloog} --enable-cloog-backend=isl"
+      "--with-cloog=${cloog} --disable-cloog-version-check --enable-cloog-backend=isl"
       else ""}
     ${if langJava then
       "--with-ecj-jar=${javaEcj} " +
@@ -407,7 +428,9 @@ stdenv.mkDerivation ({
   # Needed for the cross compilation to work
   AR = "ar";
   LD = "ld";
-  CC = "gcc";
+  # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
+  CC = if stdenv.system == "x86_64-solaris" then "gcc -m64"
+       else "gcc";
 
   # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
   # the library headers and binaries, regarless of the language being
@@ -497,6 +520,7 @@ stdenv.mkDerivation ({
   installTargets = "install-gcc install-target-libgcc";
 }
 
+
 # Strip kills static libs of other archs (hence cross != null)
 // optionalAttrs (!stripped || cross != null) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
 )
diff --git a/pkgs/development/compilers/gcc/4.8/arm-eabi.patch b/pkgs/development/compilers/gcc/4.8/arm-eabi.patch
new file mode 100644
index 000000000000..63b017062b5b
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/arm-eabi.patch
@@ -0,0 +1,230 @@
+Index: gcc-4_7-branch/libstdc++-v3/configure.host
+===================================================================
+--- gcc-4_7-branch/libstdc++-v3/configure.host	(revision 194579)
++++ gcc-4_7-branch/libstdc++-v3/configure.host	(revision 194580)
+@@ -340,7 +340,7 @@
+         fi
+     esac
+     case "${host}" in
+-      arm*-*-linux-*eabi)
++      arm*-*-linux-*eabi*)
+ 	port_specific_symbol_files="\$(srcdir)/../config/os/gnu-linux/arm-eabi-extra.ver"
+ 	;;
+     esac
+Index: gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc
+===================================================================
+--- gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc	(revision 194579)
++++ gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc	(revision 194580)
+@@ -1,5 +1,5 @@
+ // { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" }
+-// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ 
+ // 2007-05-03  Benjamin Kosnik  <bkoz@redhat.com>
+ //
+Index: gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc
+===================================================================
+--- gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc	(revision 194579)
++++ gcc-4_7-branch/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc	(revision 194580)
+@@ -1,5 +1,5 @@
+ // { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" }
+-// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ 
+ // 2007-05-03  Benjamin Kosnik  <bkoz@redhat.com>
+ //
+Index: gcc-4_7-branch/libjava/configure.ac
+===================================================================
+--- gcc-4_7-branch/libjava/configure.ac	(revision 194579)
++++ gcc-4_7-branch/libjava/configure.ac	(revision 194580)
+@@ -931,7 +931,7 @@
+     # on Darwin -single_module speeds up loading of the dynamic libraries.
+     extra_ldflags_libjava=-Wl,-single_module
+     ;;
+-arm*linux*eabi)
++arm*-*-linux*eabi*)
+     # Some of the ARM unwinder code is actually in libstdc++.  We
+     # could in principle replicate it in libgcj, but it's better to
+     # have a dependency on libstdc++.
+Index: gcc-4_7-branch/libjava/configure
+===================================================================
+--- gcc-4_7-branch/libjava/configure	(revision 194579)
++++ gcc-4_7-branch/libjava/configure	(revision 194580)
+@@ -20542,7 +20542,7 @@
+     # on Darwin -single_module speeds up loading of the dynamic libraries.
+     extra_ldflags_libjava=-Wl,-single_module
+     ;;
+-arm*linux*eabi)
++arm*-*-linux*eabi*)
+     # Some of the ARM unwinder code is actually in libstdc++.  We
+     # could in principle replicate it in libgcj, but it's better to
+     # have a dependency on libstdc++.
+Index: gcc-4_7-branch/libgcc/config.host
+===================================================================
+--- gcc-4_7-branch/libgcc/config.host	(revision 194579)
++++ gcc-4_7-branch/libgcc/config.host	(revision 194580)
+@@ -327,7 +327,7 @@
+ arm*-*-linux*)			# ARM GNU/Linux with ELF
+ 	tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix"
+ 	case ${host} in
+-	arm*-*-linux-*eabi)
++	arm*-*-linux-*eabi*)
+ 	  tmake_file="${tmake_file} arm/t-elf arm/t-bpabi arm/t-linux-eabi t-slibgcc-libgcc"
+ 	  tm_file="$tm_file arm/bpabi-lib.h"
+ 	  unwind_header=config/arm/unwind-arm.h
+Index: gcc-4_7-branch/gcc/doc/install.texi
+===================================================================
+--- gcc-4_7-branch/gcc/doc/install.texi	(revision 194579)
++++ gcc-4_7-branch/gcc/doc/install.texi	(revision 194580)
+@@ -3222,7 +3222,7 @@
+ @heading @anchor{arm-x-eabi}arm-*-eabi
+ ARM-family processors.  Subtargets that use the ELF object format
+ require GNU binutils 2.13 or newer.  Such subtargets include:
+-@code{arm-*-netbsdelf}, @code{arm-*-*linux-gnueabi}
++@code{arm-*-netbsdelf}, @code{arm-*-*linux-gnueabi*}
+ and @code{arm-*-rtemseabi}.
+ 
+ @html
+Index: gcc-4_7-branch/gcc/testsuite/gcc.target/arm/synchronize.c
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/gcc.target/arm/synchronize.c	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/gcc.target/arm/synchronize.c	(revision 194580)
+@@ -1,4 +1,4 @@
+-/* { dg-final { scan-assembler "__sync_synchronize|dmb|mcr" { target arm*-*-linux-*eabi } } } */
++/* { dg-final { scan-assembler "__sync_synchronize|dmb|mcr" { target arm*-*-linux-*eabi* } } } */
+ 
+ void *foo (void)
+ {
+Index: gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.jason/enum6.C
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.jason/enum6.C	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.jason/enum6.C	(revision 194580)
+@@ -7,10 +7,10 @@
+ // enum-size attributes should only be emitted if there are values of
+ // enum type that can escape the compilation unit, gcc cannot currently
+ // detect this; if this facility is added then this linker option should
+-// not be needed.  arm-*-linux*eabi should be a good approximation to
++// not be needed.  arm-*-linux*eabi* should be a good approximation to
+ // those platforms where the EABI supplement defines enum values to be
+ // 32 bits wide.
+-// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ 
+ #include <limits.h>
+ 
+Index: gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.other/enum4.C
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.other/enum4.C	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.other/enum4.C	(revision 194580)
+@@ -9,10 +9,10 @@
+ // enum-size attributes should only be emitted if there are values of
+ // enum type that can escape the compilation unit, gcc cannot currently
+ // detect this; if this facility is added then this linker option should
+-// not be needed.  arm-*-linux*eabi should be a good approximation to
++// not be needed.  arm-*-linux*eabi* should be a good approximation to
+ // those platforms where the EABI supplement defines enum values to be
+ // 32 bits wide.
+-// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ 
+ enum E { 
+   a = -312
+Index: gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.law/enum9.C
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.law/enum9.C	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/g++.old-deja/g++.law/enum9.C	(revision 194580)
+@@ -7,10 +7,10 @@
+ // enum-size attributes should only be emitted if there are values of
+ // enum type that can escape the compilation unit, gcc cannot currently
+ // detect this; if this facility is added then this linker option should
+-// not be needed.  arm-*-linux*eabi should be a good approximation to
++// not be needed.  arm-*-linux*eabi* should be a good approximation to
+ // those platforms where the EABI supplement defines enum values to be
+ // 32 bits wide.
+-// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ 
+ // GROUPS passed enums
+   extern "C" int printf (const char *, ...);
+Index: gcc-4_7-branch/gcc/testsuite/lib/target-supports.exp
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/lib/target-supports.exp	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/lib/target-supports.exp	(revision 194580)
+@@ -3818,7 +3818,7 @@
+ 		}
+ 	    } ""
+ 	}]
+-    } elseif { [istarget arm*-*-linux-gnueabi] } {
++    } elseif { [istarget arm*-*-linux-gnueabi*] } {
+ 	return [check_runtime sync_longlong_runtime {
+ 	    #include <stdlib.h>
+ 	    int main ()
+@@ -3860,7 +3860,7 @@
+ 	     || [istarget i?86-*-*]
+ 	     || [istarget x86_64-*-*]
+ 	     || [istarget alpha*-*-*] 
+-	     || [istarget arm*-*-linux-gnueabi] 
++	     || [istarget arm*-*-linux-gnueabi*] 
+ 	     || [istarget bfin*-*linux*]
+ 	     || [istarget hppa*-*linux*]
+ 	     || [istarget s390*-*-*] 
+@@ -3890,7 +3890,7 @@
+ 	     || [istarget i?86-*-*]
+ 	     || [istarget x86_64-*-*]
+ 	     || [istarget alpha*-*-*] 
+-	     || [istarget arm*-*-linux-gnueabi] 
++	     || [istarget arm*-*-linux-gnueabi*] 
+ 	     || [istarget hppa*-*linux*]
+ 	     || [istarget s390*-*-*] 
+ 	     || [istarget powerpc*-*-*]
+Index: gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_9.f90
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_9.f90	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_9.f90	(revision 194580)
+@@ -1,6 +1,6 @@
+ ! { dg-do run }
+ ! { dg-options "-fshort-enums" }
+-! { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++! { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ ! Program to test enumerations when option -fshort-enums is given
+ 
+ program main
+Index: gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_10.f90
+===================================================================
+--- gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_10.f90	(revision 194579)
++++ gcc-4_7-branch/gcc/testsuite/gfortran.dg/enum_10.f90	(revision 194580)
+@@ -1,7 +1,7 @@
+ ! { dg-do run }
+ ! { dg-additional-sources enum_10.c }
+ ! { dg-options "-fshort-enums -w" }
+-! { dg-options "-fshort-enums -w -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } }
++! { dg-options "-fshort-enums -w -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi* } }
+ ! Make sure short enums are indeed interoperable with the
+ ! corresponding C type.
+ 
+Index: gcc-4_7-branch/gcc/ada/gcc-interface/Makefile.in
+===================================================================
+--- gcc-4_7-branch/gcc/ada/gcc-interface/Makefile.in	(revision 194579)
++++ gcc-4_7-branch/gcc/ada/gcc-interface/Makefile.in	(revision 194580)
+@@ -1866,7 +1866,7 @@
+   LIBRARY_VERSION := $(LIB_VERSION)
+ endif
+ 
+-ifeq ($(strip $(filter-out arm% linux-gnueabi,$(arch) $(osys)-$(word 4,$(targ)))),)
++ifeq ($(strip $(filter-out arm%-linux,$(arch)-$(osys)) $(if $(findstring eabi,$(word 4,$(targ))),,$(word 4,$(targ)))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<a-intnam-linux.ads \
+   s-inmaop.adb<s-inmaop-posix.adb \
+Index: gcc-4_7-branch/gcc/config.gcc
+===================================================================
+--- gcc-4_7-branch/gcc/config.gcc	(revision 194579)
++++ gcc-4_7-branch/gcc/config.gcc	(revision 194580)
+@@ -855,7 +855,7 @@
+ 	esac
+ 	tmake_file="${tmake_file} arm/t-arm"
+ 	case ${target} in
+-	arm*-*-linux-*eabi)
++	arm*-*-linux-*eabi*)
+ 	    tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
+ 	    tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi"
+ 	    # Define multilib configuration for arm-linux-androideabi.
diff --git a/pkgs/development/compilers/gcc/4.8/builder.sh b/pkgs/development/compilers/gcc/4.8/builder.sh
new file mode 100644
index 000000000000..dc6fdd935613
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/builder.sh
@@ -0,0 +1,245 @@
+source $stdenv/setup
+
+
+export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
+mkdir $NIX_FIXINC_DUMMY
+
+
+if test "$staticCompiler" = "1"; then
+    EXTRA_LDFLAGS="-static"
+else
+    EXTRA_LDFLAGS=""
+fi
+
+# GCC interprets empty paths as ".", which we don't want.
+if test -z "$CPATH"; then unset CPATH; fi
+if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi
+echo "\$CPATH is \`$CPATH'"
+echo "\$LIBRARY_PATH is \`$LIBRARY_PATH'"
+
+if test "$noSysDirs" = "1"; then
+
+    if test -e $NIX_GCC/nix-support/orig-libc; then
+
+        # Figure out what extra flags to pass to the gcc compilers
+        # being generated to make sure that they use our glibc.
+        extraFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
+        extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
+
+        # Use *real* header files, otherwise a limits.h is generated
+        # that does not include Glibc's limits.h (notably missing
+        # SSIZE_MAX, which breaks the build).
+        export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include
+
+        # The path to the Glibc binaries such as `crti.o'.
+        glibc_libdir="$(cat $NIX_GCC/nix-support/orig-libc)/lib"
+        
+    else
+        # Hack: support impure environments.
+        extraFlags="-isystem /usr/include"
+        extraLDFlags="-L/usr/lib64 -L/usr/lib"
+        glibc_libdir="/usr/lib"
+        export NIX_FIXINC_DUMMY=/usr/include
+    fi
+
+    extraFlags="-I$NIX_FIXINC_DUMMY $extraFlags"
+    extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+
+    # BOOT_CFLAGS defaults to `-g -O2'; since we override it below,
+    # make sure to explictly add them so that files compiled with the
+    # bootstrap compiler are optimized and (optionally) contain
+    # debugging information (info "(gccinstall) Building").
+    if test -n "$dontStrip"; then
+	extraFlags="-O2 -g $extraFlags"
+    else
+	# Don't pass `-g' at all; this saves space while building.
+	extraFlags="-O2 $extraFlags"
+    fi
+
+    EXTRA_FLAGS="$extraFlags"
+    for i in $extraLDFlags; do
+        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i"
+    done
+
+    if test -n "$targetConfig"; then
+        # Cross-compiling, we need gcc not to read ./specs in order to build
+        # the g++ compiler (after the specs for the cross-gcc are created).
+        # Having LIBRARY_PATH= makes gcc read the specs from ., and the build
+        # breaks. Having this variable comes from the default.nix code to bring
+        # gcj in.
+        unset LIBRARY_PATH
+        unset CPATH
+        if test -z "$crossStageStatic"; then
+            EXTRA_TARGET_CFLAGS="-B${libcCross}/lib -idirafter ${libcCross}/include"
+            EXTRA_TARGET_LDFLAGS="-Wl,-L${libcCross}/lib -Wl,-rpath,${libcCross}/lib -Wl,-rpath-link,${libcCross}/lib"
+        fi
+    else
+        if test -z "$NIX_GCC_CROSS"; then
+            EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS"
+            EXTRA_TARGET_CXXFLAGS="$EXTRA_FLAGS"
+            EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS"
+        else
+            # This the case of cross-building the gcc.
+            # We need special flags for the target, different than those of the build
+            # Assertion:
+            test -e $NIX_GCC_CROSS/nix-support/orig-libc
+
+            # Figure out what extra flags to pass to the gcc compilers
+            # being generated to make sure that they use our glibc.
+            extraFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-cflags)"
+            extraLDFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-ldflags) $(cat $NIX_GCC_CROSS/nix-support/libc-ldflags-before)"
+
+            # Use *real* header files, otherwise a limits.h is generated
+            # that does not include Glibc's limits.h (notably missing
+            # SSIZE_MAX, which breaks the build).
+            NIX_FIXINC_DUMMY_CROSS=$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/include
+
+            # The path to the Glibc binaries such as `crti.o'.
+            glibc_dir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)"
+            glibc_libdir="$glibc_dir/lib"
+            configureFlags="$configureFlags --with-native-system-header-dir=$glibc_dir/include"
+
+            extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags"
+            extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
+
+            EXTRA_TARGET_CFLAGS="$extraFlags"
+            for i in $extraLDFlags; do
+                EXTRA_TARGET_LDFLAGS="$EXTRA_TARGET_LDFLAGS -Wl,$i"
+            done
+        fi
+    fi
+
+
+    # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
+    # the startfiles.
+    # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
+    # for the startfiles.
+    makeFlagsArray=( \
+        "${makeFlagsArray[@]}" \
+        NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+        SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+        CFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+        CXXFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+        CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+        CXXFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+        FLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+        LDFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+        LDFLAGS_FOR_TARGET="$EXTRA_TARGET_LDFLAGS $EXTRA_TARGET_LDFLAGS" \
+        )
+
+    if test -z "$targetConfig"; then
+        makeFlagsArray=( \
+            "${makeFlagsArray[@]}" \
+            BOOT_CFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \
+            BOOT_LDFLAGS="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \
+            )
+    fi
+
+    if test -n "$targetConfig" -a "$crossStageStatic" == 1; then
+        # We don't want the gcc build to assume there will be a libc providing
+        # limits.h in this stagae
+        makeFlagsArray=( \
+            "${makeFlagsArray[@]}" \
+            LIMITS_H_TEST=false \
+            )
+    else
+        makeFlagsArray=( \
+            "${makeFlagsArray[@]}" \
+            LIMITS_H_TEST=true \
+            )
+    fi
+fi
+
+if test -n "$targetConfig"; then
+    # The host strip will destroy some important details of the objects
+    dontStrip=1
+fi
+
+providedPreConfigure="$preConfigure";
+preConfigure() {
+    if test -n "$newlibSrc"; then
+        tar xvf "$newlibSrc" -C ..
+        ln -s ../newlib-*/newlib newlib
+        # Patch to get armvt5el working:
+        sed -i -e 's/ arm)/ arm*)/' newlib/configure.host
+    fi
+    # Bug - they packaged zlib
+    if test -d "zlib"; then
+        # This breaks the build without-headers, which should build only
+        # the target libgcc as target libraries.
+        # See 'configure:5370'
+        rm -Rf zlib
+    fi
+
+    if test -f "$NIX_GCC/nix-support/orig-libc"; then
+        # Patch the configure script so it finds glibc headers.  It's
+        # important for example in order not to get libssp built,
+        # because its functionality is in glibc already.
+        glibc_headers="$(cat $NIX_GCC/nix-support/orig-libc)/include"
+        sed -i \
+            -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$glibc_headers", \
+            gcc/configure
+    fi
+
+    if test -n "$crossMingw" -a -n "$crossStageStatic"; then
+        mkdir -p ../mingw
+        # --with-build-sysroot expects that:
+        cp -R $libcCross/include ../mingw
+        configureFlags="$configureFlags --with-build-sysroot=`pwd`/.."
+    fi
+
+    # Eval the preConfigure script from nix expression.
+    eval $providedPreConfigure;
+    env;
+    # Perform the build in a different directory.
+    mkdir ../build
+    cd ../build
+    configureScript=../$sourceRoot/configure
+}
+
+
+postConfigure() {
+    # Don't store the configure flags in the resulting executables.
+    sed -e '/TOPLEVEL_CONFIGURE_ARGUMENTS=/d' -i Makefile
+}
+
+
+postInstall() {
+    # Remove precompiled headers for now.  They are very big and
+    # probably not very useful yet.
+    find $out/include -name "*.gch" -exec rm -rf {} \; -prune
+
+    # Remove `fixincl' to prevent a retained dependency on the
+    # previous gcc.
+    rm -rf $out/libexec/gcc/*/*/install-tools
+    rm -rf $out/lib/gcc/*/*/install-tools
+    
+    # More dependencies with the previous gcc or some libs (gccbug stores the build command line)
+    rm -rf $out/bin/gccbug
+    # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
+    for i in $out/libexec/gcc/*/*/*; do
+        if PREV_RPATH=`patchelf --print-rpath $i`; then
+            patchelf --set-rpath `echo $PREV_RPATH | sed 's,:[^:]*bootstrap-tools/lib,,'` $i
+        fi
+    done
+
+    # Get rid of some "fixed" header files
+    rm -rf $out/lib/gcc/*/*/include/root
+
+    # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
+    for i in $out/bin/*-gcc*; do
+        if cmp -s $out/bin/gcc $i; then
+            ln -sfn gcc $i
+        fi
+    done
+
+    for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do
+        if cmp -s $out/bin/g++ $i; then
+            ln -sfn g++ $i
+        fi
+    done
+
+    eval "$postInstallGhdl"
+}
+
+genericBuild
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
new file mode 100644
index 000000000000..3e4a9bb030ca
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -0,0 +1,525 @@
+{ stdenv, fetchurl, noSysDirs
+, langC ? true, langCC ? true, langFortran ? false
+, langJava ? false
+, langAda ? false
+, langVhdl ? false
+, langGo ? false
+, profiledCompiler ? false
+, staticCompiler ? false
+, enableShared ? true
+, texinfo ? null
+, perl ? null # optional, for texi2pod (then pod2man); required for Java
+, gmp, mpfr, mpc, gettext, which
+, libelf                      # optional, for link-time optimizations (LTO)
+, ppl ? null, cloog ? null, isl ? null # optional, for the Graphite optimization framework.
+, zlib ? null, boehmgc ? null
+, zip ? null, unzip ? null, pkgconfig ? null, gtk ? null, libart_lgpl ? null
+, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null
+, libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null
+, libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null
+, gnatboot ? null
+, enableMultilib ? false
+, enablePlugin ? true             # whether to support user-supplied plug-ins
+, name ? "gcc"
+, cross ? null
+, binutilsCross ? null
+, libcCross ? null
+, crossStageStatic ? true
+, gnat ? null
+, libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
+, stripped ? true
+, gnused ? null
+}:
+
+assert langJava     -> zip != null && unzip != null
+                       && zlib != null && boehmgc != null
+                       && perl != null;  # for `--enable-java-home'
+assert langAda      -> gnatboot != null;
+assert langVhdl     -> gnat != null;
+
+# We enable the isl cloog backend.
+assert cloog != null -> isl != null;
+
+# LTO needs libelf and zlib.
+assert libelf != null -> zlib != null;
+
+# Make sure we get GNU sed.
+assert stdenv.isDarwin -> gnused != null;
+
+# The go frontend is written in c++
+assert langGo -> langCC;
+
+with stdenv.lib;
+with builtins;
+
+let version = "4.8.2";
+
+    # Whether building a cross-compiler for GNU/Hurd.
+    crossGNU = cross != null && cross.config == "i586-pc-gnu";
+
+    patches = []
+      ++ optional stdenv.isArm [ ./arm-eabi.patch ]
+      ++ optional (cross != null) ./libstdc++-target.patch
+      # ++ optional noSysDirs ./no-sys-dirs.patch
+      # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
+      # target libraries and tools.
+      ++ optional langAda ./gnat-cflags.patch
+      ++ optional langFortran ./gfortran-driving.patch;
+
+    javaEcj = fetchurl {
+      # The `$(top_srcdir)/ecj.jar' file is automatically picked up at
+      # `configure' time.
+
+      # XXX: Eventually we might want to take it from upstream.
+      url = "ftp://sourceware.org/pub/java/ecj-4.3.jar";
+      sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx";
+    };
+
+    # Antlr (optional) allows the Java `gjdoc' tool to be built.  We want a
+    # binary distribution here to allow the whole chain to be bootstrapped.
+    javaAntlr = fetchurl {
+      url = http://www.antlr.org/download/antlr-3.1.3.jar;
+      sha256 = "1f41j0y4kjydl71lqlvr73yagrs2jsg1fjymzjz66mjy7al5lh09";
+    };
+
+    xlibs = [
+      libX11 libXt libSM libICE libXtst libXrender libXrandr libXi
+      xproto renderproto xextproto inputproto randrproto
+    ];
+
+    javaAwtGtk = langJava && gtk != null;
+
+    /* Platform flags */
+    platformFlags = let
+        gccArch = stdenv.lib.attrByPath [ "platform" "gcc" "arch" ] null stdenv;
+        gccCpu = stdenv.lib.attrByPath [ "platform" "gcc" "cpu" ] null stdenv;
+        gccAbi = stdenv.lib.attrByPath [ "platform" "gcc" "abi" ] null stdenv;
+        gccFpu = stdenv.lib.attrByPath [ "platform" "gcc" "fpu" ] null stdenv;
+        gccFloat = stdenv.lib.attrByPath [ "platform" "gcc" "float" ] null stdenv;
+        gccMode = stdenv.lib.attrByPath [ "platform" "gcc" "mode" ] null stdenv;
+        withArch = if gccArch != null then " --with-arch=${gccArch}" else "";
+        withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else "";
+        withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else "";
+        withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
+        withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
+        withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
+      in
+        (withArch +
+        withCpu +
+        withAbi +
+        withFpu +
+        withFloat +
+        withMode);
+
+    /* Cross-gcc settings */
+    crossMingw = (cross != null && cross.libc == "msvcrt");
+    crossConfigureFlags = let
+        gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null cross;
+        gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross;
+        gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross;
+        gccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null cross;
+        gccFloat = stdenv.lib.attrByPath [ "gcc" "float" ] null cross;
+        gccMode = stdenv.lib.attrByPath [ "gcc" "mode" ] null cross;
+        withArch = if gccArch != null then " --with-arch=${gccArch}" else "";
+        withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else "";
+        withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else "";
+        withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else "";
+        withFloat = if gccFloat != null then " --with-float=${gccFloat}" else "";
+        withMode = if gccMode != null then " --with-mode=${gccMode}" else "";
+      in
+        "--target=${cross.config}" +
+        withArch +
+        withCpu +
+        withAbi +
+        withFpu +
+        withFloat +
+        withMode +
+        (if crossMingw && crossStageStatic then
+          " --with-headers=${libcCross}/include" +
+          " --with-gcc" +
+          " --with-gnu-as" +
+          " --with-gnu-ld" +
+          " --with-gnu-ld" +
+          " --disable-shared" +
+          " --disable-nls" +
+          " --disable-debug" +
+          " --enable-sjlj-exceptions" +
+          " --enable-threads=win32" +
+          " --disable-win32-registry"
+          else if crossStageStatic then
+          " --disable-libssp --disable-nls" +
+          " --without-headers" +
+          " --disable-threads " +
+          " --disable-libmudflap " +
+          " --disable-libgomp " +
+          " --disable-libquadmath" +
+          " --disable-shared" +
+          " --disable-decimal-float" # libdecnumber requires libc
+          else
+          " --with-headers=${libcCross}/include" +
+          " --enable-__cxa_atexit" +
+          " --enable-long-long" +
+          (if crossMingw then
+            " --enable-threads=win32" +
+            " --enable-sjlj-exceptions" +
+            " --enable-hash-synchronization" +
+            " --disable-libssp" +
+            " --disable-nls" +
+            " --with-dwarf2" +
+            # I think noone uses shared gcc libs in mingw, so we better do the same.
+            # In any case, mingw32 g++ linking is broken by default with shared libs,
+            # unless adding "-lsupc++" to any linking command. I don't know why.
+            " --disable-shared" +
+            (if cross.config == "x86_64-w64-mingw32" then
+              # To keep ABI compatibility with upstream mingw-w64
+              " --enable-fully-dynamic-string"
+              else "")
+            else (if cross.libc == "uclibc" then
+              # In uclibc cases, libgomp needs an additional '-ldl'
+              # and as I don't know how to pass it, I disable libgomp.
+              " --disable-libgomp" else "") +
+            " --enable-threads=posix" +
+            " --enable-nls" +
+            " --disable-decimal-float") # No final libdecnumber (it may work only in 386)
+          );
+    stageNameAddon = if crossStageStatic then "-stage-static" else
+      "-stage-final";
+    crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
+
+  bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
+
+in
+
+# We need all these X libraries when building AWT with GTK+.
+assert gtk != null -> (filter (x: x == null) xlibs) == [];
+
+stdenv.mkDerivation ({
+  name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon;
+
+  builder = ./builder.sh;
+
+  src = fetchurl {
+    url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
+    sha256 = "1j6dwgby4g3p3lz7zkss32ghr45zpdidrg8xvazvn91lqxv25p09";
+  };
+
+  inherit patches;
+
+  postPatch =
+    if (stdenv.isGNU
+        || (libcCross != null                  # e.g., building `gcc.crossDrv'
+            && libcCross ? crossConfig
+            && libcCross.crossConfig == "i586-pc-gnu")
+        || (crossGNU && libcCross != null))
+    then
+      # On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not
+      # in glibc, so add the right `-I' flags to the default spec string.
+      assert libcCross != null -> libpthreadCross != null;
+      let
+        libc = if libcCross != null then libcCross else stdenv.glibc;
+        gnu_h = "gcc/config/gnu.h";
+        extraCPPDeps =
+             libc.propagatedBuildInputs
+          ++ stdenv.lib.optional (libpthreadCross != null) libpthreadCross
+          ++ stdenv.lib.optional (libpthread != null) libpthread;
+        extraCPPSpec =
+          concatStrings (intersperse " "
+                          (map (x: "-I${x}/include") extraCPPDeps));
+        extraLibSpec =
+          if libpthreadCross != null
+          then "-L${libpthreadCross}/lib ${libpthreadCross.TARGET_LDFLAGS}"
+          else "-L${libpthread}/lib";
+      in
+        '' echo "augmenting \`CPP_SPEC' in \`${gnu_h}' with \`${extraCPPSpec}'..."
+           sed -i "${gnu_h}" \
+               -es'|CPP_SPEC *"\(.*\)$|CPP_SPEC "${extraCPPSpec} \1|g'
+
+           echo "augmenting \`LIB_SPEC' in \`${gnu_h}' with \`${extraLibSpec}'..."
+           sed -i "${gnu_h}" \
+               -es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
+
+           echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc}/include'..."
+           sed -i "${gnu_h}" \
+               -es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc}/include"|g'
+        ''
+    else if cross != null || stdenv.gcc.libc != null then
+      # On NixOS, use the right path to the dynamic linker instead of
+      # `/lib/ld*.so'.
+      let
+        libc = if libcCross != null then libcCross else stdenv.gcc.libc;
+      in
+        '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..."
+           for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h
+           do
+             grep -q LIBC_DYNAMIC_LINKER "$header" || continue
+             echo "  fixing \`$header'..."
+             sed -i "$header" \
+                 -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc}\3"|g'
+           done
+        ''
+    else null;
+
+  inherit noSysDirs staticCompiler langJava crossStageStatic
+    libcCross crossMingw;
+
+  nativeBuildInputs = [ texinfo which gettext ]
+    ++ (optional (perl != null) perl)
+    ++ (optional javaAwtGtk pkgconfig);
+
+  buildInputs = [ gmp mpfr mpc libelf ]
+    ++ (optional (ppl != null) ppl)
+    ++ (optional (cloog != null) cloog)
+    ++ (optional (isl != null) isl)
+    ++ (optional (zlib != null) zlib)
+    ++ (optionals langJava [ boehmgc zip unzip ])
+    ++ (optionals javaAwtGtk ([ gtk libart_lgpl ] ++ xlibs))
+    ++ (optionals (cross != null) [binutilsCross])
+    ++ (optionals langAda [gnatboot])
+    ++ (optionals langVhdl [gnat])
+
+    # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
+    # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
+    ++ (optional stdenv.isDarwin gnused)
+    ;
+
+  NIX_LDFLAGS = stdenv.lib.optionalString  stdenv.isSunOS "-lm -ldl";
+
+  preConfigure = ''
+    configureFlagsArray=(
+      ${stdenv.lib.optionalString (ppl != null && ppl ? dontDisableStatic && ppl.dontDisableStatic)
+        "'--with-host-libstdcxx=-lstdc++ -lgcc_s'"}
+      ${stdenv.lib.optionalString (ppl != null && stdenv.isSunOS)
+        "\"--with-host-libstdcxx=-Wl,-rpath,\$prefix/lib/amd64 -lstdc++\"
+         \"--with-boot-ldflags=-L../prev-x86_64-pc-solaris2.11/libstdc++-v3/src/.libs\""}
+    );
+    ${stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit)
+      ''
+        export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
+        export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
+        export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
+        export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
+      ''}
+    '';
+
+  # 'iant' at #go-nuts@freenode, gccgo maintainer, said that
+  # they have a bug in 4.7.1 if adding "--disable-static"
+  dontDisableStatic = langGo || staticCompiler;
+
+  configureFlags = "
+    ${if stdenv.isSunOS then
+      " --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " +
+      # On Illumos/Solaris GNU as is preferred
+      " --with-gnu-as --without-gnu-ld "
+      else ""}
+    --enable-lto
+    ${if enableMultilib then "" else "--disable-multilib"}
+    ${if enableShared then "" else "--disable-shared"}
+    ${if enablePlugin then "--enable-plugin" else "--disable-plugin"}
+    ${if ppl != null then "--with-ppl=${ppl} --disable-ppl-version-check" else ""}
+    ${optionalString (isl != null) "--with-isl=${isl}"}
+    ${optionalString (cloog != null) "--with-cloog=${cloog} --disable-cloog-version-check --enable-cloog-backend=isl"}
+    ${if langJava then
+      "--with-ecj-jar=${javaEcj} " +
+
+      # Follow Sun's layout for the convenience of IcedTea/OpenJDK.  See
+      # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
+      "--enable-java-home --with-java-home=\${prefix}/lib/jvm/jre "
+      else ""}
+    ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
+    ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr}" else ""}
+    --with-gmp=${gmp}
+    --with-mpfr=${mpfr}
+    --with-mpc=${mpc}
+    ${if libelf != null then "--with-libelf=${libelf}" else ""}
+    --disable-libstdcxx-pch
+    --without-included-gettext
+    --with-system-zlib
+    --enable-languages=${
+      concatStrings (intersperse ","
+        (  optional langC        "c"
+        ++ optional langCC       "c++"
+        ++ optional langFortran  "fortran"
+        ++ optional langJava     "java"
+        ++ optional langAda      "ada"
+        ++ optional langVhdl     "vhdl"
+        ++ optional langGo       "go"
+        )
+      )
+    }
+    ${if (stdenv ? glibc && cross == null)
+      then " --with-native-system-header-dir=${stdenv.glibc}/include"
+      else ""}
+    ${if langAda then " --enable-libada" else ""}
+    ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
+    ${if cross != null then crossConfigureFlags else ""}
+    ${if !bootstrap then "--disable-bootstrap" else ""}
+    ${if cross == null then platformFlags else ""}
+  ";
+
+  targetConfig = if cross != null then cross.config else null;
+
+  buildFlags = if bootstrap then
+    (if profiledCompiler then "profiledbootstrap" else "bootstrap")
+    else "";
+
+  installTargets =
+    if stripped
+    then "install-strip"
+    else "install";
+
+  crossAttrs = let
+    xgccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null stdenv.cross;
+    xgccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null stdenv.cross;
+    xgccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null stdenv.cross;
+    xgccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null stdenv.cross;
+    xgccFloat = stdenv.lib.attrByPath [ "gcc" "float" ] null stdenv.cross;
+    xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else "";
+    xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else "";
+    xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else "";
+    xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else "";
+    xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else "";
+  in {
+    AR = "${stdenv.cross.config}-ar";
+    LD = "${stdenv.cross.config}-ld";
+    CC = "${stdenv.cross.config}-gcc";
+    CXX = "${stdenv.cross.config}-gcc";
+    AR_FOR_TARGET = "${stdenv.cross.config}-ar";
+    LD_FOR_TARGET = "${stdenv.cross.config}-ld";
+    CC_FOR_TARGET = "${stdenv.cross.config}-gcc";
+    NM_FOR_TARGET = "${stdenv.cross.config}-nm";
+    CXX_FOR_TARGET = "${stdenv.cross.config}-g++";
+    # If we are making a cross compiler, cross != null
+    NIX_GCC_CROSS = if cross == null then "${stdenv.gccCross}" else "";
+    dontStrip = true;
+    configureFlags = ''
+      ${if enableMultilib then "" else "--disable-multilib"}
+      ${if enableShared then "" else "--disable-shared"}
+      ${if ppl != null then "--with-ppl=${ppl.crossDrv}" else ""}
+      ${if cloog != null then "--with-cloog=${cloog.crossDrv} --enable-cloog-backend=isl" else ""}
+      ${if langJava then "--with-ecj-jar=${javaEcj.crossDrv}" else ""}
+      ${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
+      ${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.crossDrv}" else ""}
+      --with-gmp=${gmp.crossDrv}
+      --with-mpfr=${mpfr.crossDrv}
+      --disable-libstdcxx-pch
+      --without-included-gettext
+      --with-system-zlib
+      --enable-languages=${
+        concatStrings (intersperse ","
+          (  optional langC        "c"
+          ++ optional langCC       "c++"
+          ++ optional langFortran  "fortran"
+          ++ optional langJava     "java"
+          ++ optional langAda      "ada"
+          ++ optional langVhdl     "vhdl"
+          ++ optional langGo       "go"
+          )
+        )
+      }
+      ${if langAda then " --enable-libada" else ""}
+      --target=${stdenv.cross.config}
+      ${xwithArch}
+      ${xwithCpu}
+      ${xwithAbi}
+      ${xwithFpu}
+      ${xwithFloat}
+    '';
+    buildFlags = "";
+  };
+
+
+  # Needed for the cross compilation to work
+  AR = "ar";
+  LD = "ld";
+  # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210
+  CC = if stdenv.system == "x86_64-solaris" then "gcc -m64"
+       else "gcc";
+
+  # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
+  # the library headers and binaries, regarless of the language being
+  # compiled.
+
+  # Note: When building the Java AWT GTK+ peer, the build system doesn't
+  # honor `--with-gmp' et al., e.g., when building
+  # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just
+  # add them to $CPATH and $LIBRARY_PATH in this case.
+  #
+  # Likewise, the LTO code doesn't find zlib.
+
+  CPATH = concatStrings
+            (intersperse ":" (map (x: x + "/include")
+                                  (optionals (zlib != null) [ zlib ]
+                                   ++ optionals langJava [ boehmgc ]
+                                   ++ optionals javaAwtGtk xlibs
+                                   ++ optionals javaAwtGtk [ gmp mpfr ]
+                                   ++ optional (libpthread != null) libpthread
+                                   ++ optional (libpthreadCross != null) libpthreadCross
+
+                                   # On GNU/Hurd glibc refers to Mach & Hurd
+                                   # headers.
+                                   ++ optionals (libcCross != null &&
+                                                 hasAttr "propagatedBuildInputs" libcCross)
+                                        libcCross.propagatedBuildInputs)));
+
+  LIBRARY_PATH = concatStrings
+                   (intersperse ":" (map (x: x + "/lib")
+                                         (optionals (zlib != null) [ zlib ]
+                                          ++ optionals langJava [ boehmgc ]
+                                          ++ optionals javaAwtGtk xlibs
+                                          ++ optionals javaAwtGtk [ gmp mpfr ]
+                                          ++ optional (libpthread != null) libpthread)));
+
+  EXTRA_TARGET_CFLAGS =
+    if cross != null && libcCross != null
+    then "-idirafter ${libcCross}/include"
+    else null;
+
+  EXTRA_TARGET_LDFLAGS =
+    if cross != null && libcCross != null
+    then "-B${libcCross}/lib -Wl,-L${libcCross}/lib" +
+         (optionalString (libpthreadCross != null)
+           " -L${libpthreadCross}/lib -Wl,${libpthreadCross.TARGET_LDFLAGS}")
+    else null;
+
+  passthru = { inherit langC langCC langAda langFortran langVhdl
+      langGo enableMultilib version; };
+
+  /* From gccinstall.info:
+     "parallel make is currently not supported since collisions in profile
+     collecting may occur"
+  */
+  enableParallelBuilding = !profiledCompiler;
+
+  meta = {
+    homepage = http://gcc.gnu.org/;
+    license = "GPLv3+";  # runtime support libraries are typically LGPLv3+
+    description = "GNU Compiler Collection, version ${version}"
+      + (if stripped then "" else " (with debugging info)");
+
+    longDescription = ''
+      The GNU Compiler Collection includes compiler front ends for C, C++,
+      Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well
+      as libraries for these languages (libstdc++, libgcj, libgomp,...).
+
+      GCC development is a part of the GNU Project, aiming to improve the
+      compiler used in the GNU system including the GNU/Linux variant.
+    '';
+
+    maintainers = with stdenv.lib.maintainers; [ ludo viric shlevy simons ];
+
+    # Volunteers needed for the {Cyg,Dar}win ports of *PPL.
+    # gnatboot is not available out of linux platforms, so we disable the darwin build
+    # for the gnat (ada compiler).
+    platforms = stdenv.lib.platforms.linux ++ optionals (langAda == false && libelf == null) [ "i686-darwin" ];
+  };
+}
+
+// optionalAttrs (cross != null && cross.libc == "msvcrt" && crossStageStatic) {
+  makeFlags = [ "all-gcc" "all-target-libgcc" ];
+  installTargets = "install-gcc install-target-libgcc";
+}
+
+
+# Strip kills static libs of other archs (hence cross != null)
+// optionalAttrs (!stripped || cross != null) { dontStrip = true; NIX_STRIP_DEBUG = 0; }
+)
diff --git a/pkgs/development/compilers/gcc/4.8/gfortran-driving.patch b/pkgs/development/compilers/gcc/4.8/gfortran-driving.patch
new file mode 100644
index 000000000000..70708886b405
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/gfortran-driving.patch
@@ -0,0 +1,20 @@
+This patch fixes interaction with Libtool.
+See <http://thread.gmane.org/gmane.comp.gcc.patches/258777>, for details.
+
+--- a/gcc/fortran/gfortranspec.c
++++ b/gcc/fortran/gfortranspec.c
+@@ -461,8 +461,15 @@ For more information about these matters, see the file named COPYING\n\n"));
+     {
+       fprintf (stderr, _("Driving:"));
+       for (i = 0; i < g77_newargc; i++)
++	{
++	  if (g77_new_decoded_options[i].opt_index == OPT_l)
++	    /* Make sure no white space is inserted after `-l'.  */
++	    fprintf (stderr, " -l%s",
++		     g77_new_decoded_options[i].canonical_option[1]);
++	  else
+ 	fprintf (stderr, " %s",
+ 		 g77_new_decoded_options[i].orig_option_with_args_text);
++	}
+       fprintf (stderr, "\n");
+     }
diff --git a/pkgs/development/compilers/gcc/4.8/gnat-cflags.patch b/pkgs/development/compilers/gcc/4.8/gnat-cflags.patch
new file mode 100644
index 000000000000..bf2acf065e9b
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/gnat-cflags.patch
@@ -0,0 +1,33 @@
+diff --git a/libada/Makefile.in b/libada/Makefile.in
+index f5057a0..337e0c6 100644
+--- a/libada/Makefile.in
++++ b/libada/Makefile.in
+@@ -55,7 +55,7 @@ GCC_WARN_CFLAGS = $(LOOSE_WARN)
+ WARN_CFLAGS = @warn_cflags@
+ 
+ TARGET_LIBGCC2_CFLAGS=
+-GNATLIBCFLAGS= -g -O2
++GNATLIBCFLAGS= -g -O2 $(CFLAGS)
+ GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \
+ 	-DIN_RTS @have_getipinfo@
+ 
+--- a/gcc/ada/gcc-interface/Makefile.in
++++ b/gcc/ada/gcc-interface/Makefile.in
+@@ -105,7 +105,7 @@ ADAFLAGS = -W -Wall -gnatpg -gnata
+ SOME_ADAFLAGS =-gnata
+ FORCE_DEBUG_ADAFLAGS = -g
+ GNATLIBFLAGS = -gnatpg -nostdinc
+-GNATLIBCFLAGS = -g -O2
++GNATLIBCFLAGS = -g -O2 $(CFLAGS_FOR_TARGET)
+ # Pretend that _Unwind_GetIPInfo is available for the target by default.  This
+ # should be autodetected during the configuration of libada and passed down to
+ # here, but we need something for --disable-libada and hope for the best.
+@@ -193,7 +193,7 @@ RTSDIR = rts$(subst /,_,$(MULTISUBDIR))
+ # Link flags used to build gnat tools.  By default we prefer to statically
+ # link with libgcc to avoid a dependency on shared libgcc (which is tricky
+ # to deal with as it may conflict with the libgcc provided by the system).
+-GCC_LINK_FLAGS=-static-libgcc
++GCC_LINK_FLAGS=-static-libgcc $(CFLAGS_FOR_TARGET)
+ 
+ # End of variables for you to override.
+ 
diff --git a/pkgs/development/compilers/gcc/4.8/java-jvgenmain-link.patch b/pkgs/development/compilers/gcc/4.8/java-jvgenmain-link.patch
new file mode 100644
index 000000000000..2612e8bfbbbc
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/java-jvgenmain-link.patch
@@ -0,0 +1,17 @@
+The `jvgenmain' executable must be linked against `vec.o', among others,
+since it uses its vector API.
+
+--- gcc-4.3.3/gcc/java/Make-lang.in	2008-12-05 00:00:19.000000000 +0100
++++ gcc-4.3.3/gcc/java/Make-lang.in	2009-07-03 16:11:41.000000000 +0200
+@@ -109,9 +109,9 @@ jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIB
+ 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JCFDUMP_OBJS) \
+ 		$(CPPLIBS) $(ZLIB) $(LDEXP_LIB) $(LIBS)
+ 
+-jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS)
++jvgenmain$(exeext): $(JVGENMAIN_OBJS) $(LIBDEPS) $(BUILD_RTL)
+ 	rm -f $@
+-	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) $(LIBS)
++	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JVGENMAIN_OBJS) $(BUILD_RTL) $(LIBS)
+ 
+ #
+ # Build hooks:
diff --git a/pkgs/development/compilers/gcc/4.8/libstdc++-target.patch b/pkgs/development/compilers/gcc/4.8/libstdc++-target.patch
new file mode 100644
index 000000000000..fb622b395806
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/libstdc++-target.patch
@@ -0,0 +1,32 @@
+Patch to make the target libraries 'configure' scripts find the proper CPP.
+I noticed that building the mingw32 cross compiler.
+Looking at the build script for mingw in archlinux, I think that only nixos
+needs this patch. I don't know why.
+diff --git a/Makefile.in b/Makefile.in
+index 93f66b6..d691917 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \
+ 	AR="$(AR_FOR_TARGET)"; export AR; \
+ 	AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
+ 	CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
++	CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \
+ 	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+ 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
+ 	CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
+@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \
+ RAW_CXX_TARGET_EXPORTS = \
+ 	$(BASE_TARGET_EXPORTS) \
+ 	CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
+-	CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
++	CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
++	CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
+ 
+ NORMAL_TARGET_EXPORTS = \
+ 	$(BASE_TARGET_EXPORTS) \
+-	CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
++	CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
++	CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
+ 
+ # Where to find GMP
+ HOST_GMPLIBS = @gmplibs@
diff --git a/pkgs/development/compilers/gcc/4.8/no-sys-dirs.patch b/pkgs/development/compilers/gcc/4.8/no-sys-dirs.patch
new file mode 100644
index 000000000000..79901703cb82
--- /dev/null
+++ b/pkgs/development/compilers/gcc/4.8/no-sys-dirs.patch
@@ -0,0 +1,41 @@
+diff -ru gcc-4.3.1-orig/gcc/cppdefault.c gcc-4.3.1/gcc/cppdefault.c
+--- gcc-4.3.1-orig/gcc/cppdefault.c	2007-07-26 10:37:01.000000000 +0200
++++ gcc-4.3.1/gcc/cppdefault.c	2008-06-25 17:48:23.000000000 +0200
+@@ -41,6 +41,10 @@
+ # undef CROSS_INCLUDE_DIR
+ #endif
+ 
++#undef LOCAL_INCLUDE_DIR
++#undef SYSTEM_INCLUDE_DIR
++#undef STANDARD_INCLUDE_DIR
++
+ const struct default_include cpp_include_defaults[]
+ #ifdef INCLUDE_DEFAULTS
+ = INCLUDE_DEFAULTS;
+diff -ru gcc-4.3.1-orig/gcc/gcc.c gcc-4.3.1/gcc/gcc.c
+--- gcc-4.3.1-orig/gcc/gcc.c	2008-03-02 23:55:19.000000000 +0100
++++ gcc-4.3.1/gcc/gcc.c	2008-06-25 17:52:53.000000000 +0200
+@@ -1478,10 +1478,10 @@
+ /* Default prefixes to attach to command names.  */
+ 
+ #ifndef STANDARD_STARTFILE_PREFIX_1
+-#define STANDARD_STARTFILE_PREFIX_1 "/lib/"
++#define STANDARD_STARTFILE_PREFIX_1 ""
+ #endif
+ #ifndef STANDARD_STARTFILE_PREFIX_2
+-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
++#define STANDARD_STARTFILE_PREFIX_2 ""
+ #endif
+ 
+ #ifdef CROSS_DIRECTORY_STRUCTURE  /* Don't use these prefixes for a cross compiler.  */
+--- gcc-4.3.1-orig/gcc/Makefile.in	2008-05-11 20:54:15.000000000 +0200
++++ gcc-4.3.1/gcc/Makefile.in	2008-06-25 17:48:23.000000000 +0200
+@@ -3277,7 +3281,7 @@
+   -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
+   -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
+   -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
+-  -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
++  -DLOCAL_INCLUDE_DIR=\"/no-such-dir\" \
+   -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
+   -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
+   -DPREFIX=\"$(prefix)/\" \
diff --git a/pkgs/development/compilers/ghc/ghc-get-packages.sh b/pkgs/development/compilers/ghc/ghc-get-packages.sh
deleted file mode 100755
index 9ed1455d2321..000000000000
--- a/pkgs/development/compilers/ghc/ghc-get-packages.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#! /bin/sh
-# Usage:
-#  $1: version of GHC
-#  $2: invocation path of GHC
-#  $3: prefix
-version="$1"
-if test -z "$3"; then
-  prefix="-package-conf "
-else
-  prefix="$3"
-fi
-PATH="$2:$PATH"
-IFS=":"
-for p in $PATH; do
-  PkgDir="$p/../lib/ghc-pkgs/ghc-$version"
-  for i in $PkgDir/*.installedconf; do
-    # output takes place here
-    test -f $i && echo -n " $prefix$i"
-  done
-done
-test -f "$2/../lib/ghc-$version/package.conf" && echo -n " $prefix$2/../lib/ghc-$version/package.conf"
diff --git a/pkgs/development/compilers/llvm/default.nix b/pkgs/development/compilers/llvm/default.nix
index abd3277d919e..a7129f5cef3f 100644
--- a/pkgs/development/compilers/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, perl, groff, cmake, python, libffi, binutils_gold }:
+{ stdenv, fetchurl, perl, groff, cmake, python, libffi, binutils }:
 
 let version = "3.3"; in
 
@@ -24,8 +24,9 @@ stdenv.mkDerivation rec {
   cmakeFlags = with stdenv; [
     "-DCMAKE_BUILD_TYPE=Release"
     "-DLLVM_ENABLE_FFI=ON"
-    "-DLLVM_BINUTILS_INCDIR=${binutils_gold}/include"
-  ] ++ lib.optional (!isDarwin) [ "-DBUILD_SHARED_LIBS=ON" ];
+    "-DLLVM_BINUTILS_INCDIR=${binutils}/include"
+    "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=R600" # for mesa
+  ] ++ lib.optional (!isDarwin) "-DBUILD_SHARED_LIBS=ON";
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/compilers/openjdk/default.nix b/pkgs/development/compilers/openjdk/default.nix
index 0be36379f33a..d7e42d38948f 100644
--- a/pkgs/development/compilers/openjdk/default.nix
+++ b/pkgs/development/compilers/openjdk/default.nix
@@ -108,6 +108,7 @@ stdenv.mkDerivation rec {
     "DEVTOOLS_PATH="
     "UNIXCOMMAND_PATH="
     "BOOTDIR=${jdk}"
+    "STATIC_CXX=false"
   ];
 
   configurePhase = ''
diff --git a/pkgs/development/interpreters/perl/5.14/default.nix b/pkgs/development/interpreters/perl/5.14/default.nix
index 08690e9507fa..dd4e7acf71f3 100644
--- a/pkgs/development/interpreters/perl/5.14/default.nix
+++ b/pkgs/development/interpreters/perl/5.14/default.nix
@@ -17,7 +17,8 @@ stdenv.mkDerivation rec {
   patches = 
     [ # Do not look in /usr etc. for dependencies.
       ./no-sys-dirs.patch
-    ] 
+    ]
+    ++ stdenv.lib.optional stdenv.isSunOS  ./ld-shared.patch
     ++ stdenv.lib.optional stdenv.isDarwin ./no-libutil.patch;
 
   # Build a thread-safe Perl with a dynamic libperls.o.  We need the
diff --git a/pkgs/development/interpreters/perl/5.14/ld-shared.patch b/pkgs/development/interpreters/perl/5.14/ld-shared.patch
new file mode 100644
index 000000000000..b1834ff7a1f2
--- /dev/null
+++ b/pkgs/development/interpreters/perl/5.14/ld-shared.patch
@@ -0,0 +1,11 @@
+--- perl-5.14.2/hints/solaris_2.sh.orig	2013-02-14 19:29:49.453988140 +0000
++++ perl-5.14.2/hints/solaris_2.sh	2013-02-14 19:30:31.681631019 +0000
+@@ -568,7 +568,7 @@
+ #		    ccflags="$ccflags -Wa,`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
+ #		fi
+ 		ldflags="$ldflags -m64"
+-		lddlflags="$lddlflags -G -m64"
++		lddlflags="$lddlflags -shared -m64"
+ 		;;
+ 	    *)
+ 		getconfccflags="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
diff --git a/pkgs/development/interpreters/perl/5.16/default.nix b/pkgs/development/interpreters/perl/5.16/default.nix
index a3ab0ef4b96f..a8c175453037 100644
--- a/pkgs/development/interpreters/perl/5.16/default.nix
+++ b/pkgs/development/interpreters/perl/5.16/default.nix
@@ -6,6 +6,10 @@ let
 
 in
 
+with {
+  inherit (stdenv.lib) optional optionalString;
+};
+
 stdenv.mkDerivation rec {
   name = "perl-5.16.3";
 
@@ -18,7 +22,8 @@ stdenv.mkDerivation rec {
     [ # Do not look in /usr etc. for dependencies.
       ./no-sys-dirs.patch
     ]
-    ++ stdenv.lib.optionals stdenv.isDarwin [ ./cpp-precomp.patch ./no-libutil.patch ] ;
+    ++ optional stdenv.isSunOS  ./ld-shared.patch
+    ++ stdenv.lib.optional stdenv.isDarwin [ ./cpp-precomp.patch ./no-libutil.patch ] ;
 
   # Build a thread-safe Perl with a dynamic libperls.o.  We need the
   # "installstyle" option to ensure that modules are put under
@@ -34,7 +39,7 @@ stdenv.mkDerivation rec {
       "-Dlocincpth=${libc}/include"
       "-Dloclibpth=${libc}/lib"
     ]
-    ++ stdenv.lib.optional (stdenv ? glibc) "-Dusethreads";
+    ++ optional (stdenv ? glibc) "-Dusethreads";
 
   configureScript = "${stdenv.shell} ./Configure";
 
@@ -46,12 +51,12 @@ stdenv.mkDerivation rec {
     ''
       configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3"
 
-      ${stdenv.lib.optionalString stdenv.isArm ''
+      ${optionalString stdenv.isArm ''
         configureFlagsArray=(-Dldflags="-lm -lrt")
       ''}
     '';
 
-  preBuild = stdenv.lib.optionalString (!(stdenv ? gcc && stdenv.gcc.nativeTools))
+  preBuild = optionalString (!(stdenv ? gcc && stdenv.gcc.nativeTools))
     ''
       # Make Cwd work on NixOS (where we don't have a /bin/pwd).
       substituteInPlace dist/Cwd/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'"
@@ -59,5 +64,27 @@ stdenv.mkDerivation rec {
 
   setupHook = ./setup-hook.sh;
 
+  doCheck = !stdenv.isDarwin;
+
+  # some network-related tests don't work, mostly probably due to our sandboxing
+  testsToSkip = ''
+    lib/Net/hostent.t \
+    dist/IO/t/{io_multihomed.t,io_sock.t} \
+    t/porting/{maintainers.t,regen.t} \
+    cpan/Socket/t/get{name,addr}info.t \
+  '' + optionalString stdenv.isFreeBSD ''
+    cpan/CPANPLUS/t/04_CPANPLUS-Module.t \
+    cpan/CPANPLUS/t/20_CPANPLUS-Dist-MM.t \
+  '' + " ";
+
+  postPatch = optionalString (!stdenv.isDarwin) /* this failed on Darwin, no idea why */ ''
+    for test in ${testsToSkip}; do
+      echo "Removing test" $test
+      rm "$test"
+      pat=`echo "$test" | sed 's,/,\\\\/,g'` # just escape slashes
+      sed "/^$pat/d" -i MANIFEST
+    done
+  '';
+
   passthru.libPrefix = "lib/perl5/site_perl";
 }
diff --git a/pkgs/development/interpreters/perl/5.16/ld-shared.patch b/pkgs/development/interpreters/perl/5.16/ld-shared.patch
new file mode 100644
index 000000000000..be45230c8a73
--- /dev/null
+++ b/pkgs/development/interpreters/perl/5.16/ld-shared.patch
@@ -0,0 +1,11 @@
+--- perl-5.16.2/hints/solaris_2.sh.orig	2013-02-14 19:29:49.453988140 +0000
++++ perl-5.16.2/hints/solaris_2.sh	2013-02-14 19:30:31.681631019 +0000
+@@ -568,7 +568,7 @@
+ #		    ccflags="$ccflags -Wa,`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
+ #		fi
+ 		ldflags="$ldflags -m64"
+-		lddlflags="$lddlflags -G -m64"
++		lddlflags="$lddlflags -shared -m64"
+ 		;;
+ 	    *)
+ 		getconfccflags="`getconf XBS5_LP64_OFF64_CFLAGS 2>/dev/null`"
diff --git a/pkgs/development/interpreters/perl/5.16/no-sys-dirs.patch b/pkgs/development/interpreters/perl/5.16/no-sys-dirs.patch
index 54ffb28e2065..883b24889c37 100644
--- a/pkgs/development/interpreters/perl/5.16/no-sys-dirs.patch
+++ b/pkgs/development/interpreters/perl/5.16/no-sys-dirs.patch
@@ -1,7 +1,8 @@
-diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
---- perl-5.14.2-orig/Configure	2011-09-26 11:44:34.000000000 +0200
-+++ perl-5.14.2/Configure	2012-01-20 17:05:23.089223129 +0100
-@@ -106,15 +106,7 @@
+diff --git a/Configure b/Configure
+index fdbbf20..ba1fd07 100755
+--- a/Configure
++++ b/Configure
+@@ -106,15 +106,7 @@ if test -d c:/. || ( uname -a | grep -i 'os\(/\|\)2' ) 2>&1 >/dev/null ; then
  fi
  
  : Proper PATH setting
@@ -18,7 +19,7 @@ diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
  
  for p in $paths
  do
-@@ -1311,8 +1303,7 @@
+@@ -1323,8 +1315,7 @@ archobjs=''
  archname=''
  : Possible local include directories to search.
  : Set locincpth to "" in a hint file to defeat local include searches.
@@ -28,8 +29,8 @@ diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
  :
  : no include file wanted by default
  inclwanted=''
-@@ -1328,17 +1319,12 @@
- archobjs=''
+@@ -1335,17 +1326,12 @@ DEBUGGING=''
+ 
  libnames=''
  : change the next line if compiling for Xenix/286 on Xenix/386
 -xlibpth='/usr/lib/386 /lib/386'
@@ -49,7 +50,7 @@ diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
  
  : Private path used by Configure to find libraries.  Its value
  : is prepended to libpth. This variable takes care of special
-@@ -1371,8 +1357,6 @@
+@@ -1380,8 +1366,6 @@ libswanted="sfio socket bind inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun"
  libswanted="$libswanted m crypt sec util c cposix posix ucb bsd BSD"
  : We probably want to search /usr/shlib before most other libraries.
  : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
@@ -58,7 +59,7 @@ diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
  : Do not use vfork unless overridden by a hint file.
  usevfork=false
  
-@@ -2380,7 +2364,6 @@
+@@ -2389,7 +2373,6 @@ uname
  zip
  "
  pth=`echo $PATH | sed -e "s/$p_/ /g"`
@@ -66,7 +67,7 @@ diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
  for file in $loclist; do
  	eval xxx=\$$file
  	case "$xxx" in
-@@ -4785,7 +4768,7 @@
+@@ -4708,7 +4691,7 @@ $rm -f testcpp.c testcpp.out
  : Set private lib path
  case "$plibpth" in
  '') if ./mips; then
@@ -75,7 +76,7 @@ diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
  	fi;;
  esac
  case "$libpth" in
-@@ -8390,13 +8373,8 @@
+@@ -8354,13 +8337,8 @@ esac
  echo " "
  case "$sysman" in
  '') 
@@ -91,7 +92,7 @@ diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
  	;;
  esac
  if $test -d "$sysman"; then
-@@ -19721,9 +19699,10 @@
+@@ -19742,9 +19720,10 @@ $rm_try tryp
  case "$full_ar" in
  '') full_ar=$ar ;;
  esac
@@ -103,10 +104,11 @@ diff -ru -x '*~' perl-5.14.2-orig/Configure perl-5.14.2/Configure
  
  : see what type gids are declared as in the kernel
  echo " "
-diff -ru -x '*~' perl-5.14.2-orig/ext/Errno/Errno_pm.PL perl-5.14.2/ext/Errno/Errno_pm.PL
---- perl-5.14.2-orig/ext/Errno/Errno_pm.PL	2011-09-26 11:44:34.000000000 +0200
-+++ perl-5.14.2/ext/Errno/Errno_pm.PL	2012-01-20 17:02:07.938138311 +0100
-@@ -137,11 +137,7 @@
+diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL
+index 439f254..2cdfdb0 100644
+--- a/ext/Errno/Errno_pm.PL
++++ b/ext/Errno/Errno_pm.PL
+@@ -137,11 +137,7 @@ sub get_files {
  	if ($dep =~ /(\S+errno\.h)/) {
  	     $file{$1} = 1;
  	}
@@ -119,10 +121,11 @@ diff -ru -x '*~' perl-5.14.2-orig/ext/Errno/Errno_pm.PL perl-5.14.2/ext/Errno/Er
  	# Some Linuxes have weird errno.hs which generate
  	# no #file or #line directives
  	my $linux_errno_h = -e '/usr/include/errno.h' ?
-diff -ru -x '*~' perl-5.14.2-orig/hints/freebsd.sh perl-5.14.2/hints/freebsd.sh
---- perl-5.14.2-orig/hints/freebsd.sh	2011-09-19 15:18:22.000000000 +0200
-+++ perl-5.14.2/hints/freebsd.sh	2012-01-20 17:10:37.267924044 +0100
-@@ -118,21 +118,21 @@
+diff --git a/hints/freebsd.sh b/hints/freebsd.sh
+index a67c0bb..0f07ca5 100644
+--- a/hints/freebsd.sh
++++ b/hints/freebsd.sh
+@@ -119,21 +119,21 @@ case "$osvers" in
          objformat=`/usr/bin/objformat`
          if [ x$objformat = xaout ]; then
              if [ -e /usr/lib/aout ]; then
@@ -150,3 +153,73 @@ diff -ru -x '*~' perl-5.14.2-orig/hints/freebsd.sh perl-5.14.2/hints/freebsd.sh
         ldflags="-Wl,-E "
          lddlflags="-shared "
          cccdlflags='-DPIC -fPIC'
+diff --git a/hints/linux.sh b/hints/linux.sh
+index 688c68d..c12f5f5 100644
+--- a/hints/linux.sh
++++ b/hints/linux.sh
+@@ -60,17 +60,6 @@ libswanted="$*"
+ # Debian 4.0 puts ndbm in the -lgdbm_compat library.
+ libswanted="$libswanted gdbm_compat"
+ 
+-# If you have glibc, then report the version for ./myconfig bug reporting.
+-# (Configure doesn't need to know the specific version since it just uses
+-# gcc to load the library for all tests.)
+-# We don't use __GLIBC__ and  __GLIBC_MINOR__ because they
+-# are insufficiently precise to distinguish things like
+-# libc-2.0.6 and libc-2.0.7.
+-if test -L /lib/libc.so.6; then
+-    libc=`ls -l /lib/libc.so.6 | awk '{print $NF}'`
+-    libc=/lib/$libc
+-fi
+-
+ # Configure may fail to find lstat() since it's a static/inline
+ # function in <sys/stat.h>.
+ d_lstat=define
+@@ -154,24 +143,6 @@ case "$optimize" in
+     ;;
+ esac
+ 
+-# Ubuntu 11.04 (and later, presumably) doesn't keep most libraries
+-# (such as -lm) in /lib or /usr/lib.  So we have to ask gcc to tell us
+-# where to look.  We don't want gcc's own libraries, however, so we
+-# filter those out.
+-# This could be conditional on Unbuntu, but other distributions may
+-# follow suit, and this scheme seems to work even on rather old gcc's.
+-# This unconditionally uses gcc because even if the user is using another
+-# compiler, we still need to find the math library and friends, and I don't
+-# know how other compilers will cope with that situation.
+-# Morever, if the user has their own gcc earlier in $PATH than the system gcc,
+-# we don't want its libraries. So we try to prefer the system gcc
+-# Still, as an escape hatch, allow Configure command line overrides to
+-# plibpth to bypass this check.
+-if [ -x /usr/bin/gcc ] ; then
+-    gcc=/usr/bin/gcc
+-else
+-    gcc=gcc
+-fi
+ 
+ case "$plibpth" in
+ '') plibpth=`LANG=C LC_ALL=C $gcc -print-search-dirs | grep libraries |
+@@ -345,22 +316,6 @@ sparc*)
+ 	;;
+ esac
+ 
+-# SuSE8.2 has /usr/lib/libndbm* which are ld scripts rather than
+-# true libraries. The scripts cause binding against static
+-# version of -lgdbm which is a bad idea. So if we have 'nm'
+-# make sure it can read the file
+-# NI-S 2003/08/07
+-if [ -r /usr/lib/libndbm.so  -a  -x /usr/bin/nm ] ; then
+-   if /usr/bin/nm /usr/lib/libndbm.so >/dev/null 2>&1 ; then
+-    echo 'Your shared -lndbm seems to be a real library.'
+-   else
+-    echo 'Your shared -lndbm is not a real library.'
+-    set `echo X "$libswanted "| sed -e 's/ ndbm / /'`
+-    shift
+-    libswanted="$*"
+-   fi
+-fi
+-
+ 
+ # This script UU/usethreads.cbu will get 'called-back' by Configure
+ # after it has prompted the user for whether to use threads.
diff --git a/pkgs/development/interpreters/python/2.6/default.nix b/pkgs/development/interpreters/python/2.6/default.nix
index 6192c9e11e74..6b746185b6cc 100644
--- a/pkgs/development/interpreters/python/2.6/default.nix
+++ b/pkgs/development/interpreters/python/2.6/default.nix
@@ -45,7 +45,7 @@ let
     C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
     LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
 
-    configureFlags = "--enable-shared --with-threads --enable-unicode --with-wctype-functions";
+    configureFlags = "--enable-shared --with-threads --enable-unicode";
 
     preConfigure =
       ''
diff --git a/pkgs/development/interpreters/python/2.7/default.nix b/pkgs/development/interpreters/python/2.7/default.nix
index 617be4f29f13..043094c03036 100644
--- a/pkgs/development/interpreters/python/2.7/default.nix
+++ b/pkgs/development/interpreters/python/2.7/default.nix
@@ -59,7 +59,7 @@ let
     C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
     LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
 
-    configureFlags = "--enable-shared --with-threads --enable-unicode --with-wctype-functions";
+    configureFlags = "--enable-shared --with-threads --enable-unicode";
 
     preConfigure = "${ensurePurity}" + optionalString stdenv.isCygwin
       ''
diff --git a/pkgs/development/libraries/acl/default.nix b/pkgs/development/libraries/acl/default.nix
index bc0821f39fdd..d37d8926fbdc 100644
--- a/pkgs/development/libraries/acl/default.nix
+++ b/pkgs/development/libraries/acl/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, gettext, attr }:
 
 stdenv.mkDerivation rec {
-  name = "acl-2.2.51";
+  name = "acl-2.2.52";
 
   src = fetchurl {
     url = "mirror://savannah/acl/${name}.src.tar.gz";
-    sha256 = "09aj30m49ivycl3irram8c3givc0crivjm3ymw0nhfaxrwhlb186";
+    sha256 = "08qd9s3wfhv0ajswsylnfwr5h0d7j9d4rgip855nrh400nxp940p";
   };
 
   nativeBuildInputs = [ gettext ];
diff --git a/pkgs/development/libraries/attr/default.nix b/pkgs/development/libraries/attr/default.nix
index 3c5855ea284f..8d87e2ee50dd 100644
--- a/pkgs/development/libraries/attr/default.nix
+++ b/pkgs/development/libraries/attr/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, gettext }:
 
 stdenv.mkDerivation rec {
-  name = "attr-2.4.46";
+  name = "attr-2.4.47";
 
   src = fetchurl {
     url = "mirror://savannah/attr/${name}.src.tar.gz";
-    sha256 = "07qf6kb2zk512az481bbnsk9jycn477xpva1a726n5pzlzf9pmnw";
+    sha256 = "0nd8y0m6awc9ahv0ciiwf8gy54c8d3j51pw9xg7f7cn579jjyxr5";
   };
 
   nativeBuildInputs = [ gettext ];
diff --git a/pkgs/development/libraries/cloog/default.nix b/pkgs/development/libraries/cloog/default.nix
index ab5737b20ede..c3878ef4b789 100644
--- a/pkgs/development/libraries/cloog/default.nix
+++ b/pkgs/development/libraries/cloog/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv, gmp, isl }:
 
 stdenv.mkDerivation rec {
-  name = "cloog-0.16.3";
+  name = "cloog-0.18.0";
 
   src = fetchurl {
     url = "http://www.bastoul.net/cloog/pages/download/count.php3?url=./${name}.tar.gz";
-    sha256 = "0lzbsszfzsr0jfwkccfbsvx913d2yc45dqwa472plmxkhbwykmc9";
+    sha256 = "1c4aa8dde7886be9cbe0f9069c334843b21028f61d344a2d685f88cb1dcf2228";
   };
 
   buildInputs = [ gmp ];
diff --git a/pkgs/development/libraries/coin3d/default.nix b/pkgs/development/libraries/coin3d/default.nix
index 2ada02441492..f866b2299c1f 100644
--- a/pkgs/development/libraries/coin3d/default.nix
+++ b/pkgs/development/libraries/coin3d/default.nix
@@ -9,6 +9,15 @@ stdenv.mkDerivation rec {
     sha256 = "05ylhrcglm81dajbk132l1w892634z2i97x10fm64y1ih72phd2q";
   };
 
+  patches = [
+    (fetchurl {
+      url = http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/media-libs/coin/files/coin-3.1.3-gcc-4.7.patch;
+      name = "gcc-4.7.patch";
+      sha256 = "076dyc52swk8qc7ylps53fg6iqmd52x8s7m18i80x49dd109yw20";
+    })
+    ./gcc-4.8.patch # taken from FC-17 source rpm
+  ];
+
   buildInputs = [ mesa ];
 
   meta = {
diff --git a/pkgs/development/libraries/coin3d/gcc-4.8.patch b/pkgs/development/libraries/coin3d/gcc-4.8.patch
new file mode 100644
index 000000000000..be5b8b03b638
--- /dev/null
+++ b/pkgs/development/libraries/coin3d/gcc-4.8.patch
@@ -0,0 +1,38 @@
+From 9f5d96a2b9a71ab539237d2dab4c54fc46fc5c5b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ralf=20Cors=C3=A9pius?= <corsepiu@corsepiu.home>
+Date: Thu, 18 Apr 2013 19:17:06 +0200
+Subject: [PATCH 10/10] GCC-4.8.0 fixes
+
+---
+ src/fonts/freetype.cpp | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/fonts/freetype.cpp b/src/fonts/freetype.cpp
+index 760b88b..e705d3a 100644
+--- a/src/fonts/freetype.cpp
++++ b/src/fonts/freetype.cpp
+@@ -32,18 +32,18 @@
+ 
+    20050613 mortene. */
+ 
+-#include "fonts/freetype.h"
+-
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif /* HAVE_CONFIG_H */
+ 
+-#include <stdlib.h>
++#include <cstdlib>
+ #include <assert.h>
+ 
+ #include "glue/freetype.h"
+ #include "glue/GLUWrapper.h"
+ 
++#include "fonts/freetype.h"
++
+ /* ************************************************************************* */
+ 
+ #ifdef __cplusplus
+-- 
+1.8.1.4
+
diff --git a/pkgs/development/libraries/ctl/default.nix b/pkgs/development/libraries/ctl/default.nix
index a802f5716746..65489ee8c88d 100644
--- a/pkgs/development/libraries/ctl/default.nix
+++ b/pkgs/development/libraries/ctl/default.nix
@@ -8,12 +8,12 @@ stdenv.mkDerivation {
     sha256 = "16lzgbpxdyhykdwndj1i9vx3h4bfkxqqcrvasvgg70gb5raxj0mj";
   };
 
-  patches = [ ./patch.patch ];
-  
+  patches = [ ./patch.patch ./gcc47.patch ];
+
   propagatedBuildInputs = [ ilmbase ];
-  
+
   configureFlags = "--with-ilmbase-prefix=${ilmbase}";
-  
+
   #configurePhase = "
     #export CXXFLAGS=\"-I${ilmbase}/include -L${ilmbase}/lib\"
     #echo $CXXFLAGS
diff --git a/pkgs/development/libraries/ctl/gcc47.patch b/pkgs/development/libraries/ctl/gcc47.patch
new file mode 100644
index 000000000000..1aa4be4fe6d0
--- /dev/null
+++ b/pkgs/development/libraries/ctl/gcc47.patch
@@ -0,0 +1,15 @@
+ https://bugs.gentoo.org/426368
+ 
+ IlmCtl/CtlInterpreter.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/IlmCtl/CtlInterpreter.cpp
++++ b/IlmCtl/CtlInterpreter.cpp
+@@ -64,6 +64,7 @@
+ #include <fstream>
+ #include <algorithm>
+ #include <cassert>
++#include <unistd.h>
+ 
+ #ifdef WIN32
+     #include <io.h>
diff --git a/pkgs/development/libraries/dbus-cplusplus/default.nix b/pkgs/development/libraries/dbus-cplusplus/default.nix
index 0a4b80d3f3ea..2bd4f8149853 100644
--- a/pkgs/development/libraries/dbus-cplusplus/default.nix
+++ b/pkgs/development/libraries/dbus-cplusplus/default.nix
@@ -10,6 +10,12 @@ stdenv.mkDerivation rec {
     sha256 = "0qafmy2i6dzx4n1dqp6pygyy6gjljnb7hwjcj2z11c1wgclsq4dw";
   };
 
+  patches = [( fetchurl {
+    url = http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-libs/dbus-c%2B%2B/files/dbus-c%2B%2B-0.9.0-gcc-4.7.patch;
+    name = "gcc-4.7.patch";
+    sha256 = "0rwcz9pvc13b3yfr0lkifnfz0vb5q6dg240bzgf37ni4s8rpc72g";
+  })];
+
   buildInputs = [ dbus glib gtkmm pkgconfig expat ];
 
   configureFlags = "--disable-ecore";
diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix
index 4908662591cb..4d400a6ea7da 100644
--- a/pkgs/development/libraries/gettext/default.nix
+++ b/pkgs/development/libraries/gettext/default.nix
@@ -1,19 +1,17 @@
-{ stdenv, fetchurl, libiconvOrEmpty }:
-
-with { inherit (stdenv.lib) optionals optionalAttrs; };
+{ stdenv, fetchurl, libiconv, xz }:
 
 stdenv.mkDerivation (rec {
-  name = "gettext-0.18.1.1";
+  name = "gettext-0.18.2";
 
   src = fetchurl {
     url = "mirror://gnu/gettext/${name}.tar.gz";
-    sha256 = "1sa3ch12qxa4h3ya6hkz119yclcccmincl9j20dhrdx5mykp3b4k";
+    sha256 = "516a6370b3b3f46e2fc5a5e222ff5ecd76f3089bc956a7587a6e4f89de17714c";
   };
 
-  patches = [ ./no-gets.patch ];
+  LDFLAGS = if stdenv.isSunOS then "-lm -lmd -lmp -luutil -lnvpair -lnsl -lidmap -lavl -lsec" else "";
 
-  configureFlags = [ "--disable-csharp" ]
-     ++ (optionals stdenv.isCygwin
+  configureFlags = [ "--disable-csharp" "--with-xz" ]
+     ++ (stdenv.lib.optionals stdenv.isCygwin
           [ # We have a static libiconv, so we can only build the static lib.
             "--disable-shared" "--enable-static"
 
@@ -32,12 +30,12 @@ stdenv.mkDerivation (rec {
     fi
   '';
 
-  buildInputs = libiconvOrEmpty;
+  buildInputs = [ xz ] ++ stdenv.lib.optional (!stdenv.isLinux) libiconv;
 
   enableParallelBuilding = true;
 
   crossAttrs = {
-    buildInputs = optional (stdenv.gccCross.libc ? libiconv)
+    buildInputs = stdenv.lib.optional (stdenv.gccCross.libc ? libiconv)
       stdenv.gccCross.libc.libiconv.crossDrv;
     # Gettext fails to guess the cross compiler
     configureFlags = "CXX=${stdenv.cross.config}-g++";
@@ -72,11 +70,11 @@ stdenv.mkDerivation (rec {
   };
 }
 
-// optionalAttrs stdenv.isDarwin {
+// stdenv.lib.optionalAttrs stdenv.isDarwin {
   makeFlags = "CFLAGS=-D_FORTIFY_SOURCE=0";
 }
 
-// optionalAttrs stdenv.isCygwin {
+// stdenv.lib.optionalAttrs stdenv.isCygwin {
   patchPhase =
    # Make sure `error.c' gets compiled and is part of `libgettextlib.la'.
    # This fixes:
diff --git a/pkgs/development/libraries/gettext/no-gets.patch b/pkgs/development/libraries/gettext/no-gets.patch
deleted file mode 100644
index 9daa48eae649..000000000000
--- a/pkgs/development/libraries/gettext/no-gets.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-hack until gzip pulls a newer gnulib version
-
-From 66712c23388e93e5c518ebc8515140fa0c807348 Mon Sep 17 00:00:00 2001
-From: Eric Blake <eblake@redhat.com>
-Date: Thu, 29 Mar 2012 13:30:41 -0600
-Subject: [PATCH] stdio: don't assume gets any more
-
-Gnulib intentionally does not have a gets module, and now that C11
-and glibc have dropped it, we should be more proactive about warning
-any user on a platform that still has a declaration of this dangerous
-interface.
-
---- a/gettext-tools/libgettextpo/stdio.in.h
-+++ b/gettext-tools/libgettextpo/stdio.in.h
-@@ -125,7 +125,6 @@
-    so any use of gets warrants an unconditional warning.  Assume it is
-    always declared, since it is required by C89.  */
- #undef gets
--_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
- 
- #if @GNULIB_FOPEN@
- # if @REPLACE_FOPEN@
---- a/gettext-tools/gnulib-lib/stdio.in.h
-+++ b/gettext-tools/gnulib-lib/stdio.in.h
-@@ -125,7 +125,6 @@
-    so any use of gets warrants an unconditional warning.  Assume it is
-    always declared, since it is required by C89.  */
- #undef gets
--_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
- 
- #if @GNULIB_FOPEN@
- # if @REPLACE_FOPEN@
---- a/gettext-runtime/gnulib-lib/stdio.in.h
-+++ b/gettext-runtime/gnulib-lib/stdio.in.h
-@@ -125,7 +125,6 @@
-    so any use of gets warrants an unconditional warning.  Assume it is
-    always declared, since it is required by C89.  */
- #undef gets
--_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
- 
- #if @GNULIB_FOPEN@
- # if @REPLACE_FOPEN@
diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix
index 119584deb1eb..97ad7da16260 100644
--- a/pkgs/development/libraries/glib/default.nix
+++ b/pkgs/development/libraries/glib/default.nix
@@ -44,7 +44,10 @@ stdenv.mkDerivation rec {
   propagatedBuildInputs = [ pcre zlib libffi ] ++ libiconvOrEmpty ++ libintlOrEmpty;
 
   preConfigure = "autoreconf -fi";
-  configureFlags = "--with-pcre=system --disable-fam";
+
+  configureFlags = stdenv.lib.optional stdenv.isSunOS "--disable-modular-tests";
+
+  CPPFLAGS = stdenv.lib.optionalString stdenv.isSunOS "-DBSD_COMP";
 
   NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-lintl";
 
diff --git a/pkgs/development/libraries/glibc/2.17/common.nix b/pkgs/development/libraries/glibc/2.17/common.nix
index 66251e0fc49f..e82cceda7c77 100644
--- a/pkgs/development/libraries/glibc/2.17/common.nix
+++ b/pkgs/development/libraries/glibc/2.17/common.nix
@@ -57,6 +57,11 @@ stdenv.mkDerivation ({
          src->results[i].native == a2_native' failed." crashes. */
       ./glibc-rh739743.patch
 
+      /* The command "getconf CS_PATH" returns the default search path
+         "/bin:/usr/bin", which is inappropriate on NixOS machines. This
+         patch extends the search path by "/run/current-system/sw/bin". */
+      ./fix_path_attribute_in_getconf.patch
+
       /* Fix buffer overrun in regexp matcher. */
       ./cve-2013-0242.patch
 
diff --git a/pkgs/development/libraries/glibc/2.17/fix_path_attribute_in_getconf.patch b/pkgs/development/libraries/glibc/2.17/fix_path_attribute_in_getconf.patch
new file mode 100644
index 000000000000..714e49db5607
--- /dev/null
+++ b/pkgs/development/libraries/glibc/2.17/fix_path_attribute_in_getconf.patch
@@ -0,0 +1,6 @@
+diff -ubr glibc-2.17-orig/sysdeps/unix/confstr.h glibc-2.17/sysdeps/unix/confstr.h
+--- glibc-2.17-orig/sysdeps/unix/confstr.h	2013-06-03 22:01:44.829726968 +0200
++++ glibc-2.17/sysdeps/unix/confstr.h	2013-06-03 22:04:39.469376740 +0200
+@@ -1 +1 @@
+-#define	CS_PATH	"/bin:/usr/bin"
++#define	CS_PATH	"/run/current-system/sw/bin:/bin:/usr/bin"
diff --git a/pkgs/development/libraries/gmp/4.3.2.nix b/pkgs/development/libraries/gmp/4.3.2.nix
index df7bd0ea3b96..f003979c701c 100644
--- a/pkgs/development/libraries/gmp/4.3.2.nix
+++ b/pkgs/development/libraries/gmp/4.3.2.nix
@@ -23,7 +23,9 @@ stdenv.mkDerivation rec {
 
   configureFlags = if cxx then "--enable-cxx" else "--disable-cxx";
 
-  doCheck = true;
+  # The test t-lucnum_ui fails (on Linux/x86_64) when built with GCC 4.8.
+  # Newer versions of GMP don't have that issue anymore.
+  doCheck = false;
 
   meta = {
     description = "GMP, the GNU multiple precision arithmetic library";
diff --git a/pkgs/development/libraries/gmp/5.1.1.nix b/pkgs/development/libraries/gmp/5.1.x.nix
index 1f43e07e58d5..a25eabbee86e 100644
--- a/pkgs/development/libraries/gmp/5.1.1.nix
+++ b/pkgs/development/libraries/gmp/5.1.x.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, m4, cxx ? true }:
 
 stdenv.mkDerivation rec {
-  name = "gmp-5.1.1";
+  name = "gmp-5.1.3";
 
-  src = fetchurl {
+  src = fetchurl { # we need to use bz2, others aren't in bootstrapping stdenv
     urls = [ "mirror://gnu/gmp/${name}.tar.bz2" "ftp://ftp.gmplib.org/pub/${name}/${name}.tar.bz2" ];
-    sha256 = "1bdgf04k2i12pfivxgjq68iarz3ngix9hpzbmkgijrdk92gpgm50";
+    sha256 = "0q5i39pxrasgn9qdxzpfbwhh11ph80p57x6hf48m74261d97j83m";
   };
 
   nativeBuildInputs = [ m4 ];
@@ -15,7 +15,8 @@ stdenv.mkDerivation rec {
     # (x86), except on Solaris where some tests crash with "Memory fault".
     # See <http://hydra.nixos.org/build/2760931>, for instance.
     (stdenv.lib.optional (!stdenv.isSunOS) "--enable-fat")
-    ++ (if cxx then [ "--enable-cxx" ] else [ "--disable-cxx" ]);
+    ++ (if cxx then [ "--enable-cxx" ] else [ "--disable-cxx" ])
+    ++ (if stdenv.is64bit then [ "--with-pic" ] else []);
 
   doCheck = true;
 
diff --git a/pkgs/development/libraries/gsl/default.nix b/pkgs/development/libraries/gsl/default.nix
index 9afcc4ad41d6..94b422d7a914 100644
--- a/pkgs/development/libraries/gsl/default.nix
+++ b/pkgs/development/libraries/gsl/default.nix
@@ -8,6 +8,10 @@ stdenv.mkDerivation rec {
     sha256 = "0lrgipi0z6559jqh82yx8n4xgnxkhzj46v96dl77hahdp58jzg3k";
   };
 
+  # ToDo: there might be more impurities than FMA support check
+  patches = [ ./disable-fma.patch ]; # http://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html
+  patchFlags = "-p0";
+
   doCheck = true;
 
   meta = {
diff --git a/pkgs/development/libraries/gsl/disable-fma.patch b/pkgs/development/libraries/gsl/disable-fma.patch
new file mode 100644
index 000000000000..d5c0d620863e
--- /dev/null
+++ b/pkgs/development/libraries/gsl/disable-fma.patch
@@ -0,0 +1,32 @@
+--- configure.ac        2011-09-22 16:13:22 +0000
++++ configure.ac        2011-11-26 23:55:24 +0000
+@@ -381,6 +381,28 @@
+ AC_SUBST(HAVE_DARWIN_IEEE_INTERFACE)
+ AC_SUBST(HAVE_DARWIN86_IEEE_INTERFACE)
+ 
++dnl check for compiler flags to disable use of FMA
++save_cflags="$CFLAGS"
++AC_CACHE_CHECK([for compiler flags to disable use of FMA], ac_cv_c_fma_flags,
++[
++if test X"$GCC" = Xyes; then
++    fma_flags='-ffp-contract=off'
++else
++    fma_flags=
++fi
++if test X"$fma_flags" != X; then
++  CFLAGS="$fma_flags $CFLAGS"
++  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int foo;]])],[ac_cv_c_fma_flags="$fma_flags"],[ac_cv_c_fma_flags="none"])
++else
++  ac_cv_c_fma_flags="none"
++fi])
++
++if test "$ac_cv_c_fma_flags" != "none" ; then
++   CFLAGS="$ac_cv_c_fma_flags $save_cflags"
++else
++   CFLAGS="$save_cflags"
++fi
++
+ dnl Check for IEEE control flags
+ 
+ save_cflags="$CFLAGS"
+
diff --git a/pkgs/development/libraries/icu/default.nix b/pkgs/development/libraries/icu/default.nix
index 838d6f7b75fd..932c8114c0f8 100644
--- a/pkgs/development/libraries/icu/default.nix
+++ b/pkgs/development/libraries/icu/default.nix
@@ -5,12 +5,12 @@ let
   pname = "icu4c";
   version = "51.1";
 in
-
 stdenv.mkDerivation {
   name = pname + "-" + version;
 
   src = fetchurl {
-    url = http://download.icu-project.org/files/icu4c/51.1/icu4c-51_1-src.tgz;
+    url = "http://download.icu-project.org/files/${pname}/${version}/${pname}-"
+      + (stdenv.lib.replaceChars ["."] ["_"] version) + "-src.tgz";
     sha256 = "0sv6hgkm92pm27zgjxgk284lcxxbsl0syi40ckw2b7yj7d8sxrc7";
   };
 
diff --git a/pkgs/development/libraries/isl/default.nix b/pkgs/development/libraries/isl/default.nix
index aaec37eae8f2..7711d4f170f9 100644
--- a/pkgs/development/libraries/isl/default.nix
+++ b/pkgs/development/libraries/isl/default.nix
@@ -1,17 +1,15 @@
 { stdenv, fetchurl, gmp }:
 
 stdenv.mkDerivation rec {
-  name = "isl-0.07"; # CLooG 0.16.3 fails to build with ISL 0.08.
+  name = "isl-0.11.1"; # CLooG 0.16.3 fails to build with ISL 0.08.
 
   src = fetchurl {
-    urls = [
-        "http://www.kotnet.org/~skimo/isl/${name}.tar.bz2"
-        "ftp://ftp.linux.student.kuleuven.be/pub/people/skimo/isl/${name}.tar.bz2"
-      ];
-    sha256 = "0kpxmvhrwwdygqqafqzjf9xiksq7paac2x24g9jhr3f9ajj3zkyx";
+    url = "http://pkgs.fedoraproject.org/repo/pkgs/gcc/isl-0.11.1.tar.bz2/bce1586384d8635a76d2f017fb067cd2/isl-0.11.1.tar.bz2";
+    sha256 = "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9";
   };
 
   buildInputs = [ gmp ];
+  patches = [ ./fix-gcc-build.diff ];
 
   meta = {
     homepage = http://www.kotnet.org/~skimo/isl/;
diff --git a/pkgs/development/libraries/isl/fix-gcc-build.diff b/pkgs/development/libraries/isl/fix-gcc-build.diff
new file mode 100644
index 000000000000..6fbd1f9d478b
--- /dev/null
+++ b/pkgs/development/libraries/isl/fix-gcc-build.diff
@@ -0,0 +1,12 @@
+diff -ru isl-0.11.1/include/isl/int.h isl-0.11.1.new/include/isl/int.h
+--- isl-0.11.1/include/isl/int.h        2012-11-29 09:47:32.000000000 +0100
++++ isl-0.11.1.new/include/isl/int.h    2013-10-27 15:35:31.348553812 +0100
+@@ -14,7 +14,7 @@
+ #include <string.h>
+ #include <gmp.h>
+ #if defined(__cplusplus)
+-#include <iostream>
++#include <ostream>
+ #endif
+ 
+ #if defined(__cplusplus)
diff --git a/pkgs/development/libraries/kerberos/krb5.nix b/pkgs/development/libraries/kerberos/krb5.nix
index 5c408e9a76c5..647a6b031138 100644
--- a/pkgs/development/libraries/kerberos/krb5.nix
+++ b/pkgs/development/libraries/kerberos/krb5.nix
@@ -23,11 +23,13 @@ stdenv.mkDerivation (rec {
     cd ${name}/src
   '';
 
+  #doCheck = true; # report: No suitable file for testing purposes
+
   enableParallelBuilding = true;
 
   meta = {
-      description = "MIT Kerberos 5";
-      homepage = webpage;
-      license = "MPL";
+    description = "MIT Kerberos 5";
+    homepage = webpage;
+    license = "MPL";
   };
 })
diff --git a/pkgs/development/libraries/libarchive/default.nix b/pkgs/development/libraries/libarchive/default.nix
index 851601fe9639..e0f2ba77de2d 100644
--- a/pkgs/development/libraries/libarchive/default.nix
+++ b/pkgs/development/libraries/libarchive/default.nix
@@ -2,11 +2,11 @@
 , sharutils }:
 
 stdenv.mkDerivation rec {
-  name = "libarchive-3.0.4";
+  name = "libarchive-3.1.2";
 
   src = fetchurl {
-    url = "https://github.com/downloads/libarchive/libarchive/${name}.tar.gz";
-    sha256 = "76e8d7c7b100ec4071e48c1b7d3f3ea1d22b39db3e45b7189f75b5ff4df90fac";
+    url = "${meta.homepage}/downloads/${name}.tar.gz";
+    sha256 = "0pixqnrcf35dnqgv0lp7qlcw7k13620qkhgxr288v7p4iz6ym1zb";
   };
 
   buildInputs = [ sharutils libxml2 zlib bzip2 openssl xz ] ++
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
       compressions formats including (but not limited to) tar, shar, cpio, zip, and
       compressed with gzip, bzip2, lzma, xz, .. 
     '';
-    homepage = http://libarchive.github.com/;
+    homepage = http://libarchive.org;
     license = stdenv.lib.licenses.bsd3;
     platforms = with stdenv.lib.platforms; all;
     maintainers = with stdenv.lib.maintainers; [ jcumming ];
diff --git a/pkgs/development/libraries/libofa/curl-types.patch b/pkgs/development/libraries/libofa/curl-types.patch
deleted file mode 100644
index acd8d9aeabb8..000000000000
--- a/pkgs/development/libraries/libofa/curl-types.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -rc libofa-0.9.3/examples/protocol.cpp libofa-0.9.3-new/examples/protocol.cpp
-*** libofa-0.9.3/examples/protocol.cpp	2006-05-10 14:05:42.000000000 -0400
---- libofa-0.9.3-new/examples/protocol.cpp	2011-11-06 09:24:05.653283203 -0500
-***************
-*** 12,18 ****
-  #include <map>
-  #include <expat.h>
-  #include <curl/curl.h>
-- #include <curl/types.h>
-  #include <curl/easy.h>
-  
-  using namespace std;
---- 12,17 ----
diff --git a/pkgs/development/libraries/libofa/default.nix b/pkgs/development/libraries/libofa/default.nix
index 6b1ceee40f1c..2e2640e86362 100644
--- a/pkgs/development/libraries/libofa/default.nix
+++ b/pkgs/development/libraries/libofa/default.nix
@@ -1,17 +1,24 @@
 { stdenv, fetchurl, expat, curl, fftw }:
 
+let
+  version = "0.9.3";
+  deb_patch = "5";
+in
 stdenv.mkDerivation rec {
-  name = "libofa-0.9.3";
-
-  propagatedBuildInputs = [ expat curl fftw ];
-
-  patches = [ ./libofa-0.9.3-gcc-4.patch ./libofa-0.9.3-gcc-4.3.patch ./gcc-4.x.patch ./curl-types.patch ];
+  name = "libofa-${version}";
 
   src = fetchurl {
     url = "http://musicip-libofa.googlecode.com/files/${name}.tar.gz";
     sha256 = "184ham039l7lwhfgg0xr2vch2xnw1lwh7sid432mh879adhlc5h2";
   };
 
+  patches = fetchurl {
+    url = "mirror://debian/pool/main/libo/libofa/libofa_${version}-${deb_patch}.debian.tar.gz";
+    sha256 = "1rfkyz13cm8izm90c1xflp4rvsa24aqs6qpbbbqqcbmvzsj6j9yn";
+  };
+
+  propagatedBuildInputs = [ expat curl fftw ];
+
   meta = {
     homepage = http://code.google.com/musicip-libofa/;
     description = "LibOFA - Library Open Fingerprint Architecture";
diff --git a/pkgs/development/libraries/libofa/gcc-4.x.patch b/pkgs/development/libraries/libofa/gcc-4.x.patch
deleted file mode 100644
index 50f72bb428c6..000000000000
--- a/pkgs/development/libraries/libofa/gcc-4.x.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/examples/example.cpp b/examples/example.cpp
-index ef978d5..7d58a0f 100644
---- a/examples/example.cpp
-+++ b/examples/example.cpp
-@@ -10,6 +10,7 @@
- #include "protocol.h"
- 
- #include <string.h>
-+#include <stdio.h>
-  
- AudioData* loadWaveFile(char *file);
- AudioData* loadDataUsingLAME(char *file);
diff --git a/pkgs/development/libraries/libofa/libofa-0.9.3-gcc-4.3.patch b/pkgs/development/libraries/libofa/libofa-0.9.3-gcc-4.3.patch
deleted file mode 100644
index 7682e3710514..000000000000
--- a/pkgs/development/libraries/libofa/libofa-0.9.3-gcc-4.3.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-Fix build with gcc >=4.3
-diff -ur libofa-0.9.3.orig/examples/example.cpp libofa-0.9.3/examples/example.cpp
---- libofa-0.9.3.orig/examples/example.cpp	2006-05-10 21:05:37.000000000 +0300
-+++ libofa-0.9.3/examples/example.cpp	2008-04-16 15:51:49.000000000 +0300
-@@ -9,6 +9,8 @@
- 
- #include "protocol.h"
- 
-+#include <string.h>
-+ 
- AudioData* loadWaveFile(char *file);
- AudioData* loadDataUsingLAME(char *file);
- 
-Vain hakemistossa libofa-0.9.3/examples: example.cpp.orig
-diff -ur libofa-0.9.3.orig/examples/protocol.cpp libofa-0.9.3/examples/protocol.cpp
---- libofa-0.9.3.orig/examples/protocol.cpp	2006-05-10 21:05:42.000000000 +0300
-+++ libofa-0.9.3/examples/protocol.cpp	2008-04-16 15:51:49.000000000 +0300
-@@ -8,6 +8,7 @@
- -------------------------------------------------------------------*/
- #include <stdio.h>
- #include <stdlib.h>
-+#include <cstring>
- #include <string>
- #include <map>
- #include <expat.h>
-diff -ur libofa-0.9.3.orig/lib/signal_op.cpp libofa-0.9.3/lib/signal_op.cpp
---- libofa-0.9.3.orig/lib/signal_op.cpp	2006-05-10 21:01:12.000000000 +0300
-+++ libofa-0.9.3/lib/signal_op.cpp	2008-04-16 15:51:49.000000000 +0300
-@@ -12,6 +12,7 @@
- // DATE CREATED: 1/12/06
- 
- 
-+#include <cstdlib>
- #include <math.h>
- #include "signal_op.h"
- #include "AFLIB/aflibConverter.h"
diff --git a/pkgs/development/libraries/libofa/libofa-0.9.3-gcc-4.patch b/pkgs/development/libraries/libofa/libofa-0.9.3-gcc-4.patch
deleted file mode 100644
index 920c383c657b..000000000000
--- a/pkgs/development/libraries/libofa/libofa-0.9.3-gcc-4.patch
+++ /dev/null
@@ -1,39 +0,0 @@
---- a/lib/JAMA/tnt_math_utils.h	2006-06-17 01:46:22.000000000 +0300
-+++ b/lib/JAMA/tnt_math_utils.h	2006-06-17 01:47:02.000000000 +0300
-@@ -20,11 +20,20 @@
- namespace TNT

- {

- /**

-+	@returns the absolute value of a real (no-complex) scalar.

-+*/

-+template <class Real>

-+Real abs(const Real &a)

-+{

-+	return  (a > 0 ? a : -a);

-+}

-+/**

- 	@returns hypotenuse of real (non-complex) scalars a and b by 

- 	avoiding underflow/overflow

- 	using (a * sqrt( 1 + (b/a) * (b/a))), rather than

- 	sqrt(a*a + b*b).

- */

-+

- template <class Real>

- Real hypot(const Real &a, const Real &b)

- {

-@@ -56,15 +65,6 @@
- }

- */

- 

--/**

--	@returns the absolute value of a real (no-complex) scalar.

--*/

--template <class Real>

--Real abs(const Real &a)

--{

--	return  (a > 0 ? a : -a);

--}

--

- }

- #endif

- /* MATH_UTILS_H */

diff --git a/pkgs/development/libraries/libproxy/default.nix b/pkgs/development/libraries/libproxy/default.nix
index 68c3ac5130df..7085236feb52 100644
--- a/pkgs/development/libraries/libproxy/default.nix
+++ b/pkgs/development/libraries/libproxy/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, cmake, zlib}:
+{ stdenv, fetchurl, pkgconfig, cmake, zlib, glib }:
 
 stdenv.mkDerivation rec {
   name = "libproxy-0.4.11";
@@ -6,5 +6,9 @@ stdenv.mkDerivation rec {
     url = "http://libproxy.googlecode.com/files/${name}.tar.gz";
     sha256 = "0jw6454gxjykmbnbh544axi8hzz9gmm4jz1y5gw1hdqnakg36gyw";
   };
-  buildInputs = [cmake zlib];
+
+  nativeBuildInputs = [ pkgconfig cmake ];
+  propagatedBuildInputs = [ zlib ]
+    # now some optional deps, but many more are possible
+    ++ [ glib ];
 }
diff --git a/pkgs/development/libraries/libssh/default.nix b/pkgs/development/libraries/libssh/default.nix
index c2b812744c9a..a57e2f8d3b8c 100644
--- a/pkgs/development/libraries/libssh/default.nix
+++ b/pkgs/development/libraries/libssh/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, cmake, zlib, libgcrypt }:
 
 stdenv.mkDerivation rec {
-  name = "libssh-0.5.3";
+  name = "libssh-0.5.4";
 
   src = fetchurl {
-    url = "https://red.libssh.org/attachments/download/38/${name}.tar.gz";
-    sha256 = "1w6s217vjq0w3v5i0c5ql6m0ki1yz05g9snah3azxfkl9k4schpd";
+    url = "https://red.libssh.org/attachments/download/41/libssh-0.5.4.tar.gz";
+    sha256 = "106a9nzmr8q5kw809p5zdhmjrqv7p6609ai5c1n7xi7pxg52af2z";
   };
 
   buildInputs = [ zlib libgcrypt ];
diff --git a/pkgs/development/libraries/libxslt/default.nix b/pkgs/development/libraries/libxslt/default.nix
index e2568af6c9bc..ee369ddc58b1 100644
--- a/pkgs/development/libraries/libxslt/default.nix
+++ b/pkgs/development/libraries/libxslt/default.nix
@@ -1,15 +1,26 @@
 { stdenv, fetchurl, libxml2 }:
 
-stdenv.mkDerivation (rec {
-  name = "libxslt-1.1.27";
+stdenv.mkDerivation rec {
+  name = "libxslt-1.1.28";
 
   src = fetchurl {
     url = "ftp://xmlsoft.org/libxml2/${name}.tar.gz";
-    sha256 = "09ky3vhlaahvsb0q9gp6h3as53pfj70gincirachjqzj46jdka5n";
+    sha256 = "5fc7151a57b89c03d7b825df5a0fae0a8d5f05674c0e7cf2937ecec4d54a028c";
   };
 
   buildInputs = [ libxml2 ];
 
+  patches = stdenv.lib.optionals stdenv.isSunOS [ ./patch-ah.patch ];
+
+  configureFlags = [
+    "--with-libxml-prefix=${libxml2}"
+    "--without-python"
+    "--without-crypto"
+    "--without-debug"
+    "--without-mem-debug"
+    "--without-debugger"
+  ];
+
   postInstall = ''
     mkdir -p $out/nix-support
     ln -s ${libxml2}/nix-support/setup-hook $out/nix-support/
@@ -22,15 +33,4 @@ stdenv.mkDerivation (rec {
     platforms = stdenv.lib.platforms.unix;
     maintainers = [ stdenv.lib.maintainers.eelco ];
   };
-} // (if !stdenv.isFreeBSD then {} else {
-  buildInputs = [];
-
-  configureFlags = [
-    "--with-libxml-prefix=${libxml2}"
-    "--without-python"
-    "--without-crypto"
-    "--without-debug"
-    "--without-mem-debug"
-    "--without-debugger"
-  ];
-}))
+}
diff --git a/pkgs/development/libraries/libxslt/patch-ah.patch b/pkgs/development/libraries/libxslt/patch-ah.patch
new file mode 100644
index 000000000000..ea75b01178e3
--- /dev/null
+++ b/pkgs/development/libraries/libxslt/patch-ah.patch
@@ -0,0 +1,69 @@
+$NetBSD: patch-ah,v 1.3 2012/11/27 12:17:51 adam Exp $
+
+Fix syms file for stricter solaris ld
+
+--- libxslt-1.1.28/libxslt/libxslt.syms.orig	2012-11-27 12:04:43.000000000 +0000
++++ libxslt-1.1.28/libxslt/libxslt.syms
+@@ -107,7 +107,7 @@ LIBXML2_1.0.11 {
+   xsltFreeCompMatchList;
+   xsltFreeTemplateHashes;
+   xsltGetTemplate;
+-  xsltMatchPattern;
++# xsltMatchPattern;
+   xsltTestCompMatchList;
+ 
+ # preproc
+@@ -407,7 +407,7 @@ LIBXML2_1.1.18 {
+     global:
+ 
+ # xsltInternals
+-  xsltConstNamespaceNameXSLT; # variable
++# xsltConstNamespaceNameXSLT; # variable
+   xsltExtensionInstructionResultFinalize;
+   xsltExtensionInstructionResultRegister;
+   xsltInitCtxtKey;
+@@ -416,24 +416,24 @@ LIBXML2_1.1.18 {
+   xsltInit;
+ 
+ # xsltInternals
+-  xsltParseAnyXSLTElem;
+-  xsltParseSequenceConstructor;
+-  xsltPointerListAddSize;
+-  xsltPointerListClear;
+-  xsltPointerListCreate;
+-  xsltPointerListFree;
++# xsltParseAnyXSLTElem;
++# xsltParseSequenceConstructor;
++# xsltPointerListAddSize;
++# xsltPointerListClear;
++# xsltPointerListCreate;
++# xsltPointerListFree;
+   xsltRegisterLocalRVT;
+   xsltReleaseRVT;
+-  xsltRestoreDocumentNamespaces;
++# xsltRestoreDocumentNamespaces;
+ 
+ # extensions
+-  xsltStyleStylesheetLevelGetExtData;
++# xsltStyleStylesheetLevelGetExtData;
+ 
+ # xsltInternals
+ # xsltTransStorageAdd; removed in 1.1.28
+ # xsltTransStorageRemove; removed in 1.1.28
+   xsltUninit;
+-  xsltXSLTAttrMarker; # variable
++# xsltXSLTAttrMarker; # variable
+ } LIBXML2_1.1.9;
+ 
+ LIBXML2_1.1.20 {
+@@ -476,6 +476,10 @@ LIBXML2_1.1.26 {
+ 
+ # transform
+   xsltProcessOneNode;
++
++# Solaris ld needs explicit auto-reduction (or, alternatively, "-B local")
++    local:
++  *;
+ } LIBXML2_1.1.25;
+ 
+ LIBXML2_1.1.27 {
diff --git a/pkgs/development/libraries/mpc/default.nix b/pkgs/development/libraries/mpc/default.nix
index 3824e3d3755b..e5d212dc2690 100644
--- a/pkgs/development/libraries/mpc/default.nix
+++ b/pkgs/development/libraries/mpc/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv, gmp, mpfr }:
 
 stdenv.mkDerivation rec {
-  name = "mpc-0.9";
+  name = "mpc-1.0.1";
 
   src = fetchurl {
     url = "http://www.multiprecision.org/mpc/download/${name}.tar.gz";
-    sha1 = "229722d553030734d49731844abfef7617b64f1a";
+    sha1 = "vxg0rkyn4cs40wr2cp6bbcyr1nnijzlc";
   };
 
   buildInputs = [ gmp mpfr ];
diff --git a/pkgs/development/libraries/mpfr/3.1.2.nix b/pkgs/development/libraries/mpfr/3.1.2.nix
deleted file mode 100644
index fd164cf91052..000000000000
--- a/pkgs/development/libraries/mpfr/3.1.2.nix
+++ /dev/null
@@ -1,51 +0,0 @@
-
-{stdenv, fetchurl, gmp}:
-
-stdenv.mkDerivation (rec {
-  name = "mpfr-3.1.2";
-
-  src = fetchurl {
-    url = "mirror://gnu/mpfr/${name}.tar.bz2";
-    sha256 = "0sqvpfkzamxdr87anzakf9dhkfh15lfmm5bsqajk02h1mxh3zivr";
-  };
-
-  buildInputs = [ gmp ];
-
-  doCheck = true;
-
-  enableParallelBuilding = true;
-
-  meta = {
-    homepage = http://www.mpfr.org/;
-    description = "GNU MPFR, a library for multiple-precision floating-point arithmetic";
-
-    longDescription = ''
-      The GNU MPFR library is a C library for multiple-precision
-      floating-point computations with correct rounding.  MPFR is
-      based on the GMP multiple-precision library.
-
-      The main goal of MPFR is to provide a library for
-      multiple-precision floating-point computation which is both
-      efficient and has a well-defined semantics.  It copies the good
-      ideas from the ANSI/IEEE-754 standard for double-precision
-      floating-point arithmetic (53-bit mantissa).
-    '';
-
-    license = "LGPLv2+";
-
-    maintainers = [ stdenv.lib.maintainers.ludo ];
-    platforms = stdenv.lib.platforms.all;
-  };
-}
-
-//
-
-(stdenv.lib.optionalAttrs stdenv.isFreeBSD {
-   /* Work around a FreeBSD bug that otherwise leads to segfaults in
-      the test suite:
-        http://hydra.bordeaux.inria.fr/build/34862
-        http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00015.html
-        http://www.freebsd.org/cgi/query-pr.cgi?pr=161344
-    */
-   configureFlags = [ "--disable-thread-safe" ];
- }))
diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix
index faa2e1b1a71e..8e3281c862ae 100644
--- a/pkgs/development/libraries/mpfr/default.nix
+++ b/pkgs/development/libraries/mpfr/default.nix
@@ -1,15 +1,24 @@
-{stdenv, fetchurl, gmp}:
+{ stdenv, fetchurl, gmp }:
 
-stdenv.mkDerivation (rec {
-  name = "mpfr-3.1.0";
+stdenv.mkDerivation rec {
+  name = "mpfr-3.1.2";
 
   src = fetchurl {
     url = "mirror://gnu/mpfr/${name}.tar.bz2";
-    sha256 = "105nx8qqx5x8f4rlplr2wk4cyv61iw5j3jgi2k21rpb8s6xbp9vl";
+    sha256 = "0sqvpfkzamxdr87anzakf9dhkfh15lfmm5bsqajk02h1mxh3zivr";
   };
 
   buildInputs = [ gmp ];
 
+  configureFlags =
+    /* Work around a FreeBSD bug that otherwise leads to segfaults in the test suite:
+          http://hydra.bordeaux.inria.fr/build/34862
+          http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00015.html
+          http://www.freebsd.org/cgi/query-pr.cgi?pr=161344
+      */
+    stdenv.lib.optional (stdenv.isSunOS or stdenv.isFreeBSD) "--disable-thread-safe" ++
+    stdenv.lib.optional stdenv.is64bit "--with-pic";
+
   doCheck = true;
 
   enableParallelBuilding = true;
@@ -37,14 +46,3 @@ stdenv.mkDerivation (rec {
   };
 }
 
-//
-
-(stdenv.lib.optionalAttrs stdenv.isFreeBSD {
-   /* Work around a FreeBSD bug that otherwise leads to segfaults in
-      the test suite:
-        http://hydra.bordeaux.inria.fr/build/34862
-        http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00015.html
-        http://www.freebsd.org/cgi/query-pr.cgi?pr=161344
-    */
-   configureFlags = [ "--disable-thread-safe" ];
- }))
diff --git a/pkgs/development/libraries/ncurses/5_4.nix b/pkgs/development/libraries/ncurses/5_4.nix
index 1cf08bd30c69..fd35a1d4887a 100644
--- a/pkgs/development/libraries/ncurses/5_4.nix
+++ b/pkgs/development/libraries/ncurses/5_4.nix
@@ -19,10 +19,14 @@ stdenv.mkDerivation (rec {
   };
 
   configureFlags = ''
-    --with-shared --includedir=''${out}/include --without-debug
+    --with-shared --without-debug
     ${if unicode then "--enable-widec" else ""}${if cxx then "" else "--without-cxx-binding"}
   '';
 
+  preConfigure = ''
+    export configureFlags="$configureFlags --includedir=$out/include"
+  '';
+
   selfNativeBuildInput = true;
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
index 569d7fe2a328..9ba21e99a787 100644
--- a/pkgs/development/libraries/ncurses/default.nix
+++ b/pkgs/development/libraries/ncurses/default.nix
@@ -8,7 +8,7 @@ let
      <http://mail.python.org/pipermail/python-bugs-list/2006-September/035362.html>,
      but this is left as an exercise to the reader.
      So disable them for now.  */
-  cxx = stdenv.system != "i686-solaris";
+  cxx = !stdenv.isSunOS;
 in
 stdenv.mkDerivation (rec {
   name = "ncurses-5.9";
@@ -18,11 +18,17 @@ stdenv.mkDerivation (rec {
     sha256 = "0fsn7xis81za62afan0vvm38bvgzg5wfmv1m86flqcj0nj7jjilh";
   };
 
+  patches = [ ./patch-ac ];
+
   configureFlags = ''
-    --with-shared --includedir=''${out}/include --without-debug
+    --with-shared --without-debug
     ${if unicode then "--enable-widec" else ""}${if cxx then "" else "--without-cxx-binding"}
   '';
 
+  preConfigure = ''
+    export configureFlags="$configureFlags --includedir=$out/include"
+  '';
+
   selfNativeBuildInput = true;
 
   enableParallelBuilding = true;
@@ -46,6 +52,7 @@ stdenv.mkDerivation (rec {
         ln -svf lib''${lib}w.so.5 $out/lib/lib$lib.so.5
       fi
     done;
+    ln -svf . $out/include/ncursesw
   '' else "";
 
   meta = {
diff --git a/pkgs/development/libraries/ncurses/patch-ac b/pkgs/development/libraries/ncurses/patch-ac
new file mode 100644
index 000000000000..73578f8a3675
--- /dev/null
+++ b/pkgs/development/libraries/ncurses/patch-ac
@@ -0,0 +1,40 @@
+$NetBSD: patch-ac,v 1.18 2011/11/01 14:47:46 hans Exp $
+
+--- ncurses-5.9/configure.orig	2011-02-21 01:40:36.000000000 +0000
++++ ncurses-5.9/configure
+@@ -7096,6 +7096,13 @@ sco*) #(vi
+ 	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+ 	;;
+ solaris2.1[0-9]) #(vi
++	case "$GCC_VERSION" in 
++		4.[67].*)
++			cf_XOPEN_SOURCE=600
++			cf_add_cflags=-std=c99
++			CPPFLAGS="$CPPFLAGS -std=c99"
++			;;
++	esac
+ 	cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+ 	;;
+ solaris2.[1-9]) #(vi
+@@ -9640,12 +9647,7 @@ case ".$MANPAGE_RENAMES" in #(vi
+ .no) #(vi
+   ;;
+ .|.yes)
+-  # Debian 'man' program?
+-  if test -f /etc/debian_version ; then
+-    MANPAGE_RENAMES=`cd $srcdir && pwd`/man/man_db.renames
+-  else
+     MANPAGE_RENAMES=no
+-  fi
+   ;;
+ esac
+ 
+@@ -18449,7 +18444,7 @@ echo "${ECHO_T}$LIB_SUBSETS" >&6
+ 
+ ### Construct the list of include-directories to be generated
+ 
+-CPPFLAGS="$CPPFLAGS -I. -I../include"
++CPPFLAGS="-I. -I../include $CPPFLAGS"
+ if test "$srcdir" != "."; then
+ 	CPPFLAGS="$CPPFLAGS -I\${srcdir}/../include"
+ fi
diff --git a/pkgs/development/libraries/ois/default.nix b/pkgs/development/libraries/ois/default.nix
index abf6c7112a5c..67df3645eb90 100644
--- a/pkgs/development/libraries/ois/default.nix
+++ b/pkgs/development/libraries/ois/default.nix
@@ -1,4 +1,4 @@
-x@{builderDefsPackage
+x@{builderDefsPackage, fetchurl
   , autoconf, automake, libtool, m4
   , libX11, xproto, libXi, inputproto
   , libXaw, libXmu, libXt
@@ -30,10 +30,17 @@ rec {
   inherit (sourceInfo) name version;
   inherit buildInputs;
 
-  phaseNames = ["doConfigure" "doMakeInstall"];
+  phaseNames = ["doPatch" "doConfigure" "doMakeInstall"];
+
+  patches = [(fetchurl {
+    url = http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-games/ois/files/ois-1.3-gcc47.patch;
+    sha256 = "026jw06n42bcrmg0sbdhzc4cqxsnf7fw30a2z9cigd9x282zhii8";
+    name = "gcc47.patch";
+  })];
+  patchFlags = "-p0";
 
   configureCommand = ''sh bootstrap; sh configure'';
-      
+
   meta = {
     description = "Object-oriented C++ input system";
     maintainers = with a.lib.maintainers;
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index 640b99df5473..55beb8bbc53d 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -53,7 +53,9 @@ stdenv.mkDerivation {
   # On x86_64-darwin, "./config" misdetects the system as
   # "darwin-i386-cc".  So specify the system type explicitly.
   configureScript =
-    if stdenv.system == "x86_64-darwin" then "./Configure darwin64-x86_64-cc" else "./config";
+    if stdenv.system == "x86_64-darwin" then "./Configure darwin64-x86_64-cc"
+    else if stdenv.system == "x86_64-solaris" then "./Configure solaris64-x86_64-gcc"
+    else "./config";
 
   configureFlags = "shared --libdir=lib --openssldir=etc/ssl" +
     stdenv.lib.optionalString withCryptodev " -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS";
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index e59c249348a8..a8a89a4569c7 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, unicodeSupport ? true, cplusplusSupport ? true }:
 
 stdenv.mkDerivation rec {
-  name = "pcre-8.31";
+  name = "pcre-8.33";
 
   src = fetchurl {
     url = "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/${name}.tar.bz2";
-    sha256 = "5778a02535473c7ee7838ea598c19f451e63cf5eec0bf0307a688301c9078c3c";
+    sha256 = "0y04pkrxjvhi30qpnb9ijgn6cjgv3k3lhq2zmw21r0b695x9a0y6";
   };
 
   # The compiler on Darwin crashes with an internal error while building the
@@ -13,11 +13,14 @@ stdenv.mkDerivation rec {
   # problem. In case we ever update the Darwin GCC version, the exception for
   # that platform ought to be removed.
   configureFlags = ''
+    --enable-jit
     ${if unicodeSupport then "--enable-unicode-properties" else ""}
     ${if !cplusplusSupport then "--disable-cpp" else ""}
   '' + stdenv.lib.optionalString stdenv.isDarwin "CXXFLAGS=-O0";
 
-  doCheck = !stdenv.isCygwin;                   # XXX: test failure on Cygwin
+  doCheck = with stdenv; !(isCygwin || isFreeBSD);
+    # XXX: test failure on Cygwin
+    # we are running out of stack on both freeBSDs on Hydra
 
   meta = {
     homepage = "http://www.pcre.org/";
diff --git a/pkgs/development/libraries/ppl/default.nix b/pkgs/development/libraries/ppl/default.nix
index 2ba6b5cb9078..cbdb7b128b45 100644
--- a/pkgs/development/libraries/ppl/default.nix
+++ b/pkgs/development/libraries/ppl/default.nix
@@ -1,13 +1,13 @@
 { fetchurl, stdenv, gmpxx, perl, gnum4 }:
 
-let version = "0.11.2"; in
+let version = "1.0"; in
 
 stdenv.mkDerivation rec {
   name = "ppl-${version}";
 
   src = fetchurl {
     url = "http://bugseng.com/products/ppl/download/ftp/releases/${version}/ppl-${version}.tar.bz2";
-    sha256 = "1sxviip4yk6gp453pid5scy1ba66dzdpr02i1416yk7lkv0x3yz3";
+    sha256 = "0m0b6dzablci8mlavpsmn5w1v3r46li0wpjwvsybgxx0p1ifjsf1";
   };
 
   nativeBuildInputs = [ perl gnum4 ];
@@ -15,6 +15,8 @@ stdenv.mkDerivation rec {
 
   configureFlags = "--disable-watchdog";
 
+  patches = [ ./upstream-based.patch ];
+
   # Beware!  It took ~6 hours to compile PPL and run its tests on a 1.2 GHz
   # x86_64 box.  Nevertheless, being a dependency of GCC, it probably ought
   # to be tested.
@@ -40,7 +42,7 @@ stdenv.mkDerivation rec {
       version of the simplex algorithm.
     '';
 
-    homepage = http://www.cs.unipr.it/ppl/;
+    homepage = http://bugseng.com/products/ppl/;
 
     license = "GPLv3+";
 
diff --git a/pkgs/development/libraries/ppl/upstream-based.patch b/pkgs/development/libraries/ppl/upstream-based.patch
new file mode 100644
index 000000000000..551050f67bf9
--- /dev/null
+++ b/pkgs/development/libraries/ppl/upstream-based.patch
@@ -0,0 +1,42 @@
+https://bugs.gentoo.org/show_bug.cgi?id=447928
+--- ppl-1.0/src/p_std_bits.cc.org	2012-12-30 00:37:03.033948083 +0100
++++ ppl-1.0/src/mp_std_bits.cc	2012-12-30 00:44:12.893019313 +0100
+@@ -25,6 +25,9 @@
+ #include "ppl-config.h"
+ #include "mp_std_bits.defs.hh"
+ 
++#if __GNU_MP_VERSION < 5 \
++  || (__GNU_MP_VERSION == 5 && __GNU_MP_VERSION_MINOR < 1)
++
+ const bool std::numeric_limits<mpz_class>::is_specialized;
+ const int std::numeric_limits<mpz_class>::digits;
+ const int std::numeric_limits<mpz_class>::digits10;
+@@ -70,3 +73,6 @@
+ const bool std::numeric_limits<mpq_class>::traps;
+ const bool std::numeric_limits<mpq_class>::tininess_before;
+ const std::float_round_style std::numeric_limits<mpq_class>::round_style;
++
++#endif // __GNU_MP_VERSION < 5
++       // || (__GNU_MP_VERSION == 5 && __GNU_MP_VERSION_MINOR < 1)
+--- ppl-1.0/src/mp_std_bits.defs.hh.org	2012-12-30 00:37:03.037948187 +0100
++++ ppl-1.0/src/mp_std_bits.defs.hh	2012-12-30 00:42:32.002424189 +0100
+@@ -38,6 +38,9 @@
+ #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
+ void swap(mpq_class& x, mpq_class& y);
+ 
++#if __GNU_MP_VERSION < 5 \
++  || (__GNU_MP_VERSION == 5 && __GNU_MP_VERSION_MINOR < 1)
++
+ namespace std {
+ 
+ #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
+@@ -164,6 +167,9 @@
+ 
+ } // namespace std
+ 
++#endif // __GNU_MP_VERSION < 5
++       // || (__GNU_MP_VERSION == 5 && __GNU_MP_VERSION_MINOR < 1)
++
+ #include "mp_std_bits.inlines.hh"
+ 
+ #endif // !defined(PPL_mp_std_bits_defs_hh)
diff --git a/pkgs/development/libraries/qca2/default.nix b/pkgs/development/libraries/qca2/default.nix
index 1da9ef193b5f..952bdfa29cee 100644
--- a/pkgs/development/libraries/qca2/default.nix
+++ b/pkgs/development/libraries/qca2/default.nix
@@ -21,6 +21,8 @@ stdenv.mkDerivation rec {
               EMSA3_SHA512      ///< SHA512, with EMSA3 (ie PKCS#1 Version 1.5) encoding'
     '';
 
+  patches = [ ./gcc47.patch ];
+
   configureFlags = "--no-separate-debug-info";
 
   enableParallelBuilding = true;
diff --git a/pkgs/development/libraries/qca2/gcc47.patch b/pkgs/development/libraries/qca2/gcc47.patch
new file mode 100644
index 000000000000..08711884a570
--- /dev/null
+++ b/pkgs/development/libraries/qca2/gcc47.patch
@@ -0,0 +1,12 @@
+# Thanks to http://lists.pld-linux.org/mailman/pipermail/pld-cvs-commit/Week-of-Mon-20120917/347917.html
+--- qca-2.0.3/src/botantools/botan/botan/secmem.h.orig 2007-04-19 23:26:13.000000000 +0200
++++ qca-2.0.3/src/botantools/botan/botan/secmem.h  2012-09-16 23:28:43.767480490 +0200
+@@ -214,7 +214,7 @@
+ 
+       SecureVector(u32bit n = 0) { MemoryRegion<T>::init(true, n); }
+       SecureVector(const T in[], u32bit n)
+-         { MemoryRegion<T>::init(true); set(in, n); }
++         { MemoryRegion<T>::init(true); this->set(in, n); }
+       SecureVector(const MemoryRegion<T>& in)
+          { MemoryRegion<T>::init(true); set(in); }
+       SecureVector(const MemoryRegion<T>& in1, const MemoryRegion<T>& in2)
diff --git a/pkgs/development/libraries/strigi/default.nix b/pkgs/development/libraries/strigi/default.nix
index fc8dc123032a..6b8b611d3f7a 100644
--- a/pkgs/development/libraries/strigi/default.nix
+++ b/pkgs/development/libraries/strigi/default.nix
@@ -20,6 +20,8 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ cmake pkgconfig perl ];
 
+  patches = [ ./export_bufferedstream.patch ];
+
   enableParallelBuilding = true;
 
   meta = {
diff --git a/pkgs/development/libraries/strigi/export_bufferedstream.patch b/pkgs/development/libraries/strigi/export_bufferedstream.patch
new file mode 100644
index 000000000000..4c6b34fe1bec
--- /dev/null
+++ b/pkgs/development/libraries/strigi/export_bufferedstream.patch
@@ -0,0 +1,12 @@
+diff -u -r strigi-0.7.8/libstreams/include/strigi/bufferedstream.h strigi-0.7.8_new/libstreams/include/strigi/bufferedstream.h
+--- strigi-0.7.8/libstreams/include/strigi/bufferedstream.h	2013-02-05 13:34:57.000000000 -0800
++++ strigi-0.7.8_new/libstreams/include/strigi/bufferedstream.h	2013-07-14 17:01:54.000000000 -0700
+@@ -34,7 +34,7 @@
+  * BufferedStream will do the rest.
+  */
+ template <class T>
+-class BufferedStream : public StreamBase<T> {
++class STRIGI_EXPORT BufferedStream : public StreamBase<T> {
+ private:
+     StreamBuffer<T> buffer;
+     bool finishedWritingToBuffer;
diff --git a/pkgs/development/libraries/sword/default.nix b/pkgs/development/libraries/sword/default.nix
index 3486981463f3..f62bc2eb11da 100644
--- a/pkgs/development/libraries/sword/default.nix
+++ b/pkgs/development/libraries/sword/default.nix
@@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
   buildInputs = [ pkgconfig icu cluceneCore curl ];
 
   # because curl/types.h disappeared since at least curl 7.21.7
-  patches = [ ./dont_include_curl_types_h.patch ];
+  patches = [ ./dont_include_curl_types_h.patch ./gcc47.patch ];
 
   prePatch = ''
     patchShebangs .;
diff --git a/pkgs/development/libraries/sword/gcc47.patch b/pkgs/development/libraries/sword/gcc47.patch
new file mode 100644
index 000000000000..7b55de75b646
--- /dev/null
+++ b/pkgs/development/libraries/sword/gcc47.patch
@@ -0,0 +1,35 @@
+https://bugs.gentoo.org/419505
+
+
+--- a/include/multimapwdef.h
++++ b/include/multimapwdef.h
+@@ -12,21 +12,21 @@ class multimapwithdefault : public std::multimap<Key, T, Compare> {
+ public:
+ 	typedef std::pair<const Key, T> value_type;
+ 	T& getWithDefault(const Key& k, const T& defaultValue) {
+-		if (find(k) == this->end()) {
+-			insert(value_type(k, defaultValue));
++		if (this->find(k) == this->end()) {
++			this->insert(value_type(k, defaultValue));
+ 		}
+-		return (*(find(k))).second;
++		return (*(this->find(k))).second;
+ 	}
+ 
+ 	T& operator[](const Key& k) {
+-		if (find(k) == this->end()) {
+-			insert(value_type(k, T()));
++		if (this->find(k) == this->end()) {
++			this->insert(value_type(k, T()));
+ 		}
+-		return (*(find(k))).second;
++		return (*(this->find(k))).second;
+ 	}
+ 	bool has(const Key& k, const T &val) const {
+-		typename std::multimap<Key, T, Compare>::const_iterator start = lower_bound(k);
+-		typename std::multimap<Key, T, Compare>::const_iterator end = upper_bound(k);
++		typename std::multimap<Key, T, Compare>::const_iterator start = this->lower_bound(k);
++		typename std::multimap<Key, T, Compare>::const_iterator end = this->upper_bound(k);
+ 		for (; start!=end; start++) {
+ 			if (start->second == val)
+ 				return true;
diff --git a/pkgs/development/libraries/v8/default.nix b/pkgs/development/libraries/v8/default.nix
index 5ac2487c9edc..0564e6887957 100644
--- a/pkgs/development/libraries/v8/default.nix
+++ b/pkgs/development/libraries/v8/default.nix
@@ -26,7 +26,7 @@ stdenv.mkDerivation {
       ln -sv ${gyp}/bin/gyp build/gyp/gyp
     '';
 
-    nativeBuildInputs = stdenv.lib.optional (system == "i686-linux") which;
+    nativeBuildInputs = [ which ];
     buildInputs = [ readline python ];
 
     buildFlags = [
@@ -35,6 +35,9 @@ stdenv.mkDerivation {
       "${arch}.release"
     ];
 
+    # http://code.google.com/p/v8/issues/detail?id=2149
+    NIX_CFLAGS_COMPILE = "-Wno-unused-local-typedefs -Wno-aggressive-loop-optimizations";
+
     enableParallelBuilding = true;
 
     installPhase = ''
diff --git a/pkgs/development/libraries/vigra/default.nix b/pkgs/development/libraries/vigra/default.nix
index 83b921dd49b9..5130abc9a963 100644
--- a/pkgs/development/libraries/vigra/default.nix
+++ b/pkgs/development/libraries/vigra/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, cmake, libtiff, libpng, libjpeg, doxygen, python,
   fftw, fftwSinglePrec, hdf5, boost, numpy }:
 stdenv.mkDerivation rec {
-  name = "vigra-1.8.0";
+  name = "vigra-1.9.0";
 
   src = fetchurl {
     url = "${meta.homepage}/${name}-src.tar.gz";
-    sha256 = "0542qy1bqaq73l7i8aqdhwdbhd6m1wldsn1w2sfyf8yf4398ffpw";
+    sha256 = "00fg64da6dj9k42d90dz6y7x91xw1xqppcla14im74m4afswrgcg";
   };
 
   buildInputs = [ cmake fftw fftwSinglePrec libtiff libpng libjpeg python boost
diff --git a/pkgs/development/libraries/xbase/default.nix b/pkgs/development/libraries/xbase/default.nix
index 847ca6510e5a..81447276db79 100644
--- a/pkgs/development/libraries/xbase/default.nix
+++ b/pkgs/development/libraries/xbase/default.nix
@@ -9,7 +9,13 @@ stdenv.mkDerivation {
   };
 
   prePatch = "find . -type f -not -name configure -print0 | xargs -0 chmod -x";
-  patches = [ ./xbase-fixes.patch ];
+  patches = [
+    ./xbase-fixes.patch
+    (fetchurl {
+      url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-db/xbase/files/xbase-3.1.2-gcc47.patch?revision=1.1";
+      sha256 = "1kpcrkkcqdwl609yd0qxlvp743icz3vni13993sz6fkgn5lah8yl";
+    })
+  ];
 
   meta = {
     homepage = http://linux.techass.com/projects/xdb/;
diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix
index ec47c35c1530..0d4abaf25e0a 100644
--- a/pkgs/development/libraries/zlib/default.nix
+++ b/pkgs/development/libraries/zlib/default.nix
@@ -1,16 +1,16 @@
 { stdenv, fetchurl, static ? false }:
 
-let version = "1.2.7"; in
+let version = "1.2.8"; in
 
 stdenv.mkDerivation rec {
   name = "zlib-${version}";
-  
+
   src = fetchurl {
     urls =
       [ "http://www.zlib.net/${name}.tar.gz"  # old versions vanish from here
         "mirror://sourceforge/libpng/zlib/${version}/${name}.tar.gz"
       ];
-    sha256 = "1i96gsdvxqb6skp9a58bacf1wxamwi9m9pg4yn7cpf7g7239r77s";
+    sha256 = "039agw5rqvqny92cpkrfn243x2gd4xn13hs3xi6isk55d2vqqr9n";
   };
 
   configureFlags = if static then "" else "--shared";
diff --git a/pkgs/development/lisp-modules/stumpwm/default.nix b/pkgs/development/lisp-modules/stumpwm/default.nix
index f6ef41dda1da..a41ee799d8a0 100644
--- a/pkgs/development/lisp-modules/stumpwm/default.nix
+++ b/pkgs/development/lisp-modules/stumpwm/default.nix
@@ -1,4 +1,4 @@
-{pkgs, nixLib, clwrapper, cl-ppcre, clx, buildLispPackage}: 
+{pkgs, nixLib, clwrapper, cl-ppcre, clx, buildLispPackage}:
 buildLispPackage rec {
   baseName = "stumpwm";
   version = "2013-09";
@@ -9,7 +9,7 @@ buildLispPackage rec {
   };
   description = "Tiling window manager for X11";
   deps = [cl-ppcre clx];
-  buildInputs = with pkgs; [texinfo autoconf which makeWrapper];
+  buildInputs = with pkgs; [texinfo4 autoconf which makeWrapper];
   meta = {
     maintainers = [nixLib.maintainers.raskin];
     platforms = nixLib.platforms.linux;
@@ -18,11 +18,11 @@ buildLispPackage rec {
     preConfigure = ''
       ${x.deployConfigScript}
       export CL_SOURCE_REGISTRY="$CL_SOURCE_REGISTRY:$PWD/"
-      ./autogen.sh 
+      ./autogen.sh
       configureFlags=" --with-lisp=$NIX_LISP --with-$NIX_LISP=$(which common-lisp.sh) "
     '';
     installPhase=x.installPhase + ''
-      make install 
+      make install
 
       if [ "$NIX_LISP" = "sbcl" ]; then
         wrapProgram "$out"/bin/stumpwm --set SBCL_HOME "${clwrapper.lisp}/lib/sbcl"
diff --git a/pkgs/development/tools/build-managers/cmake/762-13887.patch b/pkgs/development/tools/build-managers/cmake/762-13887.patch
new file mode 100644
index 000000000000..3ef27a09b5c2
--- /dev/null
+++ b/pkgs/development/tools/build-managers/cmake/762-13887.patch
@@ -0,0 +1,17 @@
+diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
+index e7491bb..57b4348 100644
+--- a/Source/CTest/cmCTestTestHandler.cxx
++++ b/Source/CTest/cmCTestTestHandler.cxx
+@@ -1303,10 +1303,9 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec)
+   for ( it = vec.begin(); it != vec.end(); ++it )
+     {
+     int retVal = 0;
+-    std::string cmd = cmSystemTools::ConvertToOutputPath(it->c_str());
+-    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << cmd
++    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it
+       << std::endl);
+-    if ( !cmSystemTools::RunSingleCommand(cmd.c_str(), 0, &retVal, 0,
++    if ( !cmSystemTools::RunSingleCommand((*it).c_str(), 0, &retVal, 0,
+                                           cmSystemTools::OUTPUT_MERGE
+         /*this->Verbose*/) || retVal != 0 )
+       {
diff --git a/pkgs/development/tools/build-managers/cmake/default.nix b/pkgs/development/tools/build-managers/cmake/default.nix
index d66149a95096..35ae214266dc 100644
--- a/pkgs/development/tools/build-managers/cmake/default.nix
+++ b/pkgs/development/tools/build-managers/cmake/default.nix
@@ -7,7 +7,7 @@ with stdenv.lib;
 let
   os = stdenv.lib.optionalString;
   majorVersion = "2.8";
-  minorVersion = "9";
+  minorVersion = "11.2";
   version = "${majorVersion}.${minorVersion}";
 in
 
@@ -18,13 +18,19 @@ stdenv.mkDerivation rec {
 
   src = fetchurl {
     url = "${meta.homepage}files/v${majorVersion}/cmake-${version}.tar.gz";
-    sha256 = "1yg68ng732cfm5c0h91chqwhg06zdh45bybm353kd1myk5rwqgfw";
+    sha256 = "0qh5dhd7ff08n2h569j7g9m92gb3bz14wvhwjhwl7lgx794cnamk";
   };
 
+  enableParallelBuilding = true;
+
   patches =
+    # See https://github.com/NixOS/nixpkgs/issues/762
+    # and http://public.kitware.com/Bug/view.php?id=13887
+    # Remove this patch when a CMake release contains the corresponding fix
+    [ ./762-13887.patch ]
     # Don't search in non-Nix locations such as /usr, but do search in
-    # Nixpkgs' Glibc.
-    optional (stdenv ? glibc) ./search-path.patch;
+    # Nixpkgs' Glibc. 
+    ++ optional (stdenv ? glibc) ./search-path.patch;
 
   buildInputs = [ curl expat zlib bzip2 libarchive ]
     ++ optional useNcurses ncurses
diff --git a/pkgs/development/tools/build-managers/cmake/search-path.patch b/pkgs/development/tools/build-managers/cmake/search-path.patch
index ef8a9eef7c18..31c85d6f5220 100644
--- a/pkgs/development/tools/build-managers/cmake/search-path.patch
+++ b/pkgs/development/tools/build-managers/cmake/search-path.patch
@@ -1,41 +1,43 @@
-diff -ru -x '*~' cmake-2.8.5-orig/Modules/Platform/Linux.cmake cmake-2.8.5/Modules/Platform/Linux.cmake
---- cmake-2.8.5-orig/Modules/Platform/Linux.cmake	2011-07-08 14:21:44.000000000 +0200
-+++ cmake-2.8.5/Modules/Platform/Linux.cmake	2011-07-21 19:45:00.000000000 +0200
-@@ -36,13 +36,13 @@
+diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake
+index fe8e003..378512c 100644
+--- a/Modules/Platform/Linux.cmake
++++ b/Modules/Platform/Linux.cmake
+@@ -36,13 +36,13 @@ else()
    # checking the platform every time.  This option is advanced enough
    # that only package maintainers should need to adjust it.  They are
    # capable of providing a setting on the command line.
--  IF(EXISTS "/etc/debian_version")
--    SET(CMAKE_INSTALL_SO_NO_EXE 1 CACHE INTERNAL
+-  if(EXISTS "/etc/debian_version")
+-    set(CMAKE_INSTALL_SO_NO_EXE 1 CACHE INTERNAL
 -      "Install .so files without execute permission.")
--  ELSE(EXISTS "/etc/debian_version")
-+  #IF(EXISTS "/etc/debian_version")
-+  #  SET(CMAKE_INSTALL_SO_NO_EXE 1 CACHE INTERNAL
-+  #    "Install .so files without execute permission.")
-+  #ELSE(EXISTS "/etc/debian_version")
-     SET(CMAKE_INSTALL_SO_NO_EXE 0 CACHE INTERNAL
+-  else()
++  # if(EXISTS "/etc/debian_version")
++  #   set(CMAKE_INSTALL_SO_NO_EXE 1 CACHE INTERNAL
++  #     "Install .so files without execute permission.")
++  # else()
+     set(CMAKE_INSTALL_SO_NO_EXE 0 CACHE INTERNAL
        "Install .so files without execute permission.")
--  ENDIF(EXISTS "/etc/debian_version")
-+  #ENDIF(EXISTS "/etc/debian_version")
- ENDIF(DEFINED CMAKE_INSTALL_SO_NO_EXE)
+-  endif()
++  # endif()
+ endif()
  
  # Match multiarch library directory names.
-@@ -52,6 +52,6 @@
+@@ -52,6 +52,6 @@ include(Platform/UnixPaths)
  
  # Debian has lib64 paths only for compatibility so they should not be
  # searched.
--IF(EXISTS "/etc/debian_version")
--  SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
--ENDIF(EXISTS "/etc/debian_version")
-+#IF(EXISTS "/etc/debian_version")
-+#  SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
-+#ENDIF(EXISTS "/etc/debian_version")
-diff -ru -x '*~' cmake-2.8.5-orig/Modules/Platform/UnixPaths.cmake cmake-2.8.5/Modules/Platform/UnixPaths.cmake
---- cmake-2.8.5-orig/Modules/Platform/UnixPaths.cmake	2011-07-08 14:21:44.000000000 +0200
-+++ cmake-2.8.5/Modules/Platform/UnixPaths.cmake	2011-07-21 19:50:52.000000000 +0200
-@@ -33,55 +33,18 @@
+-if(EXISTS "/etc/debian_version")
+-  set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
+-endif()
++# if(EXISTS "/etc/debian_version")
++#  set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
++#endif()
+diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
+index ccb2663..39834e6 100644
+--- a/Modules/Platform/UnixPaths.cmake
++++ b/Modules/Platform/UnixPaths.cmake
+@@ -33,55 +33,18 @@ get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
  # search types.
- LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH
    # Standard
 -  /usr/local /usr /
 -
@@ -47,7 +49,7 @@ diff -ru -x '*~' cmake-2.8.5-orig/Modules/Platform/UnixPaths.cmake cmake-2.8.5/M
 -  )
 -
 -# List common include file locations not under the common prefixes.
--LIST(APPEND CMAKE_SYSTEM_INCLUDE_PATH
+-list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
 -  # Windows API on Cygwin
 -  /usr/include/w32api
 -
@@ -56,11 +58,11 @@ diff -ru -x '*~' cmake-2.8.5-orig/Modules/Platform/UnixPaths.cmake cmake-2.8.5/M
 -
 -  # Other
 -  /usr/pkg/include
--  /opt/csw/include /opt/include  
+-  /opt/csw/include /opt/include
 -  /usr/openwin/include
 -  )
 -
--LIST(APPEND CMAKE_SYSTEM_LIBRARY_PATH
+-list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
 -  # Windows API on Cygwin
 -  /usr/lib/w32api
 -
@@ -69,25 +71,25 @@ diff -ru -x '*~' cmake-2.8.5-orig/Modules/Platform/UnixPaths.cmake cmake-2.8.5/M
 -
 -  # Other
 -  /usr/pkg/lib
--  /opt/csw/lib /opt/lib 
+-  /opt/csw/lib /opt/lib
 -  /usr/openwin/lib
 -  )
 -
--LIST(APPEND CMAKE_SYSTEM_PROGRAM_PATH
+-list(APPEND CMAKE_SYSTEM_PROGRAM_PATH
 -  /usr/pkg/bin
 +  "@glibc@"
    )
  
- LIST(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
+ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
 -  /lib /usr/lib /usr/lib32 /usr/lib64
 +  "@glibc@/lib"
    )
  
- LIST(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
+ list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
 -  /usr/include
 +  "@glibc@/include"
    )
- LIST(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
+ list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
 -  /usr/include
 +  "@glibc@/include"
    )
diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
index 175e538e5193..abc0b070a764 100755
--- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh
+++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
@@ -56,3 +56,20 @@ if [ -n "$crossConfig" ]; then
 else
     envHooks+=(addCMakeParams)
 fi
+
+makeCmakeFindLibs(){
+  for flag in $NIX_CFLAGS_COMPILE $NIX_LDFLAGS; do
+    case $flag in
+      -I*)
+        export CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH${CMAKE_INCLUDE_PATH:+:}${flag:2}"
+        ;;
+      -L*)
+        export CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH${CMAKE_LIBRARY_PATH:+:}${flag:2}"
+        ;;
+    esac
+  done
+}
+
+# not using setupHook, because it could be a setupHook adding additional
+# include flags to NIX_CFLAGS_COMPILE
+postHooks+=(makeCmakeFindLibs)
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index 6b93240ba057..300922384bd8 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -1,10 +1,13 @@
 { stdenv, fetchurl, noSysDirs, zlib
-, cross ? null, gold ? false, bison ? null, flex2535 ? null, bc ? null, dejagnu ? null
+, cross ? null, gold ? true, bison ? null
 , deterministic ? false }:
 
 let basename = "binutils-2.23.1"; in
+
+with { inherit (stdenv.lib) optional optionals optionalString; };
+
 stdenv.mkDerivation rec {
-  name = basename + stdenv.lib.optionalString (cross != null) "-${cross.config}";
+  name = basename + optionalString (cross != null) "-${cross.config}";
 
   src = fetchurl {
     url = "mirror://gnu/binutils/${basename}.tar.bz2";
@@ -21,18 +24,18 @@ stdenv.mkDerivation rec {
     # That requires upstream changes for things to work. So we can patch it to
     # get the old behaviour by now.
     ./dtneeded.patch
-  ] ++ (stdenv.lib.optional deterministic ./deterministic.patch);
+  ] ++ optional deterministic ./deterministic.patch;
 
   buildInputs =
     [ zlib ]
-    ++ stdenv.lib.optional gold bison;
+    ++ optional gold bison;
 
   inherit noSysDirs;
 
   preConfigure = ''
     # Clear the default library search path.
     if test "$noSysDirs" = "1"; then
-	echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
+        echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
     fi
 
     # Use symlinks instead of hard links to save space ("strip" in the
@@ -46,15 +49,16 @@ stdenv.mkDerivation rec {
   # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
   NIX_CFLAGS_COMPILE = "-static-libgcc";
 
-  configureFlags = "--disable-werror" # needed for dietlibc build
-      + stdenv.lib.optionalString (stdenv.system == "mips64el-linux")
-        " --enable-fix-loongson2f-nop"
-      + stdenv.lib.optionalString (cross != null) " --target=${cross.config}"
-      + stdenv.lib.optionalString gold " --enable-gold --enable-plugins"
-      + stdenv.lib.optionalString deterministic " --enable-deterministic-archives";
+  configureFlags = [ "--disable-werror" ] # needed for dietlibc build
+    ++ optional (stdenv.system == "mips64el-linux") "--enable-fix-loongson2f-nop"
+    ++ optional (cross != null) "--target=${cross.config}"
+    ++ optionals gold [ "--enable-gold" "--enable-plugins" ]
+    ++ optional deterministic "--enable-deterministic-archives"
+    ++ optional (stdenv.system == "i686-linux") "--enable-targets=x86_64-linux-gnu"
+    ;
 
   enableParallelBuilding = true;
-      
+
   meta = {
     description = "GNU Binutils, tools for manipulating binaries (linker, assembler, etc.)";
 
diff --git a/pkgs/development/tools/misc/elfutils/default.nix b/pkgs/development/tools/misc/elfutils/default.nix
index 526a66e02804..e2f6c6932987 100644
--- a/pkgs/development/tools/misc/elfutils/default.nix
+++ b/pkgs/development/tools/misc/elfutils/default.nix
@@ -3,20 +3,20 @@
 # TODO: Look at the hardcoded paths to kernel, modules etc.
 stdenv.mkDerivation rec {
   name = "elfutils-${version}";
-  version = "0.152";
-  
+  version = "0.155";
+
   src = fetchurl {
     urls = [
-      "https://fedorahosted.org/releases/e/l/elfutils/${version}/${name}.tar.bz2"
+      "http://fedorahosted.org/releases/e/l/elfutils/${version}/${name}.tar.bz2"
       "mirror://gentoo/distfiles/${name}.tar.bz2"
       ];
-    sha256 = "19mlgxyzcwiv64ynj2cibgkiw4qkm3n37kizvy6555dsmlaqfybq";
+    sha256 = "1n0fsg2q961i0lj355w2ad3cmp7d1jjcdhrfhmlgsvs14r2lli38";
   };
 
   patches = [
     (fetchurl {
-      url = https://fedorahosted.org/releases/e/l/elfutils/0.152/elfutils-portability.patch;
-      sha256 = "0q318w4cvvqv9ps4xcwphapj1gl31isgjyya4y9sm72qj68n61p0";
+      url = "http://fedorahosted.org/releases/e/l/elfutils/${version}/elfutils-portability.patch";
+      sha256 = "0w8i94x9hqirgs2lwcd1g36s77r5svh4j1fgcrd6lx5w18vch0di";
     }) ];
 
   # We need bzip2 in NativeInputs because otherwise we can't unpack the src,
diff --git a/pkgs/development/tools/misc/gnum4/default.nix b/pkgs/development/tools/misc/gnum4/default.nix
index d1b0d0e376ed..75e8e2dfe4fd 100644
--- a/pkgs/development/tools/misc/gnum4/default.nix
+++ b/pkgs/development/tools/misc/gnum4/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl}:
 
-stdenv.mkDerivation {
-  name = "gnum4-1.4.16";
+stdenv.mkDerivation rec {
+  name = "gnum4-1.4.17";
 
   src = fetchurl {
-    url = mirror://gnu/m4/m4-1.4.16.tar.bz2;
-    sha256 = "035r7ma272j2cwni2961jp22k6bn3n9xwn3b3qbcn2yrvlghql22";
+    url = "mirror://gnu/m4/m4-1.4.17.tar.bz2";
+    sha256 = "0w0da1chh12mczxa5lnwzjk9czi3dq6gnnndbpa6w4rj76b1yklf";
   };
 
   doCheck = !stdenv.isDarwin
@@ -13,7 +13,7 @@ stdenv.mkDerivation {
     && !stdenv.isSunOS;                    # XXX: `test-setlocale2.sh' fails
 
   # Upstream is aware of it; it may be in the next release.
-  patches = [ ./s_isdir.patch ./readlink-EINVAL.patch ./no-gets.patch ];
+  patches = [ ./s_isdir.patch ];
 
   meta = {
     homepage = http://www.gnu.org/software/m4/;
diff --git a/pkgs/development/tools/misc/gnum4/no-gets.patch b/pkgs/development/tools/misc/gnum4/no-gets.patch
deleted file mode 100644
index 456c08b56c34..000000000000
--- a/pkgs/development/tools/misc/gnum4/no-gets.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-devel/m4/files/m4-1.4.16-no-gets.patch?revision=1.1
-
-https://bugs.gentoo.org/424978
-
-hack until m4 pulls a newer gnulib version
-
-From 66712c23388e93e5c518ebc8515140fa0c807348 Mon Sep 17 00:00:00 2001
-From: Eric Blake <eblake@redhat.com>
-Date: Thu, 29 Mar 2012 13:30:41 -0600
-Subject: [PATCH] stdio: don't assume gets any more
-
-Gnulib intentionally does not have a gets module, and now that C11
-and glibc have dropped it, we should be more proactive about warning
-any user on a platform that still has a declaration of this dangerous
-interface.
-
---- a/lib/stdio.in.h
-+++ b/lib/stdio.in.h
-@@ -125,7 +125,6 @@
-    so any use of gets warrants an unconditional warning.  Assume it is
-    always declared, since it is required by C89.  */
- #undef gets
--_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
- 
- #if @GNULIB_FOPEN@
- # if @REPLACE_FOPEN@
diff --git a/pkgs/development/tools/misc/gnum4/readlink-EINVAL.patch b/pkgs/development/tools/misc/gnum4/readlink-EINVAL.patch
deleted file mode 100644
index dd371584a798..000000000000
--- a/pkgs/development/tools/misc/gnum4/readlink-EINVAL.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-Newer Linux kernels would return EINVAL instead of ENOENT.
-The patch below, taken from Gnulib, allows the test to pass when
-these Linux versions are in use:
-https://lists.gnu.org/archive/html/bug-gnulib/2011-03/msg00308.html .
-
-diff --git a/tests/test-readlink.h b/tests/test-readlink.h
-index 08d5662..7247fc4 100644
---- a/tests/test-readlink.h
-+++ b/tests/test-readlink.h
-@@ -38,7 +38,7 @@ test_readlink (ssize_t (*func) (char const *, char *, size_t), bool print)
-   ASSERT (errno == ENOENT);
-   errno = 0;
-   ASSERT (func ("", buf, sizeof buf) == -1);
--  ASSERT (errno == ENOENT);
-+  ASSERT (errno == ENOENT || errno == EINVAL);
-   errno = 0;
-   ASSERT (func (".", buf, sizeof buf) == -1);
-   ASSERT (errno == EINVAL);
diff --git a/pkgs/development/tools/misc/texinfo/4.9.nix b/pkgs/development/tools/misc/texinfo/4.9.nix
deleted file mode 100644
index fd42093e561d..000000000000
--- a/pkgs/development/tools/misc/texinfo/4.9.nix
+++ /dev/null
@@ -1,10 +0,0 @@
-{stdenv, fetchurl, ncurses}:
-
-stdenv.mkDerivation {
-  name = "texinfo-4.9";
-  src = fetchurl {
-    url = mirror://gnu/texinfo/texinfo-4.9.tar.bz2;
-    sha256 = "0h7q9h405m88fjj067brzniiv8306ryl087pgjpmbpd2jci9h6g7";
-  };
-  buildInputs = [ncurses];
-}
diff --git a/pkgs/development/tools/misc/texinfo/5.1.nix b/pkgs/development/tools/misc/texinfo/5.2.nix
index 2f318f18d542..1bb8fca0ecff 100644
--- a/pkgs/development/tools/misc/texinfo/5.1.nix
+++ b/pkgs/development/tools/misc/texinfo/5.2.nix
@@ -1,14 +1,14 @@
-{ stdenv, fetchurl, ncurses, perl }:
+{ stdenv, fetchurl, ncurses, perl, xz }:
 
 stdenv.mkDerivation rec {
-  name = "texinfo-5.1";
+  name = "texinfo-5.2";
 
   src = fetchurl {
     url = "mirror://gnu/texinfo/${name}.tar.xz";
-    sha256 = "0864v5i488x3mb3v5p6nhy2kw0mqkzpa3b0453iibj81zlpq078q";
+    sha256 = "1njfwh2z34r2c4r0iqa7v24wmjzvsfyz4vplzry8ln3479lfywal";
   };
 
-  buildInputs = [ ncurses perl ];
+  buildInputs = [ ncurses perl xz ];
 
   preInstall = ''
     installFlags="TEXMF=$out/texmf-dist";
diff --git a/pkgs/development/tools/parsing/alex/2.3.1.nix b/pkgs/development/tools/parsing/alex/2.3.1.nix
index 7dc17cd4153a..b38979256c66 100644
--- a/pkgs/development/tools/parsing/alex/2.3.1.nix
+++ b/pkgs/development/tools/parsing/alex/2.3.1.nix
@@ -8,6 +8,7 @@ cabal.mkDerivation (self: {
   isExecutable = true;
   buildTools = [ perl ];
   doCheck = false;
+  patches = [ ./adapt-crazy-perl-regex-for-cpp-4.8.0.patch ];
   meta = {
     homepage = "http://www.haskell.org/alex/";
     description = "Alex is a tool for generating lexical analysers in Haskell";
diff --git a/pkgs/development/tools/parsing/alex/2.3.2.nix b/pkgs/development/tools/parsing/alex/2.3.2.nix
index 5d10dbd69951..dc4a0261c4a9 100644
--- a/pkgs/development/tools/parsing/alex/2.3.2.nix
+++ b/pkgs/development/tools/parsing/alex/2.3.2.nix
@@ -8,6 +8,7 @@ cabal.mkDerivation (self: {
   isExecutable = true;
   buildTools = [ perl ];
   doCheck = false;
+  patches = [ ./adapt-crazy-perl-regex-for-cpp-4.8.0.patch ];
   meta = {
     homepage = "http://www.haskell.org/alex/";
     description = "Alex is a tool for generating lexical analysers in Haskell";
diff --git a/pkgs/development/tools/parsing/alex/2.3.3.nix b/pkgs/development/tools/parsing/alex/2.3.3.nix
index bbe413d478ff..146f784463e4 100644
--- a/pkgs/development/tools/parsing/alex/2.3.3.nix
+++ b/pkgs/development/tools/parsing/alex/2.3.3.nix
@@ -8,6 +8,7 @@ cabal.mkDerivation (self: {
   isExecutable = true;
   buildTools = [ perl ];
   doCheck = false;
+  patches = [ ./adapt-crazy-perl-regex-for-cpp-4.8.0.patch ];
   meta = {
     homepage = "http://www.haskell.org/alex/";
     description = "Alex is a tool for generating lexical analysers in Haskell";
diff --git a/pkgs/development/tools/parsing/alex/2.3.5.nix b/pkgs/development/tools/parsing/alex/2.3.5.nix
index 3fb843e69557..65faf84aa2cb 100644
--- a/pkgs/development/tools/parsing/alex/2.3.5.nix
+++ b/pkgs/development/tools/parsing/alex/2.3.5.nix
@@ -8,6 +8,7 @@ cabal.mkDerivation (self: {
   isExecutable = true;
   buildTools = [ perl ];
   doCheck = false;
+  patches = [ ./adapt-crazy-perl-regex-for-cpp-4.8.0.patch ];
   meta = {
     homepage = "http://www.haskell.org/alex/";
     description = "Alex is a tool for generating lexical analysers in Haskell";
diff --git a/pkgs/development/tools/parsing/alex/adapt-crazy-perl-regex-for-cpp-4.8.0.patch b/pkgs/development/tools/parsing/alex/adapt-crazy-perl-regex-for-cpp-4.8.0.patch
new file mode 100644
index 000000000000..1e5942bfbefb
--- /dev/null
+++ b/pkgs/development/tools/parsing/alex/adapt-crazy-perl-regex-for-cpp-4.8.0.patch
@@ -0,0 +1,12 @@
+diff -ubr alex-2.3.5-orig/Setup.lhs alex-2.3.5/Setup.lhs
+--- alex-2.3.5-orig/Setup.lhs	2013-04-19 12:00:15.812606335 +0000
++++ alex-2.3.5/Setup.lhs	2013-04-19 12:05:41.635450321 +0000
+@@ -25,7 +25,7 @@
+ -- hack to turn cpp-style '# 27 "GenericTemplate.hs"' into 
+ -- '{-# LINE 27 "GenericTemplate.hs" #-}'.
+ crazy_perl_regexp =
+- "s/^#\\s+(\\d+)\\s+(\"[^\"]*\")/{-# LINE \\1 \\2 #-}/g;s/\\$(Id:.*)\\$/\\1/g"
++ "s/^#\\s+(\\d+)\\s+(\"[^\"]*\").*/{-# LINE \\1 \\2 #-}/g;s/\\$(Id:.*)\\$/\\1/g"
+ 
+ myPostBuild _ flags _ lbi = do
+   let runProgram p = rawSystemProgramConf (buildVerbose flags) p (withPrograms lbi)
diff --git a/pkgs/development/tools/parsing/bison/2.x.nix b/pkgs/development/tools/parsing/bison/2.x.nix
index 77ba164f07ae..5660d51f0606 100644
--- a/pkgs/development/tools/parsing/bison/2.x.nix
+++ b/pkgs/development/tools/parsing/bison/2.x.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, m4, perl }:
 
 stdenv.mkDerivation rec {
-  name = "bison-2.6.5";
+  name = "bison-2.7";
 
   src = fetchurl {
-    url = "mirror://gnu/bison/${name}.tar.xz";
-    sha256 = "8640d5b51aad462db6863711f333a9159836853e0b1e79fdef708c6efb5cd52b";
+    url = "mirror://gnu/bison/${name}.tar.gz";
+    sha256 = "0cd8s2g7zjshya7kwjc9rh3drsssl4hiq4sccnkgf0nn9wvygfqr";
   };
 
   nativeBuildInputs = [ m4 ] ++ stdenv.lib.optional doCheck perl;
diff --git a/pkgs/development/tools/parsing/bison/3.x.nix b/pkgs/development/tools/parsing/bison/3.x.nix
index 9b1499c15375..e80f903db124 100644
--- a/pkgs/development/tools/parsing/bison/3.x.nix
+++ b/pkgs/development/tools/parsing/bison/3.x.nix
@@ -4,14 +4,14 @@ stdenv.mkDerivation rec {
   name = "bison-3.0";
 
   src = fetchurl {
-    url = "mirror://gnu/bison/${name}.tar.xz";
-    sha256 = "1j14fqgi9wzqgsy4fhkcdrv4hv6rrvhvn84axs520w9b022mbb79";
+    url = "mirror://gnu/bison/${name}.tar.gz";
+    sha256 = "1ll22hcfslyl9n3pgvvphzdp18w9cyic8m0qimfnb8mrs1syrdz5";
   };
 
-  nativeBuildInputs = [ m4 ] ++ stdenv.lib.optionals doCheck [perl flex];
+  nativeBuildInputs = [ m4 perl ] ++ stdenv.lib.optionals doCheck [ flex ];
   propagatedBuildInputs = [ m4 ];
 
-  doCheck = true;
+  doCheck = flex != null;
 
   meta = {
     homepage = "http://www.gnu.org/software/bison/";
diff --git a/pkgs/development/tools/parsing/flex/flex-2.5.35.nix b/pkgs/development/tools/parsing/flex/default.nix
index 21180e7d185e..21180e7d185e 100644
--- a/pkgs/development/tools/parsing/flex/flex-2.5.35.nix
+++ b/pkgs/development/tools/parsing/flex/default.nix
diff --git a/pkgs/development/tools/parsing/flex/flex-2.5.33.nix b/pkgs/development/tools/parsing/flex/flex-2.5.33.nix
deleted file mode 100644
index 9be98689aeaa..000000000000
--- a/pkgs/development/tools/parsing/flex/flex-2.5.33.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-# !!! this should be moved to default.nix eventually (but I delay
-# doing that since it would cause a rebuild of lots of stuff).
-
-{stdenv, fetchurl, yacc, m4}:
-
-assert yacc != null && m4 != null;
-
-stdenv.mkDerivation {
-  name = "flex-2.5.33";
-  src = fetchurl {
-    url = mirror://sourceforge/flex/flex-2.5.33.tar.bz2;
-    md5 = "343374a00b38d9e39d1158b71af37150";
-  };
-  buildInputs = [yacc];
-  propagatedBuildInputs = [m4];
-
-  meta = {
-    description = "A fast lexical analyser generator";
-  };
-}
diff --git a/pkgs/development/tools/parsing/flex/flex-2.5.34.nix b/pkgs/development/tools/parsing/flex/flex-2.5.34.nix
deleted file mode 100644
index d56cf0c88a2e..000000000000
--- a/pkgs/development/tools/parsing/flex/flex-2.5.34.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-# This should be moved to default.nix eventually (?)
-
-{stdenv, fetchurl, yacc, m4}:
-
-assert yacc != null && m4 != null;
-
-stdenv.mkDerivation {
-  name = "flex-2.5.34";
-  src = fetchurl {
-    url = mirror://sourceforge/flex/flex-2.5.34.tar.bz2;
-    sha256 = "1c8e64f32508841b0441ddfb139c4cfd25fee3728cadb63f5f351c6eb9b224a6";
-  };
-  buildInputs = [yacc];
-  propagatedBuildInputs = [m4];
-
-  meta = {
-    description = "A fast lexical analyser generator";
-  };
-}
diff --git a/pkgs/development/tools/parsing/flex/flex-2.5.4a.nix b/pkgs/development/tools/parsing/flex/flex-2.5.4a.nix
deleted file mode 100644
index 13bb68349790..000000000000
--- a/pkgs/development/tools/parsing/flex/flex-2.5.4a.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-{stdenv, fetchurl, yacc}:
-
-assert yacc != null;
-
-stdenv.mkDerivation {
-  name = "flex-2.5.4a";
-  src = fetchurl {
-    url = mirror://sourceforge/flex/flex-2.5.4a.tar.gz;
-    md5 = "bd8753d0b22e1f4ec87a553a73021adf";
-  };
-  buildInputs = [yacc];
-}
diff --git a/pkgs/development/tools/parsing/happy/1.18.4.nix b/pkgs/development/tools/parsing/happy/1.18.4.nix
index 401c4d1475ce..5ebac4303e75 100644
--- a/pkgs/development/tools/parsing/happy/1.18.4.nix
+++ b/pkgs/development/tools/parsing/happy/1.18.4.nix
@@ -8,6 +8,7 @@ cabal.mkDerivation (self: {
   isExecutable = true;
   buildDepends = [ mtl ];
   buildTools = [ perl ];
+  patches = [ ./adapt-crazy-perl-regex-for-cpp-4.8.0.patch ];
   meta = {
     homepage = "http://www.haskell.org/happy/";
     description = "Happy is a parser generator for Haskell";
diff --git a/pkgs/development/tools/parsing/happy/1.18.5.nix b/pkgs/development/tools/parsing/happy/1.18.5.nix
index d64d8983e9cb..7463a9f94a0a 100644
--- a/pkgs/development/tools/parsing/happy/1.18.5.nix
+++ b/pkgs/development/tools/parsing/happy/1.18.5.nix
@@ -8,6 +8,7 @@ cabal.mkDerivation (self: {
   isExecutable = true;
   buildDepends = [ mtl ];
   buildTools = [ perl ];
+  patches = [ ./adapt-crazy-perl-regex-for-cpp-4.8.0.patch ];
   meta = {
     homepage = "http://www.haskell.org/happy/";
     description = "Happy is a parser generator for Haskell";
diff --git a/pkgs/development/tools/parsing/happy/1.18.6.nix b/pkgs/development/tools/parsing/happy/1.18.6.nix
index fdc483fe5714..3a3795c90db6 100644
--- a/pkgs/development/tools/parsing/happy/1.18.6.nix
+++ b/pkgs/development/tools/parsing/happy/1.18.6.nix
@@ -8,6 +8,7 @@ cabal.mkDerivation (self: {
   isExecutable = true;
   buildDepends = [ mtl ];
   buildTools = [ perl ];
+  patches = [ ./adapt-crazy-perl-regex-for-cpp-4.8.0.patch ];
   meta = {
     homepage = "http://www.haskell.org/happy/";
     description = "Happy is a parser generator for Haskell";
diff --git a/pkgs/development/tools/parsing/happy/1.18.8.nix b/pkgs/development/tools/parsing/happy/1.18.8.nix
index decc992809a2..141205d19402 100644
--- a/pkgs/development/tools/parsing/happy/1.18.8.nix
+++ b/pkgs/development/tools/parsing/happy/1.18.8.nix
@@ -8,6 +8,7 @@ cabal.mkDerivation (self: {
   isExecutable = true;
   buildDepends = [ mtl ];
   buildTools = [ perl ];
+  patches = [ ./adapt-crazy-perl-regex-for-cpp-4.8.0.patch ];
   meta = {
     homepage = "http://www.haskell.org/happy/";
     description = "Happy is a parser generator for Haskell";
diff --git a/pkgs/development/tools/parsing/happy/adapt-crazy-perl-regex-for-cpp-4.8.0.patch b/pkgs/development/tools/parsing/happy/adapt-crazy-perl-regex-for-cpp-4.8.0.patch
new file mode 100644
index 000000000000..8bc4db0f405e
--- /dev/null
+++ b/pkgs/development/tools/parsing/happy/adapt-crazy-perl-regex-for-cpp-4.8.0.patch
@@ -0,0 +1,12 @@
+diff -ubr happy-1.18.6-orig/Setup.lhs happy-1.18.6/Setup.lhs
+--- happy-1.18.6-orig/Setup.lhs	2013-04-19 14:17:10.865999210 +0200
++++ happy-1.18.6/Setup.lhs	2013-04-19 14:17:15.285214809 +0200
+@@ -25,7 +25,7 @@
+ -- hack to turn cpp-style '# 27 "GenericTemplate.hs"' into 
+ -- '{-# LINE 27 "GenericTemplate.hs" #-}'.
+ crazy_perl_regexp =
+- "s/^#\\s+(\\d+)\\s+(\"[^\"]*\")/{-# LINE \\1 \\2 #-}/g;s/\\$(Id:.*)\\$/\\1/g"
++ "s/^#\\s+(\\d+)\\s+(\"[^\"]*\").*/{-# LINE \\1 \\2 #-}/g;s/\\$(Id:.*)\\$/\\1/g"
+ 
+ myPostBuild _ flags _ lbi = do
+   let runProgram p = rawSystemProgramConf (buildVerbose flags) p (withPrograms lbi)