From ce5b20a1631a47b63f750bfc1da1923d639eb1e5 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 28 Jun 2017 10:23:54 +0200 Subject: [PATCH] Now this installs the lua extension, too --- config.m4 | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ config_x64.path | 21 ++++++++++++++++++++ php.sh | 29 ++++++++++++++++++++++++++- 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 config.m4 create mode 100644 config_x64.path diff --git a/config.m4 b/config.m4 new file mode 100644 index 0000000..c790ece --- /dev/null +++ b/config.m4 @@ -0,0 +1,52 @@ +dnl $Id: config.m4 321796 2012-01-05 17:23:48Z laruence $ +PHP_ARG_WITH(lua, for lua support, +[ --with-lua=[DIR] Include php lua support]) + +if test "$PHP_LUA" != "no"; then + if test -r $PHP_LUA/include/lua.h; then + LUA_DIR=$PHP_LUA + else + AC_MSG_CHECKING(for lua in default path) + for i in /usr/local /usr/include/lua/5.2.1 /tmp/phplua/lua-5.2.1/src; do + if test -r $i/lua.h; then + LUA_DIR=$i + AC_MSG_RESULT(found in $i) + break + fi + done + fi + + LUA_DIR=/usr/local/include + + if test -z "$LUA_DIR"; then + AC_MSG_RESULT(not found) + AC_MSG_ERROR(Please reinstall the lua distribution - lua.h should be in /include/) + fi + + LUA_LIB_NAME=liblua.a + + if test -r $PHP_LUA/$PHP_LIBDIR/${LUA_LIB_NAME}; then + LUA_LIB_DIR=$PHP_LUA/$PHP_LIBDIR + else + AC_MSG_CHECKING(for lua library in default path) + for i in /usr/lib /usr/lib64; do + if test -r $i/${LUA_LIB_NAME}; then + LUA_LIB_DIR=$i + AC_MSG_RESULT(found in $i) + break + fi + done + fi + + LUA_LIB_DIR=/usr/local/lib + + if test -z "$LUA_LIB_DIR"; then + AC_MSG_RESULT(not found) + AC_MSG_ERROR(Please reinstall the lua distribution - lua library should be in /lib/) + fi + + PHP_ADD_INCLUDE($LUA_DIR/include) + PHP_ADD_LIBRARY_WITH_PATH(lua, $LUA_LIB_DIR, LUA_SHARED_LIBADD) + PHP_SUBST(LUA_SHARED_LIBADD) + PHP_NEW_EXTENSION(lua, lua.c lua_closure.c, $ext_shared) +fi diff --git a/config_x64.path b/config_x64.path new file mode 100644 index 0000000..91572fd --- /dev/null +++ b/config_x64.path @@ -0,0 +1,21 @@ +*** config.m4 2013-06-26 10:23:10.139973845 +0800 +--- config_x64.m4 2013-06-26 11:50:18.772203193 +0800 +*************** +*** 7,14 **** + LUA_DIR=$PHP_LUA + else + AC_MSG_CHECKING(for lua in default path) +! for i in /usr/local /usr; do +! if test -r $i/include/lua/5.2.1/lua.h; then + LUA_DIR=$i + AC_MSG_RESULT(found in $i) + break +--- 7,14 ---- + LUA_DIR=$PHP_LUA + else + AC_MSG_CHECKING(for lua in default path) +! for i in /usr/local /usr/include/lua/5.2.1 /tmp/phplua/lua-5.2.1/src; do +! if test -r $i/lua.h; then + LUA_DIR=$i + AC_MSG_RESULT(found in $i) + break diff --git a/php.sh b/php.sh index ce1c3ba..fa8e1f8 100644 --- a/php.sh +++ b/php.sh @@ -1,7 +1,8 @@ + # If you add some configuration command, add the dependencies here apt-get update apt-get -y dist-upgrade -apt-get install -y libicu-dev libmcrypt-dev libssl-dev libcurl4-openssl-dev libbz2-dev libxml2-dev libpng-dev libjpeg-dev libedit-dev libgmp-dev openssl bc libbison-dev bison build-essential git-core vim curl pkg-config libgmp-dev autoconf libopus-dev +apt-get install -y libicu-dev libmcrypt-dev libssl-dev libcurl4-openssl-dev libbz2-dev libxml2-dev libpng-dev libjpeg-dev libedit-dev libgmp-dev openssl bc libbison-dev bison build-essential git-core vim curl pkg-config libgmp-dev autoconf libopus-dev libreadline-dev libncurses5-dev if [ -d php-script-stuff/ ]; then rm -rf php-script-stuff @@ -63,7 +64,33 @@ cd ../php-libtgvoip make -j16 make install +cd .. +LUA_DOWNLOAD_URL=http://www.lua.org/ftp/ +LUA_VERSION=5.2.1 +LUA_GET_URL=${LUA_DOWNLOAD_URL}lua-${LUA_VERSION}.tar.gz +PHP_LUA_DOWNLOAD_URL=http://pecl.php.net/get/lua-2.0.3.tgz +PHP_VERSION=$(php-config --phpapi) + + +wget $LUA_GET_URL $PHP_LUA_DOWNLOAD_URL http://daniil.it/config.m4 http://daniil.it/config_x64.path +tar -xf lua-${LUA_VERSION}.tar.gz +tar -xf lua-2.0.2.tgz + +cd lua-${LUA_VERSION} +sed -i 's/CFLAGS= -O2/CFLAGS= -fPIC -O2/g' src/Makefile +make linux test +make linux install + +patch -p1 config.m4 -i config_x64.path + +cd ../lua-2.0.2 +cp ../config.m4 . +phpize +./configure +sed -i "s/INCLUDES =/INCLUDES = -I\/tmp\/phplua\/lua-${LUA_VERSION}\/src/g" /tmp/phplua/lua-2.0.2/Makefile +make +make install cd ../.. rm -rf php-script-stuff