about summary refs log tree commit diff
path: root/pkgs/development/libraries/boost/generic.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/boost/generic.nix')
-rw-r--r--pkgs/development/libraries/boost/generic.nix53
1 files changed, 30 insertions, 23 deletions
diff --git a/pkgs/development/libraries/boost/generic.nix b/pkgs/development/libraries/boost/generic.nix
index 5b0c06bd6bb2a..8ba8dc1900915 100644
--- a/pkgs/development/libraries/boost/generic.nix
+++ b/pkgs/development/libraries/boost/generic.nix
@@ -1,11 +1,11 @@
-{ stdenv, icu, expat, zlib, bzip2, python, fixDarwinDylibNames
+{ stdenv, fetchurl, icu, expat, zlib, bzip2, python, fixDarwinDylibNames, libiconv
 , toolset ? if stdenv.cc.isClang then "clang" else null
 , enableRelease ? true
 , enableDebug ? false
 , enableSingleThreaded ? false
 , enableMultiThreaded ? true
-, enableShared ? true
-, enableStatic ? false
+, enableShared ? !(stdenv.cross.libc or null == "msvcrt") # problems for now
+, enableStatic ? !enableShared
 , enablePIC ? false
 , enableExceptions ? false
 , taggedLayout ? ((enableRelease && enableDebug) || (enableSingleThreaded && enableMultiThreaded) || (enableShared && enableStatic))
@@ -53,7 +53,7 @@ let
 
   genericB2Flags = [
     "--includedir=$dev/include"
-    "--libdir=$lib/lib"
+    "--libdir=$out/lib"
     "-j$NIX_BUILD_CORES"
     "--layout=${layout}"
     "variant=${variant}"
@@ -76,8 +76,14 @@ let
     "--user-config=user-config.jam"
     "toolset=gcc-cross"
     "--without-python"
+  ] ++ optionals (stdenv.cross.libc == "msvcrt") [
+    "target-os=windows"
+    "threadapi=win32"
+    "binary-format=pe"
+    "address-model=${if hasPrefix "x86_64-" stdenv.cross.config then "64" else "32"}"
+    "architecture=x86"
   ];
-  crossB2Args = concatMapStringsSep " " (genericB2Flags ++ crossB2Flags);
+  crossB2Args = concatStringsSep " " (genericB2Flags ++ crossB2Flags);
 
   builder = b2Args: ''
     ./b2 ${b2Args}
@@ -90,10 +96,6 @@ let
 
     # Let boost install everything else
     ./b2 ${b2Args} install
-
-    # Create a derivation which encompasses everything, making buildInputs nicer
-    mkdir -p $out/nix-support
-    echo "$dev $lib" > $out/nix-support/propagated-native-build-inputs
   '';
 
   commonConfigureFlags = [
@@ -108,6 +110,8 @@ let
       find include \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \
         -exec sed '1i#line 1 "{}"' -i '{}' \;
     )
+  '' + optionalString (stdenv.cross.libc or null == "msvcrt") ''
+    ${stdenv.cross.config}-ranlib "$lib/lib/"*.a
   '';
 
 in
@@ -123,14 +127,13 @@ stdenv.mkDerivation {
     license = stdenv.lib.licenses.boost;
 
     platforms = platforms.unix;
-    maintainers = with maintainers; [ simons wkennington ];
+    maintainers = with maintainers; [ peti wkennington ];
   };
 
   preConfigure = ''
-    NIX_LDFLAGS="$(echo $NIX_LDFLAGS | sed "s,$out,$lib,g")"
     if test -f tools/build/src/tools/clang-darwin.jam ; then
         substituteInPlace tools/build/src/tools/clang-darwin.jam \
-          --replace '@rpath/$(<[1]:D=)' "$lib/lib/\$(<[1]:D=)";
+          --replace '@rpath/$(<[1]:D=)' "$out/lib/\$(<[1]:D=)";
     fi;
   '' + optionalString (mpi != null) ''
     cat << EOF > user-config.jam
@@ -143,14 +146,15 @@ stdenv.mkDerivation {
 
   enableParallelBuilding = true;
 
-  buildInputs = [ icu expat zlib bzip2 python ]
+  buildInputs = [ expat zlib bzip2 libiconv ]
+    ++ stdenv.lib.optionals (! stdenv ? cross) [ python icu ]
     ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
   configureScript = "./bootstrap.sh";
-  configureFlags = commonConfigureFlags ++ [
-    "--with-icu=${icu.dev}"
-    "--with-python=${python.interpreter}"
-  ] ++ optional (toolset != null) "--with-toolset=${toolset}";
+  configureFlags = commonConfigureFlags
+    ++ [ "--with-python=${python.interpreter}" ]
+    ++ optional (! stdenv ? cross) "--with-icu=${icu.dev}"
+    ++ optional (toolset != null) "--with-toolset=${toolset}";
 
   buildPhase = builder nativeB2Args;
 
@@ -158,19 +162,14 @@ stdenv.mkDerivation {
 
   postFixup = fixup;
 
-  outputs = [ "out" "dev" "lib" ];
+  outputs = [ "dev" "out" ];
   setOutputFlags = false;
 
   crossAttrs = rec {
-    buildInputs = [ expat.crossDrv zlib.crossDrv bzip2.crossDrv ];
-    # 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="--without-icu ${concatStringsSep " " commonConfigureFlags}"
-      set -x
       cat << EOF > user-config.jam
       using gcc : cross : $crossConfig-g++ ;
       EOF
@@ -178,5 +177,13 @@ stdenv.mkDerivation {
     buildPhase = builder crossB2Args;
     installPhase = installer crossB2Args;
     postFixup = fixup;
+  } // optionalAttrs (stdenv.cross.libc == "msvcrt") {
+    patches = fetchurl {
+      url = "https://svn.boost.org/trac/boost/raw-attachment/ticket/7262/"
+          + "boost-mingw.patch";
+      sha256 = "0s32kwll66k50w6r5np1y5g907b7lcpsjhfgr7rsw7q5syhzddyj";
+    };
+
+    patchFlags = "-p0";
   };
 }