]>
Commit | Line | Data |
---|---|---|
944dc32c | 1 | #!/usr/bin/env bash |
800811a0 | 2 | |
a93f15c0 | 3 | # Cycript - Optimizing JavaScript Compiler/Runtime |
c1d3e52e | 4 | # Copyright (C) 2009-2015 Jay Freeman (saurik) |
a93f15c0 | 5 | |
f95d2598 | 6 | # GNU Affero General Public License, Version 3 {{{ |
a93f15c0 | 7 | # |
f95d2598 JF |
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. | |
a93f15c0 | 12 | # |
f95d2598 JF |
13 | # This program is distributed in the hope that it will be useful, |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
a93f15c0 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f95d2598 | 16 | # GNU Affero General Public License for more details. |
a93f15c0 | 17 | # |
f95d2598 JF |
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/>. | |
a93f15c0 JF |
20 | # }}} |
21 | ||
800811a0 JF |
22 | set -e |
23 | ||
a93f15c0 | 24 | cd "${0%%/*}" |
800811a0 | 25 | |
42311506 JF |
26 | if [[ ! -e readline.osx/libreadline.a ]]; then |
27 | ./apple-readline.sh; fi | |
a93f15c0 JF |
28 | if [[ ! -e libffi.a ]]; then |
29 | ./libffi.sh; fi | |
81d7bcec JF |
30 | |
31 | if ! which aclocal; then | |
32 | touch aclocal.m4; fi | |
33 | if ! which autoconf; then | |
34 | touch configure.ac; fi | |
35 | if ! which automake; then | |
36 | touch Makefile.in; fi | |
37 | if ! which autoheader; then | |
38 | touch config.h.in; fi | |
800811a0 | 39 | |
a93f15c0 JF |
40 | flags=("$@") |
41 | ||
42 | function path() { | |
43 | xcodebuild -sdk "$1" -version Path | |
44 | } | |
45 | ||
46 | xcs=$(xcode-select --print-path) | |
47 | mac=$(path macosx) | |
48 | ||
49 | function configure() { | |
50 | local dir=$1 | |
51 | local sdk=$2 | |
52 | local flg=$3 | |
53 | shift 3 | |
54 | ||
4af4085c JF |
55 | cc=$(xcrun --sdk "${sdk}" -f clang) |
56 | cxx=$(xcrun --sdk "${sdk}" -f clang++) | |
a93f15c0 JF |
57 | flg+=" -isysroot $(path "${sdk}")" |
58 | ||
59 | rm -rf build."${dir}" | |
60 | mkdir build."${dir}" | |
61 | cd build."${dir}" | |
5239f927 JF |
62 | |
63 | CC="${cc} ${flg}" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" \ | |
3615a2f7 | 64 | ../configure --enable-maintainer-mode "${flags[@]}" --prefix="/usr" "$@" |
5239f927 | 65 | |
a93f15c0 JF |
66 | cd .. |
67 | } | |
68 | ||
a93f15c0 JF |
69 | function build() { |
70 | local dir=$1 | |
71 | local sdk=$2 | |
72 | local flg=$3 | |
73 | shift 3 | |
74 | ||
e9abea04 | 75 | configure "${dir}" "${sdk}" "${flg}" "$@" --enable-static --with-pic |
a93f15c0 JF |
76 | } |
77 | ||
2b9635f6 JF |
78 | gof=(-g0 -O3) |
79 | ||
a412fff4 | 80 | for arch in i386 x86_64; do |
9d3cfb4a | 81 | build "osx-${arch}" "${mac}" "-arch ${arch} -mmacosx-version-min=10.6" \ |
7be938d9 | 82 | CFLAGS="${gof[*]}" CXXFLAGS="${gof[*]}" OBJCXXFLAGS="${gof[*]}" \ |
42311506 | 83 | CPPFLAGS="-I../readline.osx" LDFLAGS="-L../readline.osx" |
a412fff4 JF |
84 | done |
85 | ||
3615a2f7 | 86 | for arch in i386 x86_64; do |
0ad8029f | 87 | build "sim-${arch}" iphonesimulator "-arch ${arch} -mios-simulator-version-min=4.0" \ |
7be938d9 | 88 | CFLAGS="${gof[*]}" CXXFLAGS="${gof[*]}" OBJCXXFLAGS="${gof[*]} -fobjc-abi-version=2 -fobjc-legacy-dispatch" \ |
5239f927 JF |
89 | CPPFLAGS="-I../libffi.${arch}/include" \ |
90 | LDFLAGS="-L.." \ | |
91 | --disable-console | |
abc804fa JF |
92 | done |
93 | ||
0ad8029f JF |
94 | for arch in armv6 armv7 armv7s arm64; do |
95 | cpf="-I../libffi.${arch}/include" | |
96 | ldf="-L.." | |
97 | ||
3615a2f7 | 98 | flg=() |
0ad8029f | 99 | if [[ ${arch} != armv6 ]]; then |
3615a2f7 | 100 | flg+=(--disable-console) |
0ad8029f | 101 | else |
e5f0ecf9 | 102 | flg+=(LTLIBGCC="-lgcc_s.1") |
a1cda481 | 103 | cpf+=" -include ${PWD}/xcode.h" |
e9b51ae0 | 104 | cpf+=" -mllvm -arm-reserve-r9" |
10d0e915 | 105 | cpf+=" -I../sysroot.ios/usr/include" |
0ad8029f | 106 | ldf+=" -L../sysroot.ios/usr/lib" |
e9abea04 JF |
107 | fi |
108 | ||
8c0927fb JF |
109 | if [[ ${arch} == arm64 ]]; then |
110 | min=7.0 | |
111 | else | |
112 | min=2.0 | |
79e239bf | 113 | ldf+=" -Wl,-segalign,4000" |
73fd6f57 | 114 | #cpf+=" -mthumb" |
8c0927fb JF |
115 | fi |
116 | ||
117 | build "ios-${arch}" iphoneos "-arch ${arch} -miphoneos-version-min=${min}" --host=arm-apple-darwin10 \ | |
7be938d9 | 118 | CFLAGS="${gof[*]}" CXXFLAGS="${gof[*]}" OBJCXXFLAGS="${gof[*]}" \ |
0ad8029f | 119 | CPPFLAGS="${cpf}" LDFLAGS="${ldf}" "${flg[@]}" --host=arm-apple-darwin10 |
abc804fa | 120 | done |