]> git.saurik.com Git - cycript.git/blob - apple-configure.sh
Attach FFI closure deallocation to Functor's pool.
[cycript.git] / apple-configure.sh
1 #!/usr/bin/env bash
2
3 # Cycript - Optimizing JavaScript Compiler/Runtime
4 # Copyright (C) 2009-2015 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 cd "${0%%/*}"
25
26 if ! which aclocal; then
27 touch aclocal.m4; fi
28 if ! which autoconf; then
29 touch configure.ac; fi
30 if ! which automake; then
31 touch Makefile.in; fi
32 if ! which autoheader; then
33 touch config.h.in; fi
34
35 flags=("$@")
36 ccf=(-g0 -O3)
37
38 function path() {
39 xcodebuild -sdk "$1" -version Path
40 }
41
42 xcs=$(xcode-select --print-path)
43 mac=$(path macosx)
44 xct="${xcs}/Toolchains/XcodeDefault.xctoolchain/usr/lib"
45
46 system=0
47
48 function configure() {
49 local dir=$1
50 local sdk=$2
51 local arc=$3
52 local min=$4
53 local ffi=$5
54 local cpf=$6
55 local ldf=$7
56 local obc=$8
57 shift 8
58
59 set -- "$@" --enable-static --with-pic
60
61 cc=$(xcrun --sdk "${sdk}" -f clang)
62 cxx=$(xcrun --sdk "${sdk}" -f clang++)
63
64 flg="-arch ${arc} ${min}"
65 flg+=" -isysroot $(path "${sdk}")"
66
67 rm -rf build."${dir}"
68 mkdir build."${dir}"
69 cd build."${dir}"
70
71 if "${ffi}"; then
72 cpf+=" -I../libffi.${arch}/include"
73 ldf+=" -L../libffi.${arch}/.libs"
74 fi
75
76 cpf+=" -I../libuv/include"
77 ldf+=" -L../libuv.${arch}/.libs"
78
79 ../configure --enable-maintainer-mode "${flags[@]}" --prefix="/usr" "$@" \
80 --with-libclang="-rpath ${xct} ${xct}/libclang.dylib" \
81 CC="${cc} ${flg}" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" \
82 CFLAGS="${ccf[*]}" CXXFLAGS="${ccf[*]}" OBJCXXFLAGS="${ccf[*]} ${obc}" \
83 CPPFLAGS="${cpf}" LDFLAGS="${ldf}" CY_SYSTEM="$((1<<system++))"
84
85 cd ..
86 }
87
88 for arch in i386 x86_64; do
89 configure "osx-${arch}" "${mac}" "${arch}" "-mmacosx-version-min=10.6" \
90 false "-I../readline.osx" "-L../readline.osx" ""
91 done
92
93 for arch in i386 x86_64; do
94 configure "sim-${arch}" iphonesimulator "${arch}" "-mios-simulator-version-min=4.0" \
95 true "" "" "-fobjc-abi-version=2 -fobjc-legacy-dispatch" \
96 --disable-console
97 done
98
99 for arch in armv6 armv7 armv7s arm64; do
100 cpf=""
101 ldf=""
102
103 flg=()
104 if [[ ${arch} != armv6 ]]; then
105 flg+=(--disable-console)
106 else
107 flg+=(LTLIBGCC="-lgcc_s.1")
108 cpf+=" -include ${PWD}/xcode.h"
109 cpf+=" -mllvm -arm-reserve-r9"
110 cpf+=" -I../sysroot.ios/usr/include"
111 ldf+=" -L../sysroot.ios/usr/lib"
112 fi
113
114 if [[ ${arch} == arm64 ]]; then
115 min=7.0
116 else
117 min=2.0
118 ldf+=" -Wl,-segalign,4000"
119 #cpf+=" -mthumb"
120 fi
121
122 configure "ios-${arch}" iphoneos "${arch}" "-miphoneos-version-min=${min}" \
123 true "${cpf[*]}" "${ldf[*]}" "" \
124 --host=arm-apple-darwin10 LFLAGS="--ecs --meta-ecs" "${flg[@]}"
125 done