2012-02-22 18:21:47 +01:00
|
|
|
#!/bin/bash
|
2011-12-01 17:41:27 +01:00
|
|
|
|
2012-03-08 20:45:55 +01:00
|
|
|
. $(dirname $0)/environment.sh
|
2011-12-01 17:41:27 +01:00
|
|
|
|
2011-11-29 19:48:05 +01:00
|
|
|
# credit to:
|
|
|
|
# http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html
|
|
|
|
# http://latenitesoft.blogspot.com/2008/10/iphone-programming-tips-building-unix.html
|
|
|
|
|
|
|
|
# download python and patch if they aren't there
|
2013-02-28 19:21:58 +01:00
|
|
|
if [ ! -f $CACHEROOT/Python-$IOS_PYTHON_VERSION.tar.bz2 ]; then
|
2014-03-24 12:16:58 +01:00
|
|
|
curl -L https://www.python.org/ftp//python/$IOS_PYTHON_VERSION/Python-$IOS_PYTHON_VERSION.tar.bz2 > $CACHEROOT/Python-$IOS_PYTHON_VERSION.tar.bz2
|
2011-11-29 19:48:05 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# get rid of old build
|
2013-02-28 19:21:58 +01:00
|
|
|
rm -rf $TMPROOT/Python-$IOS_PYTHON_VERSION
|
|
|
|
try tar -xjf $CACHEROOT/Python-$IOS_PYTHON_VERSION.tar.bz2
|
|
|
|
try mv Python-$IOS_PYTHON_VERSION $TMPROOT
|
|
|
|
try pushd $TMPROOT/Python-$IOS_PYTHON_VERSION
|
2011-11-29 19:48:05 +01:00
|
|
|
|
|
|
|
# Patch Python for temporary reduce PY_SSIZE_T_MAX otherzise, splitting string doesnet work
|
2013-02-28 19:21:58 +01:00
|
|
|
try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-ssize-t-max.patch
|
|
|
|
try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-dynload.patch
|
|
|
|
try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-static-_sqlite3.patch
|
2011-11-29 19:48:05 +01:00
|
|
|
|
2011-12-06 10:49:14 +01:00
|
|
|
# Copy our setup for modules
|
2012-03-08 20:45:55 +01:00
|
|
|
try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local
|
2012-11-21 16:10:05 +01:00
|
|
|
try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
|
2011-11-29 19:48:05 +01:00
|
|
|
|
2013-02-12 00:39:38 +01:00
|
|
|
echo "Building for native machine ============================================"
|
|
|
|
|
2013-10-25 22:23:44 +02:00
|
|
|
OSX_SDK_ROOT=`xcrun --sdk macosx --show-sdk-path`
|
|
|
|
try ./configure CC="clang -Qunused-arguments -fcolor-diagnostics" LDFLAGS="-lsqlite3" CFLAGS="--sysroot=$OSX_SDK_ROOT"
|
|
|
|
try make -j4 python.exe Parser/pgen
|
2013-02-12 00:39:38 +01:00
|
|
|
try mv python.exe hostpython
|
|
|
|
try mv Parser/pgen Parser/hostpgen
|
|
|
|
try make distclean
|
2011-11-29 19:48:05 +01:00
|
|
|
|
|
|
|
echo "Building for iOS ======================================================="
|
|
|
|
|
2011-12-06 10:49:14 +01:00
|
|
|
# patch python to cross-compile
|
2013-02-28 19:21:58 +01:00
|
|
|
try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-xcompile.patch
|
2013-10-25 17:33:47 +02:00
|
|
|
try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-setuppath.patch
|
2011-11-29 19:48:05 +01:00
|
|
|
|
2011-12-06 10:49:14 +01:00
|
|
|
# set up environment variables for cross compilation
|
2013-10-08 11:02:05 +02:00
|
|
|
#export CPPFLAGS="-I$IOSSDKROOT/usr/lib/gcc/arm-apple-darwin11/4.2.1/include/ -I$IOSSDKROOT/usr/include/"
|
2011-12-06 10:49:14 +01:00
|
|
|
export CPP="$CCACHE /usr/bin/cpp $CPPFLAGS"
|
|
|
|
export MACOSX_DEPLOYMENT_TARGET=
|
2011-11-29 19:48:05 +01:00
|
|
|
|
|
|
|
# make a link to a differently named library for who knows what reason
|
2013-10-08 11:02:05 +02:00
|
|
|
#mkdir extralibs||echo "foo"
|
|
|
|
#ln -s "$IOSSDKROOT/usr/lib/libgcc_s.1.dylib" extralibs/libgcc_s.10.4.dylib || echo "sdf"
|
2011-11-29 19:48:05 +01:00
|
|
|
|
2011-12-06 16:52:19 +01:00
|
|
|
# Copy our setup for modules
|
2012-03-08 20:45:55 +01:00
|
|
|
try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local
|
2013-08-23 14:16:31 +02:00
|
|
|
try cat $KIVYIOSROOT/src/python_files/ModulesSetup.mobile >> Modules/Setup.local
|
2012-11-21 16:10:05 +01:00
|
|
|
try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py
|
2011-12-06 16:52:19 +01:00
|
|
|
|
2013-02-12 00:39:38 +01:00
|
|
|
try ./configure CC="$ARM_CC" LD="$ARM_LD" \
|
2013-08-23 14:16:31 +02:00
|
|
|
CFLAGS="$ARM_CFLAGS" \
|
|
|
|
LDFLAGS="$ARM_LDFLAGS -Lextralibs/ -lsqlite3 -L$BUILDROOT/lib -undefined dynamic_lookup" \
|
|
|
|
--without-pymalloc \
|
|
|
|
--disable-toolbox-glue \
|
|
|
|
--host=armv7-apple-darwin \
|
|
|
|
--prefix=/python \
|
2013-02-12 00:39:38 +01:00
|
|
|
--without-doc-strings
|
2011-11-29 19:48:05 +01:00
|
|
|
|
2013-08-26 04:07:09 +02:00
|
|
|
# with undefined lookup, checks in configure just failed :(
|
2013-08-26 20:39:29 +02:00
|
|
|
try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-pyconfig.patch
|
|
|
|
try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-ctypes_duplicate.patch
|
2013-08-26 04:07:09 +02:00
|
|
|
|
2013-10-25 22:23:44 +02:00
|
|
|
try make -j4 HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen \
|
2013-02-12 00:39:38 +01:00
|
|
|
CROSS_COMPILE_TARGET=yes
|
2011-11-29 19:48:05 +01:00
|
|
|
|
2013-08-23 14:16:31 +02:00
|
|
|
try make install HOSTPYTHON=./hostpython CROSS_COMPILE_TARGET=yes \
|
|
|
|
prefix="$BUILDROOT/python"
|
2013-02-04 21:57:33 +01:00
|
|
|
|
2013-02-12 00:39:38 +01:00
|
|
|
try mv -f $BUILDROOT/python/lib/libpython2.7.a $BUILDROOT/lib/
|
2011-12-06 15:32:31 +01:00
|
|
|
|
2013-02-12 00:39:38 +01:00
|
|
|
deduplicate $BUILDROOT/lib/libpython2.7.a
|