]> git.saurik.com Git - cycript.git/blobdiff - apple-configure.sh
Instance's toPointer() should return as CFTypeRef.
[cycript.git] / apple-configure.sh
index 457cbf621675b350b329e0cff75a0cb848efaa8a..f22fc0b5e794d06ed7b48532009ef1622adf87be 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
-# Cycript - Optimizing JavaScript Compiler/Runtime
-# Copyright (C) 2009-2015  Jay Freeman (saurik)
+# Cycript - The Truly Universal Scripting Language
+# Copyright (C) 2009-2016  Jay Freeman (saurik)
 
 # GNU Affero General Public License, Version 3 {{{
 #
@@ -23,21 +23,8 @@ set -e
 
 cd "${0%%/*}"
 
-if [[ ! -e readline.osx/libreadline.a ]]; then
-    ./apple-readline.sh; fi
-if [[ ! -e libffi.a ]]; then
-    ./libffi.sh; fi
-
-if ! which aclocal; then
-    touch aclocal.m4; fi
-if ! which autoconf; then
-    touch configure.ac; fi
-if ! which automake; then
-    touch Makefile.in; fi
-if ! which autoheader; then
-    touch config.h.in; fi
-
 flags=("$@")
+ccf=(-g0 -O3)
 
 function path() {
     xcodebuild -sdk "$1" -version Path
@@ -45,58 +32,72 @@ function path() {
 
 xcs=$(xcode-select --print-path)
 mac=$(path macosx)
+xct="${xcs}/Toolchains/XcodeDefault.xctoolchain/usr/lib"
+
+system=1
 
 function configure() {
     local dir=$1
     local sdk=$2
-    local flg=$3
-    shift 3
+    local arc=$3
+    local min=$4
+    local ffi=$5
+    local cpf=$6
+    local ldf=$7
+    local obc=$8
+    shift 8
+
+    set -- "$@" --enable-static --with-pic
 
     cc=$(xcrun --sdk "${sdk}" -f clang)
     cxx=$(xcrun --sdk "${sdk}" -f clang++)
+
+    flg="-arch ${arc} ${min}"
     flg+=" -isysroot $(path "${sdk}")"
 
     rm -rf build."${dir}"
     mkdir build."${dir}"
     cd build."${dir}"
 
-    CC="${cc} ${flg}" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" \
-        ../configure --enable-maintainer-mode "${flags[@]}" --prefix="/usr" "$@"
+    if "${ffi}"; then
+        cpf+=" -I../libffi.${arch}/include"
+        ldf+=" -L../libffi.${arch}/.libs"
+    fi
 
-    cd ..
-}
+    cpf+=" -I../libuv/include"
+    ldf+=" -L../libuv.${arch}/.libs"
 
-function build() {
-    local dir=$1
-    local sdk=$2
-    local flg=$3
-    shift 3
+    ../configure --enable-maintainer-mode "${flags[@]}" --prefix="/usr" "$@" \
+        --with-libclang="-rpath ${xct} ${xct}/libclang.dylib" \
+        CC="${cc} ${flg}" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" \
+        CFLAGS="${ccf[*]}" CXXFLAGS="${ccf[*]}" OBJCXXFLAGS="${ccf[*]} ${obc}" \
+        CPPFLAGS="${cpf}" LDFLAGS="${ldf}" CY_SYSTEM="$((1<<system++))"
 
-    configure "${dir}" "${sdk}" "${flg}" "$@" --enable-static --with-pic
+    cd ..
 }
 
-gof=(-g0 -O3)
-
 for arch in i386 x86_64; do
-    build "osx-${arch}" "${mac}" "-arch ${arch} -mmacosx-version-min=10.6" \
-        CFLAGS="${gof[*]}" CXXFLAGS="${gof[*]}" OBJCXXFLAGS="${gof[*]}" \
-        CPPFLAGS="-I../readline.osx" LDFLAGS="-L../readline.osx"
+    configure "osx-${arch}" "${mac}" "${arch}" "-mmacosx-version-min=10.6" \
+        false "-I../readline.osx" "-L../readline.osx" "" \
+        --with-python=/usr/bin/python-config
 done
 
 for arch in i386 x86_64; do
-    build "sim-${arch}" iphonesimulator "-arch ${arch} -mios-simulator-version-min=4.0" \
-        CFLAGS="${gof[*]}" CXXFLAGS="${gof[*]}" OBJCXXFLAGS="${gof[*]} -fobjc-abi-version=2 -fobjc-legacy-dispatch" \
-        CPPFLAGS="-I../libffi.${arch}/include" \
-        LDFLAGS="-L.." \
-    --disable-console
+    configure "sim-${arch}" iphonesimulator "${arch}" "-mios-simulator-version-min=4.0" \
+        true "" "" "-fobjc-abi-version=2 -fobjc-legacy-dispatch" \
+        --disable-console
 done
 
 for arch in armv6 armv7 armv7s arm64; do
-    cpf="-I../libffi.${arch}/include"
-    ldf="-L.."
+    cpf=""
+    ldf=""
 
     flg=()
-    if [[ ${arch} != armv6 ]]; then
+    if [[ ${arch} == arm64 ]]; then
+        cpf+=" -I../extra.${arch}"
+        cpf+=" -I../readline.${arch}"
+        ldf+=" -L../readline.${arch}"
+    elif [[ ${arch} != armv6 ]]; then
         flg+=(--disable-console)
     else
         flg+=(LTLIBGCC="-lgcc_s.1")
@@ -106,6 +107,9 @@ for arch in armv6 armv7 armv7s arm64; do
         ldf+=" -L../sysroot.ios/usr/lib"
     fi
 
+    ldf+=" -Wl,-dead_strip"
+    ldf+=" -Wl,-no_dead_strip_inits_and_terms"
+
     if [[ ${arch} == arm64 ]]; then
         min=7.0
     else
@@ -114,7 +118,7 @@ for arch in armv6 armv7 armv7s arm64; do
         #cpf+=" -mthumb"
     fi
 
-    build "ios-${arch}" iphoneos "-arch ${arch} -miphoneos-version-min=${min}" --host=arm-apple-darwin10 \
-        CFLAGS="${gof[*]}" CXXFLAGS="${gof[*]}" OBJCXXFLAGS="${gof[*]}" \
-        CPPFLAGS="${cpf}" LDFLAGS="${ldf}" "${flg[@]}" --host=arm-apple-darwin10
+    configure "ios-${arch}" iphoneos "${arch}" "-miphoneos-version-min=${min}" \
+        true "${cpf[*]}" "${ldf[*]}" "" \
+        --host=arm-apple-darwin10 LFLAGS="--ecs --meta-ecs" "${flg[@]}"
 done