66# This source file is subject the MIT license, that is bundled with this
77# package in the file LICENSE, and is available through the world-wide-web
88# at the following url: http://zephir-lang.com/license.html
9-
10- # Available params:
11- # --phpize
12- # --php-config
139#
14- # Example:
15- # ./install --phpize /usr/bin/phpize5.6 --php-config /usr/bin/php-config5.6
16-
17- set -e
10+ # Available options:
11+ # --phpize <PATH> Path to custom `phpize' executable
12+ # --php-config <PATH> Path to custom `php-config' executable
13+ #
14+ # Available env. vars:
15+ # RE2C_BIN Path to custom `re2c'
16+ #
17+ # Usage:
18+ #
19+ # Build and install extension using default PHP's paths:
20+ # ./install-development
21+ #
22+ # Build and install extension using custom PHP's paths:
23+ # ./install-development --phpize /usr/bin/phpize5.6 --php-config /usr/bin/php-config5.6
1824
1925CURRENT_DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
2026
21- GCC_BIN=$( command -v gcc 2> /dev/null)
22- RE2C_BIN=${RE2C_BIN:- $( command -v re2c 2>/ dev/ null) }
27+ GCC_BIN=` command -v gcc 2> /dev/null || true `
28+ RE2C_BIN=${RE2C_BIN:- ` command -v re2c 2>/ dev/ null || true` }
2329
2430if [ x" $RE2C_BIN " = x ]; then
25- echo -e " error: unable to locate the re2c"
26- exit 1
31+ echo -e " error: unable to locate the re2c"
32+ exit 1
2733fi
2834
2935if [ x" $GCC_BIN " = x ]; then
3036 echo -e " error: unable to locate the gcc"
3137 exit 1
3238fi
3339
40+ re2c_vernum=` re2c --vernum 2> /dev/null`
41+ if test -z " $re2c_vernum " ; then
42+ echo " error: unable to locate the re2c"
43+ exit 1
44+ fi
45+
46+ if test " $re2c_vernum " -lt " 1306" ; then
47+ echo " error: minimal required version of re2c is 0.13.6"
48+ exit 1
49+ fi
50+
3451# Check best compilation flags for compiler
3552export CC=gcc
3653export CFLAGS=" -march=native -mtune=native -O2 -fomit-frame-pointer"
3754
3855# Set defaults
39- PHPIZE_BIN=$( command -v phpize 2> /dev/null)
40- PHPCONFIG_BIN=$( command -v php-config 2> /dev/null)
56+ PHPIZE_BIN=` command -v phpize 2> /dev/null || true `
57+ PHPCONFIG_BIN=` command -v php-config 2> /dev/null || true `
4158
4259# Translate long options to short
4360for arg in " $@ " ; do
44- shift
45- case " $arg " in
46- " --phpize" ) set -- " $@ " " -i" ;;
47- " --php-config" ) set -- " $@ " " -c" ;;
48- * ) set -- " $@ " " $arg "
49- esac
61+ shift
62+ case " $arg " in
63+ " --phpize" ) set -- " $@ " " -i" ;;
64+ " --php-config" ) set -- " $@ " " -c" ;;
65+ * ) set -- " $@ " " $arg "
66+ esac
5067done
5168
5269# Options switcher
5370while getopts i:c: opts; do
54- case ${opts} in
55- i) PHPIZE_BIN=${OPTARG} ;;
56- c) PHPCONFIG_BIN=${OPTARG} ;;
57- esac
71+ case ${opts} in
72+ i) PHPIZE_BIN=${OPTARG} ;;
73+ c) PHPCONFIG_BIN=${OPTARG} ;;
74+ esac
5875done
5976
6077PHP_FULL_VERSION=` ${PHPCONFIG_BIN} --version`
@@ -113,7 +130,7 @@ rm -f \
113130 parser.php7.out \
114131 config.h.in~
115132
116- ${RE2C_BIN} -o scanner.c scanner.re
133+ ${RE2C_BIN} --no-generation-date - o scanner.c scanner.re
117134
118135# Compile lemon
119136${CC} lemon.c -o lemon
@@ -147,7 +164,6 @@ if [ -f Makefile ]; then
147164 ${PHPIZE_BIN} --clean
148165fi
149166
150- # Perform the compilation
151167${PHPIZE_BIN}
152168
153169# For some reason the libtool script being generated by autogen contains lines referring
@@ -156,18 +172,22 @@ export echo=echo
156172
157173# Detect Gentoo Linux
158174if [ -f /etc/gentoo-release ]; then
159- LIBTOOLIZE_BIN=$( command -v libtoolize 2> /dev/null)
160- aclocal && ${LIBTOOLIZE_BIN} --force && autoheader && autoconf
175+ LIBTOOLIZE_BIN=` command -v libtoolize 2> /dev/null || true `
176+ aclocal && ${LIBTOOLIZE_BIN} --force && autoheader && autoconf
161177fi
162178
163179# Detect macOS
164180if [ " $( uname -s 2> /dev/null) " = " Darwin" ]; then
165- LIBTOOLIZE_BIN=$( command -v glibtoolize 2> /dev/null)
166- aclocal && ${LIBTOOLIZE_BIN} --force && autoheader && autoconf
181+ LIBTOOLIZE_BIN=` command -v glibtoolize 2> /dev/null || true `
182+ aclocal && ${LIBTOOLIZE_BIN} --force && autoheader && autoconf
167183fi
168184
169- ./configure --silent --with-php-config=${PHPCONFIG_BIN} --enable-zephir_parser
185+ ./configure \
186+ --silent \
187+ --with-php-config=${PHPCONFIG_BIN} \
188+ --enable-zephir_parser
170189
190+ # Perform the compilation
171191make -s -j" $( getconf _NPROCESSORS_ONLN) "
172192make -s install
173193
@@ -195,4 +215,3 @@ rm -f \
195215 config.h.in~
196216
197217echo -e " \nThanks for compiling Zephir Parser!\nBuild succeed: Please restart your web server to complete the installation\n"
198-
0 commit comments