]> git.saurik.com Git - cycript.git/blame - xcode.sh
Finish new build environment, relocatable objects.
[cycript.git] / xcode.sh
CommitLineData
800811a0
JF
1#!/bin/bash
2
a93f15c0
JF
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
800811a0
JF
22set -e
23
a93f15c0 24cd "${0%%/*}"
800811a0 25
a93f15c0
JF
26if [[ ! -e readline/libreadline.a ]]; then
27 ./readline.sh; fi
28if [[ ! -e libffi.a ]]; then
29 ./libffi.sh; fi
81d7bcec
JF
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
800811a0 39
a93f15c0
JF
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
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}"
3370d0c0 62 CPP="${cc} -E" CC="${cc} ${flg}" CXXCPP="${cxx} -E" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" ../configure "${flags[@]}" --prefix="/usr" "$@"
a93f15c0
JF
63 cd ..
64}
65
d10cbac7 66configure mac "${mac}" "-arch i386 -arch x86_64 -mmacosx-version-min=10.6" CPPFLAGS="-I../readline" LDFLAGS="-L../readline"
a93f15c0
JF
67
68function build() {
69 local dir=$1
70 local sdk=$2
71 local flg=$3
72 shift 3
73
d10cbac7 74 configure "${dir}" "${sdk}" "${flg}" "$@" --enable-static --with-pic #CPPFLAGS="-idirafter ${mac}/usr/include"
a93f15c0
JF
75}
76
3370d0c0 77build sim iphonesimulator "-arch i386 -mios-simulator-version-min=2.0" OBJCXXFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch" CPPFLAGS="-I../libffi.i386/include" LDFLAGS="-L.." --disable-console
a93f15c0 78build ios iphoneos5.1 "-arch armv6 -miphoneos-version-min=2.0" --host=arm-apple-darwin10 CPPFLAGS="-I../libffi.armv6/include -I../sysroot.ios/usr/include -I../sysroot.ios/usr/include/apr-1" LTLIBAPR="../sysroot.ios/usr/lib/libapr-1.dylib" LDFLAGS="-L.. -L../sysroot.ios/usr/lib"