forked from phalcon/cphalcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·146 lines (124 loc) · 3.52 KB
/
install
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
#
# Phalcon Framework
#
# Copyright (c) 2011-2017 Phalcon Team (https://phalconphp.com)
#
# This source file is subject to the New BSD License that is bundled
# with this package in the file LICENSE.txt.
#
# If you did not receive a copy of the license and are unable to
# obtain it through the world-wide-web, please send an email
# to license@phalconphp.com so we can send you a copy immediately.
#
# Authors: Andres Gutierrez <andres@phalconphp.com>
# Eduar Carvajal <eduar@phalconphp.com>
#
# Available params:
# --arch
# --phpize
# --php-config
#
# Example:
# ./install --phpize /usr/bin/phpize5.6 --php-config /usr/bin/php-config5.6 --arch 32bits
# Check best compilation flags for GCC
export CC="gcc"
export CFLAGS="-march=native -mtune=native -O2 -fomit-frame-pointer"
export CPPFLAGS="-DPHALCON_RELEASE"
# Set defaults
ARCH=
PHPIZE_BIN=$(command -v phpize 2>/dev/null)
PHPCONFIG_BIN=$(command -v php-config 2>/dev/null)
# Translate long options to short
for arg in "$@"; do
shift
case "$arg" in
"--arch") set -- "$@" "-a" ;;
"--phpize") set -- "$@" "-i" ;;
"--php-config") set -- "$@" "-c" ;;
*) set -- "$@" "$arg"
esac
done
# Options switcher
while getopts a:i:c: opts; do
case ${opts} in
a) ARCH=${OPTARG} ;;
i) PHPIZE_BIN=${OPTARG} ;;
c) PHPCONFIG_BIN=${OPTARG} ;;
esac
done
PHP_FULL_VERSION=`${PHPCONFIG_BIN} --version`
if [ $? != 0 ]; then
echo "php-config is not installed"
exit 1
fi
if [ "${PHP_FULL_VERSION:0:3}" == "5.3" ]; then
echo "php 5.3 is no longer supported"
exit 1
fi
if [ "${PHP_FULL_VERSION:0:3}" == "5.4" ]; then
echo "php 5.4 is no longer supported"
exit 1
fi
if [ "${PHP_FULL_VERSION:0:1}" == "5" ]; then
PHP_VERSION="php5"
else
PHP_VERSION="php7"
fi
# Detect possible flags
echo "int main() {}" > t.c
gcc ${CFLAGS} t.c -o t 2> t.t
if [ $? != 0 ]; then
chmod +x gcccpuopt
BFLAGS=`./gcccpuopt`
export CFLAGS="-O2 -fomit-frame-pointer $BFLAGS"
gcc ${CFLAGS} t.c -o t 2> t.t
if [ $? != 0 ]; then
export CFLAGS="-O2"
fi
fi
# Activate some gcc specific optimizations for gcc >= 4
if [ $(gcc -dumpversion | cut -f1 -d.) -ge 4 ]; then
gcc ${CFLAGS}-fvisibility=hidden t.c -o t 2> t.t && export CFLAGS="$CFLAGS -fvisibility=hidden"
fi
# gcc $CFLAGS -flto t.c -o t 2> t.t && { export CFLAGS="$CFLAGS -flto"; export LDFLAGS="$LDFLAGS $CFLAGS"; }
rm -f t.t t.c t
# Check processor architecture
if [ -z ${ARCH} ]; then
DIR="32bits"
gcc gccarch.c -o gccarch
if [ -f gccarch ]; then
P64BITS=`./gccarch`
if [ "$P64BITS" == "1" ]; then
DIR="64bits"
fi
fi
else
DIR=${ARCH}
fi
# Move to specified architecture
cd "$PHP_VERSION/$DIR"
# Clean current compilation
if [ -f Makefile ]; then
make clean
${PHPIZE_BIN} --clean
fi
# Perform the compilation
${PHPIZE_BIN}
# For some reason the libtool script being generated by autogen contains lines referring
# to "$echo message" instead of "echo message".
export echo=echo
# Detect Gentoo Linux
if [ -f /etc/gentoo-release ]; then
LIBTOOLIZE_BIN=$(command -v libtoolize 2>/dev/null)
aclocal && ${LIBTOOLIZE_BIN} --force && autoheader && autoconf
fi
# Detect macOS
if [ "$(uname -s 2>/dev/null)" = "Darwin" ]; then
LIBTOOLIZE_BIN=$(command -v glibtoolize 2>/dev/null)
aclocal && ${LIBTOOLIZE_BIN} --force && autoheader && autoconf
fi
./configure --silent --with-php-config=${PHPCONFIG_BIN} --enable-phalcon
make -s -j"$(getconf _NPROCESSORS_ONLN)"
make -s install
echo -e "\nThanks for compiling Phalcon!\nBuild succeed: Please restart your web server to complete the installation\n"