]> git.saurik.com Git - cycript.git/blobdiff - macosx.sh
Split Xcode build environment by configure passes.
[cycript.git] / macosx.sh
index 9b9886755896a22c78d3060a730a84609af46bb7..e10694219cf4216b5fa6178dc4be37c015919ab9 100755 (executable)
--- a/macosx.sh
+++ b/macosx.sh
@@ -1,12 +1,32 @@
 #!/bin/bash
 
+# Cycript - Optimizing JavaScript Compiler/Runtime
+# Copyright (C) 2009-2013  Jay Freeman (saurik)
+
+# GNU General Public License, Version 3 {{{
+#
+# Cycript is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation, either version 3 of the License,
+# or (at your option) any later version.
+#
+# Cycript is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Cycript.  If not, see <http://www.gnu.org/licenses/>.
+# }}}
+
 set -e
 
-version=6.2
-readline=readline-${version}
+cd "${0%%/*}"
 
-if [[ ! -d "${readline}" ]]; then
-    ./readline.sh "${version}"; fi
+if [[ ! -e readline/libreadline.a ]]; then
+    ./readline.sh; fi
+if [[ ! -e libffi.a ]]; then
+    ./libffi.sh; fi
 
 if ! which aclocal; then
     touch aclocal.m4; fi
@@ -17,4 +37,45 @@ if ! which automake; then
 if ! which autoheader; then
     touch config.h.in; fi
 
-exec "${0%%/*}/configure" CPPFLAGS="-I${readline}" LDFLAGS="-L${readline}" "$@"
+flags=("$@")
+
+function path() {
+    xcodebuild -sdk "$1" -version Path
+}
+
+xcs=$(xcode-select --print-path)
+mac=$(path macosx)
+
+function configure() {
+    local dir=$1
+    local sdk=$2
+    local flg=$3
+    shift 3
+
+    cc=$(xcrun --sdk "${sdk}" -f gcc)
+    cxx=$(xcrun --sdk "${sdk}" -f g++)
+    flg+=" -isysroot $(path "${sdk}")"
+
+    rm -rf build."${dir}"
+    mkdir build."${dir}"
+    cd build."${dir}"
+    CPP="${cc} -E" CC="${cc} ${flg}" CXXCPP="${cxx} -E" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" ../configure "${flags[@]}" "$@"
+    cd ..
+}
+
+#configure mac "${mac}" "-arch i386 -arch x86_64 -mmacosx-version-min=10.6" CPPFLAGS="-I../readline" LDFLAGS="-L../readline"
+
+function build() {
+    local dir=$1
+    local sdk=$2
+    local flg=$3
+    shift 3
+
+    configure "${dir}" "${sdk}" "${flg}" "$@" #--with-libffi=libffi.a #CPPFLAGS="-idirafter ${mac}/usr/include"
+}
+
+sim="-mios-simulator-version-min=2.0"
+sim="" # gcc does not support this
+
+#build sim iphonesimulator "-arch i386 ${sim}" OBJCXXFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch" CPPFLAGS="-I../libffi.i386/include" LDFLAGS="-L.." --disable-console
+build 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"