summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2014-04-21 10:00:35 +0200
committeraszlig <aszlig@redmoonstudios.org>2014-04-21 10:00:35 +0200
commit625d7b9043be673a8df33cc842ec5032d7705c06 (patch)
tree38777f48f2bb7b403b3e9f148000d0ffa8026cde /pkgs/development
parentcdd1c9caa5d2a6eb184ec159bcfde3ac9745c56d (diff)
parent2d3376e84e4a24ca10480a9ade972db1e5c54e9f (diff)
downloadnixlib-625d7b9043be673a8df33cc842ec5032d7705c06.tar
nixlib-625d7b9043be673a8df33cc842ec5032d7705c06.tar.gz
nixlib-625d7b9043be673a8df33cc842ec5032d7705c06.tar.bz2
nixlib-625d7b9043be673a8df33cc842ec5032d7705c06.tar.lz
nixlib-625d7b9043be673a8df33cc842ec5032d7705c06.tar.xz
nixlib-625d7b9043be673a8df33cc842ec5032d7705c06.tar.zst
nixlib-625d7b9043be673a8df33cc842ec5032d7705c06.zip
Merge pull request #1928 from 'cross-win-osx'.
This includes a lot of fixes for cross-building to Windows and Mac OS X
and could possibly fix things even for non-cross-builds, like for
example OpenSSL on Windows.

The main reason for merging this in 14.04 already is that we already
have runInWindowsVM in master and it doesn't work until we actually
cross-build Cygwin's setup binary as the upstream version is a fast
moving target which gets _overwritten_ on every new release.

Conflicts:
	pkgs/top-level/all-packages.nix
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/compilers/gcc/4.6/default.nix6
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix18
-rw-r--r--pkgs/development/interpreters/lua-5/5.2.nix33
-rw-r--r--pkgs/development/libraries/SDL/default.nix46
-rw-r--r--pkgs/development/libraries/audiofile/default.nix2
-rw-r--r--pkgs/development/libraries/glew/default.nix29
-rw-r--r--pkgs/development/libraries/libgcrypt/1.6.nix6
-rw-r--r--pkgs/development/libraries/libgpg-error/default.nix6
-rw-r--r--pkgs/development/libraries/libjpeg/default.nix6
-rw-r--r--pkgs/development/libraries/libpng/12.nix9
-rw-r--r--pkgs/development/libraries/openssl/cert-file.patch14
-rw-r--r--pkgs/development/libraries/openssl/default.nix8
-rw-r--r--pkgs/development/libraries/pcre/default.nix16
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/default.nix3
-rw-r--r--pkgs/development/libraries/zlib/default.nix2
-rw-r--r--pkgs/development/mobile/xpwn/default.nix28
-rw-r--r--pkgs/development/tools/build-managers/cmake/default.nix8
-rw-r--r--pkgs/development/tools/misc/binutils-cross/builder.sh26
-rw-r--r--pkgs/development/tools/misc/binutils-cross/default.nix13
19 files changed, 192 insertions, 87 deletions
diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix
index 3ed0f7ad0e6d..af1113226980 100644
--- a/pkgs/development/compilers/gcc/4.6/default.nix
+++ b/pkgs/development/compilers/gcc/4.6/default.nix
@@ -159,10 +159,8 @@ let version = "4.6.3";
             # 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 "")
+            # To keep ABI compatibility with upstream mingw-w64
+            " --enable-fully-dynamic-string"
             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.
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index 890122fe4770..4f9e734d41c0 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -117,7 +117,8 @@ let version = "4.8.2";
         withMode;
 
     /* Cross-gcc settings */
-    crossMingw = (cross != null && cross.libc == "msvcrt");
+    crossMingw = cross != null && cross.libc == "msvcrt";
+    crossDarwin = cross != null && cross.libc == "libSystem";
     crossConfigureFlags = let
         gccArch = stdenv.cross.gcc.arch or null;
         gccCpu = stdenv.cross.gcc.cpu or null;
@@ -161,7 +162,13 @@ let version = "4.8.2";
           " --disable-shared" +
           " --disable-decimal-float" # libdecnumber requires libc
           else
-          " --with-headers=${libcCross}/include" +
+          (if crossDarwin then " --with-sysroot=${libcCross}/share/sysroot"
+           else                " --with-headers=${libcCross}/include") +
+          # Ensure that -print-prog-name is able to find the correct programs.
+          (stdenv.lib.optionalString (crossMingw || crossDarwin) (
+            " --with-as=${binutilsCross}/bin/${cross.config}-as" +
+            " --with-ld=${binutilsCross}/bin/${cross.config}-ld"
+          )) +
           " --enable-__cxa_atexit" +
           " --enable-long-long" +
           (if crossMingw then
@@ -175,10 +182,8 @@ let version = "4.8.2";
             # 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 "")
+            # To keep ABI compatibility with upstream mingw-w64
+            " --enable-fully-dynamic-string"
             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.
@@ -346,6 +351,7 @@ stdenv.mkDerivation ({
         ++ optional langAda      "ada"
         ++ optional langVhdl     "vhdl"
         ++ optional langGo       "go"
+        ++ optionals crossDarwin [ "objc" "obj-c++" ]
         )
       )
     }
diff --git a/pkgs/development/interpreters/lua-5/5.2.nix b/pkgs/development/interpreters/lua-5/5.2.nix
index 3e7323e461d1..f346b1b09868 100644
--- a/pkgs/development/interpreters/lua-5/5.2.nix
+++ b/pkgs/development/interpreters/lua-5/5.2.nix
@@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
     sha256 = "004zyh9p3lpvbwhyhlmrw6wwcia5abx84q4h2brkn4zdypipvmiz";
   };
 
-  buildInputs = [ readline ];
+  nativeBuildInputs = [ readline ];
 
   patches = if stdenv.isDarwin then [ ./5.2.darwin.patch ] else [ dsoPatch ];
 
@@ -54,6 +54,37 @@ stdenv.mkDerivation rec {
     EOF
   '';
 
+  crossAttrs = let
+    isMingw = stdenv.cross.libc == "msvcrt";
+    isDarwin = stdenv.cross.libc == "libSystem";
+  in {
+    configurePhase = ''
+      makeFlagsArray=(
+        INSTALL_TOP=$out
+        INSTALL_MAN=$out/share/man/man1
+        CC=${stdenv.cross.config}-gcc
+        STRIP=:
+        RANLIB=${stdenv.cross.config}-ranlib
+        V=${majorVersion}
+        R=${version}
+        ${if isMingw then "mingw" else stdenv.lib.optionalString isDarwin ''
+        AR="${stdenv.cross.config}-ar rcu"
+        macosx
+        ''}
+      )
+    '' + stdenv.lib.optionalString isMingw ''
+      installFlagsArray=(
+        TO_BIN="lua.exe luac.exe"
+        TO_LIB="liblua.a lua52.dll"
+        INSTALL_DATA="cp -d"
+      )
+    '';
+  } // stdenv.lib.optionalAttrs isDarwin {
+    postPatch = ''
+      sed -i -e 's/-Wl,-soname[^ ]* *//' src/Makefile
+    '';
+  };
+
   meta = {
     homepage = "http://www.lua.org";
     description = "Powerful, fast, lightweight, embeddable scripting language";
diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix
index e58397fa9a5b..ee3640fe64b4 100644
--- a/pkgs/development/libraries/SDL/default.nix
+++ b/pkgs/development/libraries/SDL/default.nix
@@ -7,21 +7,13 @@
 
 # OSS is no longer supported, for it's much crappier than ALSA and
 # PulseAudio.
-assert alsaSupport || pulseaudioSupport;
+assert !(stdenv ? cross) -> alsaSupport || pulseaudioSupport;
 
 assert openglSupport -> (mesa != null && x11Support);
 assert x11Support -> (x11 != null && libXrandr != null);
 assert alsaSupport -> alsaLib != null;
 assert pulseaudioSupport -> pulseaudio != null;
 
-let
-  configureFlagsFun = attrs: ''
-        --disable-oss --disable-video-x11-xme
-        --disable-x11-shared --disable-alsa-shared --enable-rpath --disable-pulseaudio-shared
-        --disable-osmesa-shared
-        ${if alsaSupport then "--with-alsa-prefix=${attrs.alsaLib}/lib" else ""}
-      '';
-in
 stdenv.mkDerivation rec {
   version = "1.2.15";
   name    = "SDL-${version}";
@@ -32,20 +24,46 @@ stdenv.mkDerivation rec {
   };
 
   # Since `libpulse*.la' contain `-lgdbm', PulseAudio must be propagated.
-  propagatedBuildInputs = stdenv.lib.optionals x11Support [ x11 libXrandr ] ++
+  propagatedNativeBuildInputs =
+    stdenv.lib.optionals x11Support [ x11 libXrandr ] ++
     stdenv.lib.optional pulseaudioSupport pulseaudio;
 
-  buildInputs = [ pkgconfig audiofile ] ++
+  buildInputs = let
+    notMingw = !(stdenv ? cross) || stdenv.cross.libc != "msvcrt";
+  in stdenv.lib.optional notMingw audiofile;
+
+  nativeBuildInputs = [ pkgconfig ] ++
     stdenv.lib.optional openglSupport [ mesa ] ++
     stdenv.lib.optional alsaSupport alsaLib;
 
   # XXX: By default, SDL wants to dlopen() PulseAudio, in which case
   # we must arrange to add it to its RPATH; however, `patchelf' seems
   # to fail at doing this, hence `--disable-pulseaudio-shared'.
-  configureFlags = configureFlagsFun { inherit alsaLib; };
+  configureFlags = [
+    "--disable-oss"
+    "--disable-video-x11-xme"
+    "--disable-x11-shared"
+    "--disable-alsa-shared"
+    "--enable-rpath"
+    "--disable-pulseaudio-shared"
+    "--disable-osmesa-shared"
+  ] ++ stdenv.lib.optionals (stdenv ? cross) ([
+    "--without-x"
+  ] ++ stdenv.lib.optional alsaSupport "--with-alsa-prefix=${alsaLib}/lib");
 
-  crossAttrs = {
-      configureFlags = configureFlagsFun { alsaLib = alsaLib.crossDrv; };
+  crossAttrs =stdenv.lib.optionalAttrs (stdenv.cross.libc == "libSystem") {
+    patches = let
+      f = rev: sha256: fetchurl {
+        url = "http://hg.libsdl.org/SDL/raw-rev/${rev}";
+        inherit sha256;
+      };
+    in [
+      (f "e9466ead70e5" "0ygir3k83d0vxp7s3k48jn3j8n2bnv9wm6613wpx3ybnjrxabrip")
+      (f "bbfb41c13a87" "17v29ybjifvka19m8qf14rjc43nfdwk9v9inaizznarhb17amlnv")
+    ];
+    postPatch = ''
+      sed -i -e 's/ *-fpascal-strings//' configure
+    '';
   };
 
   passthru = {inherit openglSupport;};
diff --git a/pkgs/development/libraries/audiofile/default.nix b/pkgs/development/libraries/audiofile/default.nix
index a5fd80dc0db9..c8fb8c53dc0c 100644
--- a/pkgs/development/libraries/audiofile/default.nix
+++ b/pkgs/development/libraries/audiofile/default.nix
@@ -3,7 +3,7 @@
 stdenv.mkDerivation rec {
   name = "audiofile-0.3.6";
 
-  buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib;
+  nativeBuildInputs = stdenv.lib.optional stdenv.isLinux alsaLib;
 
   src = fetchurl {
     url = "http://audiofile.68k.org/${name}.tar.gz";
diff --git a/pkgs/development/libraries/glew/default.nix b/pkgs/development/libraries/glew/default.nix
index ef81f210d39f..9ec88799d0dd 100644
--- a/pkgs/development/libraries/glew/default.nix
+++ b/pkgs/development/libraries/glew/default.nix
@@ -1,5 +1,7 @@
 { stdenv, fetchurl, mesa_glu, x11, libXmu, libXi }:
 
+with stdenv.lib;
+
 stdenv.mkDerivation rec {
   name = "glew-1.10.0";
 
@@ -8,23 +10,38 @@ stdenv.mkDerivation rec {
     sha256 = "01zki46dr5khzlyywr3cg615bcal32dazfazkf360s1znqh17i4r";
   };
 
-
-  buildInputs = [ x11 libXmu libXi ];
-  propagatedBuildInputs = [ mesa_glu ]; # GL/glew.h includes GL/glu.h
+  nativeBuildInputs = [ x11 libXmu libXi ];
+  propagatedNativeBuildInputs = [ mesa_glu ]; # GL/glew.h includes GL/glu.h
 
   patchPhase = ''
     sed -i 's|lib64|lib|' config/Makefile.linux
+    ${optionalString (stdenv ? cross) ''
+    sed -i -e 's/\(INSTALL.*\)-s/\1/' Makefile
+    ''}
+  '';
+
+  buildFlags = [ "all" ];
+  installFlags = [ "install.all" ];
+
+  preInstall = ''
+    export GLEW_DEST="$out"
   '';
 
-buildPhase = "make all";
-  installPhase = ''
-    GLEW_DEST=$out make install.all
+  postInstall = ''
     mkdir -pv $out/share/doc/glew
     mkdir -p $out/lib/pkgconfig
     cp glew*.pc $out/lib/pkgconfig
     cp -r README.txt LICENSE.txt doc $out/share/doc/glew
   '';
 
+  crossAttrs.makeFlags = [
+    "CC=${stdenv.cross.config}-gcc"
+    "LD=${stdenv.cross.config}-gcc"
+    "AR=${stdenv.cross.config}-ar"
+    "STRIP="
+  ] ++ optional (stdenv.cross.libc == "msvcrt") "SYSTEM=mingw"
+    ++ optional (stdenv.cross.libc == "libSystem") "SYSTEM=darwin";
+
   meta = {
     description = "An OpenGL extension loading library for C(++)";
     homepage = http://glew.sourceforge.net/;
diff --git a/pkgs/development/libraries/libgcrypt/1.6.nix b/pkgs/development/libraries/libgcrypt/1.6.nix
index ea981f7ed127..9dc8b8a23179 100644
--- a/pkgs/development/libraries/libgcrypt/1.6.nix
+++ b/pkgs/development/libraries/libgcrypt/1.6.nix
@@ -24,6 +24,12 @@ stdenv.mkDerivation rec {
     make check
   '';
 
+  crossAttrs = let
+    isCross64 = stdenv.cross.config == "x86_64-w64-mingw32";
+  in stdenv.lib.optionalAttrs isCross64 {
+    configureFlags = [ "--disable-asm" "--disable-padlock-support" ];
+  };
+
   meta = {
     description = "GNU Libgcrypt, a general-pupose cryptographic library";
 
diff --git a/pkgs/development/libraries/libgpg-error/default.nix b/pkgs/development/libraries/libgpg-error/default.nix
index da142a957ad7..8ce9a10701ec 100644
--- a/pkgs/development/libraries/libgpg-error/default.nix
+++ b/pkgs/development/libraries/libgpg-error/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, bash }:
+{ stdenv, fetchurl, bash, gettext }:
 
 stdenv.mkDerivation (rec {
   name = "libgpg-error-1.12";
@@ -8,6 +8,10 @@ stdenv.mkDerivation (rec {
     sha256 = "0pz58vr12qihq2f0bypjxsb6cf6ajq5258fmfm8s6lvwm3b9xz6a";
   };
 
+  # If architecture-dependant MO files aren't available, they're generated
+  # during build, so we need gettext for cross-builds.
+  crossAttrs.buildInputs = [ gettext ];
+
   doCheck = true;
 
   meta = {
diff --git a/pkgs/development/libraries/libjpeg/default.nix b/pkgs/development/libraries/libjpeg/default.nix
index 63d698dda18f..d7a1bcb46385 100644
--- a/pkgs/development/libraries/libjpeg/default.nix
+++ b/pkgs/development/libraries/libjpeg/default.nix
@@ -1,4 +1,6 @@
-{ stdenv, fetchurl }: 
+{ stdenv, fetchurl, static ? false }: 
+
+with stdenv.lib;
 
 stdenv.mkDerivation {
   name = "libjpeg-8d";
@@ -7,6 +9,8 @@ stdenv.mkDerivation {
     url = http://www.ijg.org/files/jpegsrc.v8d.tar.gz;
     sha256 = "1cz0dy05mgxqdgjf52p54yxpyy95rgl30cnazdrfmw7hfca9n0h0";
   };
+
+  configureFlags = optional static "--enable-static --disable-shared";
   
   meta = {
     homepage = http://www.ijg.org/;
diff --git a/pkgs/development/libraries/libpng/12.nix b/pkgs/development/libraries/libpng/12.nix
index 094483da660a..ff04c7181df5 100644
--- a/pkgs/development/libraries/libpng/12.nix
+++ b/pkgs/development/libraries/libpng/12.nix
@@ -1,6 +1,6 @@
 { stdenv, fetchurl, zlib, xz }:
 
-assert zlib != null;
+assert !(stdenv ? cross) -> zlib != null;
 
 stdenv.mkDerivation rec {
   name = "libpng-1.2.51";
@@ -16,6 +16,13 @@ stdenv.mkDerivation rec {
 
   passthru = { inherit zlib; };
 
+  crossAttrs = stdenv.lib.optionalAttrs (stdenv.cross.libc == "libSystem") {
+    propagatedBuildInputs = [];
+    passthru = {};
+  };
+
+  configureFlags = "--enable-static";
+
   meta = {
     description = "The official reference implementation for the PNG file format";
     homepage = http://www.libpng.org/pub/png/libpng.html;
diff --git a/pkgs/development/libraries/openssl/cert-file.patch b/pkgs/development/libraries/openssl/cert-file.patch
index 6b7a60e90267..26b51c0295e0 100644
--- a/pkgs/development/libraries/openssl/cert-file.patch
+++ b/pkgs/development/libraries/openssl/cert-file.patch
@@ -12,7 +12,7 @@ diff -ru -x '*~' openssl-1.0.0e-orig/crypto/x509/x509_def.c openssl-1.0.0e/crypt
  #include "cryptlib.h"
  #include <openssl/crypto.h>
  #include <openssl/x509.h>
-@@ -71,7 +75,19 @@
+@@ -71,7 +75,25 @@
  	{ return(X509_CERT_DIR); }
  
  const char *X509_get_default_cert_file(void)
@@ -23,9 +23,15 @@ diff -ru -x '*~' openssl-1.0.0e-orig/crypto/x509/x509_def.c openssl-1.0.0e/crypt
 +	if (!init) {
 +	    init = 1;
 +	    char * s = getenv("OPENSSL_X509_CERT_FILE");
-+	    if (s && getuid() == geteuid()) {
-+		strncpy(buf, s, sizeof(buf));
-+		buf[sizeof(buf) - 1] = 0;
++	    if (s) {
++#ifndef OPENSSL_SYS_WINDOWS
++	        if (getuid() == geteuid()) {
++#endif
++		        strncpy(buf, s, sizeof(buf));
++		        buf[sizeof(buf) - 1] = 0;
++#ifndef OPENSSL_SYS_WINDOWS
++	        }
++#endif
 +	    }
 +	}
 +	return buf;
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index 0d57018dcd6f..7217c876bfd9 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -8,7 +8,9 @@ let
     (throw "openssl needs its platform name cross building" null)
     stdenv.cross;
 
-  patchesCross = isCross:
+  patchesCross = isCross: let
+    isDarwin = stdenv.isDarwin || (isCross && stdenv.cross.libc == "libSystem");
+  in
     [ # Allow the location of the X509 certificate file (the CA
       # bundle) to be set through the environment variable
       # ‘OPENSSL_X509_CERT_FILE’.  This is necessary because the
@@ -29,7 +31,7 @@ let
           ./kfreebsd-gnu.patch
         ]
 
-    ++ stdenv.lib.optional stdenv.isDarwin ./darwin-arch.patch;
+    ++ stdenv.lib.optional isDarwin ./darwin-arch.patch;
 
 in
 
@@ -91,6 +93,8 @@ stdenv.mkDerivation {
       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";
   };
 
   meta = {
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index 51279701d4a5..7138c44da643 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -1,4 +1,8 @@
-{ stdenv, fetchurl, unicodeSupport ? true, cplusplusSupport ? true }:
+{ stdenv, fetchurl, unicodeSupport ? true, cplusplusSupport ? true
+, windows ? null
+}:
+
+with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "pcre-8.34";
@@ -16,12 +20,16 @@ stdenv.mkDerivation rec {
     --enable-jit
     ${if unicodeSupport then "--enable-unicode-properties" else ""}
     ${if !cplusplusSupport then "--disable-cpp" else ""}
-  '' + stdenv.lib.optionalString stdenv.isDarwin "CXXFLAGS=-O0";
+  '' + optionalString stdenv.isDarwin "CXXFLAGS=-O0";
 
   doCheck = with stdenv; !(isCygwin || isFreeBSD);
     # XXX: test failure on Cygwin
     # we are running out of stack on both freeBSDs on Hydra
 
+  crossAttrs = optionalAttrs (stdenv.cross.libc == "msvcrt") {
+    buildInputs = [ windows.mingw_w64_pthreads.crossDrv ];
+  };
+
   meta = {
     homepage = "http://www.pcre.org/";
     description = "A library for Perl Compatible Regular Expressions";
@@ -35,7 +43,7 @@ stdenv.mkDerivation rec {
       PCRE library is free, even for building proprietary software.
     '';
 
-    platforms = stdenv.lib.platforms.all;
-    maintainers = [ stdenv.lib.maintainers.simons ];
+    platforms = platforms.all;
+    maintainers = [ maintainers.simons ];
   };
 }
diff --git a/pkgs/development/libraries/qt-4.x/4.8/default.nix b/pkgs/development/libraries/qt-4.x/4.8/default.nix
index 16bd1ee65d2e..1bd027f52986 100644
--- a/pkgs/development/libraries/qt-4.x/4.8/default.nix
+++ b/pkgs/development/libraries/qt-4.x/4.8/default.nix
@@ -148,8 +148,7 @@ stdenv.mkDerivation rec {
   '';
 
   crossAttrs = let
-    isMingw = stdenv.cross.config == "i686-pc-mingw32" ||
-      stdenv.cross.config == "x86_64-w64-mingw32";
+    isMingw = stdenv.cross.libc == "msvcrt";
   in {
     # I've not tried any case other than i686-pc-mingw32.
     # -nomake tools:   it fails linking some asian language symbols
diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix
index f1eea80ab7a3..088eb1b94930 100644
--- a/pkgs/development/libraries/zlib/default.nix
+++ b/pkgs/development/libraries/zlib/default.nix
@@ -36,6 +36,8 @@ stdenv.mkDerivation rec {
       "-f" "win32/Makefile.gcc"
       "PREFIX=${stdenv.cross.config}-"
     ] ++ (if static then [] else [ "SHARED_MODE=1" ]);
+  } // stdenv.lib.optionalAttrs (stdenv.cross.libc == "libSystem") {
+    makeFlags = [ "RANLIB=${stdenv.cross.config}-ranlib" ];
   };
 
   # zlib doesn't like the automatic --disable-shared from the Cygwin stdenv.
diff --git a/pkgs/development/mobile/xpwn/default.nix b/pkgs/development/mobile/xpwn/default.nix
new file mode 100644
index 000000000000..b248107141f5
--- /dev/null
+++ b/pkgs/development/mobile/xpwn/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchgit, cmake, zlib, libpng, bzip2, libusb, openssl }:
+
+stdenv.mkDerivation {
+  name = "xpwn-0.5.8git";
+
+  src = fetchgit {
+    url = "git://github.com/dborca/xpwn.git";
+    rev = "4534da88d4e8a32cdc9da9b5326e2cc482c95ef0";
+    sha256 =
+      "1h1ak40fg5bym0hifpii9q2hqdp2m387cwfzb4bl6qq36xpkd6wv";
+  };
+
+  preConfigure = ''
+    sed -r -i \
+      -e 's/(install.*TARGET.*DESTINATION )\.\)/\1bin)/' \
+      -e 's!(install.*(FILE|DIR).*DESTINATION )([^)]*)!\1share/xpwn/\3!' \
+      */CMakeLists.txt
+    sed -i -e '/install/d' CMakeLists.txt
+  '';
+
+  buildInputs = [ cmake zlib libpng bzip2 libusb openssl ];
+
+  meta = {
+    homepage = "http://planetbeing.lighthouseapp.com/projects/15246-xpwn";
+    description = "Custom NOR firmware loader/IPSW generator for the iPhone";
+    license = stdenv.lib.licenses.gpl3Plus;
+  };
+}
diff --git a/pkgs/development/tools/build-managers/cmake/default.nix b/pkgs/development/tools/build-managers/cmake/default.nix
index 9ce69374cd88..42277b22036b 100644
--- a/pkgs/development/tools/build-managers/cmake/default.nix
+++ b/pkgs/development/tools/build-managers/cmake/default.nix
@@ -26,7 +26,13 @@ stdenv.mkDerivation rec {
   patches =
     # Don't search in non-Nix locations such as /usr, but do search in
     # Nixpkgs' Glibc. 
-    optional (stdenv ? glibc) ./search-path.patch;
+    optional (stdenv ? glibc) ./search-path.patch ++
+    optional (stdenv ? cross) (fetchurl {
+      name = "fix-darwin-cross-compile.patch";
+      url = "http://public.kitware.com/Bug/file_download.php?"
+          + "file_id=4981&type=bug";
+      sha256 = "16acmdr27adma7gs9rs0dxdiqppm15vl3vv3agy7y8s94wyh4ybv";
+    });
 
   buildInputs = [ curl expat zlib bzip2 libarchive ]
     ++ optional useNcurses ncurses
diff --git a/pkgs/development/tools/misc/binutils-cross/builder.sh b/pkgs/development/tools/misc/binutils-cross/builder.sh
deleted file mode 100644
index 29d3b3779b6a..000000000000
--- a/pkgs/development/tools/misc/binutils-cross/builder.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-source $stdenv/setup
-
-if test $cross = "arm-linux" ; then
-  configureFlags="--target=arm-linux"
-elif test $cross = "mips-linux" ; then
-  configureFlags="--target=mips-linux"
-elif test $cross = "mipsel-linux" ; then
-  configureFlags="--target=mipsel-linux"
-elif test $cross = "sparc-linux" ; then
-  configureFlags="--target=sparc-linux"
-elif test $cross = "powerpc-linux" ; then
-  configureFlags="--target=powerpc-linux"
-elif test $cross = "ppc-linux" ; then
-  configureFlags="--target=powerpc-linux"
-fi
-
-patchConfigure() {
-    # Clear the default library search path.
-    if test "$noSysDirs" = "1"; then
-        echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
-    fi
-}
-
-preConfigure=patchConfigure
-
-genericBuild
diff --git a/pkgs/development/tools/misc/binutils-cross/default.nix b/pkgs/development/tools/misc/binutils-cross/default.nix
deleted file mode 100644
index 7d77baced373..000000000000
--- a/pkgs/development/tools/misc/binutils-cross/default.nix
+++ /dev/null
@@ -1,13 +0,0 @@
-{stdenv, fetchurl, noSysDirs, cross}:
-
-stdenv.mkDerivation {
-  name = "binutils-2.16.1";
-  builder = ./builder.sh;
-  src = fetchurl {
-    url = http://ftp.nluug.nl/gnu/binutils/binutils-2.16.1.tar.bz2;
-    md5 = "6a9d529efb285071dad10e1f3d2b2967";
-  };
-  inherit noSysDirs;
-  #configureFlags = if cross=="arm-linux" then "--target=arm-linux" else if cross=="mips-linux" then "--target=mips-linux" else if cross=="sparc-linux" then "--target=sparc-linux"; 
-  inherit cross;
-}