summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/compilers/gcc/4.6/builder.sh25
-rw-r--r--pkgs/development/compilers/gcc/4.6/default.nix10
-rw-r--r--pkgs/development/compilers/gcc/4.8/builder.sh34
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix10
-rw-r--r--pkgs/development/compilers/gcc/4.9/default.nix2
-rw-r--r--pkgs/development/interpreters/perl/5.16/default.nix20
-rw-r--r--pkgs/development/libraries/acl/default.nix2
-rw-r--r--pkgs/development/libraries/apr-util/default.nix4
-rw-r--r--pkgs/development/libraries/apr/default.nix14
-rw-r--r--pkgs/development/libraries/atk/default.nix6
-rw-r--r--pkgs/development/libraries/attr/default.nix2
-rw-r--r--pkgs/development/libraries/boehm-gc/default.nix8
-rw-r--r--pkgs/development/libraries/cairo/default.nix9
-rw-r--r--pkgs/development/libraries/freetype/default.nix8
-rw-r--r--pkgs/development/libraries/gdk-pixbuf/default.nix10
-rw-r--r--pkgs/development/libraries/gettext/default.nix2
-rw-r--r--pkgs/development/libraries/glib/default.nix6
-rw-r--r--pkgs/development/libraries/glib/setup-hook.sh17
-rw-r--r--pkgs/development/libraries/glibc/builder.sh17
-rw-r--r--pkgs/development/libraries/glibc/common.nix5
-rw-r--r--pkgs/development/libraries/glibc/default.nix2
-rw-r--r--pkgs/development/libraries/glibc/locales.nix2
-rw-r--r--pkgs/development/libraries/gmime/default.nix4
-rw-r--r--pkgs/development/libraries/gmp/5.1.x.nix2
-rw-r--r--pkgs/development/libraries/gobject-introspection/default.nix4
-rw-r--r--pkgs/development/libraries/gtk+/2.x.nix4
-rw-r--r--pkgs/development/libraries/jasper/default.nix10
-rw-r--r--pkgs/development/libraries/libav/default.nix8
-rw-r--r--pkgs/development/libraries/libdrm/default.nix2
-rw-r--r--pkgs/development/libraries/libelf/default.nix16
-rw-r--r--pkgs/development/libraries/libffi/default.nix12
-rw-r--r--pkgs/development/libraries/libjpeg-turbo/default.nix8
-rw-r--r--pkgs/development/libraries/libjpeg/default.nix2
-rw-r--r--pkgs/development/libraries/libogg/default.nix2
-rw-r--r--pkgs/development/libraries/libpng/default.nix7
-rw-r--r--pkgs/development/libraries/libsamplerate/default.nix6
-rw-r--r--pkgs/development/libraries/libsndfile/default.nix4
-rw-r--r--pkgs/development/libraries/libtiff/default.nix2
-rw-r--r--pkgs/development/libraries/libvorbis/default.nix2
-rw-r--r--pkgs/development/libraries/mesa/default.nix2
-rw-r--r--pkgs/development/libraries/mpfr/default.nix2
-rw-r--r--pkgs/development/libraries/openssl/default.nix28
-rw-r--r--pkgs/development/libraries/pango/default.nix7
-rw-r--r--pkgs/development/libraries/pcre/default.nix8
-rw-r--r--pkgs/development/libraries/speex/default.nix11
-rw-r--r--pkgs/development/libraries/zlib/default.nix10
-rw-r--r--pkgs/development/perl-modules/generic/builder.sh7
-rw-r--r--pkgs/development/perl-modules/generic/default.nix10
-rw-r--r--pkgs/development/tools/build-managers/cmake/default.nix4
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix4
-rw-r--r--pkgs/development/tools/misc/libtool/libtool2.nix3
-rw-r--r--pkgs/development/tools/misc/patchelf/default.nix2
-rw-r--r--pkgs/development/tools/misc/pkgconfig/default.nix31
-rw-r--r--pkgs/development/tools/misc/texinfo/5.2.nix4
-rw-r--r--pkgs/development/web/nodejs/default.nix4
55 files changed, 329 insertions, 118 deletions
diff --git a/pkgs/development/compilers/gcc/4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh
index af2e97b1e4e..af36ec33b70 100644
--- a/pkgs/development/compilers/gcc/4.6/builder.sh
+++ b/pkgs/development/compilers/gcc/4.6/builder.sh
@@ -8,9 +8,10 @@ mkdir $NIX_FIXINC_DUMMY
 if test "$staticCompiler" = "1"; then
     EXTRA_LDFLAGS="-static"
 else
-    EXTRA_LDFLAGS=""
+    EXTRA_LDFLAGS="-Wl,-rpath,$lib/lib"
 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
@@ -29,7 +30,7 @@ if test "$noSysDirs" = "1"; then
         # 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_CC/nix-support/orig-libc)/include
+        export NIX_FIXINC_DUMMY=$libc_dev/include
 
         # The path to the Glibc binaries such as `crti.o'.
         glibc_libdir="$(cat $NIX_CC/nix-support/orig-libc)/lib"
@@ -50,10 +51,10 @@ if test "$noSysDirs" = "1"; then
     # bootstrap compiler are optimized and (optionally) contain
     # debugging information (info "(gccinstall) Building").
     if test -n "$dontStrip"; then
-	extraFlags="-O2 -g $extraFlags"
+        extraFlags="-O2 -g $extraFlags"
     else
-	# Don't pass `-g' at all; this saves space while building.
-	extraFlags="-O2 $extraFlags"
+        # Don't pass `-g' at all; this saves space while building.
+        extraFlags="-O2 $extraFlags"
     fi
 
     EXTRA_FLAGS="$extraFlags"
@@ -170,9 +171,8 @@ preConfigure() {
         # 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_CC/nix-support/orig-libc)/include"
         sed -i \
-            -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$glibc_headers", \
+            -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$libc_dev/include", \
             gcc/configure
     fi
 
@@ -206,6 +206,14 @@ preInstall() {
 
 
 postInstall() {
+    # Move runtime libraries to $lib.
+    mkdir -p $lib/lib
+    ln -s lib $lib/lib64
+    mv -v $out/lib/lib*.so $out/lib/lib*.so.*[0-9] $out/lib/*.la $lib/lib/
+    for i in $lib/lib/*.la; do
+        substituteInPlace $i --replace $out $lib
+    done
+
     # Remove precompiled headers for now.  They are very big and
     # probably not very useful yet.
     find $out/include -name "*.gch" -exec rm -rf {} \; -prune
@@ -217,6 +225,7 @@ postInstall() {
 
     # 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
@@ -225,7 +234,7 @@ postInstall() {
     done
 
     # Get rid of some "fixed" header files
-    rm -rf $out/lib/gcc/*/*/include/root
+    rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux}
 
     # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
     for i in $out/bin/*-gcc*; do
diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix
index 0f65a89bd20..4976131bb64 100644
--- a/pkgs/development/compilers/gcc/4.6/default.nix
+++ b/pkgs/development/compilers/gcc/4.6/default.nix
@@ -170,7 +170,7 @@ let version = "4.6.4";
       "-stage-final";
     crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
 
-  bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
+    bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
 
 in
 
@@ -182,13 +182,19 @@ stdenv.mkDerivation ({
 
   builder = ./builder.sh;
 
-  src = (import ./sources.nix) {
+  srcs = (import ./sources.nix) {
     inherit fetchurl optional version;
     inherit langC langCC langFortran langJava langAda langGo;
   };
 
+  outputs = [ "out" "lib" ];
+
+  setOutputFlags = false;
+
   inherit patches enableMultilib;
 
+  libc_dev = stdenv.cc.libc_dev;
+
   postPatch =
     if (stdenv.isGNU
         || (libcCross != null                  # e.g., building `gcc.crossDrv'
diff --git a/pkgs/development/compilers/gcc/4.8/builder.sh b/pkgs/development/compilers/gcc/4.8/builder.sh
index dd77c67a023..8cf04ce1c35 100644
--- a/pkgs/development/compilers/gcc/4.8/builder.sh
+++ b/pkgs/development/compilers/gcc/4.8/builder.sh
@@ -8,9 +8,10 @@ mkdir $NIX_FIXINC_DUMMY
 if test "$staticCompiler" = "1"; then
     EXTRA_LDFLAGS="-static"
 else
-    EXTRA_LDFLAGS=""
+    EXTRA_LDFLAGS="-Wl,-rpath,$lib/lib"
 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
@@ -29,7 +30,7 @@ if test "$noSysDirs" = "1"; then
         # 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_CC/nix-support/orig-libc)/include
+        export NIX_FIXINC_DUMMY=$libc_dev/include
 
         # The path to the Glibc binaries such as `crti.o'.
         glibc_libdir="$(cat $NIX_CC/nix-support/orig-libc)/lib"
@@ -171,9 +172,8 @@ preConfigure() {
         # 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_CC/nix-support/orig-libc)/include"
         sed -i \
-            -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$glibc_headers", \
+            -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$libc_dev/include", \
             gcc/configure
     fi
 
@@ -210,6 +210,14 @@ preInstall() {
 
 
 postInstall() {
+    # Move runtime libraries to $lib.
+    mkdir -p $lib/lib
+    ln -s lib $lib/lib64
+    mv -v $out/lib/lib*.so $out/lib/lib*.so.*[0-9] $out/lib/*.la $lib/lib/
+    for i in $lib/lib/*.la; do
+        substituteInPlace $i --replace $out $lib
+    done
+
     # Remove precompiled headers for now.  They are very big and
     # probably not very useful yet.
     find $out/include -name "*.gch" -exec rm -rf {} \; -prune
@@ -221,15 +229,23 @@ postInstall() {
 
     # 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
+    for i in "$out"/libexec/gcc/*/*/*; do
+        PREV_RPATH=`patchelf --print-rpath "$i"`
+        NEW_RPATH=`echo "$PREV_RPATH" | sed 's,:[^:]*bootstrap-tools/lib,,g'`
+        patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK
+    done
+
+    # For some reason the libs retain RPATH to $out
+    for i in "$lib"/lib/{libtsan.so.0.0.0,libasan.so.0.0.0}; do
+        PREV_RPATH=`patchelf --print-rpath "$i"`
+        NEW_RPATH=`echo "$PREV_RPATH" | sed "s,:${out}[^:]*,,g"`
+        patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK
     done
 
     # Get rid of some "fixed" header files
-    rm -rf $out/lib/gcc/*/*/include/root
+    rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux}
 
     # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
     for i in $out/bin/*-gcc*; do
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index 0958ce7b1c9..d94a0797e38 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -197,7 +197,7 @@ let version = "4.8.4";
     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;
+    bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips;
 
 in
 
@@ -216,6 +216,12 @@ stdenv.mkDerivation ({
 
   inherit patches;
 
+  outputs = [ "out" "lib" "doc" ];
+  setOutputFlags = false;
+  NIX_NO_SELF_RPATH = true;
+
+  libc_dev = stdenv.cc.libc_dev;
+
   postPatch =
     if (stdenv.isGNU
         || (libcCross != null                  # e.g., building `gcc.crossDrv'
@@ -357,7 +363,7 @@ stdenv.mkDerivation ({
       )
     }
     ${if (stdenv ? glibc && cross == null)
-      then " --with-native-system-header-dir=${stdenv.glibc}/include"
+      then " --with-native-system-header-dir=${stdenv.glibc.dev}/include"
       else ""}
     ${if langAda then " --enable-libada" else ""}
     ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index 7de8a140c0a..315c92664b3 100644
--- a/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -343,7 +343,7 @@ stdenv.mkDerivation ({
       )
     }
     ${if (stdenv ? glibc && cross == null)
-      then " --with-native-system-header-dir=${stdenv.glibc}/include"
+      then " --with-native-system-header-dir=${stdenv.glibc.dev}/include"
       else ""}
     ${if langAda then " --enable-libada" else ""}
     ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""}
diff --git a/pkgs/development/interpreters/perl/5.16/default.nix b/pkgs/development/interpreters/perl/5.16/default.nix
index 9ed3aa54f51..b3bc6aafde9 100644
--- a/pkgs/development/interpreters/perl/5.16/default.nix
+++ b/pkgs/development/interpreters/perl/5.16/default.nix
@@ -14,6 +14,13 @@ stdenv.mkDerivation rec {
     sha256 = "1dpd9lhc4723wmsn4dsn4m320qlqgyw28bvcbhnfqp2nl3f0ikv9";
   };
 
+  # TODO: Add a "dev" output containing the header files.
+  outputs = [ "out" "man" ];
+
+  setOutputFlags = false;
+
+  setOutputConfigureFlags = false;
+
   patches =
     [ # Do not look in /usr etc. for dependencies.
       ./no-sys-dirs.patch
@@ -47,7 +54,7 @@ stdenv.mkDerivation rec {
 
   preConfigure =
     ''
-      configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3"
+      configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$man/share/man/man1 -Dman3dir=$man/share/man/man3"
 
       ${lib.optionalString stdenv.isArm ''
         configureFlagsArray=(-Dldflags="-lm -lrt")
@@ -66,6 +73,17 @@ stdenv.mkDerivation rec {
       substituteInPlace dist/Cwd/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'"
     '';
 
+  postInstall =
+    ''
+      # Remove dependency between "out" and "man" outputs.
+      rm $out/lib/perl5/*/*/.packlist
+
+      # Remove dependencies on glibc.dev and coreutils.
+      substituteInPlace $out/lib/perl5/*/*/Config_heavy.pl \
+        --replace ${stdenv.glibc.dev or "/blabla"} /no-such-path \
+        --replace $man /no-such-path
+    ''; # */
+
   setupHook = ./setup-hook.sh;
 
   passthru.libPrefix = "lib/perl5/site_perl";
diff --git a/pkgs/development/libraries/acl/default.nix b/pkgs/development/libraries/acl/default.nix
index d37d8926fbd..4055708907b 100644
--- a/pkgs/development/libraries/acl/default.nix
+++ b/pkgs/development/libraries/acl/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "08qd9s3wfhv0ajswsylnfwr5h0d7j9d4rgip855nrh400nxp940p";
   };
 
+  outputs = [ "dev" "out" "bin" "doc" ];
+
   nativeBuildInputs = [ gettext ];
   buildInputs = [ attr ];
 
diff --git a/pkgs/development/libraries/apr-util/default.nix b/pkgs/development/libraries/apr-util/default.nix
index 0f21af94c64..e504aab0848 100644
--- a/pkgs/development/libraries/apr-util/default.nix
+++ b/pkgs/development/libraries/apr-util/default.nix
@@ -24,11 +24,13 @@ stdenv.mkDerivation rec {
   configureFlags = ''
     --with-apr=${apr} --with-expat=${expat}
     --with-crypto
-    ${stdenv.lib.optionalString sslSupport "--with-openssl=${openssl}"}
+    ${stdenv.lib.optionalString sslSupport "--with-openssl"}
     ${stdenv.lib.optionalString bdbSupport "--with-berkeley-db=${db}"}
     ${stdenv.lib.optionalString ldapSupport "--with-ldap"}
   '';
 
+  buildInputs = stdenv.lib.optional sslSupport openssl;
+
   propagatedBuildInputs = [ makeWrapper apr expat libiconv ]
     ++ optional sslSupport openssl
     ++ optional bdbSupport db
diff --git a/pkgs/development/libraries/apr/default.nix b/pkgs/development/libraries/apr/default.nix
index 3810a47fac3..2bf39f0eb26 100644
--- a/pkgs/development/libraries/apr/default.nix
+++ b/pkgs/development/libraries/apr/default.nix
@@ -10,6 +10,13 @@ stdenv.mkDerivation rec {
 
   patches = stdenv.lib.optionals stdenv.isDarwin [ ./is-this-a-compiler-bug.patch ];
 
+  outputs = [ "dev" "out" ];
+
+  preConfigure =
+    ''
+      configureFlagsArray+=("--with-installbuilddir=$dev/share/build")
+    '';
+
   configureFlags =
     # Including the Windows headers breaks unistd.h.
     # Based on ftp://sourceware.org/pub/cygwin/release/libapr1/libapr1-1.3.8-2-src.tar.bz2
@@ -17,6 +24,13 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
+  postInstall =
+    ''
+      mkdir $dev/bin $dev/lib
+      mv $out/bin/apr-1-config $dev/bin
+      mv $out/lib/pkgconfig $dev/lib
+    '';
+
   meta = {
     homepage = http://apr.apache.org/;
     description = "The Apache Portable Runtime library";
diff --git a/pkgs/development/libraries/atk/default.nix b/pkgs/development/libraries/atk/default.nix
index ce7f92a2035..d6b080050be 100644
--- a/pkgs/development/libraries/atk/default.nix
+++ b/pkgs/development/libraries/atk/default.nix
@@ -12,6 +12,10 @@ stdenv.mkDerivation rec {
     sha256 = "13zijfcmx7sda83qkryzsmr9hw0r3b73xkagq9cmm733fhcl7a28";
   };
 
+  enableParallelBuilding = true;
+
+  outputs = [ "dev" "out" "doc" ];
+
   buildInputs = libintlOrEmpty;
 
   nativeBuildInputs = [ pkgconfig perl ];
@@ -20,8 +24,6 @@ stdenv.mkDerivation rec {
 
   #doCheck = true; # no checks in there (2.10.0)
 
-  postInstall = "rm -rf $out/share/gtk-doc";
-
   meta = {
     description = "Accessibility toolkit";
 
diff --git a/pkgs/development/libraries/attr/default.nix b/pkgs/development/libraries/attr/default.nix
index 8d87e2ee50d..e4e9142b632 100644
--- a/pkgs/development/libraries/attr/default.nix
+++ b/pkgs/development/libraries/attr/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "0nd8y0m6awc9ahv0ciiwf8gy54c8d3j51pw9xg7f7cn579jjyxr5";
   };
 
+  outputs = [ "dev" "out" "bin" "doc" ];
+
   nativeBuildInputs = [ gettext ];
 
   configureFlags = "MAKE=make MSGFMT=msgfmt MSGMERGE=msgmerge XGETTEXT=xgettext ECHO=echo SED=sed AWK=gawk";
diff --git a/pkgs/development/libraries/boehm-gc/default.nix b/pkgs/development/libraries/boehm-gc/default.nix
index d71440a61d8..08937019547 100644
--- a/pkgs/development/libraries/boehm-gc/default.nix
+++ b/pkgs/development/libraries/boehm-gc/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "119x7p1cqw40mpwj80xfq879l9m1dkc7vbc1f3bz3kvkf8bf6p16";
   };
 
+  outputs = [ "dev" "out" "doc" ];
+
   configureFlags =
     [ "--enable-cplusplus" ]
     ++ lib.optional enableLargeConfig "--enable-large-config";
@@ -17,6 +19,12 @@ stdenv.mkDerivation rec {
   # Don't run the native `strip' when cross-compiling.
   dontStrip = stdenv ? cross;
 
+  postInstall =
+    ''
+      mkdir -p $out/share/doc
+      mv $out/share/gc $out/share/doc/gc
+    '';
+
   meta = {
     description = "The Boehm-Demers-Weiser conservative garbage collector for C and C++";
 
diff --git a/pkgs/development/libraries/cairo/default.nix b/pkgs/development/libraries/cairo/default.nix
index 89c791fae02..0d0d5a55ae8 100644
--- a/pkgs/development/libraries/cairo/default.nix
+++ b/pkgs/development/libraries/cairo/default.nix
@@ -18,6 +18,8 @@ stdenv.mkDerivation rec {
     sha1 = "c8da68aa66ca0855b5d0ff552766d3e8679e1d24";
   };
 
+  outputs = [ "dev" "out" "bin" "doc" ];
+
   nativeBuildInputs = [ pkgconfig libiconv ] ++ libintlOrEmpty;
 
   propagatedBuildInputs =
@@ -53,12 +55,7 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
-  # The default `--disable-gtk-doc' is ignored.
-  postInstall = "rm -rf $out/share/gtk-doc"
-    + stdenv.lib.optionalString stdenv.isDarwin (''
-      #newline
-    '' + glib.flattenInclude
-    );
+  postInstall = stdenv.lib.optionalString stdenv.isDarwin glib.flattenInclude;
 
   meta = {
     description = "A 2D graphics library with support for multiple output devices";
diff --git a/pkgs/development/libraries/freetype/default.nix b/pkgs/development/libraries/freetype/default.nix
index e9e393075b3..dccde33efcf 100644
--- a/pkgs/development/libraries/freetype/default.nix
+++ b/pkgs/development/libraries/freetype/default.nix
@@ -31,12 +31,16 @@ stdenv.mkDerivation rec {
       (fetch_bohoomil "04-infinality-2.5.4-2014.12.07.patch" "1gph7z9s2221gy5dxn01v3lga0m9yib8yqsaqj5km74bqx1vlalh")
     ];
 
+  outputs = [ "dev" "out" ];
+
   propagatedBuildInputs = [ zlib bzip2 libpng ]; # needed when linking against freetype
   # dependence on harfbuzz is looser than the reverse dependence
   buildInputs = [ pkgconfig which ]
     # FreeType requires GNU Make, which is not part of stdenv on FreeBSD.
     ++ optional (!stdenv.isLinux) gnumake;
 
+  configureFlags = "--disable-static --bindir=$(dev)/bin";
+
   # from Gentoo, see https://bugzilla.redhat.com/show_bug.cgi?id=506840
   NIX_CFLAGS_COMPILE = "-fno-strict-aliasing";
   # The asm for armel is written with the 'asm' keyword.
@@ -47,8 +51,8 @@ stdenv.mkDerivation rec {
   doCheck = true;
 
   # compat hacks
-  postInstall = glib.flattenInclude + ''
-    ln -s . "$out"/include/freetype
+  postFixup = glib.flattenInclude + ''
+    ln -s . "$dev"/include/freetype
   '';
 
   crossAttrs = {
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index da6a3ad1dff..69d39855699 100644
--- a/pkgs/development/libraries/gdk-pixbuf/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/default.nix
@@ -13,8 +13,12 @@ stdenv.mkDerivation rec {
     sha256 = "ddd861747bb7c580acce7cfa3ce38c3f52a9516e66a6477988fd100c8fb9eabc";
   };
 
+  outputs = [ "dev" "out" "bin" "doc" ];
+
   setupHook = ./setup-hook.sh;
 
+  enableParallelBuilding = true;
+
   # !!! We might want to factor out the gdk-pixbuf-xlib subpackage.
   buildInputs = [ libX11 libintlOrEmpty ];
 
@@ -28,7 +32,11 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
 
-  postInstall = "rm -rf $out/share/gtk-doc";
+  # propagate the bin output
+  postPhases = "postPostFixup";
+  postPostFixup = ''
+    echo -n " $bin" >> "$dev"/nix-support/propagated-*build-inputs
+  '';
 
   meta = {
     description = "A library for image loading and manipulation";
diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix
index 8f6277ca2e9..b48ea97abba 100644
--- a/pkgs/development/libraries/gettext/default.nix
+++ b/pkgs/development/libraries/gettext/default.nix
@@ -30,7 +30,7 @@ stdenv.mkDerivation (rec {
     fi
   '';
 
-  buildInputs = [ xz ] ++ stdenv.lib.optional (!stdenv.isLinux) libiconv;
+  buildInputs = [ xz xz.bin ] ++ stdenv.lib.optional (!stdenv.isLinux) libiconv;
 
   enableParallelBuilding = true;
 
diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix
index 91832ac650e..939f3969665 100644
--- a/pkgs/development/libraries/glib/default.nix
+++ b/pkgs/development/libraries/glib/default.nix
@@ -53,9 +53,11 @@ stdenv.mkDerivation rec {
 
   patches = optional stdenv.isDarwin ./darwin-compilation.patch ++ optional doCheck ./skip-timer-test.patch;
 
+  #outputs = [ "dev" "out" "bin" ]; # ToDo: no idea what's wrong! docs? 
+
   setupHook = ./setup-hook.sh;
 
-  buildInputs = [ libelf ]
+  buildInputs = [ /*stdenv.hookLib.multiout*/ libelf ]
     ++ optionals doCheck [ tzdata libxml2 desktop_file_utils shared_mime_info ];
 
   nativeBuildInputs = [ pkgconfig gettext perl python ];
@@ -97,8 +99,6 @@ stdenv.mkDerivation rec {
        sed -e '/g_subprocess_launcher_set_environ (launcher, envp);/a g_subprocess_launcher_setenv (launcher, "PATH", g_getenv("PATH"), TRUE);' -i gio/tests/gsubprocess.c
     '';
 
-  postInstall = ''rm -rvf $out/share/gtk-doc'';
-
   passthru = {
      gioModuleDir = "lib/gio/modules";
      inherit flattenInclude;
diff --git a/pkgs/development/libraries/glib/setup-hook.sh b/pkgs/development/libraries/glib/setup-hook.sh
index f173744e5ca..91411e68dd2 100644
--- a/pkgs/development/libraries/glib/setup-hook.sh
+++ b/pkgs/development/libraries/glib/setup-hook.sh
@@ -14,4 +14,19 @@ glibPreFixupPhase() {
     addToSearchPath GSETTINGS_SCHEMAS_PATH "$out/share/gsettings-schemas/$name"
 }
 
-preFixupPhases="$preFixupPhases glibPreFixupPhase"
+preFixupPhases+=(glibPreFixupPhase)
+
+
+preFixupHooks+=(_multioutGtkDocs)
+
+# Move documentation to the desired outputs.
+_multioutGtkDocs() {
+    if [ "$outputs" = "out" ]; then return; fi;
+    _moveToOutput share/gtk-doc "${!outputDoc}"
+
+    # Remove empty share directory.
+    if [ -d "$out/share" ]; then
+        rmdir "$out/share" 2> /dev/null || true
+    fi
+}
+
diff --git a/pkgs/development/libraries/glibc/builder.sh b/pkgs/development/libraries/glibc/builder.sh
index 2836063e3bf..46f47d9b99c 100644
--- a/pkgs/development/libraries/glibc/builder.sh
+++ b/pkgs/development/libraries/glibc/builder.sh
@@ -12,8 +12,10 @@ postConfigure() {
 
     export NIX_DONT_SET_RPATH=1
     unset CFLAGS
-}
 
+    # Apparently --bindir is not respected.
+    makeFlagsArray+=("bindir=$bin/bin" "sbindir=$bin/sbin" "rootsbindir=$bin/sbin")
+}
 
 postInstall() {
     if test -n "$installLocales"; then
@@ -27,7 +29,7 @@ postInstall() {
     if test -z "$hurdHeaders"; then
         # Include the Linux kernel headers in Glibc, except the `scsi'
         # subdirectory, which Glibc provides itself.
-        (cd $out/include && \
+        (cd $dev/include && \
          ln -sv $(ls -d $kernelHeaders/include/* | grep -v 'scsi$') .)
     fi
 
@@ -48,6 +50,17 @@ postInstall() {
 
     # Get rid of more unnecessary stuff.
     rm -rf $out/var $out/sbin/sln
+
+    # Put libraries for static linking in a separate output.  Note
+    # that libc_nonshared.a and libpthread_nonshared.a are required
+    # for dynamically-linked applications.
+    mkdir -p $static/lib
+    mv $out/lib/*.a $static/lib
+    mv $static/lib/lib*_nonshared.a $out/lib
+
+    # Work around a Nix bug: hard links across outputs cause a build failure.
+    cp $bin/bin/getconf $bin/bin/getconf_
+    mv $bin/bin/getconf_ $bin/bin/getconf
 }
 
 genericBuild
diff --git a/pkgs/development/libraries/glibc/common.nix b/pkgs/development/libraries/glibc/common.nix
index 9a451d48cbc..4bff795ba5f 100644
--- a/pkgs/development/libraries/glibc/common.nix
+++ b/pkgs/development/libraries/glibc/common.nix
@@ -119,7 +119,10 @@ stdenv.mkDerivation ({
 
   installFlags = [ "sysconfdir=$(out)/etc" ];
 
-  buildInputs = stdenv.lib.optionals (cross != null) [ gccCross ]
+  outputs = [ "out" "dev" "bin" "static" ];
+
+  buildInputs = [ ]
+    ++ stdenv.lib.optionals (cross != null) [ gccCross ]
     ++ stdenv.lib.optional (mig != null) mig
     ++ stdenv.lib.optionals withGd [ gd libpng ];
 
diff --git a/pkgs/development/libraries/glibc/default.nix b/pkgs/development/libraries/glibc/default.nix
index f60df4a30d6..8322ccefff3 100644
--- a/pkgs/development/libraries/glibc/default.nix
+++ b/pkgs/development/libraries/glibc/default.nix
@@ -96,7 +96,7 @@ in
 
       # To avoid a dependency on the build system 'bash'.
       preFixup = ''
-        rm $out/bin/{ldd,tzselect,catchsegv,xtrace}
+        rm $bin/bin/{ldd,tzselect,catchsegv,xtrace}
       '';
     }
    else {}))
diff --git a/pkgs/development/libraries/glibc/locales.nix b/pkgs/development/libraries/glibc/locales.nix
index 5d6e678bfe6..ad522f78668 100644
--- a/pkgs/development/libraries/glibc/locales.nix
+++ b/pkgs/development/libraries/glibc/locales.nix
@@ -25,7 +25,7 @@ build null {
   # $TMPDIR/nix/store/...-glibc-.../lib/locale/locale-archive.
   buildPhase =
     ''
-      mkdir -p $TMPDIR/"$(dirname $(readlink -f $(type -p localedef)))/../lib/locale"
+      mkdir -p $TMPDIR/"${stdenv.gcc.libc}/lib/locale"
 
       # Hack to allow building of the locales (needed since glibc-2.12)
       sed -i -e 's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef --prefix='$TMPDIR',' ../glibc-2*/localedata/Makefile
diff --git a/pkgs/development/libraries/gmime/default.nix b/pkgs/development/libraries/gmime/default.nix
index 6564fc51186..93bad0059b7 100644
--- a/pkgs/development/libraries/gmime/default.nix
+++ b/pkgs/development/libraries/gmime/default.nix
@@ -8,9 +8,13 @@ stdenv.mkDerivation rec {
     sha256 = "0rfzbgsh8ira5p76kdghygl5i3fvmmx4wbw5rp7f8ajc4vxp18g0";
   };
 
+  outputs = [ "dev" "out" "doc" ];
+
   nativeBuildInputs = [ pkgconfig ];
   propagatedBuildInputs = [ glib zlib libgpgerror ];
 
+  enableParallelBuilding = true;
+
   meta = {
     homepage = http://spruce.sourceforge.net/gmime/;
     description = "A C/C++ library for manipulating MIME messages";
diff --git a/pkgs/development/libraries/gmp/5.1.x.nix b/pkgs/development/libraries/gmp/5.1.x.nix
index 0df1a4f8cd8..ae8ae7c0f18 100644
--- a/pkgs/development/libraries/gmp/5.1.x.nix
+++ b/pkgs/development/libraries/gmp/5.1.x.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
     sha256 = "0q5i39pxrasgn9qdxzpfbwhh11ph80p57x6hf48m74261d97j83m";
   };
 
+  outputs = [ "out" "info" ];
+
   nativeBuildInputs = [ m4 ];
 
   patches = if stdenv.isDarwin then [ ./need-size-t.patch ] else null;
diff --git a/pkgs/development/libraries/gobject-introspection/default.nix b/pkgs/development/libraries/gobject-introspection/default.nix
index 8263ee7071c..0dcf6e9f0d5 100644
--- a/pkgs/development/libraries/gobject-introspection/default.nix
+++ b/pkgs/development/libraries/gobject-introspection/default.nix
@@ -16,6 +16,8 @@ stdenv.mkDerivation rec {
     sha256 = "162flbzwzz0b8axab2gimc4dglpaw88fh1d177zfg0whczlpbsln";
   };
 
+  outputs = [ "dev" "out" "doc" ];
+
   buildInputs = [ flex bison pkgconfig python ]
     ++ libintlOrEmpty
     ++ stdenv.lib.optional stdenv.isDarwin otool;
@@ -25,8 +27,6 @@ stdenv.mkDerivation rec {
   # other dependencies).
   configureFlags = [ "--disable-tests" ];
 
-  postInstall = "rm -rf $out/share/gtk-doc";
-
   setupHook = ./setup-hook.sh;
 
   patches = [ ./absolute_shlib_path.patch ];
diff --git a/pkgs/development/libraries/gtk+/2.x.nix b/pkgs/development/libraries/gtk+/2.x.nix
index 774193cc06c..16691e8588c 100644
--- a/pkgs/development/libraries/gtk+/2.x.nix
+++ b/pkgs/development/libraries/gtk+/2.x.nix
@@ -15,6 +15,8 @@ stdenv.mkDerivation rec {
     sha256 = "1x14rnjvqslpa1q19fp1qalz5sxds72amsgjk8m7769rwk511jr0";
   };
 
+  outputs = [ "dev" "out" "bin" "doc" ];
+
   enableParallelBuilding = true;
 
   NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (libintlOrEmpty != []) "-lintl";
@@ -35,8 +37,6 @@ stdenv.mkDerivation rec {
     then "--disable-glibtest --disable-introspection --disable-visibility"
     else "--with-xinput=yes";
 
-  postInstall = "rm -rf $out/share/gtk-doc";
-
   passthru = {
     gtkExeEnvPostBuild = ''
       rm $out/lib/gtk-2.0/2.10.0/immodules.cache
diff --git a/pkgs/development/libraries/jasper/default.nix b/pkgs/development/libraries/jasper/default.nix
index 7b86403b0aa..a642c0acb34 100644
--- a/pkgs/development/libraries/jasper/default.nix
+++ b/pkgs/development/libraries/jasper/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, unzip, xlibs, libjpeg }:
+{ stdenv, fetchurl, autoreconfHook, unzip, xlibs, libjpeg }:
 
 stdenv.mkDerivation rec {
   name = "jasper-1.900.1";
@@ -17,11 +17,15 @@ stdenv.mkDerivation rec {
     ./jasper-CVE-2014-9029.diff
   ];
 
-  nativeBuildInputs = [unzip];
+  nativeBuildInputs = [ unzip autoreconfHook ];
   propagatedBuildInputs = [ libjpeg ];
 
   configureFlags = "--enable-shared";
-  
+
+  outputs = [ "dev" "out" "man" "bin" ];
+
+  enableParallelBuilding = true;
+
   meta = {
     homepage = https://www.ece.uvic.ca/~frodo/jasper/;
     description = "JPEG2000 Library";
diff --git a/pkgs/development/libraries/libav/default.nix b/pkgs/development/libraries/libav/default.nix
index 41a8b391eb3..d0a40d7e8d0 100644
--- a/pkgs/development/libraries/libav/default.nix
+++ b/pkgs/development/libraries/libav/default.nix
@@ -10,7 +10,7 @@
 , vaapiSupport  ? false,  libva     ? null # ToDo: it has huge closure
 , vdpauSupport  ? true,   libvdpau  ? null
 , freetypeSupport ? true, freetype  ? null # it's small and almost everywhere
-, SDL # only for avplay in $tools, adds nontrivial closure to it
+, SDL # only for avplay in $bin, adds nontrivial closure to it
 , enableGPL ? true # ToDo: some additional default stuff may need GPL
 , enableUnfree ? faacSupport
 }:
@@ -77,12 +77,12 @@ let
 
     enableParallelBuilding = true;
 
-    outputs = [ "out" "tools" ];
+    outputs = [ "dev" "out" "bin" ]; #TODO: re-check
 
     # move avplay to get rid of the SDL dependency in the main output
     postInstall = ''
-      mkdir -p "$tools/bin"
-      mv "$out/bin/avplay" "$tools/bin"
+      mkdir -p "$bin/bin"
+      mv "$out/bin/avplay" "$bin/bin"
     '';
 
     doInstallCheck = false; # fails randomly
diff --git a/pkgs/development/libraries/libdrm/default.nix b/pkgs/development/libraries/libdrm/default.nix
index 5ffdd9303e0..c3608c1aea3 100644
--- a/pkgs/development/libraries/libdrm/default.nix
+++ b/pkgs/development/libraries/libdrm/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "12cqnmssi6mbr93n29mm84k8wix5nx6zs82k7wcmj7z3r335ymwr";
   };
 
+  outputs = [ "dev" "out" ];
+
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ libpthreadstubs libpciaccess ]
     ++ stdenv.lib.optional stdenv.isLinux udev;
diff --git a/pkgs/development/libraries/libelf/default.nix b/pkgs/development/libraries/libelf/default.nix
index 4a34ac6bdec..686b444e430 100644
--- a/pkgs/development/libraries/libelf/default.nix
+++ b/pkgs/development/libraries/libelf/default.nix
@@ -1,6 +1,6 @@
 { fetchurl, stdenv, gettext, glibc }:
 
-stdenv.mkDerivation (rec {
+stdenv.mkDerivation rec {
   name = "libelf-0.8.13";
 
   src = fetchurl {
@@ -15,6 +15,11 @@ stdenv.mkDerivation (rec {
     nativeBuildInputs = [ glibc ];
   };
 
+  # Libelf's custom NLS macros fail to determine the catalog file extension on
+  # Darwin, so disable NLS for now.
+  # FIXME: Eventually make Gettext a build input on all platforms.
+  configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-nls";
+
   meta = {
     description = "ELF object file access library";
 
@@ -26,12 +31,3 @@ stdenv.mkDerivation (rec {
     maintainers = [ ];
   };
 }
-
-//
-
-# Libelf's custom NLS macros fail to determine the catalog file extension on
-# Darwin, so disable NLS for now.
-# FIXME: Eventually make Gettext a build input on all platforms.
-(if stdenv.isDarwin
- then { configureFlags = [ "--disable-nls" ]; }
- else { }))
diff --git a/pkgs/development/libraries/libffi/default.nix b/pkgs/development/libraries/libffi/default.nix
index bc15e88ba2f..f0226eaaac7 100644
--- a/pkgs/development/libraries/libffi/default.nix
+++ b/pkgs/development/libraries/libffi/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "0dya49bnhianl0r65m65xndz6ls2jn1xngyn72gd28ls3n7bnvnh";
   };
 
+  outputs = [ "dev" "out" "doc" ];
+
   buildInputs = stdenv.lib.optional doCheck dejagnu;
 
   configureFlags = [
@@ -19,9 +21,15 @@ stdenv.mkDerivation rec {
 
   dontStrip = stdenv ? cross; # Don't run the native `strip' when cross-compiling.
 
-  # Install headers in the right place.
+  # Install headers and libs in the right places.
   postInstall = ''
-    ln -s${if (stdenv.isFreeBSD || stdenv.isOpenBSD || stdenv.isDarwin) then "" else "r"}v "$out/lib/"libffi*/include "$out/include"
+    mv "$out"/lib64/* "$out/lib"
+    rmdir "$out/lib64"
+    ln -s lib "$out/lib64"
+
+    mkdir -p "$dev/"
+    mv "$out/lib/${name}/include" "$dev/include"
+    rmdir "$out/lib/${name}"
   '';
 
   meta = {
diff --git a/pkgs/development/libraries/libjpeg-turbo/default.nix b/pkgs/development/libraries/libjpeg-turbo/default.nix
index 6a650de8564..4ce79a0f894 100644
--- a/pkgs/development/libraries/libjpeg-turbo/default.nix
+++ b/pkgs/development/libraries/libjpeg-turbo/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, nasm }:
+{ stdenv, fetchurl, nasm, autoreconfHook }:
 
 stdenv.mkDerivation rec {
   name = "libjpeg-turbo-1.4.0";
@@ -8,7 +8,11 @@ stdenv.mkDerivation rec {
     sha256 = "1vmv5ciqq98gi2ishqbvlx9hsk7sl06lr6xkcgw480jiddadhfnr";
   };
 
-  buildInputs = [ nasm ];
+  outputs = [ "dev" "out" "doc" "bin" ];
+
+  buildInputs = [ autoreconfHook nasm ];
+
+  enableParallelBuilding = true;
 
   doCheck = true;
   checkTarget = "test";
diff --git a/pkgs/development/libraries/libjpeg/default.nix b/pkgs/development/libraries/libjpeg/default.nix
index bf2ebb27f37..025be200959 100644
--- a/pkgs/development/libraries/libjpeg/default.nix
+++ b/pkgs/development/libraries/libjpeg/default.nix
@@ -12,6 +12,8 @@ stdenv.mkDerivation {
 
   configureFlags = optional static "--enable-static --disable-shared";
 
+  outputs = [ "dev" "out" "man" "bin" ];
+
   meta = {
     homepage = http://www.ijg.org/;
     description = "A library that implements the JPEG image file format";
diff --git a/pkgs/development/libraries/libogg/default.nix b/pkgs/development/libraries/libogg/default.nix
index 57b8b2fc66e..ea2c4226289 100644
--- a/pkgs/development/libraries/libogg/default.nix
+++ b/pkgs/development/libraries/libogg/default.nix
@@ -9,6 +9,8 @@ stdenv.mkDerivation rec {
   };
 
   meta = with stdenv.lib; {
+
+  outputs = [ "dev" "doc" "out" ];
     homepage = http://xiph.org/ogg/;
     license = licenses.bsd3;
     maintainers = [ maintainers.emery ];
diff --git a/pkgs/development/libraries/libpng/default.nix b/pkgs/development/libraries/libpng/default.nix
index 17820fa8188..7a233b6715c 100644
--- a/pkgs/development/libraries/libpng/default.nix
+++ b/pkgs/development/libraries/libpng/default.nix
@@ -18,13 +18,18 @@ in stdenv.mkDerivation rec {
     url = "mirror://sourceforge/libpng/libpng-${version}.tar.xz";
     inherit sha256;
   };
-
   postPatch = whenPatched "gunzip < ${patch_src} | patch -Np1";
 
+  outputs = [ "dev" "out" "man" ];
+
   propagatedBuildInputs = [ zlib ];
 
+  preConfigure = "export bin=$dev";
+
   doCheck = true;
 
+  postInstall = ''mv "$out/bin" "$dev/bin"'';
+
   passthru = { inherit zlib; };
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/libraries/libsamplerate/default.nix b/pkgs/development/libraries/libsamplerate/default.nix
index 85d51d0ad71..f885024bca0 100644
--- a/pkgs/development/libraries/libsamplerate/default.nix
+++ b/pkgs/development/libraries/libsamplerate/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, pkgconfig, fftw, libsndfile }:
+{ stdenv, fetchurl, pkgconfig, libsndfile }:
 
 stdenv.mkDerivation rec {
   name = "libsamplerate-0.1.8";
@@ -9,12 +9,14 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ pkgconfig ];
-  propagatedBuildInputs = [ fftw libsndfile ];
+  propagatedBuildInputs = [ libsndfile ];
 
   # maybe interesting configure flags:
   #--disable-fftw          disable usage of FFTW
   #--disable-cpu-clip      disable tricky cpu specific clipper
 
+  outputs = [ "dev" "bin" "out" ];
+
   postConfigure = stdenv.lib.optionalString stdenv.isDarwin
     ''
       # need headers from the Carbon.framework in /System/Library/Frameworks to
diff --git a/pkgs/development/libraries/libsndfile/default.nix b/pkgs/development/libraries/libsndfile/default.nix
index 74140d5f335..c4bdc23f937 100644
--- a/pkgs/development/libraries/libsndfile/default.nix
+++ b/pkgs/development/libraries/libsndfile/default.nix
@@ -10,6 +10,10 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ pkgconfig flac libogg libvorbis ];
 
+  enableParallelBuilding = true;
+
+  outputs = [ "dev" "out" "bin" "doc" ];
+
   # need headers from the Carbon.framework in /System/Library/Frameworks to
   # compile this on darwin -- not sure how to handle
   preConfigure = stdenv.lib.optionalString stdenv.isDarwin
diff --git a/pkgs/development/libraries/libtiff/default.nix b/pkgs/development/libraries/libtiff/default.nix
index 7ed9794011c..681d3d97af5 100644
--- a/pkgs/development/libraries/libtiff/default.nix
+++ b/pkgs/development/libraries/libtiff/default.nix
@@ -32,6 +32,8 @@ stdenv.mkDerivation rec {
     patch -p0 < ${patchDir}/${if stdenv.isDarwin then "tiff-4.0.3" else "*"}-tiff2pdf-colors.patch
   ''; # ^ sh on darwin seems not to expand globs in redirects, and I don't want to rebuild all again elsewhere
 
+  outputs = [ "dev" "out" "bin" "doc" ];
+
   nativeBuildInputs = [ pkgconfig ];
 
   propagatedBuildInputs = [ zlib libjpeg xz ]; #TODO: opengl support (bogus configure detection)
diff --git a/pkgs/development/libraries/libvorbis/default.nix b/pkgs/development/libraries/libvorbis/default.nix
index 5d3218169d9..0e5cd8b85e8 100644
--- a/pkgs/development/libraries/libvorbis/default.nix
+++ b/pkgs/development/libraries/libvorbis/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "1lg1n3a6r41492r7in0fpvzc7909mc5ir9z0gd3qh2pz4yalmyal";
   };
 
+  outputs = [ "dev" "out" "doc" ];
+
   buildInputs = [ pkgconfig ];
 
   propagatedBuildInputs = [ libogg ];
diff --git a/pkgs/development/libraries/mesa/default.nix b/pkgs/development/libraries/mesa/default.nix
index 8db89b60f18..39a65886585 100644
--- a/pkgs/development/libraries/mesa/default.nix
+++ b/pkgs/development/libraries/mesa/default.nix
@@ -58,7 +58,7 @@ stdenv.mkDerivation {
       --replace _EGL_DRIVER_SEARCH_DIR '"${driverLink}"'
   '';
 
-  outputs = ["out" "drivers" "osmesa"];
+  outputs = [ "dev" "out" "drivers" "osmesa" ];
 
   configureFlags = [
     "--sysconfdir=/etc"
diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix
index 555351bddc3..06cebf04189 100644
--- a/pkgs/development/libraries/mpfr/default.nix
+++ b/pkgs/development/libraries/mpfr/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "0sqvpfkzamxdr87anzakf9dhkfh15lfmm5bsqajk02h1mxh3zivr";
   };
 
+  outputs = [ "dev" "out" "doc" ];
+
   # mpfr.h requires gmp.h
   propagatedBuildInputs = [ gmp ];
 
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index 7255e91f282..3504cf5fd97 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -50,7 +50,11 @@ stdenv.mkDerivation {
 
   patches = patchesCross false;
 
-  buildInputs = stdenv.lib.optional withCryptodev cryptodevHeaders;
+  outputs = [ "dev" "out" "man" "bin" ];
+  setOutputFlags = false;
+
+  buildInputs = [ ]
+    ++ stdenv.lib.optional withCryptodev cryptodevHeaders;
 
   nativeBuildInputs = [ perl ];
 
@@ -69,7 +73,7 @@ stdenv.mkDerivation {
     sed -i -e "s|-march=i486|-march=x86-64|g" Makefile
   '';
 
-  makeFlags = "MANDIR=$(out)/share/man";
+  makeFlags = "MANDIR=$(man)/share/man";
 
   # Parallel building is broken in OpenSSL.
   enableParallelBuilding = false;
@@ -81,6 +85,18 @@ stdenv.mkDerivation {
       if [ -n "$(echo $out/lib/*.so $out/lib/*.dylib)" ]; then
           rm $out/lib/*.a
       fi
+
+      mkdir -p $bin
+      mv $out/bin $bin/
+
+      rm -rf $out/etc/ssl/misc
+
+      mkdir $dev
+      mv $out/include $dev/
+
+      # OpenSSL installs readonly files, which otherwise we can't strip.
+      # FIXME: Can remove this after the next stdenv merge.
+      chmod -R +w $out
     ''; # */
 
   crossAttrs = {
@@ -91,14 +107,6 @@ stdenv.mkDerivation {
       export configureFlags="--libdir=lib --cross-compile-prefix=${stdenv.cross.config}- shared ${opensslCrossSystem}"
     '';
 
-    postInstall = ''
-      # Openssl installs readonly files, which otherwise we can't strip.
-      # This could at some stdenv hash change be put out of crossAttrs, too
-      chmod -R +w $out
-
-      # Remove references to perl, to avoid depending on it at runtime
-      rm $out/bin/c_rehash $out/ssl/misc/CA.pl $out/ssl/misc/tsget
-    '';
     configureScript = "./Configure";
   } // stdenv.lib.optionalAttrs (opensslCrossSystem == "darwin64-x86_64-cc") {
     CC = "gcc";
diff --git a/pkgs/development/libraries/pango/default.nix b/pkgs/development/libraries/pango/default.nix
index 87187667a92..e72071b4cfd 100644
--- a/pkgs/development/libraries/pango/default.nix
+++ b/pkgs/development/libraries/pango/default.nix
@@ -14,8 +14,9 @@ stdenv.mkDerivation rec {
     sha256 = "01rdzjh68w8l5zn0648yibyarj8p6g7yfn59nw5awaz1i8dvbnqq";
   };
 
-  buildInputs = with stdenv.lib; [ gobjectIntrospection ]
-    ++ optionals stdenv.isDarwin [ fontconfig ];
+  outputs = [ "dev" "out" "bin" "doc" ];
+
+  buildInputs = with stdenv.lib; [ gobjectIntrospection ];
   nativeBuildInputs = [ pkgconfig ];
 
   propagatedBuildInputs = [ x11 glib cairo libpng fontconfig freetype harfbuzz ] ++ libintlOrEmpty;
@@ -29,8 +30,6 @@ stdenv.mkDerivation rec {
   # .../bin/sh: line 5: 14823 Abort trap: 6 srcdir=. PANGO_RC_FILE=./pangorc ${dir}$tst
   # FAIL: testiter
 
-  postInstall = "rm -rf $out/share/gtk-doc";
-
   meta = {
     description = "A library for laying out and rendering of text, with an emphasis on internationalization";
 
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index 77d21abb6d2..6ae8e475d1e 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -12,6 +12,8 @@ stdenv.mkDerivation rec {
     sha256 = "1fs5p1z67m9f4xnyil3s4lhgyld78f7m4d1yawpyhh0cvrbk90zg";
   };
 
+  outputs = [ "dev" "out" "bin" "doc" "man" ];
+
   configureFlags = ''
     --enable-jit
     ${if unicodeSupport then "--enable-unicode-properties" else ""}
@@ -26,6 +28,12 @@ stdenv.mkDerivation rec {
     buildInputs = [ windows.mingw_w64_pthreads.crossDrv ];
   };
 
+  postInstall =
+    ''
+      mkdir $dev/bin
+      mv $bin/bin/pcre-config $dev/bin/
+    '';
+
   meta = {
     homepage = "http://www.pcre.org/";
     description = "A library for Perl Compatible Regular Expressions";
diff --git a/pkgs/development/libraries/speex/default.nix b/pkgs/development/libraries/speex/default.nix
index 93a01a3d2bc..6aceef78eea 100644
--- a/pkgs/development/libraries/speex/default.nix
+++ b/pkgs/development/libraries/speex/default.nix
@@ -2,11 +2,18 @@
 
 stdenv.mkDerivation rec {
   name = "speex-1.2rc1";
-  
+
   src = fetchurl {
     url = "http://downloads.us.xiph.org/releases/speex/${name}.tar.gz";
     sha256 = "19mpkhbz3s08snvndn0h1dk2j139max6b0rr86nnsjmxazf30brl";
   };
-  
+
   buildInputs = [ libogg ];
+
+  outputs = [ "dev" "out" "bin" "doc" ];
+
+  meta = {
+    homepage = http://www.speex.org/;
+    description = "A audio compression codec designed for speech";
+  };
 }
diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix
index 8a79806bf93..706c74b6ce6 100644
--- a/pkgs/development/libraries/zlib/default.nix
+++ b/pkgs/development/libraries/zlib/default.nix
@@ -13,15 +13,21 @@ stdenv.mkDerivation (rec {
     sha256 = "039agw5rqvqny92cpkrfn243x2gd4xn13hs3xi6isk55d2vqqr9n";
   };
 
-  configureFlags = if static then "" else "--shared";
+  outputs = [ "dev" "out" "static" "man" ];
+  setOutputFlags = false;
+
+  configureFlags = stdenv.lib.optional (!static) "--shared";
 
   preConfigure = ''
     if test -n "$crossConfig"; then
       export CC=$crossConfig-gcc
-      configureFlags=${if static then "" else "--shared"}
     fi
   '';
 
+  postInstall = ''
+    _moveToOutput lib/libz.a "$static"
+  '';
+
   # As zlib takes part in the stdenv building, we don't want references
   # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
   NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (!stdenv.isDarwin) "-static-libgcc";
diff --git a/pkgs/development/perl-modules/generic/builder.sh b/pkgs/development/perl-modules/generic/builder.sh
index 7c51bf1b591..d657a6ccc98 100644
--- a/pkgs/development/perl-modules/generic/builder.sh
+++ b/pkgs/development/perl-modules/generic/builder.sh
@@ -28,6 +28,13 @@ preConfigure() {
     perl Makefile.PL PREFIX=$out INSTALLDIRS=site $makeMakerFlags
 }
 
+preFixup() {
+    if [ -n "$man" ]; then
+        mkdir -p $man/share
+        if [ -d $out/man ]; then mv $out/man $man/share/; fi
+    fi
+}
+
 postFixup() {
     # If a user installs a Perl package, she probably also wants its
     # dependencies in the user environment (since Perl modules don't
diff --git a/pkgs/development/perl-modules/generic/default.nix b/pkgs/development/perl-modules/generic/default.nix
index 6cd4134cc9c..bf41f4d3945 100644
--- a/pkgs/development/perl-modules/generic/default.nix
+++ b/pkgs/development/perl-modules/generic/default.nix
@@ -1,13 +1,15 @@
 perl:
 
-{ buildInputs ? [], ... } @ attrs:
+{ buildInputs ? [], name, ... } @ attrs:
 
 perl.stdenv.mkDerivation (
   {
+    outputs = [ "out" "man" ];
+
     doCheck = true;
-    
+
     checkTarget = "test";
-    
+
     # Prevent CPAN downloads.
     PERL_AUTOINSTALL = "--skipdeps";
 
@@ -23,7 +25,7 @@ perl.stdenv.mkDerivation (
   attrs
   //
   {
-    name = "perl-" + attrs.name;
+    name = "perl-" + name;
     builder = ./builder.sh;
     buildInputs = buildInputs ++ [ perl ];
   }
diff --git a/pkgs/development/tools/build-managers/cmake/default.nix b/pkgs/development/tools/build-managers/cmake/default.nix
index 210c9486050..2804bad2595 100644
--- a/pkgs/development/tools/build-managers/cmake/default.nix
+++ b/pkgs/development/tools/build-managers/cmake/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl
+{ stdenv, fetchurl, pkgconfig
 , bzip2, curl, expat, jsoncpp, libarchive, xz, zlib
 , useNcurses ? false, ncurses, useQt4 ? false, qt4
 , wantPS ? false, ps ? null
@@ -39,7 +39,7 @@ stdenv.mkDerivation rec {
     });
 
   buildInputs =
-    [ bzip2 curl expat libarchive xz zlib ]
+    [ pkgconfig bzip2 curl expat libarchive xz zlib ]
     ++ optional (jsoncpp != null) jsoncpp
     ++ optional useNcurses ncurses
     ++ optional useQt4 qt4;
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index f740c60c487..c0d7fdc4d93 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -36,6 +36,8 @@ stdenv.mkDerivation rec {
     ./pt-pax-flags-20121023.patch
   ];
 
+  outputs = [ "dev" "out" "info" ];
+
   nativeBuildInputs = optional gold bison;
   buildInputs = [ zlib ];
 
@@ -67,6 +69,8 @@ stdenv.mkDerivation rec {
 
   enableParallelBuilding = true;
 
+  postFixup = "ln -s $out/bin $dev/bin"; # tools needed for development
+
   meta = {
     description = "Tools for manipulating binaries (linker, assembler, etc.)";
 
diff --git a/pkgs/development/tools/misc/libtool/libtool2.nix b/pkgs/development/tools/misc/libtool/libtool2.nix
index 5d27b469680..27ec2772e09 100644
--- a/pkgs/development/tools/misc/libtool/libtool2.nix
+++ b/pkgs/development/tools/misc/libtool/libtool2.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "1qq61k6lp1fp75xs398yzi6wvbx232l7xbyn3p13cnh27mflvgg3";
   };
 
+  outputs = [ "out" "lib" ];
+
   propagatedNativeBuildInputs = [ m4 ];
   nativeBuildInputs = [ perl help2man ];
 
@@ -43,4 +45,3 @@ stdenv.mkDerivation rec {
     maintainers = [ ];
   };
 }
-
diff --git a/pkgs/development/tools/misc/patchelf/default.nix b/pkgs/development/tools/misc/patchelf/default.nix
index 5aa81e46bed..b3121ac7944 100644
--- a/pkgs/development/tools/misc/patchelf/default.nix
+++ b/pkgs/development/tools/misc/patchelf/default.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
 
   setupHook = [ ./setup-hook.sh ];
 
+  #doCheck = true; # problems when loading libc.so.6
+
   meta = {
     homepage = http://nixos.org/patchelf.html;
     license = "GPL";
diff --git a/pkgs/development/tools/misc/pkgconfig/default.nix b/pkgs/development/tools/misc/pkgconfig/default.nix
index 2ce1fd7b6e4..4decdc424d5 100644
--- a/pkgs/development/tools/misc/pkgconfig/default.nix
+++ b/pkgs/development/tools/misc/pkgconfig/default.nix
@@ -1,22 +1,27 @@
-{stdenv, fetchurl, automake, vanilla ? false}:
+{ stdenv, fetchurl, automake, vanilla ? false }:
 
-stdenv.mkDerivation (rec {
+let
+  inherit (stdenv.lib) optional;
+in
+stdenv.mkDerivation rec {
   name = "pkg-config-0.28";
-  
+
   setupHook = ./setup-hook.sh;
-  
+
   src = fetchurl {
     url = "http://pkgconfig.freedesktop.org/releases/${name}.tar.gz";
     sha256 = "0igqq5m204w71m11y0nipbdf5apx87hwfll6axs12hn4dqfb6vkb";
   };
+    # Process Requires.private properly, see
+    # http://bugs.freedesktop.org/show_bug.cgi?id=4738.
+  patches = optional (!vanilla) ./requires-private.patch;
+
+  preConfigure = stdenv.lib.optionalString (stdenv.system == "mips64el-linux")
+    ''cp -v ${automake}/share/automake*/config.{sub,guess} .'';
 
   configureFlags = [ "--with-internal-glib" ];
 
-  patches = if vanilla then [] else [
-    # Process Requires.private properly, see
-    # http://bugs.freedesktop.org/show_bug.cgi?id=4738.
-    ./requires-private.patch
-  ];
+  postInstall = ''rm "$out"/bin/*-pkg-config''; # clean the duplicate file
 
   meta = {
     description = "A tool that allows packages to find out information about other packages";
@@ -24,9 +29,5 @@ stdenv.mkDerivation (rec {
     platforms = stdenv.lib.platforms.all;
   };
 
-} // (if stdenv.system == "mips64el-linux" then
-  {
-    preConfigure = ''
-      cp -v ${automake}/share/automake*/config.{sub,guess} .
-    '';
-  } else {}))
+}
+
diff --git a/pkgs/development/tools/misc/texinfo/5.2.nix b/pkgs/development/tools/misc/texinfo/5.2.nix
index c43ebcd2de2..a9edccbd200 100644
--- a/pkgs/development/tools/misc/texinfo/5.2.nix
+++ b/pkgs/development/tools/misc/texinfo/5.2.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ncurses, perl, xz, interactive ? false }:
+{ stdenv, fetchurl, xz, ncurses, perl, interactive ? false }:
 
 stdenv.mkDerivation rec {
   name = "texinfo-5.2";
@@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
     sha256 = "1njfwh2z34r2c4r0iqa7v24wmjzvsfyz4vplzry8ln3479lfywal";
   };
 
-  buildInputs = [ perl xz ]
+  buildInputs = [ perl xz.bin ]
     ++ stdenv.lib.optional interactive ncurses;
 
   preInstall = ''
diff --git a/pkgs/development/web/nodejs/default.nix b/pkgs/development/web/nodejs/default.nix
index ee121d6788a..c4126f0fb5f 100644
--- a/pkgs/development/web/nodejs/default.nix
+++ b/pkgs/development/web/nodejs/default.nix
@@ -47,9 +47,9 @@ in stdenv.mkDerivation {
     (cd tools/gyp; patch -Np1 -i ${../../python-modules/gyp/no-darwin-cflags.patch})
   '' else null;
 
-  buildInputs = [ python which ]
+  buildInputs = [ python openssl ]
     ++ (optional stdenv.isLinux utillinux)
-    ++ optionals stdenv.isDarwin [ pkgconfig openssl dtrace ];
+    ++ optionals stdenv.isDarwin [ pkgconfig dtrace ];
   setupHook = ./setup-hook.sh;
 
   passthru.interpreterName = "nodejs";