]> git.saurik.com Git - cycript.git/blob - apple-lib.sh
Instance's toPointer() should return as CFTypeRef.
[cycript.git] / apple-lib.sh
1 #!/usr/bin/env bash
2
3 # Cycript - The Truly Universal Scripting Language
4 # Copyright (C) 2009-2016 Jay Freeman (saurik)
5
6 # GNU Affero General Public License, Version 3 {{{
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
17 #
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # }}}
21
22 set -e
23
24 extra=("$@")
25
26 archs=()
27 function arch() {
28 local lib=$1
29 shift
30
31 local arch=$1
32 local host=$2
33 local sdk=$3
34 local os=$4
35 local min=$5
36 shift 5
37
38 rm -rvf "${lib}.${arch}"
39 if ! isysroot=$(xcodebuild -sdk "${sdk}" -version Path); then
40 return
41 fi
42
43 archs+=("${arch}")
44 mkdir "${lib}.${arch}"
45
46 flags=()
47 flags+=(-isysroot "${isysroot}")
48 flags+=(-m${os}-version-min="${min}")
49 flags+=(-O3 -g3)
50
51 if [[ ${arch} == armv* && ${arch} != armv6 ]]; then
52 flags+=(-mthumb)
53 fi
54
55 cd "${lib}.${arch}"
56 CC="clang -arch ${arch}" CXX="clang++ -arch ${arch}" LDFLAGS="${flags[*]}" CPPFLAGS="${flags[*]} $*" ../"${lib}"/configure --host="${host}" --enable-static --disable-shared \
57 ac_cv_func_strcoll_works=yes bash_cv_func_sigsetjmp=present bash_cv_func_ctype_nonascii=no bash_cv_must_reinstall_sighandlers=no bash_cv_func_strcoll_broken=yes bash_cv_wcwidth_broken=no
58 make -j5
59 cd ..
60 }
61
62 function arch64() {
63 local lib=$1
64 shift
65
66 arch "${lib}" arm64 aarch64-apple-darwin11 iphoneos iphoneos 2.0 "$@"
67 }
68
69 function archs() {
70 local lib=$1
71 shift
72
73 arch "${lib}" armv6 arm-apple-darwin10 iphoneos iphoneos 2.0 "$@" -mllvm -arm-reserve-r9
74 arch "${lib}" armv7 arm-apple-darwin10 iphoneos iphoneos 2.0 "$@"
75 arch "${lib}" armv7s arm-apple-darwin10 iphoneos iphoneos 2.0 "$@"
76
77 arch64 "${lib}" "$@"
78
79 arch "${lib}" i386 i386-apple-darwin10 iphonesimulator ios-simulator 4.0 "$@"
80 arch "${lib}" x86_64 x86_64-apple-darwin11 iphonesimulator ios-simulator 4.0 "$@"
81 }
82
83 archs libffi -DPAGE_MAX_SIZE=16384 -DPAGE_MAX_SHIFT=14 -fno-stack-protector
84 archs libuv
85 arch64 readline -include sys/ioctl.h
86
87 for arch in arm64; do
88 ln -sf . "readline.${arch}/readline"
89 done