2015-06-02 01:56:15 +00:00
|
|
|
#!/bin/sh
|
2015-06-02 01:54:15 +00:00
|
|
|
|
2017-07-04 00:10:43 +00:00
|
|
|
DEFCPU=arm64
|
2015-06-02 01:54:15 +00:00
|
|
|
BUILD=1
|
|
|
|
PREFIX="/usr"
|
|
|
|
# PREFIX=/var/mobile
|
|
|
|
|
2017-10-08 23:56:44 +00:00
|
|
|
iosConfigure() {
|
|
|
|
if [ "${USE_IOS_STORE}" = 1 ]; then
|
|
|
|
cp -f plugins.ios-store.cfg plugins.cfg
|
|
|
|
else
|
|
|
|
cp -f plugins.ios.cfg plugins.cfg
|
|
|
|
fi
|
|
|
|
./configure --prefix=${PREFIX} --with-ostype=darwin \
|
|
|
|
--without-pic --with-nonpic --without-fork \
|
|
|
|
--with-compiler=ios-sdk --target=arm-unknown-darwin
|
|
|
|
# --disable-debugger --with-compiler=ios-sdk
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
iosClean() {
|
|
|
|
make clean
|
|
|
|
}
|
|
|
|
|
|
|
|
iosBuild() {
|
|
|
|
time make -j4 || exit 1
|
|
|
|
# Build and sign
|
|
|
|
( cd binr/radare2 ; make ios_sdk_sign )
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
iosPackage() {
|
|
|
|
rm -rf /tmp/r2ios
|
|
|
|
make install DESTDIR=/tmp/r2ios
|
|
|
|
rm -rf /tmp/r2ios/usr/share/radare2/*/www/enyo/node_modules
|
|
|
|
( cd /tmp/r2ios && tar czvf ../r2ios-${CPU}.tar.gz * )
|
|
|
|
# Prepare radare2
|
|
|
|
rm -rf sys/cydia/radare2/root
|
|
|
|
rm -rf sys/cydia/radare2/root/usr/lib/*.dSYM
|
|
|
|
rm -rf sys/cydia/radare2/root/usr/lib/*.a
|
|
|
|
mkdir -p sys/cydia/radare2/root
|
|
|
|
sudo tar xpzvf /tmp/r2ios-${CPU}.tar.gz -C sys/cydia/radare2/root
|
|
|
|
rm -rf sys/cydia/radare2-dev/root
|
|
|
|
# Prepare radare2-dev
|
|
|
|
mkdir -p sys/cydia/radare2-dev/root
|
|
|
|
mkdir -p sys/cydia/radare2-dev/root/usr/include
|
|
|
|
mv sys/cydia/radare2/root/usr/include/* sys/cydia/radare2-dev/root/usr/include
|
|
|
|
mkdir -p sys/cydia/radare2-dev/root/usr/lib
|
|
|
|
mv sys/cydia/radare2/root/usr/lib/lib* sys/cydia/radare2-dev/root/usr/lib
|
|
|
|
mv sys/cydia/radare2/root/usr/lib/pkgconfig sys/cydia/radare2-dev/root/usr/lib
|
|
|
|
(
|
|
|
|
cd sys/cydia/radare2/root/usr/bin ;
|
|
|
|
for a in * ; do strip $a ; done
|
|
|
|
)
|
|
|
|
( cd sys/cydia/radare2 ; sudo make clean ; sudo make )
|
|
|
|
( cd sys/cydia/radare2-dev ; sudo make clean ; sudo make )
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
|
2015-07-06 22:23:08 +00:00
|
|
|
#if [ ! -d sys/ios-include ]; then
|
|
|
|
#(
|
|
|
|
# cd sys && \
|
|
|
|
# curl -o ios-include.tar.gz http://lolcathost.org/b/ios-include.tar.gz && \
|
|
|
|
# tar xzvf ios-include.tar.gz
|
|
|
|
#)
|
|
|
|
#fi
|
2015-09-21 20:37:12 +00:00
|
|
|
case "$1" in
|
2017-07-04 00:10:43 +00:00
|
|
|
arm|armv7)
|
2015-07-06 22:23:08 +00:00
|
|
|
CPU=armv7
|
2015-09-21 20:37:12 +00:00
|
|
|
shift
|
2015-07-06 22:23:08 +00:00
|
|
|
;;
|
2015-09-21 20:37:12 +00:00
|
|
|
arm64|aarch64)
|
2015-07-06 22:23:08 +00:00
|
|
|
CPU=arm64
|
2015-09-21 20:37:12 +00:00
|
|
|
shift
|
2015-07-06 22:23:08 +00:00
|
|
|
;;
|
2017-10-08 23:56:44 +00:00
|
|
|
-p)
|
|
|
|
iosPackage
|
|
|
|
exit 0
|
|
|
|
;;
|
2015-09-21 20:37:12 +00:00
|
|
|
-s)
|
2017-10-08 23:56:44 +00:00
|
|
|
:
|
2015-07-06 22:23:08 +00:00
|
|
|
;;
|
2017-07-04 00:10:43 +00:00
|
|
|
'')
|
|
|
|
CPU=arm64
|
|
|
|
;;
|
2015-07-06 22:23:08 +00:00
|
|
|
*)
|
2015-09-21 21:40:17 +00:00
|
|
|
echo "Valid values for CPU are: armv7 or arm64 (add -s to start a shell)"
|
|
|
|
echo "Run 'sys/rebuild.sh iosdbg' for quick rebuilds for the debugger"
|
2015-07-06 22:23:08 +00:00
|
|
|
exit 1
|
|
|
|
esac
|
2015-09-21 20:37:12 +00:00
|
|
|
[ -z "$CPU" ] && CPU="$DEFCPU"
|
2015-06-02 01:54:15 +00:00
|
|
|
|
2015-07-06 22:23:08 +00:00
|
|
|
export CPU="$CPU"
|
2017-07-04 00:10:43 +00:00
|
|
|
echo CPU=$CPU
|
2015-06-02 01:54:15 +00:00
|
|
|
export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH
|
|
|
|
export PATH=`pwd`/sys:${PATH}
|
|
|
|
export CC=`pwd`/sys/ios-sdk-gcc
|
2015-07-06 15:38:45 +00:00
|
|
|
export RANLIB="xcrun --sdk iphoneos ranlib"
|
|
|
|
export LD="xcrun --sdk iphoneos ld"
|
2015-06-02 01:54:15 +00:00
|
|
|
# set only for arm64, otherwise it is armv7
|
|
|
|
# select ios sdk version
|
2017-07-04 00:10:43 +00:00
|
|
|
export IOSVER=9.0
|
2015-06-02 01:54:15 +00:00
|
|
|
export IOSINC=`pwd`/sys/ios-include
|
2017-02-18 04:10:22 +00:00
|
|
|
export CFLAGS="-O2 -fembed-bitcode"
|
2015-06-02 01:54:15 +00:00
|
|
|
export USE_SIMULATOR=0
|
2017-07-04 00:10:43 +00:00
|
|
|
export USE_IOS_STORE=1
|
2015-06-02 01:54:15 +00:00
|
|
|
|
2015-06-04 02:30:48 +00:00
|
|
|
if [ "$1" = -s ]; then
|
2015-09-21 21:40:17 +00:00
|
|
|
export PS1="\033[33m[ios-sdk-$CPU \w]> \033[0m"
|
2015-06-04 02:30:48 +00:00
|
|
|
exec $SHELL
|
2017-10-08 23:56:44 +00:00
|
|
|
exit $?
|
2015-06-04 02:30:48 +00:00
|
|
|
fi
|
|
|
|
|
2015-09-21 20:37:12 +00:00
|
|
|
echo
|
|
|
|
echo "BUILDING R2 FOR iOS CPU = $CPU"
|
|
|
|
echo
|
|
|
|
sleep 1
|
|
|
|
|
2017-07-04 00:10:43 +00:00
|
|
|
|
2017-10-08 23:56:44 +00:00
|
|
|
iosClean
|
|
|
|
iosConfigure
|
2015-06-02 01:54:15 +00:00
|
|
|
if [ $? = 0 ]; then
|
2017-10-08 23:56:44 +00:00
|
|
|
iosBuild
|
|
|
|
iosPackage
|
2015-06-02 01:54:15 +00:00
|
|
|
fi
|