#!/bin/sh
# @function install php-extension-amf
function InstallPHPExtAmf()
{
    ShowResult "[green]正在安装PHP-Extension-Amf模块... [/green]" 1
    
    # install amf
    eval cd ${_PATH_COMPILATION_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval rm -rf ./amfext* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval tar zxvf ${_PATH_SOFTWARE_}/amfext* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval cd amfext* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval /usr/local/php/bin/phpize ${_SYS_SHOW_INSTALL_DETAILS_}
    eval ./configure --with-amf --with-php-config=/usr/local/php/bin/php-config ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make ${_SYS_MAKE_EXT_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make install ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $?
}

# @function install php-extension-apcu
function InstallPHPExtAPCu()
{
    local ver_=$1
    ver_=${ver_:-4}

    ShowResult "[green]正在安装PHP-Extension-APCu模块... [/green]" 1
    
    # install
    eval cd ${_PATH_COMPILATION_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval rm -rf ./apcu-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval tar zxvf ${_PATH_SOFTWARE_}/apcu-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval cd apcu-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval /usr/local/php/bin/phpize ${_SYS_SHOW_INSTALL_DETAILS_}
    eval ./configure --enable-apcu --with-php-config=/usr/local/php/bin/php-config ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make ${_SYS_MAKE_EXT_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make install ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $?
}

# @function install php-extension-igbinary
function InstallPHPExtIgbinary()
{
    local ver_=$1
    ver_=${ver_:-2}

    ShowResult "[green]正在安装PHP-Extension-IGBINARY模块... [/green]" 1
    
    # install
    eval cd ${_PATH_COMPILATION_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval rm -rf ./igbinary-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval tar zxvf ${_PATH_SOFTWARE_}/igbinary-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval cd igbinary-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval /usr/local/php/bin/phpize ${_SYS_SHOW_INSTALL_DETAILS_}
    eval ./configure CFLAGS=\"-O2 -g\" --enable-igbinary --with-php-config=/usr/local/php/bin/php-config ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make ${_SYS_MAKE_EXT_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make install ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $?
}

# @function install php-extension-libevent
function InstallPHPExtLibEvent()
{
    local ver_=$1
    ver_=${ver_:-0}

    ShowResult "[green]正在安装PHP-Extension-LibEvent模块... [/green]" 1
    
    # install
    eval cd ${_PATH_COMPILATION_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval rm -rf ./libevent-${ver_}.*.tgz ${_SYS_SHOW_INSTALL_DETAILS_}
    eval tar zxvf ${_PATH_SOFTWARE_}/libevent-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval cd libevent-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval /usr/local/php/bin/phpize ${_SYS_SHOW_INSTALL_DETAILS_}
    eval ./configure --with-libevent --with-php-config=/usr/local/php/bin/php-config ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make ${_SYS_MAKE_EXT_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make install ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $?
}

# @function install php-extension-redis
function InstallPHPExtRedis()
{
    local ver_=$1
    ver_=${ver_:-2}

    ShowResult "[green]正在安装PHP-Extension-Redis模块... [/green]" 1
    
    # install
    eval cd ${_PATH_COMPILATION_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval rm -rf ./redis-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval tar zxvf ${_PATH_SOFTWARE_}/redis-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval cd redis-${ver_}* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval /usr/local/php/bin/phpize ${_SYS_SHOW_INSTALL_DETAILS_}
    eval ./configure --enable-redis --enable-redis-igbinary --with-php-config=/usr/local/php/bin/php-config ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make ${_SYS_MAKE_EXT_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make install ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $?
}

# @function install php-extension-memcached
function InstallPHPExtMemcached()
{
    local ver_=$1
    ver_=${ver_:-2}

    ShowResult "[green]正在安装PHP-Extension-Memcached模块... [/green]" 1
    
    # install memcached-extension
    eval cd ${_PATH_COMPILATION_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval rm -rf ./memcached-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval tar zxvf ${_PATH_SOFTWARE_}/memcached-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval cd memcached-${ver_}.* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval /usr/local/php/bin/phpize ${_SYS_SHOW_INSTALL_DETAILS_}
    eval ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcached \
        --enable-memcached-igbinary --with-libmemcached-dir=/usr/local/libmemcached ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make ${_SYS_MAKE_EXT_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make install ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $?
}

# @function install php-extension-swoole
function InstallPHPExtSwoole()
{
    ShowResult "[green]正在安装PHP-Extension-Swoole模块... [/green]" 1
    
    # install
    eval cd ${_PATH_COMPILATION_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval rm -rf ./swoole* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval tar zxvf ${_PATH_SOFTWARE_}/swoole* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval cd swoole* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval /usr/local/php/bin/phpize ${_SYS_SHOW_INSTALL_DETAILS_}
    eval ./configure --with-swoole --enable-sockets --enable-ringbuffer --with-php-config=/usr/local/php/bin/php-config ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make ${_SYS_MAKE_EXT_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make install ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $?
}

# @function install php-extension-openssl
function InstallPHPExtOpenssl()
{
    local ver_=$1
    ver_=${ver_:-7.1}

    ShowResult "[green]正在安装PHP-Extension-Openssl模块... [/green]" 1
    
    # install
    eval cd ${_PATH_COMPILATION_}/php-${ver_}* ${_SYS_SHOW_INSTALL_DETAILS_}
    eval cd ext/openssl ${_SYS_SHOW_INSTALL_DETAILS_}
    eval mv config0.m4 config.m4
    eval /usr/local/php/bin/phpize ${_SYS_SHOW_INSTALL_DETAILS_}
    eval ./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make ${_SYS_MAKE_EXT_} ${_SYS_SHOW_INSTALL_DETAILS_}
    eval make install ${_SYS_SHOW_INSTALL_DETAILS_}
    
    ShowStatus $?
}