From ca5d91aa608224368d93599416dd97b16cbe6bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 21 Nov 2009 10:44:22 +0000 Subject: [PATCH] Made more libraries cross compile. fontconfig, libxcb, bzip2, libdrm, zlib... I was trying to cross compile SDL. Many dependencies work, but I ended seeing libX11 not ready for cross compilation. Other xorg libraries cross-compile well. libX11 may need a small patch. The problem is the usual "configure test cannot be run in cross compilation", so the configure script halts. I made the pkgconfig expression always return buildDrv, as I think it rarely will be needed as buildInput. So to avoid rewriting all its mentions to use it as buildNativeInput, I prefered this small change. svn path=/nixpkgs/branches/stdenv-updates/; revision=18500 --- pkgs/development/libraries/fontconfig/default.nix | 8 ++++++++ pkgs/development/libraries/libdrm/default.nix | 7 +++++++ pkgs/development/libraries/zlib/default.nix | 7 +++++++ pkgs/servers/x11/xorg/overrides.nix | 12 +++++++++++- pkgs/top-level/all-packages.nix | 7 ++++++- 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index 1f1074096839..aa3ab19bf334 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -13,6 +13,14 @@ stdenv.mkDerivation rec { configureFlags = "--with-confdir=/etc/fonts --with-cache-dir=/var/cache/fontconfig --disable-docs --with-default-fonts="; + crossArch = stdenv.cross.arch; + + preConfigure = '' + if test -n "$crossConfig"; then + configureFlags="$configureFlags --with-arch=$crossArch"; + fi + ''; + # Don't try to write to /etc/fonts or /var/cache/fontconfig at install time. installFlags = "CONFDIR=$(out)/etc/fonts RUN_FC_CACHE_TEST=false fc_cachedir=$(TMPDIR)/dummy"; diff --git a/pkgs/development/libraries/libdrm/default.nix b/pkgs/development/libraries/libdrm/default.nix index 53c66ae7c151..ea10c3ee8d2c 100644 --- a/pkgs/development/libraries/libdrm/default.nix +++ b/pkgs/development/libraries/libdrm/default.nix @@ -10,6 +10,13 @@ stdenv.mkDerivation rec { buildInputs = [ pkgconfig libpthreadstubs ]; + preConfigure = '' + # General case: non intel. + if test -n "$crossConfig"; then + configureFlags="$configureFlags --disable-intel"; + fi + ''; + meta = { homepage = http://dri.freedesktop.org/libdrm/; description = "Library for accessing the kernel's Direct Rendering Manager"; diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index f59182c2ba58..b4ae9e63ea08 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -8,6 +8,13 @@ stdenv.mkDerivation { }; configureFlags = if static then "" else "--shared"; + preConfigure = '' + if test -n "$crossConfig"; then + export CC=$crossConfig-gcc + configureFlags=${if static then "" else "--shared"} + fi + ''; + # zlib doesn't like the automatic --disable-shared from the Cygwin stdenv. cygwinConfigureEnableShared = true; } diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix index 23937c8978e2..8114567c1b6f 100644 --- a/pkgs/servers/x11/xorg/overrides.nix +++ b/pkgs/servers/x11/xorg/overrides.nix @@ -22,7 +22,17 @@ }; libxcb = attrs : attrs // { - buildInputs = attrs.buildInputs ++ [ xorg.xproto ]; + # I only remove python from the original, and add xproto. I don't know how + # to achieve that referring to attrs.buildInputs. + buildInputs = [args.pkgconfig args.libxslt xorg.libpthreadstubs /*xorg.python*/ + xorg.libXau xorg.xcbproto xorg.libXdmcp ] ++ [ xorg.xproto ]; + buildNativeInputs = [ args.python ]; + }; + + xcbproto = attrs : attrs // { + # I only remove python from the original. + buildInputs = [args.pkgconfig /*xorg.python*/ ]; + buildNativeInputs = [ args.python ]; }; libXext = attrs: attrs // { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2fb6471ed079..899765315840 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2874,11 +2874,16 @@ let * pkgconfig is optionally taken from the stdenv to allow bootstrapping * of glib and pkgconfig itself on MinGW. */ - pkgconfig = useFromStdenv "pkgconfig" + pkgconfigReal = useFromStdenv "pkgconfig" (import ../development/tools/misc/pkgconfig { inherit fetchurl stdenv; }); + /* Make pkgconfig always return a buildDrv, never a proper hostDrv, + because most usage of pkgconfig as buildInput (inheritance of + pre-cross nixpkgs) means using it using as buildNativeInput */ + pkgconfig = pkgconfigReal // { hostDrv = pkgconfigReal.buildDrv; }; + radare = import ../development/tools/analysis/radare { inherit stdenv fetchurl pkgconfig libusb readline gtkdialog python ruby libewf perl;