AC_INIT(send-pr.sh)

AC_SUBST(GNATS_ROOT)dnl
AC_SUBST(GNATS_ADDR)dnl
AC_SUBST(GNATS_SITE)dnl
AC_SUBST(DEFAULT_RELEASE)dnl
AC_SUBST(DEFAULT_ORGANIZATION)dnl
AC_SUBST(MAIL_AGENT)dnl
AC_SUBST(SUBMITTER)dnl
AC_SUBST(ECHON)dnl

AC_ECHON
AC_LISPDIR
AC_PASSWD

if test -z "${GNATS_SITE}"; then
   GNATS_SITE=cygnus
fi
SUBMITTER=unknown
if test -z "${GNATS_ADDR}"; then
   GNATS_ADDR=bugs@cygnus.com
fi
DEFAULT_ORGANIZATION=

AC_FIND_PROGRAM(SENDMAIL,sendmail,/usr/lib:/usr/sbin:/usr/ucblib)
if test -n "$SENDMAIL" ; then
	MAIL_AGENT="$SENDMAIL -oi -t"
else
	MAIL_AGENT=false
fi

if test -f ${srcdir}/../release-info ; then
	DEFAULT_RELEASE=`. ${srcdir}/../release-info ; echo ${RELEASE_TAG}`
else
	DEFAULT_RELEASE='gnats-$(VERSION)'
fi

# Get GNATS_ROOT from environment, if possible

if test -n "$with_gnats_root"; then
	GNATS_ROOT=$with_gnats_root
fi

if test -z "${GNATS_ROOT}"; then
	GNATS_ROOT=${prefix-/usr/local}/lib/gnats/gnats-root
	_PR=${GNATS_ROOT}
fi

AC_FIND_PROGRAM(SEND_PR,send-pr)
if test -n "${SEND_PR}"; then
	test -n "${_PR}" && eval `grep '^GNATS_ROOT=' ${SEND_PR}`
	eval `grep '^SUBMITTER=' ${SEND_PR}`
	eval `egrep '^GNATS_(ADDR|SITE)=' ${SEND_PR}`
	eval `egrep '^DEFAULT_ORGANIZATION=' ${SEND_PR}`
fi

# If the config file exists, it may have more recent info than send-pr
echo checking for GNATS configuration file
test -f ${GNATS_ROOT}/gnats-adm/config && . ${GNATS_ROOT}/gnats-adm/config

if test -n "${_PR}" -a "${GNATS_ROOT}" = "${_PR}"; then
	GNATS_ROOT=
fi

if test -n "$verbose"; then
	echo "	setting GNATS_ROOT to $GNATS_ROOT"
	echo "	setting GNATS_SITE to $GNATS_SITE"
	echo "	setting GNATS_ADDR to $GNATS_ADDR"
	echo "	setting SUBMITTER to $SUBMITTER"
	echo "	setting DEFAULT_RELEASE to $DEFAULT_RELEASE"
	echo "	setting DEFAULT_ORGANIZATION to $DEFAULT_ORGANIZATION"
	echo "	setting MAIL_AGENT to $MAIL_AGENT"
fi

AC_OUTPUT(Makefile)
