From 0522052c75def35655eecdf551584a7b34b56190 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 31 May 2013 00:48:25 +0200 Subject: [PATCH] New compile script --- src/build/compile.sh | 138 +++++++++++++++------- src/build/cross-compile.sh | 234 ------------------------------------- 2 files changed, 99 insertions(+), 273 deletions(-) delete mode 100644 src/build/cross-compile.sh diff --git a/src/build/compile.sh b/src/build/compile.sh index 30880892ae..f624b61738 100755 --- a/src/build/compile.sh +++ b/src/build/compile.sh @@ -18,26 +18,69 @@ type make >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"mak type autoconf >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"autoconf\""; read -p "Press [Enter] to continue..."; exit 1; } type automake >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"automake\""; read -p "Press [Enter] to continue..."; exit 1; } type libtool >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"libtool\""; read -p "Press [Enter] to continue..."; exit 1; } -type gcc >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"gcc\""; read -p "Press [Enter] to continue..."; exit 1; } type m4 >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"m4\""; read -p "Press [Enter] to continue..."; exit 1; } type wget >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"wget\""; read -p "Press [Enter] to continue..."; exit 1; } -[ -z "$THREADS" ] && THREADS=1; -[ -z "$march" ] && march="native"; -[ -z "$mcpu" ] && mcpu="native"; -[ -z "$mtune" ] && mtune="native"; -[ -z "$CFLAGS" ] && CFLAGS=""; +export CC="gcc" +if [ "$1" == "rpi" ]; then + [ -z "$march" ] && march=armv6zk; + [ -z "$mtune" ] && mtune=arm1176jzf-s; + [ -z "$CFLAGS" ] && CFLAGS="-mfloat-abi=hard -mfpu=vfp"; + echo "[INFO] Compiling for Raspberry Pi ARMv6zk hard float" +elif [ "$1" == "mac" ]; then + [ -z "$march" ] && march=prescott; + [ -z "$mtune" ] && mtune=generic; + [ -z "$CFLAGS" ] && CFLAGS="-fomit-frame-pointer"; + echo "[INFO] Compiling for Intel MacOS" +elif [ "$1" == "crosscompile" ]; then + if [ "$2" == "android" ] || [ "$2" == "android-armv6" ]; then + [ -z "$march" ] && march=armv6; + [ -z "$mtune" ] && mtune=generic; + TOOLCHAIN_PREFIX="arm-none-linux-gnueabi" + export CC="$TOOLCHAIN_PREFIX-gcc" + CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX" + echo "[INFO] Cross-compiling for Android ARMv6" + elif [ "$2" == "android-armv7" ]; then + [ -z "$march" ] && march=armv7; + [ -z "$mtune" ] && mtune=generic; + TOOLCHAIN_PREFIX="arm-none-linux-gnueabi" + export CC="$TOOLCHAIN_PREFIX-gcc" + CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX" + echo "[INFO] Cross-compiling for Android ARMv7" + elif [ "$2" == "rpi" ]; then + TOOLCHAIN_PREFIX="arm-linux-gnueabihf" + [ -z "$march" ] && march=armv6zk; + [ -z "$mtune" ] && mtune=arm1176jzf-s; + [ -z "$CFLAGS" ] && CFLAGS="-mfloat-abi=hard -mfpu=vfp"; + export CC="$TOOLCHAIN_PREFIX-gcc" + CONFIGURE_FLAGS="--host=$TOOLCHAIN_PREFIX" + echo "[INFO] Cross-compiling for Raspberry Pi ARMv6zk hard float" + else + echo "Please supply a proper platform [android rpi] to cross-compile" + exit 1 + fi +else + echo "[INFO] Compiling for current machine" +fi -gcc -O3 -march=$march -mcpu=$mcpu -mtune=$mtune -fno-gcse $CFLAGS -Q --help=target >> "$DIR/install.log" 2>&1 +type $CC >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"$CC\""; read -p "Press [Enter] to continue..."; exit 1; } + +[ -z "$THREADS" ] && THREADS=1; +[ -z "$march" ] && march=native; +[ -z "$mtune" ] && mtune=native; +[ -z "$CFLAGS" ] && CFLAGS=""; +[ -z "$CONFIGURE_FLAGS" ] && CONFIGURE_FLAGS=""; + +$CC -O3 -march=$march -mtune=$mtune -fno-gcse $CFLAGS -Q --help=target >> "$DIR/install.log" 2>&1 if [ $? -ne 0 ]; then - gcc -O3 -fno-gcse $CFLAGS -Q --help=target >> "$DIR/install.log" 2>&1 + $CC -O3 -fno-gcse $CFLAGS -Q --help=target >> "$DIR/install.log" 2>&1 if [ $? -ne 0 ]; then export CFLAGS="-O3 -fno-gcse " else export CFLAGS="-O3 -fno-gcse $CFLAGS" fi else - export CFLAGS="-O3 -march=$march -mcpu=$mcpu -mtune=$mtune -fno-gcse $CFLAGS" + export CFLAGS="-O3 -march=$march -mtune=$mtune -fno-gcse $CFLAGS" fi @@ -56,25 +99,29 @@ wget http://php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror -q -O - | tar - mv php-$PHP_VERSION php echo " done!" -#libedit -echo -n "[libedit] downloading $LIBEDIT_VERSION..." -wget http://download.sourceforge.net/project/libedit/libedit/libedit-$LIBEDIT_VERSION/libedit-$LIBEDIT_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1 -echo -n " checking..." -cd libedit -./configure --prefix="$DIR/install_data/php/ext/libedit" --enable-static >> "$DIR/install.log" 2>&1 -echo -n " compiling..." -if make -j $THREADS >> "$DIR/install.log" 2>&1; then - echo -n " installing..." - make install >> "$DIR/install.log" 2>&1 - HAVE_LIBEDIT="--with-libedit=$DIR/install_data/php/ext/libedit" -else - echo -n " disabling..." +if [ "$1" == "crosscompile" ] || [ "$1" == "rpi" ]; then HAVE_LIBEDIT="--without-libedit" +else + #libedit + echo -n "[libedit] downloading $LIBEDIT_VERSION..." + wget http://download.sourceforge.net/project/libedit/libedit/libedit-$LIBEDIT_VERSION/libedit-$LIBEDIT_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1 + echo -n " checking..." + cd libedit + ./configure --prefix="$DIR/install_data/php/ext/libedit" --enable-static >> "$DIR/install.log" 2>&1 + echo -n " compiling..." + if make -j $THREADS >> "$DIR/install.log" 2>&1; then + echo -n " installing..." + make install >> "$DIR/install.log" 2>&1 + HAVE_LIBEDIT="--with-libedit=\"$DIR/install_data/php/ext/libedit\"" + else + echo -n " disabling..." + HAVE_LIBEDIT="--without-libedit" + fi + echo -n " cleaning..." + cd .. + rm -r -f ./libedit + echo " done!" fi -echo -n " cleaning..." -cd .. -rm -r -f ./libedit -echo " done!" #zlib echo -n "[zlib] downloading $ZLIB_VERSION..." @@ -93,8 +140,8 @@ cd .. rm -r -f ./zlib echo " done!" -if [ "$(uname -s)" == "Darwin" ]; then - WITH_CURL="--with-curl=shared,/usr/local" +if [ "$(uname -s)" == "Darwin" ] && [ "$1" != "crosscompile" ]; then + HAVE_CURL="shared,/usr/local" else #curl echo -n "[cURL] downloading $CURL_VERSION..." @@ -104,8 +151,11 @@ else cd curl ./buildconf >> "$DIR/install.log" 2>&1 ./configure --enable-ipv6 \ + --enable-optimize \ + --enable-http \ + --enable-ftp \ --disable-dict \ - --disable-file \ + --enable-file \ --disable-gopher \ --disable-imap \ --disable-pop3 \ @@ -114,7 +164,8 @@ else --disable-telnet \ --disable-tftp \ --prefix="$DIR/install_data/php/ext/curl" \ - --disable-shared >> "$DIR/install.log" 2>&1 + --disable-shared \ + $CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1 echo -n " compiling..." make -j $THREADS >> "$DIR/install.log" 2>&1 echo -n " installing..." @@ -123,7 +174,7 @@ else cd .. rm -r -f ./curl echo " done!" - WITH_CURL="--with-curl=\"$DIR/install_data/php/ext/curl\"" + HAVE_CURL="$DIR/install_data/php/ext/curl" fi #pthreads @@ -140,12 +191,11 @@ if which free >/dev/null; then else MAX_MEMORY=$(top -l 1 | grep PhysMem: | awk '{print $10}' | tr -d 'a-zA-Z') fi -if [ $MAX_MEMORY -gt 512 ] -then - echo -n " enabling optimizations..." - OPTIMIZATION="--enable-inline-optimization " +if [ $MAX_MEMORY -gt 512 ] && [ "$1" != "crosscompile" ]; then + echo -n " enabling optimizations..." + OPTIMIZATION="--enable-inline-optimization " else - OPTIMIZATION="--disable-inline-optimization " + OPTIMIZATION="--disable-inline-optimization " fi set -e echo -n " checking..." @@ -154,11 +204,15 @@ rm -rf ./aclocal.m4 >> "$DIR/install.log" 2>&1 rm -rf ./autom4te.cache/ >> "$DIR/install.log" 2>&1 rm -f ./configure >> "$DIR/install.log" 2>&1 ./buildconf --force >> "$DIR/install.log" 2>&1 +if [ "$1" == "crosscompile" ]; then + sed -i 's/pthreads_working=no/pthreads_working=yes/' ./configure + export LIBS="-lpthread -ldl" +fi ./configure $OPTIMIZATION--prefix="$DIR/php5" \ --exec-prefix="$DIR/php5" \ -"$WITH_CURL" \ +--with-curl="$HAVE_CURL" \ --with-zlib="$DIR/install_data/php/ext/zlib" \ -"$HAVE_LIBEDIT" \ +$HAVE_LIBEDIT \ --disable-libxml \ --disable-xml \ --disable-dom \ @@ -186,8 +240,14 @@ rm -f ./configure >> "$DIR/install.log" 2>&1 --without-iconv \ --without-pdo \ --without-pdo-sqlite \ ---with-zend-vm=$ZEND_VM >> "$DIR/install.log" 2>&1 +--with-zend-vm=$ZEND_VM \ +$CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1 echo -n " compiling..." +if [ "$1" == "android" ]; then + sed -i 's/-export-dynamic/-all-static/g' Makefile +elif [ "$1" == "crosscompile" ] && [ "$1" == "android" ]; then + sed -i 's/-export-dynamic/-all-static/g' Makefile +fi make -j $THREADS >> "$DIR/install.log" 2>&1 echo -n " installing..." make install >> "$DIR/install.log" 2>&1 diff --git a/src/build/cross-compile.sh b/src/build/cross-compile.sh deleted file mode 100644 index ed6b2044c6..0000000000 --- a/src/build/cross-compile.sh +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/bash -COMPILER_VERSION="0.12" - -PHP_VERSION="5.4.15" -ZEND_VM="GOTO" - -#Uncomment the double commented lines to enable (semi-broken) libedit support for cross compiling -##NCURSES_VERSION="5.9" -##LIBEDIT_VERSION="0.3" -ZLIB_VERSION="1.2.8" -PTHREADS_VERSION="0b863ea34e1f5c0a0eef6d50a7cbca58d39435cc" -CURL_VERSION="curl-7_30_0" - -if [ "$1" == "android" ]; then - TOOLCHAIN_PREFIX="arm-none-linux-gnueabi" -elif [ "$1" == "rpi" ]; then - TOOLCHAIN_PREFIX="arm-linux-gnueabihf" - march="armv6zk" - mcpu="arm1176jzf-s" - mtune="arm1176jzf-s" - CFLAGS="-mfloat-abi=hard -mfpu=vfp" -else - echo "Please supply a proper platform" - exit 1 -fi - -export CC="$TOOLCHAIN_PREFIX-gcc" -CROSS_COMPILE_FLAGS="--host=$TOOLCHAIN_PREFIX" - -echo "[PocketMine] PHP installer and compiler for Linux & Mac - v$COMPILER_VERSION" -DIR="$(pwd)" -date > "$DIR/install.log" 2>&1 -uname -a >> "$DIR/install.log" 2>&1 -echo "[INFO] Checking dependecies" -type make >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"make\""; read -p "Press [Enter] to continue..."; exit 1; } -type autoconf >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"autoconf\""; read -p "Press [Enter] to continue..."; exit 1; } -type automake >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"automake\""; read -p "Press [Enter] to continue..."; exit 1; } -type libtool >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"libtool\""; read -p "Press [Enter] to continue..."; exit 1; } -type $CC >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install the correct cross compiler \"$CC\" and add the directory to PATH"; read -p "Press [Enter] to continue..."; exit 1; } -type m4 >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"m4\""; read -p "Press [Enter] to continue..."; exit 1; } -type wget >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"wget\""; read -p "Press [Enter] to continue..."; exit 1; } -type sed >> "$DIR/install.log" 2>&1 || { echo >&2 "[ERROR] Please install \"sed\""; read -p "Press [Enter] to continue..."; exit 1; } - -[ -z "$THREADS" ] && THREADS=1; -[ -z "$march" ] && march="native"; -[ -z "$mcpu" ] && mcpu="native"; -[ -z "$mtune" ] && mtune="native"; -[ -z "$CFLAGS" ] && CFLAGS=""; - -$CC -O3 -march=$march -mcpu=$mcpu -mtune=$mtune -fno-gcse $CFLAGS -Q --help=target >> "$DIR/install.log" 2>&1 -if [ $? -ne 0 ]; then - $CC -O3 -fno-gcse $CFLAGS -Q --help=target >> "$DIR/install.log" 2>&1 - if [ $? -ne 0 ]; then - export CFLAGS="-O3 -fno-gcse " - else - export CFLAGS="-O3 -fno-gcse $CFLAGS" - fi -else - export CFLAGS="-O3 -march=$march -mcpu=$mcpu -mtune=$mtune -fno-gcse $CFLAGS" -fi - - -rm -r -f install_data/ >> "$DIR/install.log" 2>&1 -rm -r -f php5/ >> "$DIR/install.log" 2>&1 -rm -r -f bin/ >> "$DIR/install.log" 2>&1 -mkdir -m 0777 install_data >> "$DIR/install.log" 2>&1 -mkdir -m 0777 php5 >> "$DIR/install.log" 2>&1 -mkdir -m 0777 bin >> "$DIR/install.log" 2>&1 -cd install_data -set -e - -#PHP 5 -echo -n "[PHP] downloading $PHP_VERSION..." -wget http://php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror -q -O - | tar -zx >> "$DIR/install.log" 2>&1 -mv php-$PHP_VERSION php -echo " done!" - -#ncurses -##echo -n "[ncurses] downloading $NCURSES_VERSION..." -##wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-$NCURSES_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1 -##mv ncurses-$NCURSES_VERSION ncurses -##echo -n " checking..." -##cd ncurses -##./configure --prefix="$DIR/install_data/php/ext/ncurses" \ -##--enable-static --enable-termcap $CROSS_COMPILE_FLAGS >> "$DIR/install.log" 2>&1 -##echo -n " compiling..." -##make -j $THREADS >> "$DIR/install.log" 2>&1 -##echo -n " installing..." -##make install >> "$DIR/install.log" 2>&1 -##echo -n " cleaning..." -##cd .. -##rm -r -f ./ncurses -##echo " done!" - -#libedit -##echo -n "[libedit] downloading $LIBEDIT_VERSION..." -##wget http://download.sourceforge.net/project/libedit/libedit/libedit-$LIBEDIT_VERSION/libedit-$LIBEDIT_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1 -##echo -n " checking..." -##cd libedit - -##remove -##CFLAGS=$CFLAGS" -I$DIR/install_data/php/ext/ncurses/include/ncurses -I$DIR/install_data/php/ext/ncurses/include" ./configure --prefix="$DIR/install_data/php/ext/libedit" --enable-static $CROSS_COMPILE_FLAGS >> "$DIR/install.log" 2>&1 -##echo -n " compiling..." -##if make -j $THREADS >> "$DIR/install.log" 2>&1 ; then -## echo -n " installing..." -## make install >> "$DIR/install.log" 2>&1 -## HAVE_LIBEDIT="--with-libedit=$DIR/install_data/php/ext/libedit" -##else -## echo -n " disabling..." - HAVE_LIBEDIT="--without-libedit" -##fi -##echo -n " cleaning..." -##cd .. -##rm -r -f ./libedit -##echo " done!" - -#zlib -echo -n "[zlib] downloading $ZLIB_VERSION..." -wget http://zlib.net/zlib-$ZLIB_VERSION.tar.gz -q -O - | tar -zx >> "$DIR/install.log" 2>&1 -mv zlib-$ZLIB_VERSION zlib -echo -n " checking..." -cd zlib -./configure --prefix="$DIR/install_data/php/ext/zlib" \ ---static >> "$DIR/install.log" 2>&1 -echo -n " compiling..." -make -j $THREADS >> "$DIR/install.log" 2>&1 -echo -n " installing..." -make install >> "$DIR/install.log" 2>&1 -echo -n " cleaning..." -cd .. -rm -r -f ./zlib -echo " done!" - -#curl -echo -n "[cURL] downloading $CURL_VERSION..." -wget https://github.com/bagder/curl/archive/$CURL_VERSION.tar.gz --no-check-certificate -q -O - | tar -zx >> "$DIR/install.log" 2>&1 -mv curl-$CURL_VERSION curl -echo -n " checking..." -cd curl -./buildconf >> "$DIR/install.log" 2>&1 -./configure --enable-ipv6 \ ---disable-dict \ ---disable-file \ ---disable-gopher \ ---disable-imap \ ---disable-pop3 \ ---disable-rtsp \ ---disable-smtp \ ---disable-telnet \ ---disable-tftp \ ---prefix="$DIR/install_data/php/ext/curl" \ ---disable-shared \ -$CROSS_COMPILE_FLAGS >> "$DIR/install.log" 2>&1 -echo -n " compiling..." -make -j $THREADS >> "$DIR/install.log" 2>&1 -echo -n " installing..." -make install >> "$DIR/install.log" 2>&1 -echo -n " cleaning..." -cd .. -rm -r -f ./curl -echo " done!" - -#pthreads -echo -n "[PHP pthreads] downloading $PTHREADS_VERSION..." -wget https://github.com/krakjoe/pthreads/archive/$PTHREADS_VERSION.tar.gz --no-check-certificate -q -O - | tar -zx >> "$DIR/install.log" 2>&1 -mv pthreads-$PTHREADS_VERSION "$DIR/install_data/php/ext/pthreads" -echo " done!" - - -echo -n "[PHP]" -#Amount of RAM isn't known ahead of time, so disable optimizations -OPTIMIZATION="--disable-inline-optimization " -set -e -echo -n " checking..." -cd php -rm -rf ./aclocal.m4 >> "$DIR/install.log" 2>&1 -rm -rf ./autom4te.cache/ >> "$DIR/install.log" 2>&1 -rm -f ./configure >> "$DIR/install.log" 2>&1 -./buildconf --force >> "$DIR/install.log" 2>&1 -##LDFLAGS="-R$DIR/install_data/php/ext/libedit/lib -L$DIR/install_data/php/ext/libedit/lib -R'$DIR/install_data/php/ext/ncurses/lib' -L$DIR/install_data/php/ext/ncurses/lib" EXTRA_LDFLAGS="-R$DIR/install_data/php/ext/libedit/lib -L$DIR/install_data/php/ext/libedit/lib -R'$DIR/install_data/php/ext/ncurses/lib' -L$DIR/install_data/php/ext/ncurses/lib" LIBS="-lncurses" CFLAGS=$CFLAGS"-I$DIR/install_data/php/ext/libedit/include" \ -sed -i 's/pthreads_working=no/pthreads_working=yes/' ./configure -LIBS="-lpthread -ldl" ./configure $OPTIMIZATION--prefix="$DIR/php5" \ ---exec-prefix="$DIR/php5" \ ---with-curl="$DIR/install_data/php/ext/curl" \ ---with-zlib="$DIR/install_data/php/ext/zlib" \ -"$HAVE_LIBEDIT" \ ---disable-libxml \ ---disable-xml \ ---disable-dom \ ---disable-simplexml \ ---disable-xmlreader \ ---disable-xmlwriter \ ---disable-cgi \ ---disable-session \ ---disable-zip \ ---disable-debug \ ---disable-phar \ ---enable-ctype \ ---enable-sockets \ ---enable-shared=no \ ---enable-static=yes \ ---enable-shmop \ ---enable-pcntl \ ---enable-pthreads \ ---enable-maintainer-zts \ ---enable-zend-signals \ ---enable-embedded-mysqli \ ---enable-bcmath \ ---enable-cli \ ---without-pear \ ---without-iconv \ ---without-pdo \ ---without-pdo-sqlite \ ---with-zend-vm=$ZEND_VM \ -$CROSS_COMPILE_FLAGS >> "$DIR/install.log" 2>&1 -echo -n " compiling..." -if [ "$1" == "android" ]; then - sed -i 's/-export-dynamic/-all-static/g' Makefile -fi -##ln -s $DIR/install_data/php/ext/libedit/include/readline $DIR/install_data/php/ext/libedit/include/editline -##CFLAGS=$CFLAGS"-I$DIR/install_data/php/ext/libedit/include" LDFLAGS="-R$DIR/install_data/php/ext/libedit/lib -L$DIR/install_data/php/ext/libedit/lib -R'$DIR/install_data/php/ext/ncurses/lib' -L$DIR/install_data/php/ext/ncurses/lib" \ -make -j $THREADS >> "$DIR/install.log" 2>&1 -echo -n " installing..." -make install >> "$DIR/install.log" 2>&1 -echo " done!" -cd "$DIR" -echo -n "[INFO] Cleaning up..." -rm -r -f install_data/ >> "$DIR/install.log" 2>&1 -mv php5/bin/php bin/php -rm -r -f php/ >> "$DIR/install.log" 2>&1 -date >> "$DIR/install.log" 2>&1 -echo " done!" -echo "[PocketMine] You should start the server now using \"./start.sh\"" -echo "[PocketMine] If it doesn't works, please send the \"install.log\" file to the Bug Tracker"