Improvements to installation script

* More status updates
* Output ./configure options for easy debugging
* Support sodium and gmp extensions
This commit is contained in:
Michael Bianco
2021-04-23 11:36:12 -06:00
parent 248e9c6e2a
commit 259994fadc

View File

@@ -13,6 +13,7 @@ install_php() {
local tmp_download_dir=${TMPDIR%/} local tmp_download_dir=${TMPDIR%/}
fi fi
echo "Determining configuration options..."
local source_path=$(get_download_file_path $install_type $version $tmp_download_dir) local source_path=$(get_download_file_path $install_type $version $tmp_download_dir)
local configure_options="$(construct_configure_options $install_path)" local configure_options="$(construct_configure_options $install_path)"
local make_flags="-j$ASDF_CONCURRENCY" local make_flags="-j$ASDF_CONCURRENCY"
@@ -66,11 +67,13 @@ install_php() {
fi fi
fi fi
echo "Downloading source code..."
download_source $install_type $version $source_path download_source $install_type $version $source_path
# Running this in a subshell because we don't to disturb the current # Running this in a subshell because we don't to disturb the current
# working directory. # working directory.
( (
echo "Extracting source code..."
cd $(dirname $source_path) cd $(dirname $source_path)
tar -zxf $source_path || exit 1 tar -zxf $source_path || exit 1
@@ -80,12 +83,20 @@ install_php() {
# target=$(get_target) # target=$(get_target)
# Build PHP # Build PHP
echo "Running buildconfig..."
./buildconf --force || exit 1 ./buildconf --force || exit 1
echo "Running ./configure $configure_options"
./configure $configure_options || exit 1 ./configure $configure_options || exit 1
echo "Running make \"$make_flags\""
make "$make_flags" || exit 1 make "$make_flags" || exit 1
echo "Running make install..."
# make "$make_flags" test || exit 1 # make "$make_flags" test || exit 1
make "$make_flags" install || exit 1 make "$make_flags" install || exit 1
) )
# it's not obvious where php.ini should be placed, let us make it easy for the user
mkdir $install_path/conf.d/
echo "# add system-wide php configuration options here" > $install_path/conf.d/php.ini
} }
install_composer() { install_composer() {
@@ -101,6 +112,8 @@ install_composer() {
construct_configure_options() { construct_configure_options() {
local install_path=$1 local install_path=$1
# many options included below are not applicable to newer PHP versions
# including these will trigger a build warning, but will not b
global_config="--prefix=$install_path \ global_config="--prefix=$install_path \
--enable-bcmath \ --enable-bcmath \
--enable-calendar \ --enable-calendar \
@@ -146,12 +159,6 @@ construct_configure_options() {
local configure_options="$PHP_CONFIGURE_OPTIONS $global_config" local configure_options="$PHP_CONFIGURE_OPTIONS $global_config"
fi fi
if [ "${PHP_WITH_GMP:-no}" != "no" ]; then
configure_options="$configure_options --with-gmp"
else
configure_options="$configure_options --without-gmp"
fi
if [ "${PHP_WITHOUT_PEAR:-no}" != "no" ]; then if [ "${PHP_WITHOUT_PEAR:-no}" != "no" ]; then
configure_options="$configure_options --without-pear" configure_options="$configure_options --without-pear"
else else
@@ -208,8 +215,25 @@ os_based_configure_options() {
local webp_path=$(homebrew_package_path webp) local webp_path=$(homebrew_package_path webp)
local zlib_path=$(homebrew_package_path zlib) local zlib_path=$(homebrew_package_path zlib)
# optional
# if these packages exist they are included in the php compilation
local gmp_path=$(homebrew_package_path gmp)
local sodium_path=$(homebrew_package_path libsodium)
if [ -n "$gmp_path" ]; then
configure_options="--with-gmp=$gmp_path"
else
echo "gmp not found, not including in installation"
fi
if [ -n "$sodium_path" ]; then
configure_options="$configure_options --with-sodium=$sodium_path"
else
echo "sodium not found, not including in installation"
fi
if [ -n "$freetype_path" ]; then if [ -n "$freetype_path" ]; then
configure_options="--with-freetype-dir=$freetype_path" configure_options="$configure_options --with-freetype-dir=$freetype_path"
else else
export ASDF_PKG_MISSING="freetype" export ASDF_PKG_MISSING="freetype"
fi fi
@@ -366,4 +390,4 @@ get_php_version() {
} }
install_php $ASDF_INSTALL_TYPE $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH install_php $ASDF_INSTALL_TYPE $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH
install_composer $ASDF_INSTALL_PATH install_composer ${ASDF_INSTALL_PATH}