biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / emulators / wine / setup-hook-darwin.sh
blob39eee193ded621f1e1f009fd661f4788cb56c9ce
2 fixupCFlagsForDarwin() {
3 # Because it’s getting called from a Darwin stdenv, MinGW will pick up on Darwin-specific
4 # flags, and the ./configure tests will fail to consider it a working cross-compiler.
5 # Strip them out, so Wine can use MinGW to build its DLLs instead of trying to use Clang.
6 # Ideally, it would be possible to build the DLLs on Windows (i.e., as part of `pkgsCross``),
7 # but that is not the case currently with Wine’s build system.
8 cflagsFilter='s|-F[^ ]*||g;s|-iframework [^ ]*||g;s|-isystem [^ ]*||g;s| *| |g'
10 # libiconv and libintl aren’t needed by Wine, and having them causes linking to fail.
11 # The `CoreFoundation` reference is added by `linkSystemCoreFoundationFramework` in the
12 # Apple SDK’s setup hook. Remove that because MingW will fail due to file not found.
13 ldFlagsFilter='s|-lintl||g;s|-liconv||g;s|/nix/store/[^-]*-apple-framework-CoreFoundation[^ ]*||g'
15 # `cc-wrapper.sh`` supports getting flags from a system-specific salt. While it is currently a
16 # tuple, that’s not considered a stable interface, so the Wine derivation will provide them:
17 # - for Darwin: The source is `stdenv.cc.suffixSalt`; and
18 # - for MinGW: The source is the `suffixSalt`` attribute of each of the `mingwGccs`.
19 export NIX_CFLAGS_COMPILE_@darwinSuffixSalt@=${NIX_CFLAGS_COMPILE-}
20 export NIX_LDFLAGS_@darwinSuffixSalt@=${NIX_LDFLAGS-}
21 for mingwSalt in @mingwGccsSuffixSalts@; do
22 echo removing @darwinSuffixSalt@-specific flags from NIX_CFLAGS_COMPILE for $mingwSalt
23 export NIX_CFLAGS_COMPILE_$mingwSalt+="$(sed "$cflagsFilter" <<< "$NIX_CFLAGS_COMPILE")"
24 echo removing @darwinSuffixSalt@-specific flags from NIX_LDFLAGS for $mingwSalt
25 export NIX_LDFLAGS_$mingwSalt+="$(sed "$ldFlagsFilter;$cflagsFilter" <<< "$NIX_LDFLAGS")"
26 done
28 # Make sure the global flags aren’t accidentally influencing the platform-specific flags.
29 export NIX_CFLAGS_COMPILE=""
30 export NIX_LDFLAGS=""
33 # This is pretty hacky, but this hook _must_ run after `linkSystemCoreFoundationFramework`.
34 function runFixupCFlagsForDarwinLast() {
35 preConfigureHooks+=(fixupCFlagsForDarwin)
37 postUnpackHooks+=(runFixupCFlagsForDarwinLast)