1 { appleDerivation, lib, stdenv, buildPackages, python3 }:
4 formatVersionNumeric = version:
6 versionParts = lib.versions.splitVersion version;
7 major = lib.toInt (lib.elemAt versionParts 0);
8 minor = lib.toInt (lib.elemAt versionParts 1);
9 patch = if lib.length versionParts > 2 then lib.toInt (lib.elemAt versionParts 2) else 0;
10 in toString (major * 10000 + minor * 100 + patch);
14 patches = [ ./suppress-icu-check-crash.patch ];
16 nativeBuildInputs = [ python3 ];
18 depsBuildBuild = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ buildPackages.stdenv.cc ];
21 substituteInPlace makefile \
22 --replace-fail "/usr/bin/" "" \
23 --replace-fail "xcrun --sdk macosx --find" "echo -n" \
24 --replace-fail "xcrun --sdk macosx.internal --show-sdk-path" "echo -n /dev/null" \
25 --replace-fail "-install_name " "-install_name $out" \
26 --replace-fail '-x -u -r -S' '-x --keep-undefined -S'
28 substituteInPlace icuSources/config/mh-darwin \
29 --replace-fail "-install_name " "-install_name $out/"
31 # drop using impure /var/db/timezone/icutz
32 substituteInPlace makefile \
33 --replace-fail '-DU_TIMEZONE_FILES_DIR=\"\\\"$(TZDATA_LOOKUP_DIR)\\\"\" -DU_TIMEZONE_PACKAGE=\"\\\"$(TZDATA_PACKAGE)\\\"\"' ""
35 # FIXME: This will cause `ld: warning: OS version (12.0) too small, changing to 13.0.0`, APPLE should fix it.
36 substituteInPlace makefile \
37 --replace-fail "ZIPPERING_LDFLAGS=-Wl,-iosmac_version_min,12.0" "ZIPPERING_LDFLAGS="
39 # skip test for missing encodingSamples data
40 substituteInPlace icuSources/test/cintltst/ucsdetst.c \
41 --replace-fail "&TestMailFilterCSS" "NULL"
43 patchShebangs icuSources
44 '' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
46 # This looks like a bug in the makefile. It defines ENV_BUILDHOST to
47 # propagate the correct value of CC, CXX, etc, but has the following double
48 # expansion that results in the empty string.
49 substituteInPlace makefile \
50 --replace-fail '$($(ENV_BUILDHOST))' '$(ENV_BUILDHOST)'
53 # APPLE is using makefile to save its default configuration and call ./configure, so we hack makeFlags
54 # instead of configuring ourself, trying to stay abreast of APPLE.
59 # remove /usr prefix on include and lib
63 "DATA_INSTALL_DIR=/share/icu/"
64 "DATA_LOOKUP_DIR=$(DSTROOT)$(DATA_INSTALL_DIR)"
65 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # darwin* platform properties are only defined on darwin
66 # hack to use our lower macos version
67 "MAC_OS_X_VERSION_MIN_REQUIRED=${formatVersionNumeric stdenv.hostPlatform.darwinMinVersion}"
68 "ICU_TARGET_VERSION=-m${stdenv.hostPlatform.darwinPlatform}-version-min=${stdenv.hostPlatform.darwinMinVersion}"
70 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
73 "RC_ARCHS=${stdenv.hostPlatform.darwinArch}"
76 "CC=${stdenv.cc.targetPrefix}cc"
77 "CXX=${stdenv.cc.targetPrefix}c++"
79 "OSX_HOST_VERSION_MIN_STRING=${stdenv.buildPlatform.darwinMinVersion}"
83 checkTarget = "check";
86 # we don't need all those in usr/local