]> git.saurik.com Git - cycript.git/blob - simulator.sh
Use the LC_ID_DYLIB when possible to ID dylibs.
[cycript.git] / simulator.sh
1 #!/usr/bin/env bash
2
3 # Cycript - Optimizing JavaScript Compiler/Runtime
4 # Copyright (C) 2009-2013 Jay Freeman (saurik)
5
6 # GNU General Public License, Version 3 {{{
7 #
8 # Cycript is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published
10 # by the Free Software Foundation, either version 3 of the License,
11 # or (at your option) any later version.
12 #
13 # Cycript is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Cycript. If not, see <http://www.gnu.org/licenses/>.
20 # }}}
21
22 set -e
23
24 rm -rf sysroot.sim
25 mkdir -p sysroot.sim
26
27 xsp=$(xcode-select --print-path)
28 plt=iPhoneSimulator
29 dev=${xsp}/Platforms/${plt}.platform/Developer
30 sdk=${dev}/SDKs/${plt}6.1.sdk
31 mac=${xsp}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
32
33 mkdir -p sysroot.sim/usr/include
34 cp -a "${mac}"/usr/include/ffi sysroot.sim/usr/include
35
36 mkdir -p sysroot.sim/usr/lib
37 cp -a /usr/lib/libffi.dylib sysroot.sim/usr/lib
38 cp -a /usr/lib/libapr-1.* sysroot.sim/usr/lib
39
40 ln -s /System/Library/Frameworks/WebKit.framework/Versions/A/Headers sysroot.sim/usr/include/WebKit
41
42 mkdir -p sysroot.sim/Library/Frameworks/JavaScriptCore.framework
43 ln -s "${sdk}"/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore sysroot.sim/Library/Frameworks/JavaScriptCore.framework
44 ln -s /System/Library/Frameworks/JavaScriptCore.framework/Headers sysroot.sim/Library/Frameworks/JavaScriptCore.framework
45
46 export CC=/usr/bin/clang
47 export CXX=/usr/bin/clang++
48 export OBJCXX=/usr/bin/clang++
49
50 flags=(-arch i386)
51 flags+=(-isysroot "${sdk}")
52 flags+=(-Fsysroot.sim/Library/Frameworks)
53
54 cflags=("${flags[@]}")
55 cflags+=(-Isysroot.sim/usr/include)
56 cflags+=(-fobjc-abi-version=2)
57 cflags+=(-Wno-overloaded-virtual)
58 cflags+=(-Wno-unneeded-internal-declaration)
59
60 lflags=("${flags[@]}")
61 lflags+=(-Lsysroot.sim/usr/lib)
62 lflags+=(-F"${sdk}"/System/Library/PrivateFrameworks)
63 lflags+=(-framework WebCore)
64
65 cflags=${cflags[*]}
66 export CFLAGS=${cflags}
67 export CXXFLAGS=${cflags}
68 export OBJCXXFLAGS=${cflags}
69
70 export OBJCXXFLAGS="${OBJCXXFLAGS} -fobjc-legacy-dispatch"
71
72 lflags=${lflags[*]}
73 export LDFLAGS=${lflags}
74
75 tflags=()
76 for flag in "${flags[@]}"; do
77 tflags+=("-Xcompiler ${flag}")
78 done
79
80 tflags=${tflags[*]}
81 export LTFLAGS=${tflags}
82
83 export DYLD_ROOT_PATH=${sdk}
84 export DYLD_FALLBACK_LIBRARY_PATH=/usr/lib
85 export DYLD_FALLBACK_FRAMEWORK_PATH=/System/Library/Frameworks
86
87 ./configure "$@"