From cbe172fa678615c903dce18dd8680c1cc2038cd8 Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Thu, 19 Nov 2020 17:21:44 +0900 Subject: darwin.ICU: cross compilation --- .../darwin/apple-source-releases/ICU/default.nix | 36 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/pkgs/os-specific/darwin/apple-source-releases/ICU/default.nix b/pkgs/os-specific/darwin/apple-source-releases/ICU/default.nix index 032b1447463..f2dd63cf2de 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/ICU/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/ICU/default.nix @@ -1,8 +1,20 @@ -{ appleDerivation, python3 }: +{ appleDerivation, lib, stdenv, buildPackages, python3 }: + +let + formatVersionNumeric = version: + let + versionParts = lib.versions.splitVersion version; + major = lib.toInt (lib.elemAt versionParts 0); + minor = lib.toInt (lib.elemAt versionParts 1); + patch = if lib.length versionParts > 2 then lib.toInt (lib.elemAt versionParts 2) else 0; + in toString (major * 10000 + minor * 100 + patch); +in appleDerivation { nativeBuildInputs = [ python3 ]; + depsBuildBuild = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ buildPackages.stdenv.cc ]; + postPatch = '' substituteInPlace makefile \ --replace "/usr/bin/" "" \ @@ -26,6 +38,13 @@ appleDerivation { --replace "&TestMailFilterCSS" "NULL" patchShebangs icuSources + '' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' + + # This looks like a bug in the makefile. It defines ENV_BUILDHOST to + # propagate the correct value of CC, CXX, etc, but has the following double + # expansion that results in the empty string. + substituteInPlace makefile \ + --replace '$($(ENV_BUILDHOST))' '$(ENV_BUILDHOST)' ''; # APPLE is using makefile to save its default configuration and call ./configure, so we hack makeFlags @@ -42,8 +61,19 @@ appleDerivation { "DATA_LOOKUP_DIR=$(DSTROOT)$(DATA_INSTALL_DIR)" # hack to use our lower macos version - "MAC_OS_X_VERSION_MIN_REQUIRED=__MAC_OS_X_VERSION_MIN_REQUIRED" - "OSX_HOST_VERSION_MIN_STRING=$(MACOSX_DEPLOYMENT_TARGET)" + "MAC_OS_X_VERSION_MIN_REQUIRED=${formatVersionNumeric stdenv.hostPlatform.darwinMinVersion}" + "ICU_TARGET_VERSION=-m${stdenv.hostPlatform.darwinPlatform}-version-min=${stdenv.hostPlatform.darwinMinVersion}" + ] + ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "CROSS_BUILD=YES" + "BUILD_TYPE=" + "RC_ARCHS=${stdenv.hostPlatform.darwinArch}" + "HOSTCC=cc" + "HOSTCXX=c++" + "CC=${stdenv.cc.targetPrefix}cc" + "CXX=${stdenv.cc.targetPrefix}c++" + "HOSTISYSROOT=" + "OSX_HOST_VERSION_MIN_STRING=${stdenv.buildPlatform.darwinMinVersion}" ]; doCheck = true; -- cgit 1.4.1