. "$GRIMOIRE/FUNCTIONS" &&

# requires JCS_EXTENSIONS
depends libjpeg-turbo &&
depends gtk+2 &&
depends libidl &&
depends libxft &&
depends nspr &&

if spell_ok nspr && is_version_less $(installed_version nspr) 4.10.3; then
  force_depends nspr
fi &&

depends -sub 3.17.x nss &&

if spell_ok nss && is_version_less $(installed_version nss) 3.17.4; then
  force_depends nss
fi &&

depends -sub "TSAFE SECURE_DELETE ENABLE_UNLOCK_NOTIFY" sqlite &&

if spell_ok sqlite && is_version_less $(installed_version sqlite) 3.8.7.4; then
  force_depends sqlite
fi &&

depends perl &&
depends zip &&
depends zlib &&
depends bzip2 &&
depends libxt &&
depends libffi &&
depends libevent &&

if list_find "$SEAMONKEY_OPTS" "--enable-system-cairo"; then
  list_add "SEAMONKEY_OPTS" "--enable-system-pixman" &&

  depends pixman &&
  depends cairo
fi &&


if list_find "$SEAMONKEY_OPTS" "--enable-system-hunspell"; then
  depends hunspell
fi &&

if list_find "$SEAMONKEY_OPTS" "--enable-pango"; then
  depends pango
fi &&

if list_find "$SEAMONKEY_OPTS" "--enable-ldap"; then
  depends openldap
fi &&

if list_find "$SEAMONKEY_OPTS" "--enable-necko-wifi"; then
  depends wireless_tools
fi &&

if list_find "$SEAMONKEY_OPTS" "--enable-dbus"; then
  depends dbus-glib &&
  depends libnotify
fi &&

if list_find "$SEAMONKEY_OPTS" "--enable-webm"; then
  depends yasm &&
  depends alsa-lib &&

  optional_depends libvpx "" "" "to use system libvpx for WebM support"
else
  optional_depends alsa-lib "" "" "for audio support"
fi &&

optional_depends icu "" "" "to use system ICU library" &&

optional_depends pulseaudio "" "" "for PulseAudio support" &&

if is_depends_enabled $SPELL pulseaudio; then
  list_add "SEAMONKEY_OPTS" "--enable-pulseaudio" &&
  list_remove "SEAMONKEY_OPTS" "--disable-pulseaudio"
else
  list_add "SEAMONKEY_OPTS" "--disable-pulseaudio" &&
  list_remove "SEAMONKEY_OPTS" "--enable-pulseaudio"
fi &&

if [[ $SEAMONKEY_GST != "none" ]]; then
  depends $SEAMONKEY_GST &&

  if [[ $SEAMONKEY_GST == gstreamer ]]; then
    list_add "SEAMONKEY_OPTS" "--enable-gstreamer=0.10"
  else
    list_add "SEAMONKEY_OPTS" "--enable-gstreamer=1.0"
  fi &&

  list_remove "SEAMONKEY_OPTS" "--disable-gstreamer"
else
  list_add "SEAMONKEY_OPTS" "--disable-gstreamer" &&
  list_remove "SEAMONKEY_OPTS" "--enable-gstreamer"
fi &&

if is_depends_enabled $SPELL libvpx; then
  list_add "SEAMONKEY_OPTS" "--with-system-libvpx"
fi &&

if is_depends_enabled $SPELL icu; then
  list_add "SEAMONKEY_OPTS" "--with-system-icu"
fi &&

if ! is_depends_enabled $SPELL alsa-lib; then
  list_add "SEAMONKEY_OPTS" "--disable-ogg" &&
  list_add "SEAMONKEY_OPTS" "--disable-wave"
fi
