]>
Commit | Line | Data |
---|---|---|
944dc32c | 1 | #!/usr/bin/env bash |
800811a0 | 2 | |
7341eedb JF |
3 | # Cycript - The Truly Universal Scripting Language |
4 | # Copyright (C) 2009-2016 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 | |
a93f15c0 | 26 | flags=("$@") |
ae1b611e | 27 | ccf=(-g0 -O3) |
a93f15c0 JF |
28 | |
29 | function path() { | |
30 | xcodebuild -sdk "$1" -version Path | |
31 | } | |
32 | ||
33 | xcs=$(xcode-select --print-path) | |
34 | mac=$(path macosx) | |
8d20f0f1 JF |
35 | xct="${xcs}/Toolchains/XcodeDefault.xctoolchain/usr/lib" |
36 | ||
1ed581bb | 37 | system=1 |
a93f15c0 JF |
38 | |
39 | function configure() { | |
40 | local dir=$1 | |
41 | local sdk=$2 | |
ae1b611e JF |
42 | local arc=$3 |
43 | local min=$4 | |
44 | local ffi=$5 | |
45 | local cpf=$6 | |
46 | local ldf=$7 | |
47 | local obc=$8 | |
48 | shift 8 | |
49 | ||
50 | set -- "$@" --enable-static --with-pic | |
a93f15c0 | 51 | |
4af4085c JF |
52 | cc=$(xcrun --sdk "${sdk}" -f clang) |
53 | cxx=$(xcrun --sdk "${sdk}" -f clang++) | |
ae1b611e JF |
54 | |
55 | flg="-arch ${arc} ${min}" | |
a93f15c0 JF |
56 | flg+=" -isysroot $(path "${sdk}")" |
57 | ||
58 | rm -rf build."${dir}" | |
59 | mkdir build."${dir}" | |
60 | cd build."${dir}" | |
5239f927 | 61 | |
ae1b611e JF |
62 | if "${ffi}"; then |
63 | cpf+=" -I../libffi.${arch}/include" | |
64 | ldf+=" -L../libffi.${arch}/.libs" | |
65 | fi | |
5239f927 | 66 | |
ae1b611e JF |
67 | cpf+=" -I../libuv/include" |
68 | ldf+=" -L../libuv.${arch}/.libs" | |
a93f15c0 | 69 | |
ae1b611e | 70 | ../configure --enable-maintainer-mode "${flags[@]}" --prefix="/usr" "$@" \ |
8d20f0f1 | 71 | --with-libclang="-rpath ${xct} ${xct}/libclang.dylib" \ |
ae1b611e JF |
72 | CC="${cc} ${flg}" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" \ |
73 | CFLAGS="${ccf[*]}" CXXFLAGS="${ccf[*]}" OBJCXXFLAGS="${ccf[*]} ${obc}" \ | |
8d20f0f1 | 74 | CPPFLAGS="${cpf}" LDFLAGS="${ldf}" CY_SYSTEM="$((1<<system++))" |
a93f15c0 | 75 | |
ae1b611e | 76 | cd .. |
a93f15c0 JF |
77 | } |
78 | ||
a412fff4 | 79 | for arch in i386 x86_64; do |
ae1b611e | 80 | configure "osx-${arch}" "${mac}" "${arch}" "-mmacosx-version-min=10.6" \ |
591b913e JF |
81 | false "-I../readline.osx" "-L../readline.osx" "" \ |
82 | --with-python=/usr/bin/python-config | |
a412fff4 JF |
83 | done |
84 | ||
3615a2f7 | 85 | for arch in i386 x86_64; do |
ae1b611e JF |
86 | configure "sim-${arch}" iphonesimulator "${arch}" "-mios-simulator-version-min=4.0" \ |
87 | true "" "" "-fobjc-abi-version=2 -fobjc-legacy-dispatch" \ | |
88 | --disable-console | |
abc804fa JF |
89 | done |
90 | ||
0ad8029f | 91 | for arch in armv6 armv7 armv7s arm64; do |
ae1b611e JF |
92 | cpf="" |
93 | ldf="" | |
0ad8029f | 94 | |
3615a2f7 | 95 | flg=() |
3e50deaf JF |
96 | if [[ ${arch} == arm64 ]]; then |
97 | cpf+=" -I../extra.${arch}" | |
98 | cpf+=" -I../readline.${arch}" | |
99 | ldf+=" -L../readline.${arch}" | |
100 | elif [[ ${arch} != armv6 ]]; then | |
3615a2f7 | 101 | flg+=(--disable-console) |
0ad8029f | 102 | else |
e5f0ecf9 | 103 | flg+=(LTLIBGCC="-lgcc_s.1") |
a1cda481 | 104 | cpf+=" -include ${PWD}/xcode.h" |
e9b51ae0 | 105 | cpf+=" -mllvm -arm-reserve-r9" |
10d0e915 | 106 | cpf+=" -I../sysroot.ios/usr/include" |
0ad8029f | 107 | ldf+=" -L../sysroot.ios/usr/lib" |
e9abea04 JF |
108 | fi |
109 | ||
cf1d39e2 JF |
110 | ldf+=" -Wl,-dead_strip" |
111 | ldf+=" -Wl,-no_dead_strip_inits_and_terms" | |
112 | ||
8c0927fb JF |
113 | if [[ ${arch} == arm64 ]]; then |
114 | min=7.0 | |
115 | else | |
116 | min=2.0 | |
79e239bf | 117 | ldf+=" -Wl,-segalign,4000" |
73fd6f57 | 118 | #cpf+=" -mthumb" |
8c0927fb JF |
119 | fi |
120 | ||
ae1b611e JF |
121 | configure "ios-${arch}" iphoneos "${arch}" "-miphoneos-version-min=${min}" \ |
122 | true "${cpf[*]}" "${ldf[*]}" "" \ | |
123 | --host=arm-apple-darwin10 LFLAGS="--ecs --meta-ecs" "${flg[@]}" | |
abc804fa | 124 | done |