2 if [ -e "$NIX_ATTRS_SH_FILE" ]; then .
"$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh
]; then . .attrs.sh
; fi
7 printf "extracting $(basename $1) ...\n"
12 xz
-dc $1 |
tar "$tarflags" - ;;
14 printf "Make sure you give a iPhoneOS9.2.sdk.tar.xz file \n" ;;
18 function verify_arch
{
26 printf '%s is not an acceptable arch. Try one of %s' "$1" "$acc"
28 printf "$error_message\n"
33 function verify_sdk_version
{
34 sdk_version
=$
(basename "$1" |
grep -P -o "[0-9].[0-9]+")
35 case "$sdk_version" in
36 # Make sure the SDK is correct.
39 printf 'No iPhone SDK version in file name\n'
46 printf "usage: $0 iPhoneOS.sdk.tar* <target cpu>\n" 1>&2
47 printf "i.e. $0 /path/to/iPhoneOS.sdk.tar.xz armv7\n" 1>&2
53 chmod -R 755 "$cctools_port"
55 pushd "$cctools_port"/usage_examples
/ios_toolchain
&> /dev
/null
60 triple
='%s-apple-darwin11'
61 target_dir
="$PWD/target"
62 sdk_dir
="$target_dir/SDK"
63 platform
="$(uname -s)"
64 # Will be mutated by verify_sdk_version
67 mkdir
-p "$target_dir"
68 mkdir
-p "$target_dir/bin"
72 verify_sdk_version
"$1"
74 triple
="$(printf "$triple" "$2")"
75 pushd "$sdk_dir" &>/dev
/null
79 find $sdk_dir -name libSystem.dylib
-o -name libSystem.tbd |
head -n1
82 if [ -z "$sys_lib" ]; then
83 printf "SDK should contain libSystem{.dylib,.tbd}\n" 1>&2
87 local sys_root
=$
(readlink
-f "$(dirname $sys_lib)/../..")
89 local sdk_unboxed
=$
(basename $sys_root)
91 mv -f "$sys_root"/* "$sdk_dir" || true
95 printf "\nbuilding wrapper\n"
97 printf "int main(){return 0;}" | clang
-xc -O2 -o "$target_dir"/bin
/dsymutil
-
99 clang
-O2 -std=c99
$alt_wrapper \
100 -DTARGET_CPU=$
(printf '"%s"' "$2") \
102 printf '"%s"' "-I$out/$sdk/usr/include"
104 -DNIX_APPLE_FRAMEWORKS=$
(
105 printf '"%s"' "$out/$sdk/System/Library/Frameworks"
107 -DNIX_APPLE_PRIV_FRAMEWORKS=$
(
108 printf '"%s"' "$out/$sdk/System/Library/PrivateFrameworks"
110 -DOS_VER_MIN=$
(printf '"%s"' "7.1") \
111 -o "$target_dir/bin/$triple-clang"
113 pushd "$target_dir"/bin
&>/dev
/null
115 cp "$triple"-clang "$triple"-clang++
119 printf "\nbuilding ldid\n"
122 pushd tmp
&>/dev
/null
123 pushd "$ldid" &>/dev
/null
127 make INSTALLPREFIX
="$target_dir" -j4 install
131 printf "\nbuilding cctools / ld64\n"
133 pushd ..
/..
/cctools
&>/dev
/null
134 git clean
-fdx .
&>/dev
/null || true
136 .
/configure
--target="$triple" --prefix="$target_dir"
138 make install &>/dev
/null
144 for d
in bin libexec SDK
; do
145 chown
-R $me:$me target
/$d
151 mv $out/SDK
$out/$sdk