-
Notifications
You must be signed in to change notification settings - Fork 8
/
install_x64.sh
executable file
·56 lines (46 loc) · 1.76 KB
/
install_x64.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# checking required packages
for PKG in php7.1-dev libncurses5-dev php-pear libreadline-dev make; do
dpkg -s "$PKG" >/dev/null 2>&1 && {
echo "$PKG already installed. Skipping..."
} || {
echo "$PKG is not installed. Try to install..."
apt-get -y install $PKG
}
done;
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LUA_DOWNLOAD_URL=http://www.lua.org/ftp/
LUA_VERSION=5.3.4
LUA_GET_URL=${LUA_DOWNLOAD_URL}lua-${LUA_VERSION}.tar.gz
PECL_VERSION=2.0.3
PHP_LUA_DOWNLOAD_URL=http://pecl.php.net/get/lua-${PECL_VERSION}.tgz
PHP_VERSION=$(grep '#define PHP_API_VERSION' /usr/include/php5/main/php.h|sed 's/#define PHP_API_VERSION//' | sed 's/\s//');
echo "======= Getting lua and php lua source ======="
mkdir /tmp/phplua
cd /tmp/phplua
echo "======= Getting lua source from ${LUA_GET_URL} ======="
wget $LUA_GET_URL
echo "======= Getting php lua source ======="
wget $PHP_LUA_DOWNLOAD_URL
echo "======= Extracting source ======="
tar -xf lua-${LUA_VERSION}.tar.gz
tar -xf lua-${PECL_VERSION}.tgz
echo "======= Building Lua ======="
cd /tmp/phplua/lua-${LUA_VERSION}
#patching makefile for compiling in 64 bit
echo "Adding -fPIC argument to compiler for building in 64bit system"
sed -i 's/CFLAGS= -O2/CFLAGS= -fPIC -O2/g' src/Makefile
make linux test
make linux install
echo "======= Building PHP Lua ======="
cd /tmp/phplua/lua-${PECL_VERSION}
echo "Patching config for building in 64bit system"
patch -p1 ${SCRIPT_DIR}/config.m4 -i ${SCRIPT_DIR}/config_x64.path
cp ${SCRIPT_DIR}/config.m4 /tmp/phplua/lua-${PECL_VERSION}/
phpize
./configure
# patching php-lua by adding include path for lua sources
sed -i "s/INCLUDES =/INCLUDES = -I\/tmp\/phplua\/lua-${LUA_VERSION}\/src/g" /tmp/phplua/lua-${PECL_VERSION}/Makefile
make
make install
rm -r /tmp/phplua