biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / simavr / setup-hook-darwin.sh
blob3861e45973ac49ad3849b20d8389b86d2361e157
2 fixupCFlagsForDarwin() {
3 # Because it’s getting called from a Darwin stdenv, avr-gcc will pick up on
4 # Darwin-specific flags, and it will barf and die on -iframework in
5 # particular. Strip them out, so simavr can compile its test firmware.
6 cflagsFilter='s|-F[^ ]*||g;s|-iframework [^ ]*||g;s|-isystem [^ ]*||g;s| *| |g'
8 # The `CoreFoundation` reference is added by `linkSystemCoreFoundationFramework` in the
9 # Apple SDK’s setup hook. Remove that because avr-gcc will fail due to file not found.
10 ldFlagsFilter='s|/nix/store/[^-]*-apple-framework-CoreFoundation[^ ]*||g'
12 # `cc-wrapper.sh`` supports getting flags from a system-specific salt. While it is currently a
13 # tuple, that’s not considered a stable interface, so the derivation will provide them.
14 export NIX_CFLAGS_COMPILE_@darwinSuffixSalt@=${NIX_CFLAGS_COMPILE-}
15 export NIX_LDFLAGS_@darwinSuffixSalt@=${NIX_LDFLAGS-}
17 echo removing @darwinSuffixSalt@-specific flags from NIX_CFLAGS_COMPILE for @avrSuffixSalt@
18 export NIX_CFLAGS_COMPILE_@avrSuffixSalt@+="$(sed "$cflagsFilter" <<< "$NIX_CFLAGS_COMPILE")"
19 echo removing @darwinSuffixSalt@-specific flags from NIX_LDFLAGS for @avrSuffixSalt@
20 export NIX_LDFLAGS_@avrSuffixSalt@+="$(sed "$ldFlagsFilter;$cflagsFilter" <<< "$NIX_LDFLAGS")"
22 # Make sure the global flags aren’t accidentally influencing the platform-specific flags.
23 export NIX_CFLAGS_COMPILE=""
24 export NIX_LDFLAGS=""
27 # This is pretty hacky, but this hook _must_ run after `linkSystemCoreFoundationFramework`.
28 function runFixupCFlagsForDarwinLast() {
29 preConfigureHooks+=(fixupCFlagsForDarwin)
32 if [ -z "${dontFixupCFlagsForDarwin-}" ]; then
33 postUnpackHooks+=(runFixupCFlagsForDarwinLast)