about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/audio/sonic-visualiser/default.nix5
-rw-r--r--pkgs/applications/editors/ed/default.nix4
-rw-r--r--pkgs/applications/graphics/inkscape/default.nix4
-rw-r--r--pkgs/applications/graphics/inkscape/libpng-1.5.patch47
-rw-r--r--pkgs/applications/graphics/inkscape/spuriouscomma.patch11
-rw-r--r--pkgs/applications/misc/goldendict/default.nix2
-rw-r--r--pkgs/applications/misc/goldendict/gcc47.patch40
-rw-r--r--pkgs/applications/networking/esniper/default.nix15
-rw-r--r--pkgs/applications/version-management/git-and-tools/git/default.nix3
-rw-r--r--pkgs/build-support/cabal/default.nix27
-rw-r--r--pkgs/build-support/gcc-wrapper/builder.sh21
-rw-r--r--pkgs/build-support/gcc-wrapper/default.nix1
-rw-r--r--pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh40
-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
-rw-r--r--pkgs/development/compilers/ghc/6.10.1-binary.nix4
-rw-r--r--pkgs/development/compilers/ghc/6.10.2-binary.nix4
-rw-r--r--pkgs/development/compilers/ghc/6.12.1-binary.nix4
-rw-r--r--pkgs/development/compilers/ghc/7.0.4-binary.nix4
-rw-r--r--pkgs/development/compilers/ghc/7.4.2-binary.nix4
-rw-r--r--pkgs/development/compilers/ghc/7.4.2.nix1
-rw-r--r--pkgs/development/compilers/ghc/7.6.3.nix5
-rwxr-xr-xpkgs/development/compilers/ghc/ghc-get-packages.sh21
-rw-r--r--pkgs/development/compilers/ghc/head.nix1
-rw-r--r--pkgs/development/compilers/ghc/with-packages.nix141
-rw-r--r--pkgs/development/compilers/ghc/wrapper.nix93
-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/cln/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/haskell/bytestring-progress/default.nix1
-rw-r--r--pkgs/development/libraries/haskell/dns/default.nix2
-rw-r--r--pkgs/development/libraries/haskell/modular-arithmetic/default.nix1
-rw-r--r--pkgs/development/libraries/haskell/multirec/default.nix1
-rw-r--r--pkgs/development/libraries/haskell/wxHaskell/wxc.nix1
-rw-r--r--pkgs/development/libraries/icu/default.nix4
-rw-r--r--pkgs/development/libraries/isl/default.nix9
-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.nix12
-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/default.nix5
-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/protobuf/default.nix4
-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/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/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
-rw-r--r--pkgs/games/asc/default.nix4
-rw-r--r--pkgs/misc/emulators/zsnes/default.nix32
-rw-r--r--pkgs/misc/emulators/zsnes/zsnes-1.51-libpng15.patch12
-rw-r--r--pkgs/misc/emulators/zsnes/zsnes.patch80
-rw-r--r--pkgs/servers/x11/xorg/overrides.nix13
-rw-r--r--pkgs/shells/bash/bash-4.2-patches.nix3
-rw-r--r--pkgs/stdenv/default.nix1
-rw-r--r--pkgs/stdenv/generic/default.nix6
-rw-r--r--pkgs/stdenv/generic/setup.sh60
-rw-r--r--pkgs/stdenv/linux/bootstrap/armv5tel/default.nix69
-rw-r--r--pkgs/stdenv/linux/bootstrap/armv6l/default.nix10
-rw-r--r--pkgs/stdenv/linux/bootstrap/i686/default.nix70
-rw-r--r--pkgs/stdenv/linux/bootstrap/loongson2f/default.nix70
-rw-r--r--pkgs/stdenv/linux/bootstrap/powerpc/default.nix64
-rw-r--r--pkgs/stdenv/linux/default.nix8
-rw-r--r--pkgs/stdenv/native/default.nix3
-rw-r--r--pkgs/stdenv/nix/default.nix1
-rw-r--r--pkgs/tools/archivers/cpio/default.nix17
-rw-r--r--pkgs/tools/archivers/cpio/no-gets.patch (renamed from pkgs/development/tools/misc/gnum4/no-gets.patch)10
-rw-r--r--pkgs/tools/archivers/gnutar/default.nix10
-rw-r--r--pkgs/tools/archivers/gnutar/gets-undeclared.patch26
-rw-r--r--pkgs/tools/compression/gzip/default.nix12
-rw-r--r--pkgs/tools/compression/gzip/skip-some-tests.patch12
-rw-r--r--pkgs/tools/compression/xz/default.nix4
-rw-r--r--pkgs/tools/filesystems/e2fsprogs/default.nix2
-rw-r--r--pkgs/tools/misc/coreutils/default.nix5
-rw-r--r--pkgs/tools/misc/file/default.nix4
-rw-r--r--pkgs/tools/misc/less/default.nix29
-rw-r--r--pkgs/tools/networking/curl/default.nix15
-rw-r--r--pkgs/tools/networking/p2p/amule/default.nix8
-rw-r--r--pkgs/tools/networking/p2p/amule/gcc47.patch21
-rw-r--r--pkgs/tools/text/diffutils/default.nix10
-rw-r--r--pkgs/tools/text/diffutils/gets-undeclared.patch71
-rw-r--r--pkgs/tools/text/gawk/default.nix4
-rw-r--r--pkgs/tools/text/gnugrep/default.nix2
-rw-r--r--pkgs/tools/text/gnugrep/test-localeconv.patch18
-rw-r--r--pkgs/tools/text/gnupatch/bashishms.patch67
-rw-r--r--pkgs/tools/text/gnupatch/default.nix5
-rw-r--r--pkgs/tools/text/gnused/default.nix6
-rw-r--r--pkgs/top-level/all-packages.nix178
-rw-r--r--pkgs/top-level/haskell-packages.nix11
-rw-r--r--pkgs/top-level/release-small.nix22
-rw-r--r--pkgs/top-level/release.nix1
175 files changed, 2990 insertions, 1107 deletions
diff --git a/pkgs/applications/audio/sonic-visualiser/default.nix b/pkgs/applications/audio/sonic-visualiser/default.nix
index aeb90c09455b..6e15478ff630 100644
--- a/pkgs/applications/audio/sonic-visualiser/default.nix
+++ b/pkgs/applications/audio/sonic-visualiser/default.nix
@@ -14,6 +14,11 @@ stdenv.mkDerivation rec {
     url = "http://code.soundsoftware.ac.uk/attachments/download/194/${name}.tar.gz";
     sha256 = "00igf7j6s8xfyxnlkbqma0yby9pknxqzy8cmh0aw95ix80cw56fq";
   };
+  patches = [(fetchurl {
+    url = http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/media-sound/sonic-visualiser/files/sonic-visualiser-1.9-gcc47.patch;
+    sha256 = "0dhh111crvjvhcjqp7j9jqnvs8zmd6xrcirmzqrrnca1h0vbpkay";
+    name = "gcc47.patch";
+  })];
 
   buildInputs =
     [ libsndfile qt4 fftw /* should be fftw3f ??*/ bzip2 librdf rubberband
diff --git a/pkgs/applications/editors/ed/default.nix b/pkgs/applications/editors/ed/default.nix
index 3e22cfd0412d..88b539d29f5f 100644
--- a/pkgs/applications/editors/ed/default.nix
+++ b/pkgs/applications/editors/ed/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv }:
 
 stdenv.mkDerivation rec {
-  name = "ed-1.7";
+  name = "ed-1.9";
 
   src = fetchurl {
     url = "mirror://gnu/ed/${name}.tar.gz";
-    sha256 = "0c908wb5pm48rjrrfbm5dhrqzys8f1dbvi90dn0vgwjzk80l2hl9";
+    sha256 = "122syihsx2hwzj75mkf5a9ssiky2xby748kp4cc00wzhmp7p5cym";
   };
 
   /* FIXME: Tests currently fail on Darwin:
diff --git a/pkgs/applications/graphics/inkscape/default.nix b/pkgs/applications/graphics/inkscape/default.nix
index 37905f8a73f6..478a0ff7e50c 100644
--- a/pkgs/applications/graphics/inkscape/default.nix
+++ b/pkgs/applications/graphics/inkscape/default.nix
@@ -13,6 +13,10 @@ stdenv.mkDerivation rec {
 
   patches = [ ./configure-python-libs.patch ];
 
+  postPatch = ''
+    patch -p0 < ${./spuriouscomma.patch}
+  '';
+
   propagatedBuildInputs = [
     # Python is used at run-time to execute scripts, e.g., those from
     # the "Effects" menu.
diff --git a/pkgs/applications/graphics/inkscape/libpng-1.5.patch b/pkgs/applications/graphics/inkscape/libpng-1.5.patch
deleted file mode 100644
index 4c8a7ee5f9b6..000000000000
--- a/pkgs/applications/graphics/inkscape/libpng-1.5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-Source: upstream revisions 10061 and 10707
-
---- a/src/sp-image.cpp	2011-02-21 07:59:34 +0000
-+++ b/src/sp-image.cpp	2011-02-21 08:57:28 +0000
-@@ -387,9 +387,13 @@
- 
- #if defined(PNG_iCCP_SUPPORTED)
-                 {
--                    char* name = 0;
-+                    png_charp name = 0;
-                     int compression_type = 0;
--                    char* profile = 0;
-+#if (PNG_LIBPNG_VER < 10500)
-+                    png_charp profile = 0;
-+#else
-+                    png_bytep profile = 0;
-+#endif
-                     png_uint_32 proflen = 0;
-                     if ( png_get_iCCP(pngPtr, infoPtr, &name, &compression_type, &profile, &proflen) ) {
- //                                         g_message("Found an iCCP chunk named [%s] with %d bytes and comp %d", name, proflen, compression_type);
-
---- a/src/extension/internal/pdfinput/svg-builder.cpp	2011-10-27 04:55:51 +0000
-+++ b/src/extension/internal/pdfinput/svg-builder.cpp	2011-10-29 20:34:00 +0000
-@@ -1481,7 +1481,7 @@
-         return NULL;
-     }
-     // Set error handler
--    if (setjmp(png_ptr->jmpbuf)) {
-+    if (setjmp(png_jmpbuf(png_ptr))) {
-         png_destroy_write_struct(&png_ptr, &info_ptr);
-         return NULL;
-     }
-
---- a/src/helper/png-write.cpp	2011-08-07 10:53:12 +0000
-+++ b/src/helper/png-write.cpp	2011-10-29 20:34:00 +0000
-@@ -166,8 +166,8 @@
-     /* Set error handling.  REQUIRED if you aren't supplying your own
-      * error hadnling functions in the png_create_write_struct() call.
-      */
--    if (setjmp(png_ptr->jmpbuf)) {
--        /* If we get here, we had a problem reading the file */
-+    if (setjmp(png_jmpbuf(png_ptr))) {
-+        // If we get here, we had a problem reading the file
-         fclose(fp);
-         png_destroy_write_struct(&png_ptr, &info_ptr);
-         return false;
-
diff --git a/pkgs/applications/graphics/inkscape/spuriouscomma.patch b/pkgs/applications/graphics/inkscape/spuriouscomma.patch
new file mode 100644
index 000000000000..bc538068f9e3
--- /dev/null
+++ b/pkgs/applications/graphics/inkscape/spuriouscomma.patch
@@ -0,0 +1,11 @@
+--- src/widgets/desktop-widget.h~	2011-07-08 13:25:09.000000000 -0500
++++ src/widgets/desktop-widget.h	2013-02-15 16:04:45.806910365 -0600
+@@ -239,7 +239,7 @@
+ private:
+     GtkWidget *tool_toolbox;
+     GtkWidget *aux_toolbox;
+-    GtkWidget *commands_toolbox,;
++    GtkWidget *commands_toolbox;
+     GtkWidget *snap_toolbox;
+ 
+     static void init(SPDesktopWidget *widget);
diff --git a/pkgs/applications/misc/goldendict/default.nix b/pkgs/applications/misc/goldendict/default.nix
index f7b8a511bc66..717d0a012a2c 100644
--- a/pkgs/applications/misc/goldendict/default.nix
+++ b/pkgs/applications/misc/goldendict/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     cd ${name}-src
     tar xf ${src}
   '';
-  patches = [ ./goldendict-paths.diff ];
+  patches = [ ./goldendict-paths.diff ./gcc47.patch ];
   patchFlags = "-p 0";
   configurePhase = ''
     qmake
diff --git a/pkgs/applications/misc/goldendict/gcc47.patch b/pkgs/applications/misc/goldendict/gcc47.patch
new file mode 100644
index 000000000000..311dad4f6487
--- /dev/null
+++ b/pkgs/applications/misc/goldendict/gcc47.patch
@@ -0,0 +1,40 @@
+From b00d081da20b9a6b257573c6b23a6bc640c4dab1 Mon Sep 17 00:00:00 2001
+From: Michael Palimaka <kensington@gentoo.org>
+Date: Fri, 20 Jul 2012 03:27:38 +1000
+Subject: [PATCH] Fix build with GCC 4.7 by adding missing includes.
+
+---
+ processwrapper.cc                       | 4 ++++
+ qtsingleapplication/src/qtlocalpeer.cpp | 1 +
+ 2 files changed, 5 insertions(+)
+
+diff --git processwrapper.cc processwrapper.cc
+index f7f3f19..86b985d 100644
+--- processwrapper.cc
++++ processwrapper.cc
+@@ -2,6 +2,10 @@
+ 

+ #include <QtCore>

+ 

++#if defined(Q_OS_UNIX)

++#include <unistd.h>

++#endif

++

+ #ifdef Q_OS_WIN32

+ 

+ #include <windows.h>

+diff --git qtsingleapplication/src/qtlocalpeer.cpp qtsingleapplication/src/qtlocalpeer.cpp
+index 382d182..506c142 100644
+--- qtsingleapplication/src/qtlocalpeer.cpp
++++ qtsingleapplication/src/qtlocalpeer.cpp
+@@ -50,6 +50,7 @@ static PProcessIdToSessionId pProcessIdToSessionId = 0;
+ #endif
+ #if defined(Q_OS_UNIX)
+ #include <time.h>
++#include <unistd.h>
+ #endif
+ 
+ namespace QtLP_Private {
+-- 
+1.7.11.1
+
diff --git a/pkgs/applications/networking/esniper/default.nix b/pkgs/applications/networking/esniper/default.nix
index 8208da621af0..50a2764d375c 100644
--- a/pkgs/applications/networking/esniper/default.nix
+++ b/pkgs/applications/networking/esniper/default.nix
@@ -4,11 +4,11 @@ stdenv.mkDerivation {
   name = "esniper-2.28.0";
 
   src = fetchurl {
-    url = "mirror://sourceforge/esniper/esniper-2-28-0.tgz";
+    url    = "mirror://sourceforge/esniper/esniper-2-28-0.tgz";
     sha256 = "c2b0ccb757616b32f2d6cf54a4a5e367405fa7bcd6e6ed11835fe4f8a06a016b";
   };
 
-  buildInputs = [openssl curl];
+  buildInputs = [ openssl curl ];
 
   # Add support for CURL_CA_BUNDLE variable.
   patches = [ ./find-ca-bundle.patch ];
@@ -19,12 +19,11 @@ stdenv.mkDerivation {
     chmod 555 "$out/bin/snipe"
   '';
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Simple, lightweight tool for sniping eBay auctions";
-    homepage = "http://esnipe.rsourceforge.net";
-    license = "GPLv2";
-
-    platforms = stdenv.lib.platforms.all;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    homepage    = http://esnipe.rsourceforge.net;
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ lovek323 simons ];
+    platforms   = platforms.all;
   };
 }
diff --git a/pkgs/applications/version-management/git-and-tools/git/default.nix b/pkgs/applications/version-management/git-and-tools/git/default.nix
index fb2e34c7aac9..6009493b4dbc 100644
--- a/pkgs/applications/version-management/git-and-tools/git/default.nix
+++ b/pkgs/applications/version-management/git-and-tools/git/default.nix
@@ -35,7 +35,8 @@ stdenv.mkDerivation {
   NIX_LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
 
   makeFlags = "prefix=\${out} sysconfdir=/etc/ PERL_PATH=${perl}/bin/perl SHELL_PATH=${stdenv.shell} "
-      + (if pythonSupport then "PYTHON_PATH=${python}/bin/python" else "NO_PYTHON=1");
+      + (if pythonSupport then "PYTHON_PATH=${python}/bin/python" else "NO_PYTHON=1")
+      + (if stdenv.isSunOS then " INSTALL=install NO_INET_NTOP= NO_INET_PTON=" else "");
 
   # FIXME: "make check" requires Sparse; the Makefile must be tweaked
   # so that `SPARSE_FLAGS' corresponds to the current architecture...
diff --git a/pkgs/build-support/cabal/default.nix b/pkgs/build-support/cabal/default.nix
index ca985181a532..a1dc68e6484a 100644
--- a/pkgs/build-support/cabal/default.nix
+++ b/pkgs/build-support/cabal/default.nix
@@ -1,6 +1,6 @@
 # generic builder for Cabal packages
 
-{ stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal
+{ stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal, glibcLocales
 , enableLibraryProfiling ? false
 , enableCheckPhase ? true
 }:
@@ -80,6 +80,9 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
             # build-depends Cabal fields stated in test-suite stanzas
             testDepends = [];
 
+            # target(s) passed to the cabal test phase as an argument
+            testTarget = "";
+
             # build-tools Cabal field
             buildTools = [];
 
@@ -109,6 +112,10 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
               (stdenv.lib.enableFeature self.enableSplitObjs "split-objs")
             ] ++ stdenv.lib.optional (stdenv.lib.versionOlder "7" ghc.ghcVersion) (stdenv.lib.enableFeature self.doCheck "tests");
 
+            # GHC needs the locale configured during the Haddock phase.
+            LANG = "en_US.UTF-8";
+            LOCALE_ARCHIVE = lib.optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
+
             # compiles Setup and configures
             configurePhase = ''
               eval "$preConfigure"
@@ -120,18 +127,22 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
               done
 
               for p in $extraBuildInputs $propagatedNativeBuildInputs; do
+                if [ -d "$p/lib/ghc-${ghc.ghc.version}/package.conf.d" ]; then
+                  # Haskell packages don't need any extra configuration.
+                  continue;
+                fi
                 if [ -d "$p/include" ]; then
-                  extraConfigureFlags+=" --extra-include-dir=$p/include"
+                  extraConfigureFlags+=" --extra-include-dirs=$p/include"
                 fi
                 for d in lib{,64}; do
                   if [ -d "$p/$d" ]; then
-                    extraConfigureFlags+=" --extra-lib-dir=$p/$d"
+                    extraConfigureFlags+=" --extra-lib-dirs=$p/$d"
                   fi
                 done
               done
 
               echo "configure flags: $extraConfigureFlags $configureFlags"
-              ./Setup configure --verbose --prefix="$out" $extraConfigureFlags $configureFlags
+              ./Setup configure --verbose --prefix="$out" --libdir='$prefix/lib/$compiler' --libsubdir='$pkgid' $extraConfigureFlags $configureFlags
 
               eval "$postConfigure"
             '';
@@ -142,8 +153,8 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
 
               ./Setup build
 
-              export GHC_PACKAGE_PATH=$(ghc-packages)
-              [ -n "$noHaddock" ] || ./Setup haddock
+              export GHC_PACKAGE_PATH=$(${ghc.GHCPackages})
+              test -n "$noHaddock" || ./Setup haddock
 
               eval "$postBuild"
             '';
@@ -151,7 +162,7 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
             checkPhase = stdenv.lib.optional self.doCheck ''
               eval "$preCheck"
 
-              ./Setup test
+              ./Setup test ${self.testTarget}
 
               eval "$postCheck"
             '';
@@ -166,7 +177,7 @@ assert enableCheckPhase -> stdenv.lib.versionOlder "7" ghc.ghcVersion;
 
               ensureDir $out/bin # necessary to get it added to PATH
 
-              local confDir=$out/lib/ghc-pkgs/ghc-${ghc.ghc.version}
+              local confDir=$out/lib/ghc-${ghc.ghc.version}/package.conf.d
               local installedPkgConf=$confDir/${self.fname}.installedconf
               local pkgConf=$confDir/${self.fname}.conf
               ensureDir $confDir
diff --git a/pkgs/build-support/gcc-wrapper/builder.sh b/pkgs/build-support/gcc-wrapper/builder.sh
index ed7ad0a50b73..e7c3400e9f7f 100644
--- a/pkgs/build-support/gcc-wrapper/builder.sh
+++ b/pkgs/build-support/gcc-wrapper/builder.sh
@@ -66,13 +66,23 @@ else
     echo "$gccCFlags" > $out/nix-support/gcc-cflags
     
     gccPath="$gcc/bin"
-    ldPath="$binutils/bin"
+    # On Illumos/Solaris we might prefer native ld
+    if test -n "$nativePrefix"; then
+      ldPath="$nativePrefix/bin"
+    else
+      ldPath="$binutils/bin"
+    fi;
 fi
 
 
 doSubstitute() {
     local src=$1
     local dst=$2
+    local ld="$ldPath/ld"
+    if $ld -V 2>&1 |grep Solaris; then
+      # Use Solaris specific linker wrapper
+      ld="$out/bin/ld-solaris"
+    fi
     # Can't use substitute() here, because replace may not have been
     # built yet (in the bootstrap).
     sed \
@@ -85,7 +95,7 @@ doSubstitute() {
         -e "s^@binutils@^$binutils^g" \
         -e "s^@coreutils@^$coreutils^g" \
         -e "s^@libc@^$libc^g" \
-        -e "s^@ld@^$ldPath/ld^g" \
+        -e "s^@ld@^$ld^g" \
         < "$src" > "$dst" 
 }
 
@@ -174,6 +184,13 @@ ln -s $ldPath/as $out/bin/as
 doSubstitute "$ldWrapper" "$out/bin/ld"
 chmod +x "$out/bin/ld"
 
+# Copy solaris ld wrapper if needed
+if $ldPath/ld -V 2>&1 |grep Solaris; then
+  # Use Solaris specific linker wrapper
+  sed -e "s^@ld@^$ldPath/ld^g" < "$ldSolarisWrapper" > "$out/bin/ld-solaris"
+  chmod +x "$out/bin/ld-solaris"
+fi
+
 
 # Emit a setup hook.  Also store the path to the original GCC and
 # Glibc.
diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix
index 992c0f9af371..58dde3485ca0 100644
--- a/pkgs/build-support/gcc-wrapper/default.nix
+++ b/pkgs/build-support/gcc-wrapper/default.nix
@@ -36,6 +36,7 @@ stdenv.mkDerivation {
   gnatWrapper = ./gnat-wrapper.sh;
   gnatlinkWrapper = ./gnatlink-wrapper.sh;
   ldWrapper = ./ld-wrapper.sh;
+  ldSolarisWrapper = ./ld-solaris-wrapper.sh;
   utils = ./utils.sh;
   addFlags = ./add-flags;
   
diff --git a/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh
new file mode 100644
index 000000000000..5a7b92b5ad7d
--- /dev/null
+++ b/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+set -e
+set -u
+
+# I've also tried adding -z direct and -z lazyload, but it gave too many problems with C++ exceptions :'(
+# Also made sure libgcc would not be lazy-loaded, as suggested here: https://www.illumos.org/issues/2534#note-3
+#   but still no success.
+cmd="@ld@ -z ignore"
+
+args=("$@");
+
+# This loop makes sure all -L arguments are before -l arguments, or ld may complain it cannot find a library.
+# GNU binutils does not have this problem:
+#   http://stackoverflow.com/questions/5817269/does-the-order-of-l-and-l-options-in-the-gnu-linker-matter
+i=0;
+while [[ $i -lt $# ]]; do
+    case "${args[$i]}" in
+        -L)  cmd="$cmd ${args[$i]} ${args[($i+1)]}"; i=($i+1); ;;
+        -L*) cmd="$cmd ${args[$i]}" ;;
+        *)   ;;
+    esac
+    i=($i+1);
+done
+
+i=0;
+while [[ $i -lt $# ]]; do
+    case "${args[$i]}" in
+        -L)  i=($i+1); ;;
+        -L*) ;;
+        *)   cmd="$cmd ${args[$i]}" ;;
+    esac
+    i=($i+1);
+done
+
+# Trace:
+set -x
+exec $cmd
+
+exit 0
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..1435277c1052
--- /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.1";
+
+    # 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 = "04sqn0ds17ys8l6zn7vyyvjz1a7hsk4zb0381vlw9wnr7az48nsl";
+  };
+
+  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/6.10.1-binary.nix b/pkgs/development/compilers/ghc/6.10.1-binary.nix
index dd79ef9c8e75..e7d4d3c1946f 100644
--- a/pkgs/development/compilers/ghc/6.10.1-binary.nix
+++ b/pkgs/development/compilers/ghc/6.10.1-binary.nix
@@ -36,10 +36,10 @@ stdenv.mkDerivation rec {
      ''
       mkdir "$TMP/bin"
       for i in strip; do
-        echo '#!/bin/sh' >> "$TMP/bin/$i"
+        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
         chmod +x "$TMP/bin/$i"
-        PATH="$TMP/bin:$PATH"
       done
+      PATH="$TMP/bin:$PATH"
      '' +
     # On Linux, use patchelf to modify the executables so that they can
     # find editline/gmp.
diff --git a/pkgs/development/compilers/ghc/6.10.2-binary.nix b/pkgs/development/compilers/ghc/6.10.2-binary.nix
index 7effff83c69a..5af89e38c21f 100644
--- a/pkgs/development/compilers/ghc/6.10.2-binary.nix
+++ b/pkgs/development/compilers/ghc/6.10.2-binary.nix
@@ -30,10 +30,10 @@ stdenv.mkDerivation rec {
      ''
       mkdir "$TMP/bin"
       for i in strip; do
-        echo '#!/bin/sh' >> "$TMP/bin/$i"
+        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
         chmod +x "$TMP/bin/$i"
-        PATH="$TMP/bin:$PATH"
       done
+      PATH="$TMP/bin:$PATH"
      '' +
     # On Linux, use patchelf to modify the executables so that they can
     # find editline/gmp.
diff --git a/pkgs/development/compilers/ghc/6.12.1-binary.nix b/pkgs/development/compilers/ghc/6.12.1-binary.nix
index 6f3411da4af6..da4658c3829e 100644
--- a/pkgs/development/compilers/ghc/6.12.1-binary.nix
+++ b/pkgs/development/compilers/ghc/6.12.1-binary.nix
@@ -28,10 +28,10 @@ stdenv.mkDerivation rec {
      ''
       mkdir "$TMP/bin"
       for i in strip; do
-        echo '#!/bin/sh' >> "$TMP/bin/$i"
+        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
         chmod +x "$TMP/bin/$i"
-        PATH="$TMP/bin:$PATH"
       done
+      PATH="$TMP/bin:$PATH"
      '' +
     # We have to patch the GMP paths for the integer-gmp package.
      ''
diff --git a/pkgs/development/compilers/ghc/7.0.4-binary.nix b/pkgs/development/compilers/ghc/7.0.4-binary.nix
index 455d552b91ac..2c9b11f2b654 100644
--- a/pkgs/development/compilers/ghc/7.0.4-binary.nix
+++ b/pkgs/development/compilers/ghc/7.0.4-binary.nix
@@ -38,10 +38,10 @@ stdenv.mkDerivation rec {
      ''
       mkdir "$TMP/bin"
       for i in strip; do
-        echo '#!/bin/sh' >> "$TMP/bin/$i"
+        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
         chmod +x "$TMP/bin/$i"
-        PATH="$TMP/bin:$PATH"
       done
+      PATH="$TMP/bin:$PATH"
      '' +
     # We have to patch the GMP paths for the integer-gmp package.
      ''
diff --git a/pkgs/development/compilers/ghc/7.4.2-binary.nix b/pkgs/development/compilers/ghc/7.4.2-binary.nix
index 59eb957a45f4..7000081e5dbe 100644
--- a/pkgs/development/compilers/ghc/7.4.2-binary.nix
+++ b/pkgs/development/compilers/ghc/7.4.2-binary.nix
@@ -38,10 +38,10 @@ stdenv.mkDerivation rec {
      ''
       mkdir "$TMP/bin"
       for i in strip; do
-        echo '#!/bin/sh' >> "$TMP/bin/$i"
+        echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
         chmod +x "$TMP/bin/$i"
-        PATH="$TMP/bin:$PATH"
       done
+      PATH="$TMP/bin:$PATH"
      '' +
     # We have to patch the GMP paths for the integer-gmp package.
      ''
diff --git a/pkgs/development/compilers/ghc/7.4.2.nix b/pkgs/development/compilers/ghc/7.4.2.nix
index 51f3f7f9df4b..0bc2a8553069 100644
--- a/pkgs/development/compilers/ghc/7.4.2.nix
+++ b/pkgs/development/compilers/ghc/7.4.2.nix
@@ -22,6 +22,7 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     echo "${buildMK}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+    export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}"
   '';
 
   configureFlags=[
diff --git a/pkgs/development/compilers/ghc/7.6.3.nix b/pkgs/development/compilers/ghc/7.6.3.nix
index dc3a912a34ac..427d21660b89 100644
--- a/pkgs/development/compilers/ghc/7.6.3.nix
+++ b/pkgs/development/compilers/ghc/7.6.3.nix
@@ -22,11 +22,10 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     echo "${buildMK}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+    export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}"
   '';
 
-  configureFlags = [
-    "--with-gcc=${stdenv.gcc}/bin/gcc"
-  ];
+  configureFlags = "--with-gcc=${stdenv.gcc}/bin/gcc";
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
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/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix
index c9cd71fc2b51..37bcde172324 100644
--- a/pkgs/development/compilers/ghc/head.nix
+++ b/pkgs/development/compilers/ghc/head.nix
@@ -22,6 +22,7 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     echo "${buildMK}" > mk/build.mk
     sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+    export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}"
   '';
 
   configureFlags = "--with-gcc=${stdenv.gcc}/bin/gcc";
diff --git a/pkgs/development/compilers/ghc/with-packages.nix b/pkgs/development/compilers/ghc/with-packages.nix
index e3cc71bbccfd..979b24805868 100644
--- a/pkgs/development/compilers/ghc/with-packages.nix
+++ b/pkgs/development/compilers/ghc/with-packages.nix
@@ -1,127 +1,42 @@
-{stdenv, ghc, packages ? [], makeWrapper}:
+{ stdenv, ghc, packages, buildEnv, makeWrapper }:
 
-stdenv.mkDerivation rec {
-  name = "haskell-env-${ghc.name}";
-
-  allPackages = stdenv.lib.closePropagation packages;
-  buildInputs = allPackages ++ [makeWrapper];
-  propagatedBuildInputs = packages;
-
-  unpackPhase = "true";
-
-  installPhase = ''
-    numversion=$(${ghc}/bin/ghc --numeric-version)
-    majorversion=''${numversion%%.*}
-    minorversion=''${numversion#*.}
-    minorversion=''${minorversion%%.*}
-
-    if [[ $majorversion -gt 6 ]] && [[ $minorversion -gt 4 ]]; then
-      globalConf="--global-package-db"
-    else
-      globalConf="--global-conf"
-    fi
-
-    originalTopDir="${ghc}/lib/ghc-${ghc.version}"
-    originalPkgDir="$originalTopDir/package.conf.d"
-    linkedTopDir="$out/lib"
-    linkedPkgDir="$linkedTopDir/package.conf.d"
-
-    mkdir -p $out/bin
-    mkdir -p $linkedTopDir
-    mkdir -p $linkedPkgDir
-
-    echo "Linking GHC core libraries:"
-
-    echo -n "Linking $originalTopDir "
-    for f in "$originalTopDir/"*; do
-      if test -f $f; then
-        ln -s $f $linkedTopDir
-        echo -n .
-      fi
-    done
-    echo
+assert packages != [];
 
-    echo -n "Linking $originalPkgDir "
-    for f in "$originalPkgDir/"*.conf; do
-      ln -s $f $linkedPkgDir
-      echo -n .
-    done
-    echo
-
-    echo "Linking selected packages and dependencies:"
-
-    for currentPath in ${stdenv.lib.concatStringsSep " " allPackages}; do
-      currentPkgDir="$currentPath/lib/ghc-pkgs/ghc-${ghc.version}"
-      # Check if current path is a Cabal package for the current GHC
-      if test -d $currentPkgDir; then
-        echo -n "Linking $currentPath "
-        for f in "$currentPath/bin/"*; do
-          ln -s $f $out/bin
-          echo -n .
-        done
-        for f in "$currentPath/etc/bash_completion.d/"*; do
-          mkdir -p $out/etc/bash_completion.d
-          ln -s $f $out/etc/bash_completion.d/
-          echo -n .
-        done
-        for s in 1 2 3 4 5 6 7 8 9; do
-          for f in "$currentPath/share/man/man$s/"*; do
-            mkdir -p $out/share/man/man$s
-            ln -sv $f $out/share/man/man$s/
-            echo -n .
-          done
-        done
-        for f in "$currentPath/share/emacs/site-lisp/"*; do
-          mkdir -p $out/share/emacs/site-lisp
-          ln -s $f $out/share/emacs/site-lisp/
-          echo -n .
-        done
-        for f in "$currentPath/share/ghci/"*; do
-          mkdir -p $out/share/ghci
-          ln -s $f $out/share/ghci/
-          echo -n .
-        done
-        for f in "$currentPkgDir/"*.conf; do
-          ln -s $f $linkedPkgDir
-          echo -n .
-        done
-        echo
-      fi
-    done
-
-    echo -n "Generating package cache "
-    ${ghc}/bin/ghc-pkg $globalConf $linkedPkgDir recache
-    echo .
-
-    echo -n "Generating wrappers "
+let
+  ghc761OrLater = stdenv.lib.versionOlder "7.6.1" ghc.version;
+  packageDBFlag = if ghc761OrLater then "--package-db" else "--package-conf";
+  libDir        = "$out/lib/ghc-${ghc.version}";
+  packageCfgDir = "${libDir}/package.conf.d";
+in
+buildEnv {
+  name = "haskell-env-${ghc.name}";
+  paths = stdenv.lib.filter (x: x ? ghc) (stdenv.lib.closePropagation (packages ++ [ghc]));
+  postBuild = ''
+    . ${makeWrapper}/nix-support/setup-hook
 
     for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
-      # The NIX env-vars are picked up by our patched version of ghc-paths.
-      makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
-        --add-flags "-B$linkedTopDir" \
-        --set "NIX_GHC"        "$out/bin/ghc"     \
-        --set "NIX_GHCPKG"     "$out/bin/ghc-pkg" \
-        --set "NIX_GHC_LIBDIR" "$linkedTopDir"
-      echo -n .
+      rm -f $out/bin/$prg
+      makeWrapper ${ghc}/bin/$prg $out/bin/$prg         \
+        --add-flags '"-B$NIX_GHC_LIBDIR"'               \
+        --set "NIX_GHC"        "$out/bin/ghc"           \
+        --set "NIX_GHCPKG"     "$out/bin/ghc-pkg"       \
+        --set "NIX_GHC_LIBDIR" "${libDir}"
     done
 
     for prg in runghc runhaskell; do
-      makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "-f $out/bin/ghc"
-      echo -n .
+      rm -f $out/bin/$prg
+      makeWrapper ${ghc}/bin/$prg $out/bin/$prg         \
+        --add-flags "-f $out/bin/ghc"                   \
+        --set "NIX_GHC"        "$out/bin/ghc"           \
+        --set "NIX_GHCPKG"     "$out/bin/ghc-pkg"       \
+        --set "NIX_GHC_LIBDIR" "${libDir}"
     done
 
     for prg in ghc-pkg ghc-pkg-${ghc.version}; do
-      makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "$globalConf $linkedPkgDir"
-      echo -n .
+      rm -f $out/bin/$prg
+      makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag} ${packageCfgDir}"
     done
 
-    for prg in hp2ps hpc hasktags hsc2hs haddock haddock-${ghc.version}; do
-      if test -x ${ghc}/bin/$prg -a ! -x $out/bin/$prg; then
-        ln -s ${ghc}/bin/$prg $out/bin/$prg && echo -n .
-      fi
-    done
-    echo
+    $out/bin/ghc-pkg recache
   '';
-
-  meta = ghc.meta;
 }
diff --git a/pkgs/development/compilers/ghc/wrapper.nix b/pkgs/development/compilers/ghc/wrapper.nix
index 55fd16be5edb..24deb89c2ec4 100644
--- a/pkgs/development/compilers/ghc/wrapper.nix
+++ b/pkgs/development/compilers/ghc/wrapper.nix
@@ -1,10 +1,53 @@
-{ stdenv, ghc, makeWrapper, coreutils, forUserEnv ? false }:
+{ stdenv, ghc, makeWrapper, coreutils, writeScript }:
 
 let
   ghc761OrLater = !stdenv.lib.versionOlder ghc.version "7.6.1";
   packageDBFlag = if ghc761OrLater then "-package-db" else "-package-conf";
+
+  GHCGetPackages = writeScript "ghc-get-packages.sh" ''
+    #! ${stdenv.shell}
+    # Usage:
+    #  $1: version of GHC
+    #  $2: invocation path of GHC
+    #  $3: prefix
+    version="$1"
+    if test -z "$3"; then
+      prefix="${packageDBFlag} "
+    else
+      prefix="$3"
+    fi
+    PATH="$2:$PATH"
+    IFS=":"
+    for p in $PATH; do
+      PkgDir="$p/../lib/ghc-$version/package.conf.d"
+      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"
+  '';
+
+  GHCPackages = writeScript "ghc-packages.sh" ''
+    #! ${stdenv.shell} -e
+    declare -A GHC_PACKAGES_HASH # using bash4 hashs to get uniq paths
+
+    for arg in $(${GHCGetPackages} ${ghc.version} "$(dirname $0)"); do
+      case "$arg" in
+        ${packageDBFlag}) ;;
+        *)
+          CANONICALIZED="$(${coreutils}/bin/readlink -f -- "$arg")"
+          GHC_PACKAGES_HASH["$CANONICALIZED"]= ;;
+      esac
+    done
+
+    for path in ''${!GHC_PACKAGES_HASH[@]}; do
+      echo -n "$path:"
+    done
+  '';
+
 in
-stdenv.mkDerivation ({
+stdenv.mkDerivation {
   name = "ghc-${ghc.version}-wrapper";
 
   buildInputs = [makeWrapper];
@@ -12,53 +55,33 @@ stdenv.mkDerivation ({
 
   unpackPhase = "true";
   installPhase = ''
+    runHook preInstall
+
     mkdir -p $out/bin
-    cp $GHCGetPackages $out/bin/ghc-get-packages.sh
-    chmod 755 $out/bin/ghc-get-packages.sh
     for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
-      makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\")"
+      makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$(${GHCGetPackages} ${ghc.version} \"\$(dirname \$0)\")"
     done
     for prg in runghc runhaskell; do
-      makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\" \" ${packageDBFlag} --ghc-arg=\")"
+      makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$(${GHCGetPackages} ${ghc.version} \"\$(dirname \$0)\" \" ${packageDBFlag} --ghc-arg=\")"
     done
     for prg in ghc-pkg ghc-pkg-${ghc.version}; do
-      makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\" -${packageDBFlag}=)"
+      makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$(${GHCGetPackages} ${ghc.version} \"\$(dirname \$0)\" -${packageDBFlag}=)"
     done
     for prg in hp2ps hpc hasktags hsc2hs; do
       test -x $ghc/bin/$prg && ln -s $ghc/bin/$prg $out/bin/$prg
     done
-    cat >> $out/bin/ghc-packages << EOF
-    #! /bin/bash -e
-    declare -A GHC_PACKAGES_HASH # using bash4 hashs to get uniq paths
-
-    for arg in \$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\"); do
-      case "\$arg" in
-        ${packageDBFlag}) ;;
-        *)
-          CANONICALIZED="\$(${stdenv.lib.optionalString stdenv.isDarwin "${coreutils}/bin/"}readlink -f "\$arg")"
-          GHC_PACKAGES_HASH["\$CANONICALIZED"]= ;;
-      esac
-    done
 
-    for path in \''${!GHC_PACKAGES_HASH[@]}; do
-      echo -n "\$path:"
-    done
-    EOF
-    chmod +x $out/bin/ghc-packages
     mkdir -p $out/nix-support
     ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
-  '';
 
-  GHCGetPackages = ./ghc-get-packages.sh;
+    mkdir -p $out/share/doc
+    ln -s $ghc/lib $out/lib
+    ln -s $ghc/share/doc/ghc $out/share/doc/ghc-${ghc.version}
+
+    runHook postInstall
+  '';
 
-  inherit ghc;
+  inherit ghc GHCGetPackages GHCPackages;
   inherit (ghc) meta;
   ghcVersion = ghc.version;
-} // (stdenv.lib.optionalAttrs ghc761OrLater { preFixup = "sed -i -e 's|-package-conf|${packageDBFlag}|' $out/bin/ghc-get-packages.sh"; })
-  // (stdenv.lib.optionalAttrs forUserEnv {
-       postFixup= ''
-         ln -s $ghc/lib $out/lib;
-         mkdir -p $out/share/doc
-         ln -s $ghc/share/doc/ghc $out/share/doc/ghc-${ghc.version}
-       '';
-     }))
+}
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 2113faee1640..60bfacf419b2 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.optional stdenv.isDarwin ./no-libutil.patch;
+    ++ optional stdenv.isSunOS  ./ld-shared.patch
+    ++ optional stdenv.isDarwin ./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/cln/default.nix b/pkgs/development/libraries/cln/default.nix
index 66629b0561b3..f536e746d0e9 100644
--- a/pkgs/development/libraries/cln/default.nix
+++ b/pkgs/development/libraries/cln/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, gmp }:
 
 stdenv.mkDerivation rec {
-  name = "cln-1.3.1";
+  name = "cln-1.3.3";
 
   src = fetchurl {
     url = "${meta.homepage}${name}.tar.bz2";
-    sha256 = "1sd8jy5vnmww537zq6g6i586ffslm7fjliz04krv6scapgklq6ca";
+    sha256 = "04i6kdjwm4cr5pa70pilifnpvsh430rrlapkgw1x8c5vxkijxz2p";
   };
 
   buildInputs = [ gmp ];
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 49364f882429..eee977e97037 100644
--- a/pkgs/development/libraries/gsl/default.nix
+++ b/pkgs/development/libraries/gsl/default.nix
@@ -8,6 +8,10 @@ stdenv.mkDerivation rec {
     sha256 = "18qf6jzz1r3mzb5qynywv4xx3z9g61hgkbpkdrhbgqh2g7jhgfc5";
   };
 
+  # 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/haskell/bytestring-progress/default.nix b/pkgs/development/libraries/haskell/bytestring-progress/default.nix
index e9bb268b9fce..c73932b3760a 100644
--- a/pkgs/development/libraries/haskell/bytestring-progress/default.nix
+++ b/pkgs/development/libraries/haskell/bytestring-progress/default.nix
@@ -5,7 +5,6 @@ cabal.mkDerivation (self: {
   version = "1.0.3";
   sha256 = "1v9cl7d4fcchbdrpbgjj4ilg79cj241vzijiifdsgkq30ikv2yxs";
   buildDepends = [ terminalProgressBar time ];
-  noHaddock = true;
   meta = {
     homepage = "http://github.com/acw/bytestring-progress";
     description = "A library for tracking the consumption of a lazy ByteString";
diff --git a/pkgs/development/libraries/haskell/dns/default.nix b/pkgs/development/libraries/haskell/dns/default.nix
index 8625aec86b3d..9dd35804f430 100644
--- a/pkgs/development/libraries/haskell/dns/default.nix
+++ b/pkgs/development/libraries/haskell/dns/default.nix
@@ -15,7 +15,7 @@ cabal.mkDerivation (self: {
     attoparsec attoparsecConduit binary blazeBuilder conduit doctest
     hspec iproute mtl network networkConduit random
   ];
-  doCheck = false;
+  testTarget = "spec";
   meta = {
     description = "DNS library in Haskell";
     license = self.stdenv.lib.licenses.bsd3;
diff --git a/pkgs/development/libraries/haskell/modular-arithmetic/default.nix b/pkgs/development/libraries/haskell/modular-arithmetic/default.nix
index 7d53d81f7bb6..c4a77630e6ae 100644
--- a/pkgs/development/libraries/haskell/modular-arithmetic/default.nix
+++ b/pkgs/development/libraries/haskell/modular-arithmetic/default.nix
@@ -4,7 +4,6 @@ cabal.mkDerivation (self: {
   pname = "modular-arithmetic";
   version = "1.0.1.1";
   sha256 = "14n83kjmz8mqjivjhwxk1zckms5z3gn77yq2hsw2yybzff2vkdkd";
-  noHaddock = true;
   meta = {
     description = "A type for integers modulo some constant";
     license = self.stdenv.lib.licenses.bsd3;
diff --git a/pkgs/development/libraries/haskell/multirec/default.nix b/pkgs/development/libraries/haskell/multirec/default.nix
index a7d7459b4558..61de0cace5b5 100644
--- a/pkgs/development/libraries/haskell/multirec/default.nix
+++ b/pkgs/development/libraries/haskell/multirec/default.nix
@@ -4,7 +4,6 @@ cabal.mkDerivation (self: {
   pname = "multirec";
   version = "0.7.3";
   sha256 = "0k1wbjsvkl08nwjikflc8yyalk654mf8bvi1rhm28i4na52myi5y";
-  noHaddock = true;
   meta = {
     homepage = "http://www.cs.uu.nl/wiki/GenericProgramming/Multirec";
     description = "Generic programming for families of recursive datatypes";
diff --git a/pkgs/development/libraries/haskell/wxHaskell/wxc.nix b/pkgs/development/libraries/haskell/wxHaskell/wxc.nix
index 74ca4f91d70f..b89b39acb50a 100644
--- a/pkgs/development/libraries/haskell/wxHaskell/wxc.nix
+++ b/pkgs/development/libraries/haskell/wxHaskell/wxc.nix
@@ -6,7 +6,6 @@ cabal.mkDerivation (self: {
   sha256 = "1bh20i1rb8ng0ni1v98nm8qv5wni19dvxwf5i3ijxhrxqdq4i7p6";
   buildDepends = [ wxdirect ];
   extraLibraries = [ libX11 mesa wxGTK ];
-  noHaddock = true;
   postInstall = ''
     cp -v dist/build/libwxc.so.${self.version} $out/lib/libwxc.so
   '';
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..9242af95e270 100644
--- a/pkgs/development/libraries/isl/default.nix
+++ b/pkgs/development/libraries/isl/default.nix
@@ -1,14 +1,11 @@
 { 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 ];
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 8461bfef4391..7085236feb52 100644
--- a/pkgs/development/libraries/libproxy/default.nix
+++ b/pkgs/development/libraries/libproxy/default.nix
@@ -1,10 +1,14 @@
-{stdenv, fetchurl, cmake, zlib}:
+{ stdenv, fetchurl, pkgconfig, cmake, zlib, glib }:
 
 stdenv.mkDerivation rec {
-  name = "libproxy-0.4.7";
+  name = "libproxy-0.4.11";
   src = fetchurl {
     url = "http://libproxy.googlecode.com/files/${name}.tar.gz";
-    sha256 = "15rp97g3s2xkc842p5qfm8kx3p4awvrwrpl6w71a76qk224abq4g";
+    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 ed56ffaff736..eedcd78767f0 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.linux;
     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/default.nix b/pkgs/development/libraries/ncurses/default.nix
index 569d7fe2a328..8d20a7339b73 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";
@@ -23,6 +23,8 @@ stdenv.mkDerivation (rec {
     ${if unicode then "--enable-widec" else ""}${if cxx then "" else "--without-cxx-binding"}
   '';
 
+  patches = [ ./patch-ac ];
+
   selfNativeBuildInput = true;
 
   enableParallelBuilding = true;
@@ -46,6 +48,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/protobuf/default.nix b/pkgs/development/libraries/protobuf/default.nix
index 57dc58bdfa17..bba8481780a5 100644
--- a/pkgs/development/libraries/protobuf/default.nix
+++ b/pkgs/development/libraries/protobuf/default.nix
@@ -1,11 +1,11 @@
 { fetchurl, stdenv, zlib }:
 
 stdenv.mkDerivation rec {
-  name = "protobuf-2.4.1";
+  name = "protobuf-2.5.0";
 
   src = fetchurl {
     url = "http://protobuf.googlecode.com/files/${name}.tar.bz2";
-    sha256 = "1gxhfhk37jyjq1z4y3d4bz4i1fk2an5ydhk5kjzlp0rhfcs5516g";
+    sha256 = "0xxn9gxhvsgzz2sgmihzf6pf75clr05mqj6218camwrwajpcbgqk";
   };
 
   buildInputs = [ zlib ];
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/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/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 cca368f619a6..31f81cbf3af0 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";
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)
diff --git a/pkgs/games/asc/default.nix b/pkgs/games/asc/default.nix
index 86cf929aede7..bf2fb1e89c21 100644
--- a/pkgs/games/asc/default.nix
+++ b/pkgs/games/asc/default.nix
@@ -10,6 +10,10 @@ stdenv.mkDerivation rec {
     sha256 = "1r011l4gsliky6szjvda8xzyhkkc50ahrr7p14911v5ydar0w3hh";
   };
 
+  configureFlags = [ "--disable-paragui" "--disable-paraguitest" ];
+
+  NIX_CFLAGS_COMPILE = "-fpermissive"; # I'm too lazy to catch all gcc47-related problems
+
   buildInputs = [
     SDL SDL_image SDL_mixer SDL_sound libsigcxx physfs boost expat freetype
     libjpeg wxGTK lua perl pkgconfig zlib zip bzip2 libpng
diff --git a/pkgs/misc/emulators/zsnes/default.nix b/pkgs/misc/emulators/zsnes/default.nix
index 0b34fc0f9fec..a2896e70d174 100644
--- a/pkgs/misc/emulators/zsnes/default.nix
+++ b/pkgs/misc/emulators/zsnes/default.nix
@@ -2,33 +2,27 @@
 
 stdenv.mkDerivation {
   name = "zsnes-1.51";
-  
+
   src = fetchurl {
     url = mirror://sourceforge/zsnes/zsnes151src.tar.bz2;
     sha256 = "08s64qsxziv538vmfv38fg1rfrz5k95dss5zdkbfxsbjlbdxwmi8";
   };
 
-  buildInputs = [ nasm SDL zlib libpng ncurses mesa ];
-  
+  # copied from arch linux, fixes gcc-4.8 compatibility
+  patches = [ ./zsnes.patch ];
+
+  postPatch = ''
+    patch -p0 < ${./zsnes-1.51-libpng15.patch}
+  '';
+
   preConfigure = ''
     cd src
-    
-    # Fix for undefined strncasecmp()
-    echo '#include <strings.h>' > tmp.cpp 
-    cat tmp.cpp tools/strutil.h > tools/strutil.h.new
-    mv tools/strutil.h.new tools/strutil.h
-    
-    # Fix for undefined system()
-    echo '#include <stdlib.h>' > tmp.cpp
-    cat tmp.cpp tools/depbuild.cpp > tools/depbuild.cpp.new
-    mv tools/depbuild.cpp.new tools/depbuild.cpp
-    
-    # Fix for lots of undefined strcmp, strncmp etc.
-    echo '#include <string.h>' > tmp.cpp 
-    cat tmp.cpp parsegen.cpp > parsegen.cpp.new
-    mv parsegen.cpp.new parsegen.cpp
   '';
-  
+
+  buildInputs = [ nasm SDL zlib libpng ncurses mesa ];
+
+  configureFlags = "--enable-release";
+
   meta = {
     description = "A Super Nintendo Entertainment System Emulator";
     license = "GPLv2+";
diff --git a/pkgs/misc/emulators/zsnes/zsnes-1.51-libpng15.patch b/pkgs/misc/emulators/zsnes/zsnes-1.51-libpng15.patch
new file mode 100644
index 000000000000..b32c30967547
--- /dev/null
+++ b/pkgs/misc/emulators/zsnes/zsnes-1.51-libpng15.patch
@@ -0,0 +1,12 @@
+Use existing png_set_IHDR() and stop accessing PNG structure members directly
+
+--- src/zip/zpng.c
++++ src/zip/zpng.c
+@@ -129,7 +129,6 @@
+         png_set_IHDR(png_ptr, info_ptr, width, height, 8,
+                      PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
+                      PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+-        info_ptr->color_type = PNG_COLOR_TYPE_RGB;
+ 
+         //Allocate an array of scanline pointers
+         row_pointers = (png_bytep*)malloc(height*sizeof(png_bytep));
diff --git a/pkgs/misc/emulators/zsnes/zsnes.patch b/pkgs/misc/emulators/zsnes/zsnes.patch
new file mode 100644
index 000000000000..d5d681ae67a8
--- /dev/null
+++ b/pkgs/misc/emulators/zsnes/zsnes.patch
@@ -0,0 +1,80 @@
+diff -aur zsnes_1_51//src/Makefile.in zsnes_1_51_new//src/Makefile.in
+--- zsnes_1_51//src/Makefile.in	2007-01-24 21:54:12.000000000 +0100
++++ zsnes_1_51_new//src/Makefile.in	2010-09-06 00:03:04.715810431 +0200
+@@ -95,7 +95,7 @@
+ %.o: %.cpp
+ 	@CXX@ @CXXFLAGS@ -o $@ -c $<
+ %.o %.h: %.psr $(PSR)
+-	./$(PSR) @PSRFLAGS@ -gcc @CC@ -compile -flags "@CFLAGS@ -O1" -cheader $*.h -fname $* $*.o $<
++	./$(PSR) @PSRFLAGS@ -gcc "@CC@" -compile -flags "@CFLAGS@ -O1 -D_FORTIFY_SOURCE=0" -cheader $*.h -fname $* $*.o $<
+ 
+ default: main
+ all: main tools
+@@ -133,7 +133,7 @@
+ 
+ include makefile.dep
+ makefile.dep: $(TOOL_D)/depbuild Makefile
+-	$(TOOL_D)/depbuild @CC@ "@CFLAGS@" @NASMPATH@ "@NFLAGS@" $(Z_OBJS) > makefile.dep
++	$(TOOL_D)/depbuild "@CC@" "@CFLAGS@" "@NASMPATH@" "@NFLAGS@" $(Z_OBJS) > makefile.dep
+ 
+ Makefile: Makefile.in config.status
+ 	./config.status
+diff -aur zsnes_1_51//src/parsegen.cpp zsnes_1_51_new//src/parsegen.cpp
+--- zsnes_1_51//src/parsegen.cpp	2007-10-31 05:30:26.000000000 +0100
++++ zsnes_1_51_new//src/parsegen.cpp	2010-09-05 15:48:36.903333444 +0200
+@@ -19,6 +19,9 @@
+ Config file handler creator by Nach (C) 2005-2007
+ */
+ 
++#include <cstring>
++#include <cstdlib>
++
+ #if !defined(__GNUC__) && !defined(_MSC_VER)
+ #error You are using an unsupported compiler
+ #endif
+@@ -1822,7 +1825,7 @@
+   }
+ }
+ 
+-int main(size_t argc, const char *const *const argv)
++int main(int argc, const char *const *const argv)
+ {
+   const char *cheader_file = 0;
+   bool compile = false;
+diff -aur zsnes_1_51//src/tools/depbuild.cpp zsnes_1_51_new//src/tools/depbuild.cpp
+--- zsnes_1_51//src/tools/depbuild.cpp	2006-12-27 12:04:05.000000000 +0100
++++ zsnes_1_51_new//src/tools/depbuild.cpp	2010-09-05 15:48:36.903333444 +0200
+@@ -183,7 +183,7 @@
+   }
+ }
+ 
+-int main(size_t argc, const char *const *const argv)
++int main(int argc, const char *const *const argv)
+ {
+   if (argc < 5)
+   {
+diff -aur zsnes_1_51//src/tools/strutil.h zsnes_1_51_new//src/tools/strutil.h
+--- zsnes_1_51//src/tools/strutil.h	2006-12-27 12:04:05.000000000 +0100
++++ zsnes_1_51_new//src/tools/strutil.h	2010-09-05 15:48:36.903333444 +0200
+@@ -15,6 +15,9 @@
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+ 
++#include <cstring>
++#include <cstdlib>
++
+ /*
+ This is part of a toolkit used to assist in ZSNES development
+ */
+diff -u -r zsnes_1_51/src/tools/depbuild.cpp zsnes_1_51-fix/src/tools/depbuild.cpp
+--- zsnes_1_51/src/tools/depbuild.cpp	2006-12-27 12:04:05.000000000 +0100
++++ zsnes_1_51-fix/src/tools/depbuild.cpp	2012-07-14 16:20:17.759886250 +0200
+@@ -26,6 +26,8 @@
+ #include <cstdio>
+ using namespace std;
+ 
++#include <unistd.h>
++
+ #include "fileutil.h"
+ #include "strutil.h"
+ 
diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index fb8b5856ecb1..c8e20f1f0b99 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -86,6 +86,12 @@ in
     propagatedBuildInputs = [ xorg.libSM ];
   };
 
+  # See https://bugs.freedesktop.org/show_bug.cgi?id=47792
+  # Once the bug is fixed upstream, this can be removed.
+  luit = attrs: attrs // {
+    configureFlags = "--disable-selective-werror";
+  };
+
   compositeproto = attrs: attrs // {
     propagatedBuildInputs = [ xorg.fixesproto ];
   };
@@ -179,6 +185,13 @@ in
     buildInputs = attrs.buildInputs ++ [args.intltool];
   };
 
+  xmodmap = attrs: attrs // {
+    patches = [(args.fetchurl {
+      url = http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/x11-apps/xmodmap/files/xmodmap-1.0.7-_GNU_SOURCE.patch;
+      sha256 = "0q3zhy0wy1kkbpagzav8869fais4lw5q5vybgjj7wkmak06c5648";
+      name = "new-gcc.patch";
+    })];
+  };
   xorgserver = with xorg; attrs: attrs // {
     configureFlags = [
       "--enable-xcsecurity" # enable SECURITY extension
diff --git a/pkgs/shells/bash/bash-4.2-patches.nix b/pkgs/shells/bash/bash-4.2-patches.nix
index 52392f4b32c6..ac6e9e97f180 100644
--- a/pkgs/shells/bash/bash-4.2-patches.nix
+++ b/pkgs/shells/bash/bash-4.2-patches.nix
@@ -43,4 +43,7 @@ patch: [
 (patch "040" "0v5a98ybibwsd4iyh18gy0kc51mx8qn9w2wfpjaiycn7yg5gjrdj")
 (patch "041" "1szmm8xv41hvbzgxfwrj6dg85wa7zy3781nnil428rlzpm8ikk05")
 (patch "042" "017kpdqy6v9sgi2a931wyzpix86n9mkalpm6n9cb45v58lgmraps")
+(patch "043" "0mswgjk3z80qm1mb93jmbql27nbczxk86cw5byf0m29y1y2869nw")
+(patch "044" "1rk6jywzfvg1crvhib1zk37rsps73minhr7l4vcb3vfdkin2vlqh")
+(patch "045" "0vcqn9rb26bahhrarbwhpa0ny0nrf4vyrzh97d44lfcxypqfzdyx")
 ]
diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix
index ca90b46192e3..a2723f5575c0 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -62,5 +62,6 @@ rec {
     if stdenvType == "powerpc-linux" then /* stdenvLinux */ stdenvNative else
     if stdenvType == "i686-mingw" then stdenvMinGW else
     if stdenvType == "x86_64-darwin" then stdenvNix else
+    if stdenvType == "x86_64-solaris" then stdenvNix else
     stdenvNative;
 }
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 0b1003a73921..3ae6f4bde4c0 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -124,11 +124,13 @@ let
         isx86_64 = result.system == "x86_64-linux"
                || result.system == "x86_64-darwin"
                || result.system == "x86_64-freebsd"
-               || result.system == "x86_64-openbsd";
+               || result.system == "x86_64-openbsd"
+               || result.system == "x86_64-solaris";
         is64bit = result.system == "x86_64-linux"
                 || result.system == "x86_64-darwin"
                 || result.system == "x86_64-freebsd"
-                || result.system == "x86_64-openbsd";
+                || result.system == "x86_64-openbsd"
+                || result.system == "x86_64-solaris";
         isMips = result.system == "mips-linux"
                 || result.system == "mips64el-linux";
         isArm = result.system == "armv5tel-linux"
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index a474b6a8eaf1..a50596985ec8 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -289,6 +289,9 @@ stripDirs() {
 
     if [ -n "${dirs}" ]; then
         header "stripping (with flags $stripFlags) in $dirs"
+        for dir in $dirs; do
+          test -L "$dir" || chmod -R +rw "$dir"
+        done
         find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} strip $stripFlags || true
         stopNest
     fi
@@ -540,11 +543,15 @@ patchPhase() {
             *.bz2)
                 uncompress="bzip2 -d"
                 ;;
+            *.xz)
+                uncompress="xz -d"
+                ;;
             *.lzma)
                 uncompress="lzma -d"
                 ;;
         esac
-        $uncompress < $i | patch ${patchFlags:--p1}
+        # "2>&1" is a hack to make patch fail if the decompressor fails (nonexistent patch, etc.)
+        $uncompress < $i 2>&1 | patch ${patchFlags:--p1}
         stopNest
     done
 
@@ -638,7 +645,7 @@ patchELF() {
         find "$prefix" \( \
             \( -type f -a -name "*.so*" \) -o \
             \( -type f -a -perm +0100 \) \
-            \) -print -exec patchelf --shrink-rpath {} \;
+            \) -print -exec patchelf --shrink-rpath '{}' \;
     fi
     stopNest
 }
@@ -707,16 +714,22 @@ fixupPhase() {
     fi
 
     if [ -z "$dontGzipMan" ]; then
+        echo "gzipping man pages"
         GLOBIGNORE=.:..:*.gz:*.bz2
-        for f in $out/share/man/*/* $out/share/man/*/*/*; do
-            if [ -f $f ]; then
-                if gzip -c $f > $f.gz; then
-                    rm $f
+        for f in "$out"/share/man/*/* "$out"/share/man/*/*/*; do
+            if [ -f "$f" -a ! -L "$f" ]; then
+                if gzip -c "$f" > "$f".gz; then
+                    rm "$f"
                 else
-                    rm $f.gz
+                    rm "$f".gz
                 fi
             fi
         done
+        for f in "$out"/share/man/*/* "$out"/share/man/*/*/*; do
+            if [ -L "$f" -a -f `readlink -f "$f"`.gz ]; then
+              ln -sf `readlink "$f"`.gz "$f"
+            fi
+        done
         unset GLOBIGNORE
     fi
 
@@ -742,23 +755,23 @@ fixupPhase() {
     fi
 
     if [ -n "$propagatedBuildInputs" ]; then
-        mkdir -p "$out/nix-support"
-        echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
+        mkdir -p "$prefix/nix-support"
+        echo "$propagatedBuildInputs" > "$prefix/nix-support/propagated-build-inputs"
     fi
 
     if [ -n "$propagatedNativeBuildInputs" ]; then
-        mkdir -p "$out/nix-support"
-        echo "$propagatedNativeBuildInputs" > "$out/nix-support/propagated-native-build-inputs"
+        mkdir -p "$prefix/nix-support"
+        echo "$propagatedNativeBuildInputs" > "$prefix/nix-support/propagated-native-build-inputs"
     fi
 
     if [ -n "$propagatedUserEnvPkgs" ]; then
-        mkdir -p "$out/nix-support"
-        echo "$propagatedUserEnvPkgs" > "$out/nix-support/propagated-user-env-packages"
+        mkdir -p "$prefix/nix-support"
+        echo "$propagatedUserEnvPkgs" > "$prefix/nix-support/propagated-user-env-packages"
     fi
 
     if [ -n "$setupHook" ]; then
-        mkdir -p "$out/nix-support"
-        substituteAll "$setupHook" "$out/nix-support/setup-hook"
+        mkdir -p "$prefix/nix-support"
+        substituteAll "$setupHook" "$prefix/nix-support/setup-hook"
     fi
 
     runHook postFixup
@@ -843,9 +856,16 @@ genericBuild() {
         showPhaseHeader "$curPhase"
         dumpVars
 
-        # Evaluate the variable named $curPhase if it exists, otherwise the
-        # function named $curPhase.
-        eval "${!curPhase:-$curPhase}"
+        if [ "$curPhase" = fixupPhase ]; then
+          for pref in ${outputs:-out}; do
+            echo "fixup on \$$pref"
+            prefix=${!pref} eval "${!curPhase:-$curPhase}"
+          done
+        else
+          # Evaluate the variable named $curPhase if it exists, otherwise the
+          # function named $curPhase.
+          eval "${!curPhase:-$curPhase}"
+        fi
 
         if [ "$curPhase" = unpackPhase ]; then
             cd "${sourceRoot:-.}"
@@ -862,6 +882,10 @@ genericBuild() {
     stopNest
 }
 
+for i in "${postHooks[@]}"; do
+    $i
+done
+
 
 # Execute the post-hook.
 runHook postHook
diff --git a/pkgs/stdenv/linux/bootstrap/armv5tel/default.nix b/pkgs/stdenv/linux/bootstrap/armv5tel/default.nix
index 1d4d53a38ee6..e8f04497bd91 100644
--- a/pkgs/stdenv/linux/bootstrap/armv5tel/default.nix
+++ b/pkgs/stdenv/linux/bootstrap/armv5tel/default.nix
@@ -1,10 +1,65 @@
-{
-  sh = ./sh;
-  bzip2 = ./bzip2;
-  mkdir = ./mkdir;
-  cpio = ./cpio;
-  ln = ./ln;
-  curl = ./curl.bz2;
+let fetch = { file, sha256 }:
+    let
+      nixFetchurl = import <nix/fetchurl.nix>;
+      args = {
+        url = "file://${builtins.toString ./.}/${file}";
+        inherit sha256;
+        executable = true;
+      };
+    in if (builtins.functionArgs nixFetchurl) ? executable
+      then nixFetchurl args
+      else derivation {
+        name = file;
+        builder = "/bin/sh";
+
+        system = builtins.currentSystem;
+
+        args = [ "-c" "echo $message; exit 1" ];
+
+        message = ''
+          Sorry, this version of nix cannot download all of the bootstrap tools.
+          Please download ${args.url}, make it executable, add it to the store
+          with `nix-store --add', and try again.
+        '';
+
+        outputHashAlgo = "sha256";
+
+        outputHash = args.sha256;
+
+        outputHashMode = "recursive";
+
+        preferLocalBuild = true;
+      };
+in {
+  sh = fetch {
+    file = "sh";
+    sha256 = "1kv3gc8h209rjc5i0rzzc4pjxq23kzq25iff89in05c9vl20mn4n";
+  };
+
+  bzip2 = fetch {
+    file = "bzip2";
+    sha256 = "090jrj099wl33q0iq092iljilam39pv8acli59m2af0fa9z0d9f0";
+  };
+
+  mkdir = fetch {
+    file = "mkdir";
+    sha256 = "01s8myfvi559dsxvbanxw71vxzjv49k4gi1qh0ak6l0qx0xq602b";
+  };
+
+  cpio = fetch {
+    file = "cpio";
+    sha256 = "07snc8l0mn84w2xrvdmc5yfpmlbrvl2bar8wipbpvm43nzz2qbzs";
+  };
+
+  ln = fetch {
+    file = "ln";
+    sha256 = "0m9fz02bashpfgwfkxmrp4wa8a5r3il52bclvf6z36vsam0vx56d";
+  };
+
+  curl = fetch {
+    file = "curl.bz2";
+    sha256 = "19yqdjqi31zlnqn8ss2ml60iq2a1vrwfw6dmvjqp6qbxmh7yb8n8";
+  };
 
   bootstrapTools = {
     url = "http://tarballs.nixos.org/stdenv-linux/armv5tel/r18744/bootstrap-tools.cpio.bz2";
diff --git a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix
index ecda6be8bd32..542f74de49fe 100644
--- a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix
+++ b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix
@@ -1,11 +1,7 @@
-{
-  sh = ../armv5tel/sh;
-  bzip2 = ../armv5tel/bzip2;
-  mkdir = ../armv5tel/mkdir;
-  cpio = ../armv5tel/cpio;
-  ln = ../armv5tel/ln;
-  curl = ../armv5tel/curl.bz2;
+# Use the static tools for armv5tel-linux.
+(import ../armv5tel) //
 
+{
   bootstrapTools = {
     # Built from make-bootstrap-tools-crosspi.nix
     # nixpkgs rev eb0422e4c1263a65a9b2b954fe10a1e03d67db3e
diff --git a/pkgs/stdenv/linux/bootstrap/i686/default.nix b/pkgs/stdenv/linux/bootstrap/i686/default.nix
index dc4fee1beccb..9c78dcc7b2fa 100644
--- a/pkgs/stdenv/linux/bootstrap/i686/default.nix
+++ b/pkgs/stdenv/linux/bootstrap/i686/default.nix
@@ -1,10 +1,66 @@
-{
-  sh = ./sh;
-  bzip2 = ./bzip2;
-  mkdir = ./mkdir;
-  cpio = ./cpio;
-  ln = ./ln;
-  curl = ./curl.bz2;
+let
+  fetch = { file, sha256 }:
+    let
+      nixFetchurl = import <nix/fetchurl.nix>;
+      args = {
+        url = "file://${builtins.toString ./.}/${file}";
+        inherit sha256;
+        executable = true;
+      };
+    in if (builtins.functionArgs nixFetchurl) ? executable
+      then nixFetchurl args
+      else derivation {
+        name = file;
+        builder = "/bin/sh";
+
+        system = builtins.currentSystem;
+
+        args = [ "-c" "echo $message; exit 1" ];
+
+        message = ''
+          Sorry, this version of nix cannot download all of the bootstrap tools.
+          Please download ${args.url}, make it executable, add it to the store
+          with `nix-store --add', and try again.
+        '';
+
+        outputHashAlgo = "sha256";
+
+        outputHash = args.sha256;
+
+        outputHashMode = "recursive";
+
+        preferLocalBuild = true;
+      };
+in {
+  sh = fetch {
+    file = "sh";
+    sha256 = "1l6sdhyqjlh4m5gj3pfpi8aisp1m012lpwxfcc4v1x8g429mflmy";
+  };
+
+  bzip2 = fetch {
+    file = "bzip2";
+    sha256 = "1p5nkrdn52jm6rsx8x3wwjpsh83f2qsjl1qckkgnkplwhj23zjp7";
+  };
+
+  mkdir = fetch {
+    file = "mkdir";
+    sha256 = "02ff7i9ph9ahiapsg2v9c3pwr7sl73sk4n7ic112ljkrgwkail33";
+  };
+
+  cpio = fetch {
+    file = "cpio";
+    sha256 = "046if3aqqramyhrn2yxrjf4bfkl8x1bcqxhvi7ml9nrv9smx8irg";
+  };
+
+  ln = fetch {
+    file = "ln";
+    sha256 = "06vr474i3x55p0rnqa87yx7dzf4qdfpfg201mks39id43cjm9f8j";
+  };
+
+  curl = fetch {
+    file = "curl.bz2";
+    sha256 = "1v0yfb4gcdyqpl2fxlxjh337r28c23iqm7vwck4p4643xd55di7q";
+  };
 
   bootstrapTools = {
     url = http://tarballs.nixos.org/stdenv-linux/i686/r24519/bootstrap-tools.cpio.bz2;
diff --git a/pkgs/stdenv/linux/bootstrap/loongson2f/default.nix b/pkgs/stdenv/linux/bootstrap/loongson2f/default.nix
index b9a294e13325..e49b09eb23cb 100644
--- a/pkgs/stdenv/linux/bootstrap/loongson2f/default.nix
+++ b/pkgs/stdenv/linux/bootstrap/loongson2f/default.nix
@@ -1,10 +1,66 @@
-{
-  sh = ./sh;
-  bzip2 = ./bzip2;
-  mkdir = ./mkdir;
-  cpio = ./cpio;
-  ln = ./ln;
-  curl = ./curl.bz2;
+let
+  fetch = { file, sha256 }:
+    let
+      nixFetchurl = import <nix/fetchurl.nix>;
+      args = {
+        url = "file://${builtins.toString ./.}/${file}";
+        inherit sha256;
+        executable = true;
+      };
+    in if (builtins.functionArgs nixFetchurl) ? executable
+      then nixFetchurl args
+      else derivation {
+        name = file;
+        builder = "/bin/sh";
+
+        system = builtins.currentSystem;
+
+        args = [ "-c" "echo $message; exit 1" ];
+
+        message = ''
+          Sorry, this version of nix cannot download all of the bootstrap tools.
+          Please download ${args.url}, make it executable, add it to the store
+          with `nix-store --add', and try again.
+        '';
+
+        outputHashAlgo = "sha256";
+
+        outputHash = args.sha256;
+
+        outputHashMode = "recursive";
+
+        preferLocalBuild = true;
+      };
+in {
+  sh = fetch {
+    file = "sh";
+    sha256 = "02jjl49wdq85pgh61aqf78yaknn9mi3rcspbpk7hs9c4mida2rhf";
+  };
+
+  bzip2 = fetch {
+    file = "bzip2";
+    sha256 = "1qn27y3amj9c6mnjk2kyb59y0d2w4yv16z9apaxx91hyq19gf29z";
+  };
+
+  mkdir = fetch {
+    file = "mkdir";
+    sha256 = "1vbp2bv9hkyb2fwl8hjrffpywn1wrl1kc4yrwi2lirawlnc6kymh";
+  };
+
+  cpio = fetch {
+    file = "cpio";
+    sha256 = "0mqxwdx0sl7skxx6049mk35l7d0fnibqsv174284kdp4p7iixwa0";
+  };
+
+  ln = fetch {
+    file = "ln";
+    sha256 = "05lwx8qvga3yv8xhs8bjgsfygsfrcxsfck0lxw6gsdckx25fgi7s";
+  };
+
+  curl = fetch {
+    file = "curl.bz2";
+    sha256 = "0iblnz4my54gryac04i64fn3ksi9g3dx96yjq93fj39z6kx6151c";
+  };
 
   bootstrapTools = {
     url = "http://tarballs.nixos.org/stdenv-linux/loongson2f/r22849/cross-bootstrap-tools.cpio.bz2";
diff --git a/pkgs/stdenv/linux/bootstrap/powerpc/default.nix b/pkgs/stdenv/linux/bootstrap/powerpc/default.nix
index d3569362b6c5..4ad8bc93e442 100644
--- a/pkgs/stdenv/linux/bootstrap/powerpc/default.nix
+++ b/pkgs/stdenv/linux/bootstrap/powerpc/default.nix
@@ -1,9 +1,61 @@
-{
-  bash = ./bash;
-  bzip2 = ./bzip2;
-  cp = ./cp;
-  curl = ./curl.bz2;
-  tar = ./tar.bz2;
+let
+  fetch = { file, sha256 }:
+    let
+      nixFetchurl = import <nix/fetchurl.nix>;
+      args = {
+        url = "file://${builtins.toString ./.}/${file}";
+        inherit sha256;
+        executable = true;
+      };
+    in if (builtins.functionArgs nixFetchurl) ? executable
+      then nixFetchurl args
+      else derivation {
+        name = file;
+        builder = "/bin/sh";
+
+        system = builtins.currentSystem;
+
+        args = [ "-c" "echo $message; exit 1" ];
+
+        message = ''
+          Sorry, this version of nix cannot download all of the bootstrap tools.
+          Please download ${args.url}, make it executable, add it to the store
+          with `nix-store --add', and try again.
+        '';
+
+        outputHashAlgo = "sha256";
+
+        outputHash = args.sha256;
+
+        outputHashMode = "recursive";
+
+        preferLocalBuild = true;
+      };
+in {
+  bash = fetch {
+    file = "bash";
+    sha256 = "0zss8im6hbx6z2i2wxn1554kd7ggdqdli4xk39cy5fchlnz9bqpp";
+  };
+
+  bzip2 = fetch {
+    file = "bzip2";
+    sha256 = "01ylj8x7albv6k9sqx2h1prsazh4d8y22nga0pwai2bnns0q9qdg";
+  };
+
+  cp = fetch {
+    file = "cp";
+    sha256 = "0d7xbzrv22bxgw7w9b03rakirna5zfvr9gzwm7ichd2fh634hvgl";
+  };
+
+  curl = fetch {
+    file = "curl.bz2";
+    sha256 = "17c25dfslw3qkjlcmihpbhn3x4kj9pgkslizv89ggnki7iiy4jgh";
+  };
+
+  tar = fetch {
+    file = "tar.bz2";
+    sha256 = "132ylqwz02hw5njqx7wvj4sxpcrllx8b8b3a00rlv6iad671ayyr";
+  };
 
   staticToolsURL = {
     url = http://tarballs.nixos.org/stdenv-linux/powerpc/r9828/static-tools.tar.bz2;
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index 84af23a263cd..3e71ac467398 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -17,7 +17,7 @@ rec {
     else if system == "powerpc-linux" then import ./bootstrap/powerpc
     else if system == "armv5tel-linux" then import ./bootstrap/armv5tel
     else if system == "armv6l-linux" then import ./bootstrap/armv6l
-    else if system == "armv7l-linux" then import ./bootstrap/armv5tel
+    else if system == "armv7l-linux" then import ./bootstrap/armv6l
     else if system == "mips64el-linux" then import ./bootstrap/loongson2f
     else abort "unsupported platform for the pure Linux stdenv";
 
@@ -58,7 +58,8 @@ rec {
     builder = bootstrapFiles.sh;
 
     args =
-      if (system == "armv5tel-linux" || system == "armv6l-linux")
+      if system == "armv5tel-linux" || system == "armv6l-linux" 
+        || system == "armv7l-linux"
       then [ ./scripts/unpack-bootstrap-tools-arm.sh ]
       else [ ./scripts/unpack-bootstrap-tools.sh ];
 
@@ -215,6 +216,9 @@ rec {
       cloog = pkgs.cloog.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
       ppl = pkgs.ppl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; };
     };
+    extraAttrs = {
+      glibc = stdenvLinuxGlibc;   # Required by gcc47 build
+    };
     inherit fetchurl;
   };
 
diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix
index 524b2a53337b..715bc02758bc 100644
--- a/pkgs/stdenv/native/default.nix
+++ b/pkgs/stdenv/native/default.nix
@@ -9,6 +9,7 @@ rec {
   path =
     (if system == "i686-solaris" then [ "/usr/gnu" ] else []) ++
     (if system == "i686-netbsd" then [ "/usr/pkg" ] else []) ++
+    (if system == "x86_64-solaris" then [ "/opt/local/gnu" ] else []) ++
     ["/" "/usr" "/usr/local"];
 
   prehookBase = ''
@@ -112,7 +113,7 @@ rec {
     name = "gcc-native";
     nativeTools = true;
     nativeLibc = true;
-    nativePrefix = if system == "i686-solaris" then "/usr/gnu" else "/usr";
+    nativePrefix = if system == "i686-solaris" then "/usr/gnu" else if system == "x86_64-solaris" then "/opt/local/gcc47" else "/usr";
     stdenv = stdenvBoot0;
   };
 
diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix
index d0f7d60f101c..b16c51f7580b 100644
--- a/pkgs/stdenv/nix/default.nix
+++ b/pkgs/stdenv/nix/default.nix
@@ -23,6 +23,7 @@ import ../generic rec {
 
   gcc = import ../../build-support/gcc-wrapper {
     nativeTools = false;
+    nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr";
     nativeLibc = true;
     inherit stdenv;
     binutils =
diff --git a/pkgs/tools/archivers/cpio/default.nix b/pkgs/tools/archivers/cpio/default.nix
index 1700f03d7bd8..ec873507c85e 100644
--- a/pkgs/tools/archivers/cpio/default.nix
+++ b/pkgs/tools/archivers/cpio/default.nix
@@ -1,21 +1,14 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "cpio-2.9";
-  
+  name = "cpio-2.11";
+
   src = fetchurl {
-    url = mirror://gnu/cpio/cpio-2.9.tar.bz2;
-    sha256 = "01s7f9hg8kgpis96j99hgkiqgdy53pm7qi7bhm3fzx58jfk5z6mv";
+    url = mirror://gnu/cpio/cpio-2.11.tar.bz2;
+    sha256 = "bb820bfd96e74fc6ce43104f06fe733178517e7f5d1cdee553773e8eff7d5bbd";
   };
 
-  patches = [
-    # Make it compile on GCC 4.3.
-    (fetchurl {
-      name = "cpio-2.9-gnu-inline.patch";
-      url = "http://sources.gentoo.org/viewcvs.py/*checkout*/gentoo-x86/app-arch/cpio/files/cpio-2.9-gnu-inline.patch?rev=1.1";
-      sha256 = "1167hrq64h9lh3qhgasm2rivfzkkgx6fik92b017qfa0q61ff8c3";
-    })
-  ];
+  patches = [ ./no-gets.patch ];
 
   meta = {
     homepage = http://www.gnu.org/software/cpio/;
diff --git a/pkgs/development/tools/misc/gnum4/no-gets.patch b/pkgs/tools/archivers/cpio/no-gets.patch
index 456c08b56c34..f7a9be324df4 100644
--- a/pkgs/development/tools/misc/gnum4/no-gets.patch
+++ b/pkgs/tools/archivers/cpio/no-gets.patch
@@ -1,8 +1,6 @@
-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/424974
 
-https://bugs.gentoo.org/424978
-
-hack until m4 pulls a newer gnulib version
+hack until gzip pulls a newer gnulib version
 
 From 66712c23388e93e5c518ebc8515140fa0c807348 Mon Sep 17 00:00:00 2001
 From: Eric Blake <eblake@redhat.com>
@@ -14,8 +12,8 @@ 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
+--- a/gnu/stdio.in.h
++++ b/gnu/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.  */
diff --git a/pkgs/tools/archivers/gnutar/default.nix b/pkgs/tools/archivers/gnutar/default.nix
index 24249e383951..8735702dd33d 100644
--- a/pkgs/tools/archivers/gnutar/default.nix
+++ b/pkgs/tools/archivers/gnutar/default.nix
@@ -1,18 +1,16 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "gnutar-1.26";
+  name = "gnutar-1.27";
 
   src = fetchurl {
-    url = "mirror://gnu/tar/tar-1.26.tar.bz2";
-    sha256 = "0hbdkzmchq9ycr2x1pxqdcgdbaxksh8c6ac0jf75jajhcks6jlss";
+    url = "mirror://gnu/tar/tar-1.27.tar.bz2";
+    sha256 = "0yrwmx2f721ahpnki4fnzvnmrd3md3bq417icb4wrjky7k3caf12";
   };
 
-  patches = [ ./gets-undeclared.patch ];
-
   # May have some issues with root compilation because the bootstrap tool
   # cannot be used as a login shell for now.
-  FORCE_UNSAFE_CONFIGURE = stdenv.lib.optionalString (stdenv.system == "armv7l-linux") "1";
+  FORCE_UNSAFE_CONFIGURE = stdenv.lib.optionalString (stdenv.system == "armv7l-linux" || stdenv.isSunOS) "1";
 
   meta = {
     homepage = http://www.gnu.org/software/tar/;
diff --git a/pkgs/tools/archivers/gnutar/gets-undeclared.patch b/pkgs/tools/archivers/gnutar/gets-undeclared.patch
deleted file mode 100644
index 301a09dde128..000000000000
--- a/pkgs/tools/archivers/gnutar/gets-undeclared.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-This patch is needed to allow builds with newer versions of
-the GNU libc (2.16+).
-
-This is a backport of this patch:
-
-commit 66712c23388e93e5c518ebc8515140fa0c807348
-Author: Eric Blake <eblake@redhat.com>
-Date:   Thu Mar 29 13:30:41 2012 -0600
-
-    stdio: don't assume gets any more
-    
---- tar-1.26/gnu/stdio.in.h	2012-07-02 14:28:45.000000000 +0200
-+++ tar-1.26/gnu/stdio.in.h	2012-07-02 14:28:50.000000000 +0200
-@@ -160,12 +160,6 @@ _GL_WARN_ON_USE (fflush, "fflush is not
-                  "use gnulib module fflush for portable POSIX compliance");
- #endif
- 
--/* It is very rare that the developer ever has full control of stdin,
--   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@
- #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
diff --git a/pkgs/tools/compression/gzip/default.nix b/pkgs/tools/compression/gzip/default.nix
index 0e6742253441..3a134fea9dee 100644
--- a/pkgs/tools/compression/gzip/default.nix
+++ b/pkgs/tools/compression/gzip/default.nix
@@ -1,13 +1,19 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, less }:
 
 stdenv.mkDerivation rec {
-  name = "gzip-1.5";
+  name = "gzip-1.6";
 
   src = fetchurl {
     url = "mirror://gnu/gzip/${name}.tar.xz";
-    sha256 = "0wx1nqk709kx75cwp2axachnbxryp4gyl06qxn5nl95184w0mhls";
+    sha256 = "0ivqnbhiwd12q8hp3qw6rpsrpw2jg5y2mymk8cn22lsx90dfvprp";
   };
 
+  patches = [ ./skip-some-tests.patch ];
+
+  buildInputs = [ less ]; # just for tests
+
+  doCheck = true;
+
   meta = {
     homepage = http://www.gnu.org/software/gzip/;
     description = "Gzip, the GNU zip compression program";
diff --git a/pkgs/tools/compression/gzip/skip-some-tests.patch b/pkgs/tools/compression/gzip/skip-some-tests.patch
new file mode 100644
index 000000000000..74043a3ab56d
--- /dev/null
+++ b/pkgs/tools/compression/gzip/skip-some-tests.patch
@@ -0,0 +1,12 @@
+Skip test requiring more (not found in nixpkgs).
+--- gzip-1.5/tests/Makefile.in.orig	2013-02-23 15:15:08.017048868 +0000
++++ gzip-1.5/tests/Makefile.in	2013-02-23 15:15:32.756197039 +0000
+@@ -1441,8 +1440,7 @@
+   zfgrep	\
+   zforce	\
+   zgrep		\
+   zless		\
+-  zmore		\
+   znew
+ 
+ TESTS_ENVIRONMENT = \
diff --git a/pkgs/tools/compression/xz/default.nix b/pkgs/tools/compression/xz/default.nix
index 26c1597f2aa8..6d59bd927cff 100644
--- a/pkgs/tools/compression/xz/default.nix
+++ b/pkgs/tools/compression/xz/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl }:
 
 stdenv.mkDerivation rec {
-  name = "xz-5.0.4";
+  name = "xz-5.0.5";
 
   src = fetchurl {
     url = "http://tukaani.org/xz/${name}.tar.bz2";
-    sha256 = "14nf55b47335aakswqk0kqv1qsh4269rnb757dmkkbd1sdhb1naw";
+    sha256 = "1404i59bp6rzxya0br1q9njdv32z4sggyfrkjr7vq695hk94hv0n";
   };
 
   doCheck = true;
diff --git a/pkgs/tools/filesystems/e2fsprogs/default.nix b/pkgs/tools/filesystems/e2fsprogs/default.nix
index 712cd32d9c33..b855fce17d0f 100644
--- a/pkgs/tools/filesystems/e2fsprogs/default.nix
+++ b/pkgs/tools/filesystems/e2fsprogs/default.nix
@@ -25,8 +25,6 @@ stdenv.mkDerivation rec {
 
   postInstall = "make install-libs";
 
-  dontGzipMan = true; # See issue #523
-
   meta = {
     homepage = http://e2fsprogs.sourceforge.net/;
     description = "Tools for creating and checking ext2/ext3/ext4 filesystems";
diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix
index 65a3bec555ef..ebd68ee9cf68 100644
--- a/pkgs/tools/misc/coreutils/default.nix
+++ b/pkgs/tools/misc/coreutils/default.nix
@@ -36,7 +36,7 @@ let
           for a in *.x; do
             touch `basename $a .x`.1
           done
-          popd; make ) 
+          popd; make )
       '';
 
       postInstall = ''
@@ -80,3 +80,6 @@ let
   });
 in
   self
+  // stdenv.lib.optionalAttrs (stdenv.system == "armv7l-linux" || stdenv.isSunOS) {
+    FORCE_UNSAFE_CONFIGURE = 1;
+  }
diff --git a/pkgs/tools/misc/file/default.nix b/pkgs/tools/misc/file/default.nix
index 8b141fea8262..cbcbbb2bb4aa 100644
--- a/pkgs/tools/misc/file/default.nix
+++ b/pkgs/tools/misc/file/default.nix
@@ -1,13 +1,13 @@
 { stdenv, fetchurl, zlib }:
 
 stdenv.mkDerivation rec {
-  name = "file-5.12";
+  name = "file-5.14";
 
   buildInputs = [ zlib ];
 
   src = fetchurl {
     url = "ftp://ftp.astron.com/pub/file/${name}.tar.gz";
-    sha256 = "08ix4xrvan0k80n0l5lqfmc4azjv5lyhvhwdxny4r09j5smhv78r";
+    sha256 = "1r3zqxr7al5yy2595hd9hxwc14iij021p46d5my3n2lhs0fs06s6";
   };
 
   meta = {
diff --git a/pkgs/tools/misc/less/default.nix b/pkgs/tools/misc/less/default.nix
index b22e7521764c..3183fe2ca382 100644
--- a/pkgs/tools/misc/less/default.nix
+++ b/pkgs/tools/misc/less/default.nix
@@ -1,13 +1,22 @@
-{stdenv, fetchurl, ncurses}:
- 
-stdenv.mkDerivation {
-  name = "less-436";
- 
+{ stdenv, fetchurl, ncurses }:
+
+stdenv.mkDerivation rec {
+  name = "less-458";
+
   src = fetchurl {
-    url = http://www.greenwoodsoftware.com/less/less-436.tar.gz;
-    sha256 = "1lilcx6qrfr2dqahv7r10j9h2v86w5sb7m8wrx2sza9ifkq6z8ap";
+    url = "http://www.greenwoodsoftware.com/less/${name}.tar.gz";
+    sha256 = "1b7wn1nk8qlzx20jmn9l6zcbw81n9g0w9zzhhzab6m6yks0wfdp5";
+  };
+
+  # Look for ‘sysless’ in /etc.
+  configureFlags = "--sysconfdir=/etc";
+
+  buildInputs = [ ncurses ];
+
+  meta = {
+    homepage = http://www.greenwoodsoftware.com/less/;
+    description = "A more advanced file pager than ‘more’";
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.eelco ];
   };
- 
-  buildInputs = [ncurses];
- 
 }
diff --git a/pkgs/tools/networking/curl/default.nix b/pkgs/tools/networking/curl/default.nix
index 40e2d9706221..9902c1f1238c 100644
--- a/pkgs/tools/networking/curl/default.nix
+++ b/pkgs/tools/networking/curl/default.nix
@@ -13,11 +13,11 @@ assert scpSupport -> libssh2 != null;
 assert c-aresSupport -> c-ares != null;
 
 stdenv.mkDerivation rec {
-  name = "curl-7.30.0";
+  name = "curl-7.31.0";
 
   src = fetchurl {
     url = "http://curl.haxx.se/download/${name}.tar.bz2";
-    sha256 = "04dgm9aqvplsx43n8xin5rkr8mwmc6mdd1gcp80jda5yhw1l273b";
+    sha256 = "021ygqk4gn24iqm0i0xvzldfgqdg18fmvwqia7i5vzzcxj712fx7";
   };
 
   # Zlib and OpenSSL must be propagated because `libcurl.la' contains
@@ -27,11 +27,13 @@ stdenv.mkDerivation rec {
     optional zlibSupport zlib ++
     optional gssSupport gss ++
     optional c-aresSupport c-ares ++
-    optional sslSupport openssl;
+    optional sslSupport openssl ++
+    optional scpSupport libssh2;
 
   preConfigure = ''
     sed -e 's|/usr/bin|/no-such-path|g' -i.bak configure
   '';
+
   configureFlags = [
       ( if sslSupport then "--with-ssl=${openssl}" else "--without-ssl" )
       ( if scpSupport then "--with-libssh2=${libssh2}" else "--without-libssh2" )
@@ -67,9 +69,10 @@ stdenv.mkDerivation rec {
     inherit sslSupport openssl;
   };
 
-  meta = {
-    homepage = "http://curl.haxx.se/";
+  meta = with stdenv.lib; {
     description = "A command line tool for transferring files with URL syntax";
-    platforms = stdenv.lib.platforms.all;
+    homepage    = http://curl.haxx.se/;
+    maintainers = with maintainers; [ lovek323 ];
+    platforms   = platforms.all;
   };
 }
diff --git a/pkgs/tools/networking/p2p/amule/default.nix b/pkgs/tools/networking/p2p/amule/default.nix
index 44384507a79d..c92fcecc9fcd 100644
--- a/pkgs/tools/networking/p2p/amule/default.nix
+++ b/pkgs/tools/networking/p2p/amule/default.nix
@@ -12,17 +12,19 @@ let
   edf = enabled: flag: if enabled then "--enable-" + flag else "--disable-" + flag;
 in 
 mkDerivation rec {
-  name = "aMule-2.2.6";
+  name = "aMule-2.3.1";
 
   src = fetchurl {
-    url = "mirror://sourceforge/amule/${name}.tar.bz2";
-    sha256 = "08l1931hcg1ia8yvhgx70hx64mknjnfn6l78m0ja44w13mgjpqvc";
+    url = "mirror://sourceforge/amule/${name}.tar.xz";
+    sha256 = "0hvpx3c005nvxsfand5bwfxxiq3mv0mpykajfm2lkygjh1rw2383";
   };
 
   buildInputs =
     [ zlib wxGTK perl cryptopp libupnp gettext pkgconfig makeWrapper ]
     ++ lib.optional httpServer libpng;
 
+  patches = [ ./gcc47.patch ]; # from Gentoo
+
   configureFlags = ''
     --with-crypto-prefix=${cryptopp}
     --disable-debug
diff --git a/pkgs/tools/networking/p2p/amule/gcc47.patch b/pkgs/tools/networking/p2p/amule/gcc47.patch
new file mode 100644
index 000000000000..e776dda3240e
--- /dev/null
+++ b/pkgs/tools/networking/p2p/amule/gcc47.patch
@@ -0,0 +1,21 @@
+# http://code.google.com/p/amule/source/detail?r=10772
+diff -ur aMule-2.3.1.orig//src/ObservableQueue.h aMule-2.3.1/src/ObservableQueue.h
+--- aMule-2.3.1.orig//src/ObservableQueue.h	2012-04-22 19:40:05.560084120 +0200
++++ aMule-2.3.1/src/ObservableQueue.h	2012-04-22 19:40:32.479085322 +0200
+@@ -331,14 +331,14 @@
+ template <typename ValueType>
+ void CObservableQueue<ValueType>::ObserverAdded( ObserverType* o )
+ {
+-	NotifyObservers( EventType( EventType::STARTING ), o );
++	this->NotifyObservers( EventType( EventType::STARTING ), o );
+ }
+ 
+ 
+ template <typename ValueType>
+ void CObservableQueue<ValueType>::ObserverRemoved( ObserverType* o )
+ {
+-	NotifyObservers( EventType( EventType::STOPPING ), o );
++	this->NotifyObservers( EventType( EventType::STOPPING ), o );
+ }
+ 
+ 
\ No newline at end of file
diff --git a/pkgs/tools/text/diffutils/default.nix b/pkgs/tools/text/diffutils/default.nix
index fc4293ad7cff..f8413b9a0d0f 100644
--- a/pkgs/tools/text/diffutils/default.nix
+++ b/pkgs/tools/text/diffutils/default.nix
@@ -1,15 +1,13 @@
 { stdenv, fetchurl, coreutils ? null }:
 
-stdenv.mkDerivation {
-  name = "diffutils-3.2";
+stdenv.mkDerivation rec {
+  name = "diffutils-3.3";
 
   src = fetchurl {
-    url = mirror://gnu/diffutils/diffutils-3.2.tar.gz;
-    sha256 = "1lsf0ln0h3mnm2y0mwgrfk0lyfi7bnm4r886acvdrrsvc7pypaia";
+    url = "mirror://gnu/diffutils/${name}.tar.xz";
+    sha256 = "1761vymxbp4wb5rzjvabhdkskk95pghnn67464byvzb5mfl8jpm2";
   };
 
-  patches = [ ./gets-undeclared.patch ];
-
   /* If no explicit coreutils is given, use the one from stdenv. */
   nativeBuildInputs = [ coreutils ];
 
diff --git a/pkgs/tools/text/diffutils/gets-undeclared.patch b/pkgs/tools/text/diffutils/gets-undeclared.patch
deleted file mode 100644
index b6cdc77caa84..000000000000
--- a/pkgs/tools/text/diffutils/gets-undeclared.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-This patch is needed to allow builds with newer versions of
-the GNU libc (2.16+).
-
-
-commit 66712c23388e93e5c518ebc8515140fa0c807348
-Author: Eric Blake <eblake@redhat.com>
-Date:   Thu Mar 29 13:30:41 2012 -0600
-
-    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.
-    
-    * m4/stdio_h.m4 (gl_STDIO_H, gl_STDIO_H_DEFAULTS): Drop gets
-    support.
-    * modules/stdio (Makefile.am): Likewise.
-    * lib/stdio-read.c (gets): Likewise.
-    * tests/test-stdio-c++.cc: Likewise.
-    * m4/warn-on-use.m4 (gl_WARN_ON_USE_PREPARE): Fix comment.
-    * lib/stdio.in.h (gets): Make warning occur in more places.
-    * doc/posix-functions/gets.texi (gets): Update documentation.
-    Reported by Christer Solskogen.
-    
-    Signed-off-by: Eric Blake <eblake@redhat.com>
-
-diff --git a/lib/stdio.in.h b/lib/stdio.in.h
-index aa7b599..c377b6e 100644
---- a/lib/stdio.in.h
-+++ b/lib/stdio.in.h
-@@ -698,22 +698,11 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
- # endif
- #endif
- 
--#if @GNULIB_GETS@
--# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
--#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
--#   undef gets
--#   define gets rpl_gets
--#  endif
--_GL_FUNCDECL_RPL (gets, char *, (char *s) _GL_ARG_NONNULL ((1)));
--_GL_CXXALIAS_RPL (gets, char *, (char *s));
--# else
--_GL_CXXALIAS_SYS (gets, char *, (char *s));
--#  undef gets
--# endif
--_GL_CXXALIASWARN (gets);
- /* It is very rare that the developer ever has full control of stdin,
--   so any use of gets warrants an unconditional warning.  Assume it is
--   always declared, since it is required by C89.  */
-+   so any use of gets warrants an unconditional warning; besides, C11
-+   removed it.  */
-+#undef gets
-+#if HAVE_RAW_DECL_GETS
- _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
- #endif
- 
-@@ -1053,9 +1042,9 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
- # endif
- #endif
- 
--/* Some people would argue that sprintf should be handled like gets
--   (for example, OpenBSD issues a link warning for both functions),
--   since both can cause security holes due to buffer overruns.
-+/* Some people would argue that all sprintf uses should be warned about
-+   (for example, OpenBSD issues a link warning for it),
-+   since it can cause security holes due to buffer overruns.
-    However, we believe that sprintf can be used safely, and is more
-    efficient than snprintf in those safe cases; and as proof of our
-    belief, we use sprintf in several gnulib modules.  So this header
diff --git a/pkgs/tools/text/gawk/default.nix b/pkgs/tools/text/gawk/default.nix
index eba1dc2ac7fd..901f53c5e5cc 100644
--- a/pkgs/tools/text/gawk/default.nix
+++ b/pkgs/tools/text/gawk/default.nix
@@ -1,11 +1,11 @@
 { stdenv, fetchurl, libsigsegv }:
 
 stdenv.mkDerivation rec {
-  name = "gawk-4.0.2";
+  name = "gawk-4.1.0";
 
   src = fetchurl {
     url = "mirror://gnu/gawk/${name}.tar.xz";
-    sha256 = "04vd0axif762mf781pj3days6ilv2333b9zi9c50y5mma66g5q91";
+    sha256 = "0hin2hswbbd6kd6i4zzvgciwpl5fba8d2s524z8y5qagyz3x010q";
   };
 
   patches = [];
diff --git a/pkgs/tools/text/gnugrep/default.nix b/pkgs/tools/text/gnugrep/default.nix
index 5a31d0096107..bdf19161e431 100644
--- a/pkgs/tools/text/gnugrep/default.nix
+++ b/pkgs/tools/text/gnugrep/default.nix
@@ -13,6 +13,8 @@ stdenv.mkDerivation {
   buildInputs = [ pcre ]
     ++ stdenv.lib.optional (libiconv != null) libiconv;
 
+  patches = [ ./test-localeconv.patch ];
+
   NIX_LDFLAGS = stdenv.lib.optionalString (libiconv != null) "-L${libiconv}/lib -liconv";
 
   doCheck = !stdenv.isDarwin;
diff --git a/pkgs/tools/text/gnugrep/test-localeconv.patch b/pkgs/tools/text/gnugrep/test-localeconv.patch
new file mode 100644
index 000000000000..f5efaf222217
--- /dev/null
+++ b/pkgs/tools/text/gnugrep/test-localeconv.patch
@@ -0,0 +1,18 @@
+--- grep-2.14/gnulib-tests/test-localeconv.c.orig	2013-02-15 18:41:50.213433059 +0000
++++ grep-2.14/gnulib-tests/test-localeconv.c	2013-02-15 18:50:33.964751303 +0000
+@@ -37,13 +37,13 @@
+ 
+     ASSERT (STREQ (l->decimal_point, "."));
+     ASSERT (STREQ (l->thousands_sep, ""));
+-#if !defined __FreeBSD__
++#if !(defined __FreeBSD__ || defined __sun)
+     ASSERT (STREQ (l->grouping, ""));
+ #endif
+ 
+     ASSERT (STREQ (l->mon_decimal_point, ""));
+     ASSERT (STREQ (l->mon_thousands_sep, ""));
+-#if !defined __FreeBSD__
++#if !(defined __FreeBSD__ || defined __sun)
+     ASSERT (STREQ (l->mon_grouping, ""));
+ #endif
+     ASSERT (STREQ (l->positive_sign, ""));
diff --git a/pkgs/tools/text/gnupatch/bashishms.patch b/pkgs/tools/text/gnupatch/bashishms.patch
new file mode 100644
index 000000000000..1a2cfbd8e4a2
--- /dev/null
+++ b/pkgs/tools/text/gnupatch/bashishms.patch
@@ -0,0 +1,67 @@
+http://lists.gnu.org/archive/html/bug-patch/2012-11/msg00001.html
+Tested on Illumos, where ksh is /bin/sh.
+
+--- patch-2.7.1/tests/test-lib.sh
++++ patch-2.7.1/tests/test-lib.sh
+@@ -118,7 +118,7 @@
+ }
+ 
+ if test -z "`echo -n`"; then
+-    if eval 'test -n "${BASH_LINENO[0]}" 2>/dev/null'; then
++    if (eval 'test -n "${BASH_LINENO[0]}"') 2>/dev/null; then
+ 	eval '
+ 	    _start_test() {
+ 		echo -n "[${BASH_LINENO[2]}] $* -- "
+
+--- patch-2.7.1/tests/crlf-handling
++++ patch-2.7.1/tests/crlf-handling
+@@ -14,7 +14,7 @@
+ use_tmpdir
+ 
+ lf2crlf() {
+-    while read l; do echo -e "$l\r"; done
++    while read l; do printf "%s\r\n" "$l"; done
+ }
+ 
+ echo 1 > a
+
+--- patch-2.7.1/tests/merge
++++ patch-2.7.1/tests/merge
+@@ -32,18 +32,20 @@
+     shift
+     done > a.sed
+     echo "$body" | sed -f a.sed > b
+-    shift
+-    while test $# -gt 0 ; do
+-	echo "$1"
++    if test $# -gt 0 ; then
+ 	shift
+-    done > b.sed
++    while test $# -gt 0 ; do
++	echo "$1"
++	shift
++    done
++    fi > b.sed
+     echo "$body" | sed -f b.sed > c
+     rm -f a.sed b.sed
+     output=`diff -u a b | patch $ARGS -f c`
+     status=$?
+     echo "$output" | sed -e '/^$/d' -e '/^patching file c$/d'
+     cat c
+-    test $status == 0 || echo "Status: $status"
++    test $status = 0 || echo "Status: $status"
+ }
+ 
+ x() {
+
+--- patch-2.7.1/tests/read-only-files
++++ patch-2.7.1/tests/read-only-files
+@@ -16,7 +16,7 @@
+
+ : > read-only
+ chmod a-w read-only
+-if : 2> /dev/null > read-only; then
++if (: > read-only) 2> /dev/null; then
+     echo "Files with read-only permissions are writable" \
+         "(probably running as superuser)" >&2
+     exit 77
diff --git a/pkgs/tools/text/gnupatch/default.nix b/pkgs/tools/text/gnupatch/default.nix
index e494eba13ce3..1ad40a4a5fa0 100644
--- a/pkgs/tools/text/gnupatch/default.nix
+++ b/pkgs/tools/text/gnupatch/default.nix
@@ -14,8 +14,9 @@ stdenv.mkDerivation rec {
     configureFlags = [ "ac_cv_func_strnlen_working=yes" ];
   };
 
-  # Tests fail on FreeBSD due to a Bashism in the tests.
-  doCheck = !stdenv.isFreeBSD;
+  patches = [ ./bashishms.patch ];
+
+  doCheck = true;
 
   meta = {
     description = "GNU Patch, a program to apply differences to files";
diff --git a/pkgs/tools/text/gnused/default.nix b/pkgs/tools/text/gnused/default.nix
index d34ed00d436a..cf30169acef1 100644
--- a/pkgs/tools/text/gnused/default.nix
+++ b/pkgs/tools/text/gnused/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "gnused-4.2.1";
+  name = "gnused-4.2.2";
 
   src = fetchurl {
-    url = mirror://gnu/sed/sed-4.2.1.tar.gz;
-    sha256 = "0q1hzjvr6pzhaagidg7pj76k1fzz5nl15np7p72w9zcpw0f58ww7";
+    url = mirror://gnu/sed/sed-4.2.2.tar.bz2;
+    sha256 = "f048d1838da284c8bc9753e4506b85a1e0cc1ea8999d36f6995bcb9460cddbd7";
   };
 
   meta = {
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index e43fdd4243d2..7ed4486c98c2 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -2233,7 +2233,7 @@ let
 
   gambit = callPackage ../development/compilers/gambit { };
 
-  gcc = gcc46;
+  gcc = gcc48;
 
   gcc33 = wrapGCC (import ../development/compilers/gcc/3.3 {
     inherit fetchurl stdenv noSysDirs;
@@ -2254,12 +2254,14 @@ let
   });
 
   gcc43 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc/4.3) {
-    inherit stdenv fetchurl texinfo gmp mpfr noSysDirs;
+    inherit stdenv fetchurl gmp mpfr noSysDirs;
+    texinfo = texinfo4;
     profiledCompiler = true;
   }));
 
   gcc43_realCross = makeOverridable (import ../development/compilers/gcc/4.3) {
-    inherit stdenv fetchurl texinfo gmp mpfr noSysDirs;
+    inherit stdenv fetchurl gmp mpfr noSysDirs;
+    texinfo = texinfo4;
     binutilsCross = binutilsCross;
     libcCross = libcCross;
     profiledCompiler = false;
@@ -2270,8 +2272,9 @@ let
 
   gcc44_realCross = lib.addMetaAttrs { platforms = []; }
     (makeOverridable (import ../development/compilers/gcc/4.4) {
-      inherit stdenv fetchurl texinfo gmp mpfr /* ppl cloogppl */ noSysDirs
+      inherit stdenv fetchurl gmp mpfr /* ppl cloogppl */ noSysDirs
           gettext which;
+      texinfo = texinfo4;
       binutilsCross = binutilsCross;
       libcCross = libcCross;
       profiledCompiler = false;
@@ -2317,10 +2320,13 @@ let
 
   gcc47 = gcc47_real;
 
+  gcc48 = gcc48_real;
+
   gcc45_realCross = lib.addMetaAttrs { platforms = []; }
     (makeOverridable (import ../development/compilers/gcc/4.5) {
-      inherit fetchurl stdenv texinfo gmp mpfr mpc libelf zlib
+      inherit fetchurl stdenv gmp mpfr mpc libelf zlib
         ppl cloogppl gettext which noSysDirs;
+      texinfo = texinfo4;
       binutilsCross = binutilsCross;
       libcCross = libcCross;
       profiledCompiler = false;
@@ -2401,15 +2407,17 @@ let
   };
 
   gcc44 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc/4.4) {
-    inherit fetchurl stdenv texinfo gmp mpfr /* ppl cloogppl */
+    inherit fetchurl stdenv gmp mpfr /* ppl cloogppl */
       gettext which noSysDirs;
+    texinfo = texinfo4;
     profiledCompiler = true;
   }));
 
   gcc45_real = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc/4.5) {
-    inherit fetchurl stdenv texinfo gmp mpfr mpc libelf zlib perl
+    inherit fetchurl stdenv gmp mpfr mpc libelf zlib perl
       ppl cloogppl
       gettext which noSysDirs;
+    texinfo = texinfo4;
     # bootstrapping a profiled compiler does not work in the sheevaplug:
     # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43944
     profiledCompiler = !stdenv.isArm;
@@ -2465,6 +2473,7 @@ let
 
   gcc47_real = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.7 {
     inherit noSysDirs;
+    texinfo = texinfo4;
     # I'm not sure if profiling with enableParallelBuilding helps a lot.
     # We can enable it back some day. This makes the *gcc* builds faster now.
     profiledCompiler = false;
@@ -2482,6 +2491,32 @@ let
 
   gcc47_debug = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.7 {
     stripped = false;
+    texinfo = texinfo4;
+    inherit noSysDirs;
+    cross = null;
+    libcCross = null;
+    binutilsCross = null;
+  }));
+
+  gcc48_real = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.8 {
+    inherit noSysDirs;
+
+    # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
+    profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
+
+    # When building `gcc.crossDrv' (a "Canadian cross", with host == target
+    # and host != build), `cross' must be null but the cross-libc must still
+    # be passed.
+    cross = null;
+    libcCross = if crossSystem != null then libcCross else null;
+    libpthreadCross =
+      if crossSystem != null && crossSystem.config == "i586-pc-gnu"
+      then gnu.libpthreadCross
+      else null;
+  }));
+
+  gcc48_debug = lowPrio (wrapGCC (callPackage ../development/compilers/gcc/4.8 {
+    stripped = false;
 
     inherit noSysDirs;
     cross = null;
@@ -2499,17 +2534,9 @@ let
       stdenv = allStdenvs.stdenvNative;
     });
 
-  gfortran = gfortran46;
-
-  gfortran42 = wrapGCC (gcc42.gcc.override {
-    name = "gfortran";
-    langFortran = true;
-    langCC = false;
-    langC = false;
-    inherit gmp mpfr;
-  });
+  gfortran = gfortran47; # 48 has problems building ATM
 
-  gfortran43 = wrapGCC (gcc43.gcc.override {
+  gfortran47 = wrapGCC (gcc47.gcc.override {
     name = "gfortran";
     langFortran = true;
     langCC = false;
@@ -2517,7 +2544,7 @@ let
     profiledCompiler = false;
   });
 
-  gfortran44 = wrapGCC (gcc44.gcc.override {
+  gfortran48 = wrapGCC (gcc48.gcc.override {
     name = "gfortran";
     langFortran = true;
     langCC = false;
@@ -2525,39 +2552,51 @@ let
     profiledCompiler = false;
   });
 
-  gfortran45 = wrapGCC (gcc45_real.gcc.override {
-    name = "gfortran";
-    langFortran = true;
-    langCC = false;
+  gcj = gcj47;
+
+  gcj44 = wrapGCC (gcc44.gcc.override {
+    name = "gcj";
+    langJava = true;
+    langFortran = false;
+    langCC = true;
     langC = false;
     profiledCompiler = false;
+    inherit zip unzip zlib boehmgc gettext pkgconfig;
+    inherit gtk;
+    inherit (gnome) libart_lgpl;
+    inherit (xlibs) libX11 libXt libSM libICE libXtst libXi libXrender
+      libXrandr xproto renderproto xextproto inputproto randrproto;
   });
 
-  gfortran46 = wrapGCC (gcc46_real.gcc.override {
-    name = "gfortran";
-    langFortran = true;
-    langCC = false;
+  gcj45 = wrapGCC (gcc45.gcc.override {
+    name = "gcj";
+    langJava = true;
+    langFortran = false;
+    langCC = true;
     langC = false;
     profiledCompiler = false;
+    inherit zip unzip zlib boehmgc gettext pkgconfig perl;
+    inherit gtk;
+    inherit (gnome) libart_lgpl;
+    inherit (xlibs) libX11 libXt libSM libICE libXtst libXi libXrender
+      libXrandr xproto renderproto xextproto inputproto randrproto;
   });
 
-  gcj = gcj45;
-
-  gcj44 = wrapGCC (gcc44.gcc.override {
+  gcj46 = wrapGCC (gcc46.gcc.override {
     name = "gcj";
     langJava = true;
     langFortran = false;
     langCC = true;
     langC = false;
     profiledCompiler = false;
-    inherit zip unzip zlib boehmgc gettext pkgconfig;
+    inherit zip unzip zlib boehmgc gettext pkgconfig perl;
     inherit gtk;
     inherit (gnome) libart_lgpl;
     inherit (xlibs) libX11 libXt libSM libICE libXtst libXi libXrender
       libXrandr xproto renderproto xextproto inputproto randrproto;
   });
 
-  gcj45 = wrapGCC (gcc45.gcc.override {
+  gcj47 = wrapGCC (gcc47.gcc.override {
     name = "gcj";
     langJava = true;
     langFortran = false;
@@ -2571,11 +2610,11 @@ let
       libXrandr xproto renderproto xextproto inputproto randrproto;
   });
 
-  gcj46 = wrapGCC (gcc46.gcc.override {
+  gcj48 = wrapGCC (gcc48.gcc.override {
     name = "gcj";
     langJava = true;
     langFortran = false;
-    langCC = true;
+    langCC = false;
     langC = false;
     profiledCompiler = false;
     inherit zip unzip zlib boehmgc gettext pkgconfig perl;
@@ -2641,7 +2680,8 @@ let
   });
 
   ghdl = wrapGCC (import ../development/compilers/gcc/4.3 {
-    inherit stdenv fetchurl texinfo gmp mpfr noSysDirs gnat;
+    inherit stdenv fetchurl gmp mpfr noSysDirs gnat;
+    texinfo = texinfo4;
     name = "ghdl";
     langVhdl = true;
     langCC = false;
@@ -2652,8 +2692,9 @@ let
 
   # Not officially supported version for ghdl
   ghdl_gcc44 = lowPrio (wrapGCC (import ../development/compilers/gcc/4.4 {
-    inherit stdenv fetchurl texinfo gmp mpfr noSysDirs gnat gettext which
+    inherit stdenv fetchurl gmp mpfr noSysDirs gnat gettext which
       ppl cloogppl;
+    texinfo = texinfo4;
     name = "ghdl";
     langVhdl = true;
     langCC = false;
@@ -2804,7 +2845,6 @@ let
 
   julia = callPackage ../development/compilers/julia {
     liblapack = liblapack.override {shared = true;};
-    mpfr = mpfr_3_1_2;
     fftw = fftw.override {pthreads = true;};
     fftwSinglePrec = fftwSinglePrec.override {pthreads = true;};
   };
@@ -3421,9 +3461,9 @@ let
     deterministic = true;
   });
 
-  binutils_gold = lowPrio (callPackage ../development/tools/misc/binutils {
+  binutils_nogold = lowPrio (callPackage ../development/tools/misc/binutils {
     inherit noSysDirs;
-    gold = true;
+    gold = false;
   });
 
   binutilsCross = lowPrio (forceNativeDrv (import ../development/tools/misc/binutils {
@@ -3433,8 +3473,8 @@ let
   }));
 
   bison2 = callPackage ../development/tools/parsing/bison/2.x.nix { };
-  bison3 = lowPrio (callPackage ../development/tools/parsing/bison/3.x.nix { });
-  bison = bison2;
+  bison3 = callPackage ../development/tools/parsing/bison/3.x.nix { };
+  bison = bison3;
 
   buildbot = callPackage ../development/tools/build-managers/buildbot {
     inherit (pythonPackages) twisted jinja2 sqlalchemy sqlalchemy_migrate;
@@ -3569,19 +3609,11 @@ let
 
   checkstyle = callPackage ../development/tools/analysis/checkstyle { };
 
-  flex = flex2535;
-
-  flex2535 = callPackage ../development/tools/parsing/flex/flex-2.5.35.nix { };
-
-  flex2534 = callPackage ../development/tools/parsing/flex/flex-2.5.34.nix { };
-
-  flex2533 = callPackage ../development/tools/parsing/flex/flex-2.5.33.nix { };
-
-  # Note: 2.5.4a is much older than 2.5.35 but happens first when sorting
-  # alphabetically, hence the low priority.
-  flex254a = lowPrio (import ../development/tools/parsing/flex/flex-2.5.4a.nix {
-    inherit fetchurl stdenv yacc;
-  });
+  flex = callPackage ../development/tools/parsing/flex {
+    # Break infinite recursion: bison's test suite needs flex, so we
+    # use an untested bison build to build flex first.
+    yacc = bison.override { flex = null; };
+  };
 
   m4 = gnum4;
 
@@ -3758,9 +3790,9 @@ let
   tcptrack = callPackage ../development/tools/misc/tcptrack { };
 
   texinfo413 = callPackage ../development/tools/misc/texinfo/4.13a.nix { };
-  texinfo49 = callPackage ../development/tools/misc/texinfo/4.9.nix { };
-  texinfo5 = callPackage ../development/tools/misc/texinfo/5.1.nix { };
-  texinfo = texinfo413;
+  texinfo5 = callPackage ../development/tools/misc/texinfo/5.2.nix { };
+  texinfo4 = texinfo413;
+  texinfo = texinfo5;
 
   texi2html = callPackage ../development/tools/misc/texi2html { };
 
@@ -4260,15 +4292,17 @@ let
   gmm = callPackage ../development/libraries/gmm { };
 
   gmp = gmp5;
+  gmp5 = gmp51;
 
   gmpxx = appendToName "with-cxx" (gmp.override { cxx = true; });
 
   # The GHC bootstrap binaries link against libgmp.so.3, which is in GMP 4.x.
   gmp4 = callPackage ../development/libraries/gmp/4.3.2.nix { };
 
-  gmp5 = callPackage ../development/libraries/gmp/5.0.5.nix { };
+  gmp51 = callPackage ../development/libraries/gmp/5.1.x.nix { };
 
-  gmp51 = callPackage ../development/libraries/gmp/5.1.1.nix { };
+  #GMP ex-satellite, so better keep it near gmp
+  mpfr = callPackage ../development/libraries/mpfr/default.nix { };
 
   gobjectIntrospection = callPackage ../development/libraries/gobject-introspection { };
 
@@ -4289,10 +4323,6 @@ let
 
   gperftools = callPackage ../development/libraries/gperftools { };
 
-  #GMP ex-satellite, so better keep it near gmp
-  mpfr = callPackage ../development/libraries/mpfr { };
-  mpfr_3_1_2 = callPackage ../development/libraries/mpfr/3.1.2.nix { };
-
   gst_all = {
     inherit (pkgs) gstreamer gnonlin gst_python qt_gstreamer;
     gstPluginsBase = pkgs.gst_plugins_base;
@@ -4302,7 +4332,9 @@ let
     gstFfmpeg = pkgs.gst_ffmpeg;
   };
 
-  gstreamer = callPackage ../development/libraries/gstreamer/gstreamer {};
+  gstreamer = callPackage ../development/libraries/gstreamer/gstreamer {
+    bison = bison2;
+  };
 
   gst_plugins_base = callPackage ../development/libraries/gstreamer/gst-plugins-base {};
 
@@ -4452,7 +4484,7 @@ let
 
   heimdal = callPackage ../development/libraries/kerberos/heimdal.nix { };
 
-  harfbuzz = callPackage ../development/libraries/harfbuzz { 
+  harfbuzz = callPackage ../development/libraries/harfbuzz {
     icu = null;
     graphite2 = null;
   };
@@ -5206,7 +5238,9 @@ let
 
   mtdev = callPackage ../development/libraries/mtdev { };
 
-  mu = callPackage ../tools/networking/mu { };
+  mu = callPackage ../tools/networking/mu {
+    texinfo = texinfo4;
+  };
 
   muparser = callPackage ../development/libraries/muparser { };
 
@@ -5555,6 +5589,7 @@ let
 
   slibGuile = callPackage ../development/libraries/slib {
     scheme = guile_1_8;
+    texinfo = texinfo4; # otherwise erros: must be after `@defun' to use `@defunx'
   };
 
   smpeg = callPackage ../development/libraries/smpeg { };
@@ -6785,7 +6820,7 @@ let
 
   # The current default kernel / kernel modules.
   linux = linuxPackages.kernel;
-  linuxPackages = linuxPackages_3_4;
+  linuxPackages = linuxPackages_3_4; # should be latest longterm, see #501
 
   # A function to build a manually-configured kernel
   linuxManualConfig = import ../os-specific/linux/kernel/manual-config.nix {
@@ -9998,7 +10033,8 @@ let
     inherit fetchurl stdenv;
     inherit cups ghostscript glibc patchelf;
     gcc = import ../development/compilers/gcc/4.4 {
-      inherit stdenv fetchurl texinfo gmp mpfr noSysDirs gettext which;
+      inherit stdenv fetchurl gmp mpfr noSysDirs gettext which;
+      texinfo = texinfo4;
       profiledCompiler = true;
     };
   };
@@ -10121,7 +10157,9 @@ let
   VisualBoyAdvance = callPackage ../misc/emulators/VisualBoyAdvance { };
 
   # Wine cannot be built in 64-bit; use a 32-bit build instead.
-  wine = callPackage_i686 ../misc/emulators/wine { };
+  wine = callPackage_i686 ../misc/emulators/wine {
+    bison = bison2;
+  };
 
   # winetricks is a shell script with no binary components. Safe to just use the current platforms
   # build instead of the i686 specific build.
@@ -10171,9 +10209,7 @@ let
 
   znc = callPackage ../applications/networking/znc { };
 
-  zsnes = callPackage_i686 ../misc/emulators/zsnes {
-    libpng = libpng12;
-  };
+  zsnes = callPackage_i686 ../misc/emulators/zsnes { };
 
   misc = import ../misc/misc.nix { inherit pkgs stdenv; };
 
diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix
index f46a9bca7743..9a7c933fc4dc 100644
--- a/pkgs/top-level/haskell-packages.nix
+++ b/pkgs/top-level/haskell-packages.nix
@@ -91,16 +91,6 @@ let result = let callPackage = x : y : modifyPrio (newScope result.finalReturn x
     ghc = ghc; # refers to ghcPlain
   };
 
-  # The normal GHC wrapper doesn't create links to the documentation in
-  # ~/.nix-profile. Having this second wrapper allows us to remedy the
-  # situation without re-building all Haskell packages. At the next
-  # stdenv-updates merge, this second wrapper will go away.
-
-  ghcUserEnvWrapper = pkgs.appendToName "new" (callPackage ../development/compilers/ghc/wrapper.nix {
-    ghc = ghc; # refers to ghcPlain
-    forUserEnv = true;
-  });
-
   # An experimental wrapper around ghcPlain that does not automatically
   # pick up packages from the profile, but instead has a fixed set of packages
   # in its global database. The set of packages can be specified as an
@@ -117,6 +107,7 @@ let result = let callPackage = x : y : modifyPrio (newScope result.finalReturn x
   cabal = callPackage ../build-support/cabal {
     enableLibraryProfiling = enableLibraryProfiling;
     enableCheckPhase = pkgs.stdenv.lib.versionOlder "7.4" self.ghc.ghcVersion;
+    glibcLocales = if pkgs.stdenv.isLinux then pkgs.glibcLocales else null;
   };
 
   # A variant of the cabal build driver that disables unit testing.
diff --git a/pkgs/top-level/release-small.nix b/pkgs/top-level/release-small.nix
index ef7bc038c62f..488feb6f3b17 100644
--- a/pkgs/top-level/release-small.nix
+++ b/pkgs/top-level/release-small.nix
@@ -1,19 +1,18 @@
 /* A small release file, with few packages to be built.  The aim is to reduce
-   the load on Hydra when testing the `stdenv-updates' branch.
+   the load on Hydra when testing the `stdenv-updates' branch. */
 
+{ nixpkgs ? { outPath = (import ./all-packages.nix {}).lib.cleanSource ../..; revCount = 1234; shortRev = "abcdef"; }
+, supportedSystems ? [ "x86_64-linux" "i686-linux" "x86_64-darwin" "x86_64-freebsd" "i686-freebsd" ]
+}:
 
-   This file will be evaluated by hydra with a call like this:
-   hydra_eval_jobs --gc-roots-dir \
-     /nix/var/nix/gcroots/per-user/hydra/hydra-roots --argstr \
-     system i686-linux --argstr system x86_64-linux --arg \
-     nixpkgs "{outPath = ./}" .... release.nix
-
-   Hydra can be installed with "nix-env -i hydra".  */
-with (import ./release-lib.nix);
+with import ./release-lib.nix { inherit supportedSystems; };
 
 {
 
-  tarball = import ./make-tarball.nix;
+  tarball = import ./make-tarball.nix {
+    inherit nixpkgs;
+    officialRelease = false;
+  };
 
 } // (mapTestOn (rec {
 
@@ -47,7 +46,6 @@ with (import ./release-lib.nix);
   file = all;
   findutils = all;
   flex = all;
-  flex2535 = all;
   gcc = all;
   gcc33 = linux;
   gcc34 = linux;
@@ -198,7 +196,7 @@ with (import ./release-lib.nix);
   zile = linux;
   zip = all;
 
-  dbus_all = {
+  dbus = {
     libs = linux;
     daemon = linux;
     tools = linux;
diff --git a/pkgs/top-level/release.nix b/pkgs/top-level/release.nix
index 87b63e33891f..4d205f6882a5 100644
--- a/pkgs/top-level/release.nix
+++ b/pkgs/top-level/release.nix
@@ -106,7 +106,6 @@ let
       file = all;
       findutils = all;
       flex = all;
-      flex2535 = all;
       fontforge = linux;
       fuse = linux;
       gajim = linux;