#! /bin/sh

SED="/bin/sed"
prefix="/usr"
datarootdir="/usr/share"
exec_prefix="${prefix}"
version="8.4.14"
vernum="80414"
include_dir="${prefix}/include/php84"
lib_dir="/usr/lib/php84"
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="  -lncurses -lstdc++  -lxml2 -lpcre2-8 -lz -ledit -largon2 -lrt -ldl"
extension_dir="/usr/lib/php84/modules"
man_dir=`eval echo ${datarootdir}/man`
program_prefix=""
program_suffix="84"
exe_extension=""
php_cli_binary=NONE
php_cgi_binary=NONE
configure_options=" '--build=loongarch64-alpine-linux-musl' '--host=loongarch64-alpine-linux-musl' '--prefix=/usr' '--program-suffix=84' '--libdir=/usr/lib/php84' '--datadir=/usr/share/php84' '--sysconfdir=/etc/php84' '--localstatedir=/var' '--with-layout=GNU' '--with-pic' '--with-config-file-path=/etc/php84' '--with-config-file-scan-dir=/etc/php84/conf.d' '--disable-rpath' '--disable-short-tags' '--enable-bcmath=shared' '--with-bz2=shared' '--enable-calendar=shared' '--enable-ctype=shared' '--with-curl=shared' '--enable-dba=shared' '--with-dbmaker=shared' '--with-gdbm' '--with-lmdb' '--enable-dom=shared' '--with-enchant=shared' '--enable-exif=shared' '--with-ffi=shared' '--enable-fileinfo=shared' '--enable-ftp=shared' '--enable-gd=shared' '--with-avif' '--with-freetype' '--with-jpeg' '--with-webp' '--with-xpm' '--disable-gd-jis-conv' '--with-gettext=shared' '--with-gmp=shared' '--with-iconv=shared' '--enable-intl=shared' '--with-ldap=shared' '--with-ldap-sasl' '--with-libedit' '--with-libxml' '--enable-mbstring=shared' '--with-mysqli=shared' '--with-mysql-sock=/run/mysqld/mysqld.sock' '--enable-mysqlnd=shared' '--enable-opcache=shared' '--with-openssl=shared' '--with-system-ciphers' '--with-openssl-argon2' '--with-password-argon2' '--enable-pcntl=shared' '--with-external-pcre' '--enable-pdo=shared' '--with-pdo-dblib=shared,/usr' '--with-pdo-mysql=shared,mysqlnd' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-pgsql=shared' '--with-pdo-sqlite=shared' '--with-pgsql=shared' '--enable-phar=shared' '--enable-posix=shared' '--without-readline' '--enable-session=shared' '--enable-shmop=shared' '--enable-simplexml=shared' '--with-snmp=shared' '--enable-soap=shared' '--with-sodium=shared' '--enable-sockets=shared' '--with-sqlite3=shared' '--enable-sysvmsg=shared' '--enable-sysvsem=shared' '--enable-sysvshm=shared' '--with-tidy=shared' '--enable-tokenizer=shared' '--with-unixODBC=shared,/usr' '--enable-xml=shared' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--with-xsl=shared' '--with-zip=shared' '--with-zlib' '--enable-zend-test=shared' '--enable-phpdbg' '--with-pear=/usr/share/php84' '--enable-fpm' '--with-fpm-acl' '--enable-litespeed' '--enable-embed' 'build_alias=loongarch64-alpine-linux-musl' 'host_alias=loongarch64-alpine-linux-musl' 'CFLAGS=-O2 -Wformat -Werror=format-security -g' 'CXXFLAGS=-O2 -Wformat -Werror=format-security -D_GLIBCXX_ASSERTIONS=1 -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 -D_LIBCPP_ENABLE_HARDENED_MODE=1 -g' 'EXTENSION_DIR=/usr/lib/php84/modules'"
php_sapis=" cli embed fpm litespeed phpdbg cgi"
ini_dir="/etc/php84/conf.d"
ini_path="/etc/php84"
php_embed_type="shared"

# 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

# Set embed SAPI library path
if test "$php_embed_type" = "shared"; then
  php_embed_lib=libphp.so
elif test "$php_embed_type" = "static"; then
  php_embed_lib=libphp.a
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;;
--lib-dir)
  echo $lib_dir;;
--lib-embed)
  echo $php_embed_lib;;
--php-binary)
  echo $php_binary;;
--php-sapis)
  echo $php_sapis;;
--configure-options)
  echo $configure_options;;
--man-dir)
  echo $man_dir;;
--ini-path)
  echo $ini_path;;
--ini-dir)
  echo $ini_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]
  --lib-dir           [$lib_dir]
  --lib-embed         [$php_embed_lib]
  --man-dir           [$man_dir]
  --php-binary        [$php_binary]
  --php-sapis         [$php_sapis]
  --ini-path          [$ini_path]
  --ini-dir           [$ini_dir]
  --configure-options [$configure_options]
  --version           [$version]
  --vernum            [$vernum]
EOF
  exit 1;;
esac

exit 0
