From a76b0fb6fadc7cc70296a074d7fb0519e8dc80d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?=
 <viric@vicerveza.homeunix.net>
Date: Fri, 4 Mar 2011 09:48:24 +0000
Subject: [PATCH] Making freecad install; it still does not find all shared
 objects though.

Either eigen changed the hash of the tarball, or I did not commit its latest hash.
I add boost 1.46 apart, because 1.44 does not work easily for freecad.

svn path=/nixpkgs/trunk/; revision=26151
---
 .../graphics/freecad/cmakeinstall.patch       | 44 ++++++++++
 .../applications/graphics/freecad/default.nix |  2 +
 pkgs/development/libraries/boost/1.46.nix     | 80 +++++++++++++++++++
 pkgs/development/libraries/eigen/default.nix  |  2 +-
 pkgs/top-level/all-packages.nix               |  6 +-
 5 files changed, 132 insertions(+), 2 deletions(-)
 create mode 100644 pkgs/applications/graphics/freecad/cmakeinstall.patch
 create mode 100644 pkgs/development/libraries/boost/1.46.nix

diff --git a/pkgs/applications/graphics/freecad/cmakeinstall.patch b/pkgs/applications/graphics/freecad/cmakeinstall.patch
new file mode 100644
index 000000000000..10d8196169df
--- /dev/null
+++ b/pkgs/applications/graphics/freecad/cmakeinstall.patch
@@ -0,0 +1,44 @@
+Index: src/3rdParty/salomesmesh/CMakeLists.txt
+===================================================================
+--- a/src/3rdParty/salomesmesh/CMakeLists.txt	(revision 4193)
++++ a/src/3rdParty/salomesmesh/CMakeLists.txt	(working copy)
+@@ -206,21 +206,3 @@
+ IF(MINGW)
+   SET_TARGET_PROPERTIES(StdMeshers PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+ ENDIF(MINGW)
+-
+-###########
+-# INSTALL #
+-###########
+-
+-# Path name install: for instance, SMESH-5.1.2.7
+-SET(INSTALL_PATH_NAME SMESH-${SMESH_VERSION_MAJOR}.${SMESH_VERSION_MINOR}.${SMESH_VERSION_PATCH}.${SMESH_VERSION_TWEAK})
+-
+-IF(UNIX)
+-    # Libraries are installed by default in /usr/local/lib/SMESH-5.1.2.7
+-    INSTALL(TARGETS SMDS Driver DriverSTL DriverDAT DriverUNV
+-            SMESHDS SMESH StdMeshers
+-            DESTINATION /usr/local/lib/${INSTALL_PATH_NAME})
+-    # Headers are installed by default in /usr/local/include/SMESH-5.1.2.7
+-    INSTALL(DIRECTORY inc/
+-            DESTINATION /usr/local/include/${INSTALL_PATH_NAME}
+-            FILES_MATCHING PATTERN "*.h*")
+-ENDIF(UNIX)
+Index: CMakeLists.txt
+===================================================================
+--- a/CMakeLists.txt	(revision 4193)
++++ a/CMakeLists.txt	(working copy)
+@@ -57,13 +57,6 @@
+ 
+ # ================================================================================
+ 
+-
+-if(WIN32)
+-    SET(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
+-else(WIN32)
+-    SET(CMAKE_INSTALL_PREFIX "/usr/lib/freecad")
+-endif(WIN32)
+-
+ # ================================================================================
+ # == Win32 is default behaviour use the LibPack copied in Source tree ============
+ if(MSVC)
diff --git a/pkgs/applications/graphics/freecad/default.nix b/pkgs/applications/graphics/freecad/default.nix
index 447261b15df3..58e36369f042 100644
--- a/pkgs/applications/graphics/freecad/default.nix
+++ b/pkgs/applications/graphics/freecad/default.nix
@@ -23,6 +23,8 @@ stdenv.mkDerivation rec {
   # this for freecad to build
   NIX_CFLAGS_COMPILE = "-DBOOST_FILESYSTEM_VERSION=2";
 
+  patches = [ ./cmakeinstall.patch ];
+
   meta = {
     homepage = http://free-cad.sourceforge.net/;
     license = [ "GPLv2+" "LGPLv2+" ];
diff --git a/pkgs/development/libraries/boost/1.46.nix b/pkgs/development/libraries/boost/1.46.nix
new file mode 100644
index 000000000000..0a64efdeb3bd
--- /dev/null
+++ b/pkgs/development/libraries/boost/1.46.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.46.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_46_0.tar.bz2";
+    sha256 = "0ndsiv06332gbh6wj68pcnci3l5qrc5pm1ca9dkmxhpxj83zd41g";
+  };
+
+  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/eigen/default.nix b/pkgs/development/libraries/eigen/default.nix
index c475682c672d..9cf94ca359f7 100644
--- a/pkgs/development/libraries/eigen/default.nix
+++ b/pkgs/development/libraries/eigen/default.nix
@@ -8,7 +8,7 @@ stdenv.mkDerivation {
   src = fetchurl {
     url = "http://bitbucket.org/eigen/eigen/get/${v}.tar.bz2";
     name = "eigen-${v}.tar.bz2";
-    sha256 = "1a00hqyig4rc7nkz97xv23q7k0vdkzvgd0jkayk61fn9aqcrky79";
+    sha256 = "0frgmkwsgmqaw88qpgvfalisq0wjpcbgqbj6jhpk39nbrs3zcq83";
   };
   buildNativeInputs = [ cmake ];
   meta = with stdenv.lib; {
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index f0ce6a3697cc..52ad8a21a5f7 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -2803,6 +2803,8 @@ let
 
   boost = callPackage ../development/libraries/boost { };
 
+  boost146 = callPackage ../development/libraries/boost/1.46.nix { };
+
   # A Boost build with all library variants enabled.  Very large (about 250 MB).
   boostFull = appendToName "full" (boost.override {
     enableDebug = true;
@@ -6028,7 +6030,9 @@ let
 
   flite = callPackage ../applications/misc/flite { };
 
-  freecad = callPackage ../applications/graphics/freecad { };
+  freecad = callPackage ../applications/graphics/freecad {
+    boost = boost146;
+  };
 
   freemind = callPackage ../applications/misc/freemind {
     jdk = jdk;