static-php-cli/docker/compile-php.sh

33 lines
1.1 KiB
Bash
Raw Normal View History

2021-06-02 19:57:55 +08:00
#!/bin/sh
VER_PHP="$1"
2021-06-06 01:01:58 +08:00
self_dir=$(cd "$(dirname "$0")";pwd)
php_dir=$(find $self_dir/source -name "php-$VER_PHP" -type d | tail -n1)
2021-06-02 19:57:55 +08:00
function php_compile_args() {
_php_arg="--prefix=$self_dir/php-dist"
2021-06-02 19:57:55 +08:00
_php_arg="$_php_arg --disable-all"
_php_arg="$_php_arg --enable-shared=no"
_php_arg="$_php_arg --enable-static=yes"
_php_arg="$_php_arg --enable-inline-optimization"
_php_arg="$_php_arg --with-layout=GNU"
_php_arg="$_php_arg --with-pear=no"
_php_arg="$_php_arg --disable-cgi"
_php_arg="$_php_arg --disable-phpdbg"
2021-06-06 01:01:58 +08:00
_php_arg="$_php_arg $($self_dir/check-extensions.sh check_in_configure $1)"
2021-06-02 19:57:55 +08:00
echo $_php_arg
}
2021-06-06 01:01:58 +08:00
php_compile_args && sleep 1s
2021-06-02 19:57:55 +08:00
2021-06-06 01:01:58 +08:00
cd $php_dir && \
2021-06-02 19:57:55 +08:00
./buildconf --force && \
./configure LDFLAGS=-static $(php_compile_args $VER_PHP) && \
2021-06-06 01:01:58 +08:00
$self_dir/check-extensions.sh check_after_configure && \
2021-06-02 19:57:55 +08:00
sed -ie 's/-export-dynamic//g' "Makefile" && \
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "Makefile" && \
2022-05-09 19:10:59 +08:00
make LDFLAGS="-ldl -llzma -lbz2" -j$(cat /proc/cpuinfo | grep processor | wc -l) && \
2021-06-06 01:01:58 +08:00
make install && \
2021-12-18 02:17:05 +08:00
strip $self_dir/php-dist/bin/php