#! /bin/sh

SED="/usr/sbin/sed"
prefix="/usr"
datarootdir="/usr/share"
exec_prefix="${prefix}"
version="5.6.40"
vernum="50640"
include_dir="${prefix}/include/php56"
includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"
ldflags=""
libs="-lcrypt   -lcrypt -ledit -lncurses -lstdc++ -lz -lpcre -lcrypto -lssl -lcrypto -lrt -lm -lnsl -lacl  -lsystemd -lxml2 -lm -lz -licuuc -licudata -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcrypt -lcrypt "
extension_dir='/usr/lib/php56/modules'
man_dir=`eval echo /usr/share/man`
program_prefix=""
program_suffix="56"
exe_extension=""
php_cli_binary=NONE
php_cgi_binary=NONE
configure_options=" '--prefix=/usr' '--sbindir=/usr/bin' '--localstatedir=/var' '--with-layout=GNU' '--disable-debug' '--mandir=/usr/share/man' '--srcdir=../php-5.6.40' '--libdir=/usr/lib/php56' '--datadir=/usr/share/php56' '--program-suffix=56' '--with-config-file-scan-dir=/etc/php56/conf.d' '--enable-filter' '--enable-session' '--with-pear' '--with-mhash=/usr' '--with-kerberos' '--with-mysql-sock=/run/mysqld/mysqld.sock' '--enable-mysqlnd-compression-support' '--datarootdir=/usr/share/php56' '--with-zlib-dir=/usr' '--enable-libxml' '--with-pcre-regex=/usr' '--disable-rpath' '--config-cache' '--with-system-tzdata' '--with-openssl=/usr' '--enable-phpdbg-readline' '--with-libedit' '--sysconfdir=/etc/php56' '--with-config-file-path=/etc/php56' '--enable-cli' '--enable-xml=shared' '--with-xsl=shared' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--enable-wddx=shared' '--enable-dom=shared' '--enable-simplexml=shared' '--enable-pdo=shared' '--enable-mysqlnd=shared' '--with-mysql=shared,mysqlnd' '--with-mysqli=shared,mysqlnd' '--with-pdo-mysql=shared,mysqlnd' '--enable-phar=shared' '--enable-pcntl=shared' '--enable-posix=shared' '--enable-shmop=shared' '--enable-sockets=shared' '--enable-sysvmsg=shared' '--enable-sysvsem=shared' '--enable-sysvshm=shared' '--enable-tokenizer=shared' '--enable-dba=shared' '--with-db4=/usr' '--without-gdbm' '--with-cdb' '--with-pgsql=shared,/usr' '--with-pdo-pgsql=shared,/usr' '--with-unixODBC=shared,/usr' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-firebird=shared,/usr' '--with-interbase=shared,/usr' '--with-pdo-dblib=shared,/usr' '--with-pdo-sqlite=shared,/usr' '--with-sqlite3=shared,/usr' '--with-mssql=shared,/usr' '--with-gd=shared,/usr' '--enable-gd-native-ttf' '--with-vpx-dir=/usr' '--with-webp-dir=/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--with-freetype-dir=/usr' '--enable-exif=shared' '--with-tidy=shared,/usr' '--with-iconv=shared' '--with-xmlrpc=shared' '--enable-bcmath=shared' '--with-gmp=shared,/usr' '--enable-zip=shared' '--with-libzip=/usr' '--with-bz2=shared,/usr' '--enable-json=shared' '--enable-fileinfo=shared' '--enable-ctype=shared' '--with-recode=shared' '--enable-mbstring=shared' '--enable-mbregex' '--enable-mbregex-backtrack' '--with-pspell=shared,/usr' '--with-enchant=shared,/usr' '--enable-intl=shared' '--enable-calendar=shared' '--with-gettext=shared,/usr' '--enable-soap=shared' '--enable-ftp=shared' '--with-curl=shared,/usr' '--with-snmp=shared,/usr' '--with-ldap=shared,/usr' '--with-ldap-sasl=/usr' '--with-imap=shared,/usr' '--with-imap-ssl=yes' '--with-mcrypt=shared' '--enable-opcache' '--enable-huge-code-pages' '--enable-phpdbg' '--enable-cgi' '--enable-embed=shared' '--enable-fpm' '--with-fpm-user=http' '--with-fpm-group=http' '--with-fpm-systemd' '--with-fpm-acl' '--with-litespeed' 'CFLAGS=-march=x86-64 '-mtune=generic' '-O2' '-pipe' '-fstack-protector-strong' '-fno-plt' '-fPIC' '-std=gnu99' '-Wno-error=incompatible-pointer-types' '-Wno-implicit-function-declaration' '-fpermissive'' 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now' 'CPPFLAGS=-D_FORTIFY_SOURCE=2 '-DU_USING_ICU_NAMESPACE=1' '-DU_DEFINE_FALSE_AND_TRUE=1' 'CXXFLAGS=-march=x86-64 '-mtune=generic' '-O2' '-pipe' '-fstack-protector-strong' '-fno-plt' '-fPIC' '-Wno-error=incompatible-pointer-types' '-std=c++17' '-Wno-implicit-function-declaration' '-fpermissive''"
php_sapis=" cli embed fpm litespeed phpdbg cgi"

# Set php_cli_binary and php_cgi_binary if available
for sapi in $php_sapis; do
  case $sapi in
  cli)
    php_cli_binary="${exec_prefix}/bin/${program_prefix}php${program_suffix}${exe_extension}"
    ;;
  cgi)
    php_cgi_binary="${exec_prefix}/bin/${program_prefix}php-cgi${program_suffix}${exe_extension}"
    ;;
  esac
done

# Determine which (if any) php binary is available
if test "$php_cli_binary" != "NONE"; then
  php_binary="$php_cli_binary"
else
  php_binary="$php_cgi_binary"
fi

# Remove quotes
configure_options=`echo $configure_options | $SED -e "s#'##g"`

case "$1" in
--prefix)
  echo $prefix;;
--includes)
  echo $includes;;
--ldflags)
  echo $ldflags;;
--libs)
  echo $libs;;
--extension-dir)
  echo $extension_dir;;
--include-dir)
  echo $include_dir;;
--php-binary)
  echo $php_binary;;
--php-sapis)
  echo $php_sapis;;
--configure-options)
  echo $configure_options;;
--man-dir)
  echo $man_dir;;
--version)
  echo $version;;
--vernum)
  echo $vernum;;
*)
  cat << EOF
Usage: $0 [OPTION]
Options:
  --prefix            [$prefix]
  --includes          [$includes]
  --ldflags           [$ldflags]
  --libs              [$libs]
  --extension-dir     [$extension_dir]
  --include-dir       [$include_dir]
  --man-dir           [$man_dir]
  --php-binary        [$php_binary]
  --php-sapis         [$php_sapis]
  --configure-options [$configure_options]
  --version           [$version]
  --vernum            [$vernum]
EOF
  exit 1;;
esac

exit 0
