with_system() {
  depends "$1" --with-system-"$1" &&
  if [ "$2" ]; then
    sub_depends "$1" "$2"
  fi
}

with_system gmp &&
with_system cairo &&
with_system mpfr &&
with_system libpaper &&
with_system graphite2 &&
with_system harfbuzz GRAPHITE2 &&
with_system icu &&
with_system pixman &&
with_system potrace LIBPOTRACE &&
with_system zziplib &&
# FIXME missing teckit spell
# with_system teckit &&

depends texlive-texmf &&
depends xz-utils &&
depends bison &&
depends -sub CXX gcc &&
depends flex &&
depends expat &&
depends ed &&
depends -sub LIBS ghostscript '--with-gs=gs' &&
depends fontconfig "--enable-xetex" &&
depends perl &&

with_system freetype2 &&
with_system libpng &&
with_system zlib &&
depends t1lib &&
with_system gd &&
depends psutils '--disable-psutils' &&
depends t1utils '--disable-t1utils' &&
runtime_depends detex '--disable-detex' &&
runtime_depends dvi2tty '--disable-dvi2tty' &&
runtime_depends ps2eps '--disable-ps2eps' &&
runtime_depends dvipdfmx "--disable-dvipdfm-x" &&
runtime_depends dvipng '--disable-dvipng' &&
runtime_depends lacheck '--disable-lacheck' &&
runtime_depends lcdf-typetools '--disable-lcdf-typetools' &&
# FIXME LUA and luajit dependencies aren't actually used, see PRE_BUILD
optional_depends LUA \
                 '--enable-luatex' \
                 '--disable-luatex' \
                 'for LuaTeX, required by XeTeX and ConTeXt (MkII & MKIV)' &&
optional_depends luajit \
                 '--enable-luajittex' \
                 '--disable-luajittex' \
                 'Enable LuaJITTeX' &&
suggest_depends XDVI '--disable-xdvik' '--disable-xdvik' \
                "For an X DVI viewer" &&
suggest_depends RUBY '' '' \
		"required for epspdf, context, hyph-utf8 (Hyphenation patterns expressed in UTF-8), & Huhyphn (hungarian hyphenation)"
