#!/bin/sh

# first find which PHP binary to use
if test "x$PHP_PEAR_PHP_BIN" != "x"; then
  PHP="$PHP_PEAR_PHP_BIN"
else
  if test "/usr/php/5.2/bin/php" = '@'php_bin'@'; then
    PHP=php 
  else
    PHP="/usr/php/5.2/bin/php"
  fi
fi

# then look for the right pear include dir
if test "x$PHP_PEAR_INSTALL_DIR" != "x"; then
  INCDIR=$PHP_PEAR_INSTALL_DIR
  INCARG="-d include_path=$PHP_PEAR_INSTALL_DIR"
else
  if test "/var/php/5.2/pear" = '@'php_dir'@'; then
    INCDIR=`dirname $0`
    INCARG=""  
  else
    INCDIR="/var/php/5.2/pear"
    INCARG="-d include_path=/var/php/5.2/pear"
  fi
fi

# define CC if not defined
if test -x "/usr/bin/gcc"; then
  CC="/usr/bin/gcc"
  LD=$CC
  export CC LD
elif test -x "/usr/sfw/bin/gcc"; then
  CC="/usr/sfw/bin/gcc"
  LD=$CC
  export CC LD
fi

exec $PHP -C -n -q $INCARG -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"
