. "${GRIMOIRE}/FUNCTIONS"                                        &&
. "${GRIMOIRE}/VDEPENDS"                                         &&

depends  autoconf-2.13                                           &&
depends  -sub "CLANG" llvm                                       &&
depends  perl                                                    &&
depends  python3                                                 &&

# The build is not even trying to make this work. Do not do it.
#depends  icu     "--with-system-icu"                             &&

depends  glib2                                                   &&
vdepends <<! 
        at-spi2-core >= 2.45.0
        cbindgen >= 0.26.0
!

if [[ $FIREFOX_SCCACHE == 'y' ]]; then
  depends sccache
fi                                                               &&

optional_depends libx11 "" "" "for X11 backend"                  &&
if is_depends_enabled "${SPELL}" "libx11"; then
  depends libxext                                                &&
  depends libxrender                                             &&
  depends libxt                                                  &&
  depends libxcomposite                                          &&
  depends libxft
fi                                                               &&

optional_depends wayland "" "" "for Wayland backend"             &&
if is_depends_enabled "${SPELL}" "wayland"; then
  local WAYLAND_SUFFIX="-wayland"
fi                                                               &&

depends gtk+3 "--enable-default-toolkit=cairo-gtk3${WAYLAND_SUFFIX}" &&

depends  pango                                                   &&
depends  fontconfig                                              &&
depends  freetype2                                               &&

depends  tar   &&
depends  unzip &&
depends  zip   &&

#depends  -sub TEE cairo  "--enable-system-cairo"                 &&
depends  gdk-pixbuf2                                             &&

depends  libjpeg-turbo "--with-system-jpeg"                      &&
depends -sub APNG libpng "--with-system-png"                     &&
depends  librsvg2                                                &&
depends  libwebp       "--with-system-webp"                      &&

depends  nspr               "--with-system-nspr"                 &&

local NSS_BRANCH="3.108"                                         &&
if spell_ok nss                                                  &&
   is_version_less "$(installed_version nss)" "${NSS_BRANCH}"; then
  depends  -sub "${NSS_BRANCH}" nss  "--with-system-nss"
else
  depends  nss  "--with-system-nss"
fi                                                               &&

depends -sub "TSAFE SECURE_DELETE ENABLE_UNLOCK_NOTIFY ENABLE_DBSTAT_VTAB
SQLITE_ENABLE_FTS3" sqlite                                       &&

depends  libidl                                                  &&

depends  zip                                                     &&
depends  zlib               "--with-system-zlib"                 &&

depends libevent            "--with-system-libevent"             &&
depends libvpx              "--with-system-libvpx"               &&
depends libffi              "--enable-system-ffi"                &&
depends libnotify                                                &&
depends pixman              "--enable-system-pixman"             &&

depends rust                                                     &&

depends nodejs                                                   &&

depends startup-notification                                     &&
depends gconf2                                                   &&

for b in $FIREFOX_AUDIO
do
  case $b in
    alsa)
      depends alsa-lib
    ;;
pulseaudio)
      depends pulseaudio
    ;;
    jack)
      depends JACK-DRIVER
    ;;
    oss)
      depends oss
    ;;
    sndio)
      depends sndio
    ;;
    *)
      message "${MESSAGE_COLOR}Bad audio choice: $b${DEFAULT_COLOR}"
      exit 1
    ;;
  esac
done &&

if is_depends_enabled $SPELL alsa-lib; then
  # Firefox tries to use ogg/ogg.h even with --disable-ogg given
  #optional_depends  libogg \
  #                  '--enable-ogg' \
  #                  '--disable-ogg' \
  #                  'for sound support' &&
  depends libogg &&

  # configure script checks for yasm even when --disable-webm and --disable-dash are given
  #optional_depends  yasm \
  #                  '--enable-webm --enable-dash' \
  #                  '--disable-webm --disable-dash' \
  #                  'for WebM video support'
  depends yasm
fi &&

optional_depends dbus \
                 "--enable-dbus" \
                 "--disable-dbus --disable-necko-wifi" \
                 "for DBus support" &&
if is_depends_enabled "${SPELL}" "dbus" ; then
  optional_depends wireless_tools \
                   "--enable-necko-wifi" \
                   "" \
                   "for Necko WiFi scanning"
fi &&

# Firefox is currently borked and does not compile without OpenGL headers
#optional_depends  OPENGL \
#                  '--enable-webgl' \
#                  '--disable-webgl --without-gl-provider' \
#                  'for WebGL support' &&
depends OPENGL &&

depends LIBAVCODEC &&

suggest_depends_2 firefox-smglwiki "" "" \
  "to enable searching the SMGL Wiki from the Search Bar"

optional_depends  graphite2 \
                  "--with-system-graphite2" \
                  "--without-system-graphite2" \
                  "for system graphite2" &&

optional_depends  harfbuzz \
                  "--with-system-harfbuzz" \
                  "--without-system-harfbuzz" \
                  "for system harfbuzz" &&

# Seems FF wants libaom along with this. Package that, too,
# or just roll with the vendored copy.
#optional_depends  dav1d \
#                  "--with-system-av1" \
#                  "--without-system-av1" \
#                  "for AV1 video support" &&
if is_depends_enabled $SPELL dav1d; then
  depends nasm
fi
