persistent_remove TMP_MUTT_OPTS &&

optional_depends   "MAIL-TRANSPORT-AGENT"                       \
                   ""                                           \
                   ""                                           \
                   "to send mail"                               &&

if [[ "$MUTT_BRANCH" == "scm" ]]; then
	depends git
fi &&

depends "${TERMINAL_LIBRARY}" "--with-${TERMINAL_LIBRARY/ncurses/curses}" &&

optional_depends   "GNUPG"                                      \
                   ""                                           \
                   "--disable-pgp"                              \
                   "to support PGP signing and encrypting messages" &&

optional_depends   "ispell"                                     \
                   ""                                           \
                   ""                                           \
                   "for spell checking"                         &&

# Do NOT add --with-ssl here, that only works if POP/IMAP are used.  This is
# mostly just here to prompt for SSL if they don't have it and want
# S/MIME.
optional_depends "SSL"                                        \
                 ""                                           \
                 ""                                           \
                 "to support S/MIME signing and encrypting messages" &&

optional_depends "gpgme"                                      \
                 "--enable-gpgme"                             \
                 ""                                           \
                 "alternate backend for PGP and S/MIME"       &&

case ${HCACHE_BACKEND} in
  db)
    depends "${HCACHE_BACKEND}" "--with-bdb --without-gdbm --without-lmdb --without-qdbm --without-tokyocabinet --without-kyotocabinet"
  ;;
  lmdb)
    depends "${HCACHE_BACKEND}" "--with-lmdb --without-bdb --without-gdbm --without-qdbm --without-tokyocabinet --without-kyotocabinet"
  ;;
  gdbm)
    depends "${HCACHE_BACKEND}" "--with-gdbm --without-bdb --without-lmdb --without-qdbm --without-tokyocabinet --without-kyotocabinet"
  ;;
  qdbm)
    depends "${HCACHE_BACKEND}" "--with-qdbm --without-bdb --without-lmdb --without-gdbm --without-tokyocabinet --without-kyotocabinet"
  ;;
  tokyocabinet)
    depends "${HCACHE_BACKEND}" "--with-tokyocabinet --without-bdb --without-lmdb --without-gdbm --without-qdbm --without-kyotocabinet"
  ;;
  kyotocabinet)
    depends "${HCACHE_BACKEND}" "--with-kyotocabinet --without-bdb --without-lmdb --without-gdbm --without-tokyocabinet --without-qdbm"
  ;;
  *)
  ;;
esac &&

optional_depends "libidn"                                     \
                 "--with-idn"                                 \
                 ""                                           \
                 "to use GNU libidn for domain names"         &&

if list_find "${MUTT_OPTS}" "--enable-pop" || list_find "${MUTT_OPTS}" "--enable-imap"; then
  # If they have POP/IMAP then prompt again for SSL to get --with-ssl.
  optional_depends "SSL"                                        \
                   "--with-ssl"                                 \
                   ""                                           \
                   "to enable SSL support for POP/IMAP"         &&

  optional_depends "gnutls"                                     \
                   "--with-gnutls"                              \
                   ""                                           \
                   "to enable SSL support for POP/IMAP via GnuTLS" &&

  optional_depends "LIBSASL"                                   \
                   "--with-sasl"                               \
                   ""                                          \
                   "to enable SASL2 authentication for POP/IMAP via libsasl" &&

  optional_depends "gsasl" \
		   "--with-gsasl" \
		   "" \
		   "to enable SASL2 authentication for POP/IMAP via GNU SASL"

fi &&

if list_find "${MUTT_OPTS}" "--enable-imap"; then
  optional_depends "krb5"                                       \
                   "--with-gss"                                 \
                   ""                                           \
                   "to enable GSSAPI authentication for IMAP"
fi &&

if [[ ! -z "$REAL_PATCHES" ]] || [[ "$MUTT_BRANCH" == "scm" ]]; then
  depends "automake"
fi &&

for PATCH in ${REAL_PATCHES}; do
  if [[ -x "$PATCH_DIRECTORY/$PATCH/PATCH_DEPENDS" ]]; then
    . "$PATCH_DIRECTORY/$PATCH/PATCH_DEPENDS"
  fi
done

if [[ "$UPDATE_DOC" == "y" ]]; then
  depends linuxdoc-tools
fi
