From 8f7cab5d5c7556cdda34a7502581ca3391b1e7c9 Mon Sep 17 00:00:00 2001
From: Rob Vermaas <rob.vermaas@gmail.com>
Date: Wed, 4 May 2011 10:03:46 +0000
Subject: [PATCH] add some versions of cppunit/boost/protobuf, added binutils
 with gold, added nlopt

svn path=/nixpkgs/trunk/; revision=27132
---
 pkgs/development/libraries/boost/1.42.nix     | 80 +++++++++++++++++++
 pkgs/development/libraries/protobuf/2.2.0.nix | 28 +++++++
 .../tools/misc/binutils/default.nix           | 10 ++-
 pkgs/top-level/all-packages.nix               | 10 +++
 4 files changed, 125 insertions(+), 3 deletions(-)
 create mode 100644 pkgs/development/libraries/boost/1.42.nix
 create mode 100644 pkgs/development/libraries/protobuf/2.2.0.nix

diff --git a/pkgs/development/libraries/boost/1.42.nix b/pkgs/development/libraries/boost/1.42.nix
new file mode 100644
index 000000000000..3dbc699da4d4
--- /dev/null
+++ b/pkgs/development/libraries/boost/1.42.nix
@@ -0,0 +1,80 @@
+{ stdenv, fetchurl, icu, expat, zlib, bzip2, python
+, enableRelease ? true
+, enableDebug ? false
+, enableSingleThreaded ? false
+, enableMultiThreaded ? true
+, enableShared ? true
+, enableStatic ? false
+, enablePIC ? false
+}:
+
+let
+
+  variant = stdenv.lib.concatStringsSep ","
+    (stdenv.lib.optional enableRelease "release" ++
+     stdenv.lib.optional enableDebug "debug");
+
+  threading = stdenv.lib.concatStringsSep ","
+    (stdenv.lib.optional enableSingleThreaded "single" ++
+     stdenv.lib.optional enableMultiThreaded "multi");
+
+  link = stdenv.lib.concatStringsSep ","
+    (stdenv.lib.optional enableShared "shared" ++
+     stdenv.lib.optional enableStatic "static");
+
+  # To avoid library name collisions
+  finalLayout = if ((enableRelease && enableDebug) ||
+    (enableSingleThreaded && enableMultiThreaded) ||
+    (enableShared && enableStatic)) then
+    "tagged" else "system";
+
+  cflags = if (enablePIC) then "cflags=-fPIC cxxflags=-fPIC linkflags=-fPIC" else "";
+
+in
+
+stdenv.mkDerivation {
+  name = "boost-1.42.0";
+
+  meta = {
+    homepage = "http://boost.org/";
+    description = "Boost C++ Library Collection";
+    license = "boost-license";
+
+    maintainers = [ stdenv.lib.maintainers.simons ];
+  };
+
+  src = fetchurl {
+    url = "mirror://sourceforge/boost/boost_1_42_0.tar.bz2";
+    sha256 = "02g6m6f7m11ig93p5sx7sfq75c15y9kn2pa3csn1bkjhs9dvj7jb";
+  };
+
+  enableParallelBuilding = true;
+
+  buildInputs = [icu expat zlib bzip2 python];
+
+  configureScript = "./bootstrap.sh";
+  configureFlags = "--with-icu=${icu} --with-python=${python}/bin/python";
+
+  buildPhase = "./bjam -j$NIX_BUILD_CORES -sEXPAT_INCLUDE=${expat}/include -sEXPAT_LIBPATH=${expat}/lib --layout=${finalLayout} variant=${variant} threading=${threading} link=${link} ${cflags} install";
+
+  installPhase = ":";
+
+  crossAttrs = rec {
+    buildInputs = [ expat.hostDrv zlib.hostDrv bzip2.hostDrv ];
+    # all buildInputs set previously fell into propagatedBuildInputs, as usual, so we have to
+    # override them.
+    propagatedBuildInputs = buildInputs;
+    # We want to substitute the contents of configureFlags, removing thus the
+    # usual --build and --host added on cross building.
+    preConfigure = ''
+      export configureFlags="--prefix=$out --without-icu"
+    '';
+    buildPhase = ''
+      set -x
+      cat << EOF > user-config.jam
+      using gcc : cross : $crossConfig-g++ ;
+      EOF
+      ./bjam -j$NIX_BUILD_CORES -sEXPAT_INCLUDE=${expat.hostDrv}/include -sEXPAT_LIBPATH=${expat.hostDrv}/lib --layout=${finalLayout} --user-config=user-config.jam toolset=gcc-cross variant=${variant} threading=${threading} link=${link} ${cflags} --without-python install
+    '';
+  };
+}
diff --git a/pkgs/development/libraries/protobuf/2.2.0.nix b/pkgs/development/libraries/protobuf/2.2.0.nix
new file mode 100644
index 000000000000..c9419367fd6e
--- /dev/null
+++ b/pkgs/development/libraries/protobuf/2.2.0.nix
@@ -0,0 +1,28 @@
+{ fetchurl, stdenv, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "protobuf-2.2.0";
+
+  src = fetchurl {
+    url = "http://protobuf.googlecode.com/files/${name}.tar.bz2";
+    sha256 = "0jvj7i0fifl4fqjf84f67chb9b6q2z1jqkfc1zic9fz035mzn7bk";
+  };
+
+  buildInputs = [ zlib ];
+
+  doCheck = true;
+
+  meta = {
+    description = "Protocol Buffers - Google's data interchange format";
+
+    longDescription =
+      '' Protocol Buffers are a way of encoding structured data in an
+         efficient yet extensible format.  Google uses Protocol Buffers for
+         almost all of its internal RPC protocols and file formats.
+      '';
+
+    license = "mBSD";
+
+    homepage = http://code.google.com/p/protobuf/;
+  };
+}
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index 1928061c81dc..f31de55b8135 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -1,4 +1,4 @@
-{stdenv, fetchurl, noSysDirs, zlib, cross ? null}:
+{stdenv, fetchurl, noSysDirs, zlib, cross ? null, gold ? false, bison, flex2535, bc, dejagnu}:
 
 let
     basename = "binutils-2.21";
@@ -18,7 +18,10 @@ stdenv.mkDerivation rec {
     ./new-dtags.patch
   ];
 
-  buildInputs = [ zlib ];
+  buildInputs = [ zlib ] ++ stdenv.lib.optional gold [dejagnu flex2535 bison
+
+              # Some Gold tests require this:
+              bc] ;
 
   inherit noSysDirs;
 
@@ -38,7 +41,8 @@ stdenv.mkDerivation rec {
   configureFlags = "--disable-werror" # needed for dietlibc build
       + stdenv.lib.optionalString (stdenv.system == "mips64-linux")
         " --enable-fix-loongson2f-nop"
-      + stdenv.lib.optionalString (cross != null) " --target=${cross.config}";
+      + stdenv.lib.optionalString (cross != null) " --target=${cross.config}"
+      + stdenv.lib.optionalString gold " --enable-gold" ;
 
   meta = {
     description = "GNU Binutils, tools for manipulating binaries (linker, assembler, etc.)";
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index a678de7d7733..8a996d2b148b 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -992,6 +992,8 @@ let
 
   nilfs_utils = callPackage ../tools/filesystems/nilfs-utils {};
 
+  nlopt = callPackage ../development/libraries/nlopt {};
+
   nmap = callPackage ../tools/security/nmap {
     inherit (pythonPackages) pysqlite;
   };
@@ -2559,6 +2561,11 @@ let
     inherit noSysDirs;
   };
 
+  binutils_gold = callPackage ../development/tools/misc/binutils {
+    inherit noSysDirs;
+    gold = true;
+  };
+
   binutilsCross = forceBuildDrv (import ../development/tools/misc/binutils {
     inherit stdenv fetchurl zlib;
     noSysDirs = true;
@@ -2864,6 +2871,7 @@ let
 
   boost = callPackage ../development/libraries/boost { };
 
+  boost142 = callPackage ../development/libraries/boost/1.42.nix { };
   boost146 = callPackage ../development/libraries/boost/1.46.nix { };
 
   # A Boost build with all library variants enabled.  Very large (about 250 MB).
@@ -2950,6 +2958,7 @@ let
   ctl = callPackage ../development/libraries/ctl { };
 
   cppunit = callPackage ../development/libraries/cppunit { };
+  cppunit_1_10 = callPackage ../development/libraries/cppunit/1.10.nix { };
 
   cracklib = callPackage ../development/libraries/cracklib { };
 
@@ -4067,6 +4076,7 @@ let
   postgis = callPackage ../development/libraries/postgis { };
 
   protobuf = callPackage ../development/libraries/protobuf { };
+  protobuf_2_2_0 = callPackage ../development/libraries/protobuf/2.2.0.nix { };
 
   pth = callPackage ../development/libraries/pth { };