#! /bin/sh

SED="/usr/bin/sed"
prefix="/usr/pkg"
datarootdir="/usr/pkg/"
exec_prefix="${prefix}"
version="8.2.30"
vernum="80230"
include_dir="${prefix}/include/php/8.2"
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=" -L/usr/pkg/lib"
libs="  -lreadline -ltermcap -lutil -lrt -lm  -lxml2 -lssl -lcrypto -lpcre2-8 -lxml2 -lxml2 -lxml2 -lxml2 -lxml2 -lz -lssl -lcrypto "
extension_dir='/usr/pkg/lib/php/8.2/aarch64'
man_dir=`eval echo /usr/pkg/man`
program_prefix=""
program_suffix="82"
exe_extension=""
php_cli_binary=NONE
php_cgi_binary=NONE
configure_options=" 'ax_cv_have_func_attribute_ifunc=no' '--program-suffix=82' '--with-config-file-path=/usr/pkg/etc/php/8.2' '--with-config-file-scan-dir=/usr/pkg/etc/php/8.2/php.d' '--sysconfdir=/usr/pkg/etc/php/8.2' '--libdir=/usr/pkg/lib/php/8.2' '--datadir=/usr/pkg/share/php/8.2' '--localstatedir=/var' '--without-mysqli' '--without-iconv' '--without-pear' '--without-sqlite3' '--with-external-pcre' '--disable-intl' '--disable-posix' '--disable-opcache' '--disable-pdo' '--enable-cgi' '--enable-mysqlnd' '--enable-xml' '--enable-ipv6' '--with-openssl=/usr' '--with-readline=/usr/pkg' '--prefix=/usr/pkg' '--build=aarch64--netbsd' '--host=aarch64--netbsd' '--mandir=/usr/pkg/man' '--enable-option-checking=yes' 'build_alias=aarch64--netbsd' 'host_alias=aarch64--netbsd' 'PKG_CONFIG=/usr/pkg/bin/pkg-config' 'PKG_CONFIG_PATH=' 'PKG_CONFIG_LIBDIR=/usr/pkg/lib/pkgconfig:/usr/pkg/share/pkgconfig:/usr/lib/pkgconfig:/usr/X11R7/lib/pkgconfig' 'LIBS='"
php_sapis=" cli phpdbg cgi"
ini_dir="/usr/pkg/etc/php/8.2/php.d"
ini_path="/usr/pkg/etc/php/8.2"

# 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;;
--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]
  --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
