]> git.saurik.com Git - cycript.git/blame_incremental - apple-configure.sh
@encode syntax doesn't require Objective-C support.
[cycript.git] / apple-configure.sh
... / ...
CommitLineData
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
22set -e
23
24cd "${0%%/*}"
25
26if [[ ! -e readline.osx/libreadline.a ]]; then
27 ./apple-readline.sh; fi
28if [[ ! -e libffi.a ]]; then
29 ./libffi.sh; fi
30
31if ! which aclocal; then
32 touch aclocal.m4; fi
33if ! which autoconf; then
34 touch configure.ac; fi
35if ! which automake; then
36 touch Makefile.in; fi
37if ! which autoheader; then
38 touch config.h.in; fi
39
40flags=("$@")
41
42function path() {
43 xcodebuild -sdk "$1" -version Path
44}
45
46xcs=$(xcode-select --print-path)
47mac=$(path macosx)
48
49function configure() {
50 local dir=$1
51 local sdk=$2
52 local flg=$3
53 shift 3
54
55 cc=$(xcrun --sdk "${sdk}" -f clang)
56 cxx=$(xcrun --sdk "${sdk}" -f clang++)
57 flg+=" -isysroot $(path "${sdk}")"
58
59 rm -rf build."${dir}"
60 mkdir build."${dir}"
61 cd build."${dir}"
62
63 CC="${cc} ${flg}" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" \
64 ../configure --enable-maintainer-mode "${flags[@]}" --prefix="/usr" "$@"
65
66 cd ..
67}
68
69function build() {
70 local dir=$1
71 local sdk=$2
72 local flg=$3
73 shift 3
74
75 configure "${dir}" "${sdk}" "${flg}" "$@" --enable-static --with-pic
76}
77
78for arch in i386 x86_64; do
79 build "osx-${arch}" "${mac}" "-arch ${arch} -mmacosx-version-min=10.6" \
80 CPPFLAGS="-I../readline.osx" LDFLAGS="-L../readline.osx"
81done
82
83for arch in i386 x86_64; do
84 build "sim-${arch}" iphonesimulator "-arch ${arch} -mios-simulator-version-min=4.0" \
85 OBJCXXFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch" \
86 CPPFLAGS="-I../libffi.${arch}/include" \
87 LDFLAGS="-L.." \
88 --disable-console
89done
90
91for arch in armv6 armv7 armv7s arm64; do
92 cpf="-I../libffi.${arch}/include"
93 ldf="-L.."
94
95 flg=()
96 if [[ ${arch} != armv6 ]]; then
97 flg+=(--disable-console)
98 else
99 flg+=(LTLIBGCC="-lgcc_s.1")
100 cpf+=" -include ${PWD}/xcode.h"
101 cpf+=" -mllvm -arm-reserve-r9"
102 cpf+=" -I../sysroot.ios/usr/include"
103 ldf+=" -L../sysroot.ios/usr/lib"
104 fi
105
106 if [[ ${arch} == arm64 ]]; then
107 min=7.0
108 else
109 min=2.0
110 #cpf+=" -mthumb"
111 fi
112
113 build "ios-${arch}" iphoneos "-arch ${arch} -miphoneos-version-min=${min}" --host=arm-apple-darwin10 \
114 CPPFLAGS="${cpf}" LDFLAGS="${ldf}" "${flg[@]}" --host=arm-apple-darwin10
115done