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" ;;
  lmdb)
        depends "${HCACHE_BACKEND}" "--with-lmdb --without-db --without-gdbm"  ;;
  gdbm)
        depends "${HCACHE_BACKEND}" "--with-gdbm --without-db --without-lmdb"  ;;
     *)
        ;;
 esac &&

if [[ "${MUTT_BRANCH}" != "stable" ]]; then
  optional_depends "tokyocabinet"                             \
                   ""                                         \
                   "--without-tokyocabinet"                   \
                   "Use tokyocabinet?"                        &&

  optional_depends "kyotocabinet"                             \
                   ""                                         \
                   "--without-kyotocabinet"                   \
                   "Use kyotocabinet?"
fi &&

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"
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
