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