ocamlPackages.camlp5: 8.03.00 → 8.03.01
[NixPkgs.git] / pkgs / build-support / bintools-wrapper / add-darwin-ldflags-before.sh
blob75d9484846a8cb544de5dccb6e248f5877f57972
1 # Unconditionally adding in platform version flags will result in warnings that
2 # will be treated as errors by some packages. Add any missing flags here.
4 # There are two things to be configured: the "platform version" (oldest
5 # supported version of macos, ios, etc), and the "sdk version".
7 # The modern way of configuring these is to use:
8 # -platform_version $platform $platform_version $sdk_version"
10 # The old way is still supported, and uses flags like:
11 # -${platform}_version_min $platform_version
12 # -sdk_version $sdk_version
14 # If both styles are specified ld will combine them. If multiple versions are
15 # specified for the same platform, ld will emit an error.
17 # The following adds flags for whichever properties have not already been
18 # provided.
20 havePlatformVersionFlag=
21 haveDarwinSDKVersion=
22 haveDarwinPlatformVersion=
24 # Roles will set by add-flags.sh, but add-flags.sh can be skipped when the
25 # cc-wrapper has added the linker flags. Both the cc-wrapper and the binutils
26 # wrapper mangle the same variable (MACOSX_DEPLOYMENT_TARGET), so if roles are
27 # empty due to being run through the cc-wrapper then the mangle here is a no-op
28 # and we still do the right thing.
30 # To be robust, make sure we always have the correct set of roles.
31 accumulateRoles
33 mangleVarSingle @darwinMinVersionVariable@ ${role_suffixes[@]+"${role_suffixes[@]}"}
35 n=0
36 nParams=${#params[@]}
37 while (( n < nParams )); do
38 p=${params[n]}
39 case "$p" in
40 # the current platform
41 -@darwinPlatform@_version_min)
42 haveDarwinPlatformVersion=1
45 # legacy aliases
46 -macosx_version_min|-iphoneos_version_min|-iosmac_version_min|-uikitformac_version_min)
47 haveDarwinPlatformVersion=1
50 -sdk_version)
51 haveDarwinSDKVersion=1
54 -platform_version)
55 havePlatformVersionFlag=1
57 # If clang can't determine the sdk version it will pass 0.0.0. This
58 # has runtime effects so we override this to use the known sdk
59 # version.
60 if [ "${params[n+3]-}" = 0.0.0 ]; then
61 params[n+3]=@darwinSdkVersion@
64 esac
65 n=$((n + 1))
66 done
68 # If the caller has set -platform_version, trust they're doing the right thing.
69 # This will be the typical case for clang in nixpkgs.
70 if [ ! "$havePlatformVersionFlag" ]; then
71 if [ ! "$haveDarwinSDKVersion" ] && [ ! "$haveDarwinPlatformVersion" ]; then
72 # Nothing provided. Use the modern "-platform_version" to set both.
73 extraBefore+=(-platform_version @darwinPlatform@ "${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@}" @darwinSdkVersion@)
74 elif [ ! "$haveDarwinSDKVersion" ]; then
75 # Add missing sdk version
76 extraBefore+=(-sdk_version @darwinSdkVersion@)
77 elif [ ! "$haveDarwinPlatformVersion" ]; then
78 # Add missing platform version
79 extraBefore+=(-@darwinPlatform@_version_min "${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@}")