SUMMARY="A comprehensive TeX system"
DESCRIPTION="TeX Live is an easy way to get up and running with the TeX \
document production system. It provides a comprehensive TeX system. It \
includes all the major TeX-related programs, macro packages, and fonts that \
are free software, including support for many languages around the world."
HOMEPAGE="http://tug.org/texlive/"
COPYRIGHT="1996 by collaboration between the TeX user groups."
LICENSE="GNU GPL v2"
REVISION="1"
fullVersion=20210325
SOURCE_URI="ftp://tug.org/historic/systems/texlive/$portVersion/texlive-$fullVersion-source.tar.xz"
CHECKSUM_SHA256="7aefd96608d72061970f2d73f275be5648ea8ae815af073016d3106acc0d584b"
SOURCE_DIR="texlive-$fullVersion-source"
PATCHES="texlive_core-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

libkpathseaVersion="6.3.3"
libptexencVersion="1.3.9"
libsynctexVersion="2.0.0"
libtexluaVersion="5.3.6"
libtexluajitVersion="2.1.0"
libkpathseaVersionCompat="$libkpathseaVersion compat >= ${libkpathseaVersion%%.*}"
libptexencVersionCompat="$libptexencVersion compat >= ${libptexencVersion%%.*}"
libsynctexVersionCompat="$libsynctexVersion compat >= ${libsynctexVersion%%.*}"
libtexluaVersionCompat="$libtexluaVersion compat >= ${libtexluaVersion%%.*}"
libtexluajitVersionCompat="$libtexluajitVersion compat >= ${libtexluajitVersion%%.*}"

PROVIDES="
	texlive_core$secondaryArchSuffix = $portVersion compat >= $portVersion
	cmd:a2ping
	cmd:a5toa4
	cmd:adhocfilelist
	cmd:afm2afm
	cmd:afm2pl
	cmd:afm2tfm
	cmd:albatross
	cmd:aleph
	cmd:allcm
	cmd:allec
	cmd:allneeded
	cmd:amstex
	cmd:arara
	cmd:arlatex
	cmd:authorindex
	cmd:autoinst
	cmd:autosp
	cmd:axohelp
	cmd:bbl2bib
	cmd:bbox
	cmd:bg5+latex
	cmd:bg5+pdflatex
	cmd:bg5conv
	cmd:bg5latex
	cmd:bg5pdflatex
	cmd:bib2gls
	cmd:bibdoiadd
	cmd:bibexport
	cmd:bibmradd
	cmd:bibtex
	cmd:bibtex8
	cmd:bibtexu
	cmd:biburl2doi
	cmd:bibzbladd
	cmd:bundledoc
	cmd:cachepic
	cmd:cef5conv
	cmd:cef5latex
	cmd:cef5pdflatex
	cmd:cefconv
	cmd:ceflatex
	cmd:cefpdflatex
	cmd:cefsconv
	cmd:cefslatex
	cmd:cefspdflatex
	cmd:cfftot1
	cmd:checkcites
	cmd:checklistings
	cmd:chkdvifont
	cmd:chklref
	cmd:chktex
	cmd:chkweb
	cmd:cjk_gs_integrate
	cmd:cllualatex
	cmd:cluttex
	cmd:clxelatex
	cmd:context
	cmd:contextjit
	cmd:convbkmk
	cmd:convertgls2bib
	cmd:cslatex
	cmd:csplain
	cmd:ctan_o_mat
	cmd:ctanbib
	cmd:ctangle
	cmd:ctanify
	cmd:ctanupload
	cmd:ctie
	cmd:ctwill
	cmd:ctwill_refsort
	cmd:ctwill_twinx
	cmd:cweave
	cmd:de_macro
	cmd:depythontex
	cmd:detex
	cmd:devnag
	cmd:deweb
	cmd:diadia
	cmd:disdvi
	cmd:dosepsbin
	cmd:dt2dv
	cmd:dtxgen
	cmd:dv2dt
	cmd:dvi2fax
	cmd:dvi2tty
	cmd:dviasm
	cmd:dvibook
	cmd:dviconcat
	cmd:dvicopy
	cmd:dvidvi
	cmd:dvigif
	cmd:dvihp
	cmd:dviinfox
	cmd:dvilj
	cmd:dvilj2p
	cmd:dvilj4
	cmd:dvilj4l
	cmd:dvilj6
	cmd:dvilualatex
	cmd:dvilualatex_dev
	cmd:dviluatex
	cmd:dvipdfm
	cmd:dvipdfmx
	cmd:dvipdft
	cmd:dvipng
	cmd:dvipos
	cmd:dvips
	cmd:dvired
	cmd:dviselect
	cmd:dvispc
	cmd:dvisvgm
	cmd:dvitodvi
	cmd:dvitomp
	cmd:dvitype
	cmd:e2pall
	cmd:ebb
	cmd:ebong
	cmd:eplain
	cmd:epsffit
	cmd:epspdf
	cmd:epspdftk
	cmd:epstopdf
	cmd:eptex
	cmd:etex
	cmd:euptex
	cmd:exceltex
	cmd:extconv
	cmd:extractbb
	cmd:extractres
	cmd:fig4latex
	cmd:findhyph
	cmd:fmtutil_sys
	cmd:fmtutil_user
	cmd:fmtutil
	cmd:fontinst
	cmd:fragmaster
	cmd:gbklatex
	cmd:gbkpdflatex
	cmd:getmapdl
	cmd:gftodvi
	cmd:gftopk
	cmd:gftype
	cmd:git_latexdiff
	cmd:gregorio
	cmd:gsftopk
	cmd:hbf2gf
	cmd:ht
	cmd:htcontext
	cmd:htlatex
	cmd:htmex
	cmd:httex
	cmd:httexi
	cmd:htxelatex
	cmd:htxetex
	cmd:hyperxmp_add_bytecount
	cmd:includeres
	cmd:inimf
	cmd:initex
	cmd:installfont_tl
	cmd:jadetex
	cmd:jamo_normalize
	cmd:jfmutil
	cmd:kanji_config_updmap_sys
	cmd:kanji_config_updmap_user
	cmd:kanji_config_updmap
	cmd:kanji_fontmap_creator
	cmd:ketcindy
	cmd:komkindex
	cmd:kpseaccess
	cmd:kpsepath
	cmd:kpsereadlink
	cmd:kpsestat
	cmd:kpsetool
	cmd:kpsewhere
	cmd:kpsewhich
	cmd:kpsexpand
	cmd:l3build
	cmd:lacheck
	cmd:latex
	cmd:latex_dev
	cmd:latex_git_log
	cmd:latex_papersize
	cmd:latex2man
	cmd:latex2nemeth
	cmd:latexdef
	cmd:latexdiff_vc
	cmd:latexdiff
	cmd:latexfileversion
	cmd:latexindent
	cmd:latexmk
	cmd:latexpand
	cmd:latexrevise
	cmd:lily_glyph_commands
	cmd:lily_image_commands
	cmd:lily_rebuild_pdfs
	cmd:listbib
	cmd:listings_ext.sh
	cmd:llmk
	cmd:lollipop
	cmd:ltx2crossrefxml
	cmd:ltxfileinfo
	cmd:ltximg
	cmd:luacsplain
	cmd:luahbtex
	cmd:luajithbtex
	cmd:luajittex
	cmd:lualatex
	cmd:lualatex_dev
	cmd:luaotfload_tool
	cmd:luatex
	cmd:luatools
	cmd:lwarpmk
	cmd:m_tx
	cmd:mag
	cmd:make4ht
	cmd:makedtx
	cmd:makeglossaries_lite
	cmd:makeglossaries
	cmd:makeindex
	cmd:makejvf
	cmd:match_parens
	cmd:mathspic
	cmd:mendex
	cmd:mex
	cmd:mf_nowin
	cmd:mf
	cmd:mf2pt1
	cmd:mflua_nowin
	cmd:mflua
	cmd:mfluajit_nowin
	cmd:mfluajit
	cmd:mfplain
	cmd:mft
	cmd:mk4ht
	cmd:mkgrkindex
	cmd:mkindex
	cmd:mkjobtexmf
	cmd:mkocp
	cmd:mkofm
	cmd:mkpic
	cmd:mkt1font
	cmd:mktexfmt
	cmd:mktexlsr
	cmd:mktexmf
	cmd:mktexpk
	cmd:mktextfm
	cmd:mllatex
	cmd:mltex
	cmd:mmafm
	cmd:mmpfb
	cmd:mpost
	cmd:mptopdf
	cmd:msxlint
	cmd:mtxrun
	cmd:mtxrunjit
	cmd:multibibliography
	cmd:musixflx
	cmd:musixtex
	cmd:odvicopy
	cmd:odvitype
	cmd:ofm2opl
	cmd:omfonts
	cmd:opl2ofm
	cmd:optex
	cmd:ot2kpx
	cmd:otangle
	cmd:otfinfo
	cmd:otftotfm
	cmd:otp2ocp
	cmd:outocp
	cmd:ovf2ovp
	cmd:ovp2ovf
	cmd:pamphletangler
	cmd:patgen
	cmd:pbibtex
	cmd:pdfannotextractor
	cmd:pdfatfi
	cmd:pdfbook2
	cmd:pdfcrop
	cmd:pdfcslatex
	cmd:pdfcsplain
	cmd:pdfetex
	cmd:pdfjadetex
	cmd:pdfjam
	cmd:pdflatex
	cmd:pdflatex_dev
	cmd:pdflatexpicscale
	cmd:pdfmex
	cmd:pdftex
	cmd:pdftex_quiet
	cmd:pdftosrc
	cmd:pdfxmltex
	cmd:pdfxup
	cmd:pdvitomp
	cmd:pdvitype
	cmd:pedigree
	cmd:perltex
	cmd:pfarrei
	cmd:pfb2pfa
	cmd:pk2bm
	cmd:pkfix_helper
	cmd:pkfix
	cmd:pktogf
	cmd:pktype
	cmd:platex
	cmd:platex_dev
	cmd:pltotf
	cmd:pmpost
	cmd:pmxab
	cmd:pmxchords
	cmd:pn2pdf
	cmd:pooltype
	cmd:ppltotf
	cmd:prepmx
	cmd:ps2eps
	cmd:ps2frag
	cmd:ps2pk
	cmd:ps4pdf
	cmd:psbook
	cmd:psjoin
	cmd:pslatex
	cmd:psnup
	cmd:psresize
	cmd:psselect
	cmd:pst2pdf
	cmd:pstops
	cmd:ptex
	cmd:ptex2pdf
	cmd:ptftopl
	cmd:purifyeps
	cmd:pygmentex
	cmd:pythontex
	cmd:r_mpost
	cmd:r_pmpost
	cmd:r_upmpost
	cmd:repstopdf
	cmd:rpdfcrop
	cmd:rubibtex
	cmd:rubikrotation
	cmd:rumakeindex
	cmd:rungs
	cmd:scor2prt
	cmd:simpdftex
	cmd:sjisconv
	cmd:sjislatex
	cmd:sjispdflatex
	cmd:spix
	cmd:splitindex
	cmd:srcredact
	cmd:sty2dtx
	cmd:svn_multi
	cmd:synctex
	cmd:t1dotlessj
	cmd:t1lint
	cmd:t1rawafm
	cmd:t1reencode
	cmd:t1testpage
	cmd:t4ht
	cmd:tangle
	cmd:tex
	cmd:tex2aspc
	cmd:tex4ebook
	cmd:tex4ht
	cmd:texconfig_dialog
	cmd:texconfig_sys
	cmd:texconfig
	cmd:texcount
	cmd:texdef
	cmd:texdiff
	cmd:texdirflatten
	cmd:texdoc
	cmd:texdoctk
	cmd:texexec
	cmd:texfot
	cmd:texhash
	cmd:texlinks
	cmd:texliveonfly
	cmd:texloganalyser
	cmd:texlua
	cmd:texluac
	cmd:texluajit
	cmd:texluajitc
	cmd:texmfstart
	cmd:texosquery_jre5
	cmd:texosquery_jre8
	cmd:texosquery
	cmd:texplate
	cmd:texsis
	cmd:tftopl
	cmd:thumbpdf
	cmd:tie
	cmd:tikztosvg
	cmd:tlcockpit
	cmd:tlmgr
	cmd:tlshell
	cmd:tpic2pdftex
	cmd:ttf2afm
	cmd:ttf2kotexfont
	cmd:ttf2pk
	cmd:ttf2tfm
	cmd:ttfdump
	cmd:ttftotype42
	cmd:typeoutfileinfo
	cmd:ulqda
	cmd:upbibtex
	cmd:updmap_sys
	cmd:updmap_user
	cmd:updmap
	cmd:updvitomp
	cmd:updvitype
	cmd:uplatex
	cmd:uplatex_dev
	cmd:upmendex
	cmd:upmpost
	cmd:uppltotf
	cmd:uptex
	cmd:uptftopl
	cmd:urlbst
	cmd:utf8mex
	cmd:vftovp
	cmd:vlna
	cmd:vpe
	cmd:vpl2ovp
	cmd:vpl2vpl
	cmd:vptovf
	cmd:webquiz
	cmd:weave
	cmd:wofm2opl
	cmd:wopl2ofm
	cmd:wordcount
	cmd:wovf2ovp
	cmd:wovp2ovf
	cmd:xdvipdfmx
	cmd:xelatex
	cmd:xelatex_dev
	cmd:xetex
	cmd:xhlatex
	cmd:xindex
	cmd:xml2pmx
	cmd:xmltex
	cmd:yplan
	lib:libkpathsea$secondaryArchSuffix = $libkpathseaVersionCompat
	lib:libptexenc$secondaryArchSuffix = $libptexencVersionCompat
	lib:libsynctex$secondaryArchSuffix = $libsynctexVersionCompat
	lib:libtexlua53$secondaryArchSuffix = $libtexluaVersionCompat
	lib:libtexluajit$secondaryArchSuffix = $libtexluajitVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libTECkit$secondaryArchSuffix
	lib:libcairo$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libgd$secondaryArchSuffix
	lib:libgmp$secondaryArchSuffix
	lib:libgobject_2.0$secondaryArchSuffix
	lib:libgraphite2$secondaryArchSuffix
	lib:libharfbuzz$secondaryArchSuffix
	lib:libicudata$secondaryArchSuffix
	lib:libicui18n$secondaryArchSuffix
	lib:libicuio$secondaryArchSuffix
	lib:libicuuc$secondaryArchSuffix
	lib:libmpfr$secondaryArchSuffix
	lib:libpaper$secondaryArchSuffix
	lib:libpixman_1$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	lib:libzzip_0$secondaryArchSuffix
	"

PROVIDES_devel="
	texlive_core${secondaryArchSuffix}_devel = $portVersion
	devel:libkpathsea$secondaryArchSuffix = $libkpathseaVersionCompat
	devel:libptexenc$secondaryArchSuffix = $libptexencVersionCompat
	devel:libsynctex$secondaryArchSuffix = $libsynctexVersionCompat
	devel:libtexlua53$secondaryArchSuffix = $libtexluaVersionCompat
	devel:libtexluajit$secondaryArchSuffix = $libtexluajitVersionCompat
	"
REQUIRES_devel="
	texlive_core$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libTECkit$secondaryArchSuffix
	devel:libcairo$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libgd$secondaryArchSuffix
	devel:libgmp$secondaryArchSuffix
	devel:libgobject_2.0$secondaryArchSuffix
	devel:libgraphite2$secondaryArchSuffix
	devel:libharfbuzz$secondaryArchSuffix
	devel:libicudata$secondaryArchSuffix
	devel:libicui18n$secondaryArchSuffix
	devel:libicuio$secondaryArchSuffix
	devel:libicuuc$secondaryArchSuffix
	devel:libmpfr$secondaryArchSuffix
	devel:libpaper$secondaryArchSuffix
	devel:libpixman_1$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	devel:libzzip$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:pkg_config$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:makeinfo
	cmd:gawk
	cmd:autoconf
	cmd:automake
	cmd:find
	cmd:flex
	cmd:freetype_config$secondaryArchSuffix
	"

defineDebugInfoPackage texlive_core$secondaryArchSuffix \
	$prefix/bin/afm2pl \
	$prefix/bin/afm2tfm \
	$prefix/bin/aleph \
	$prefix/bin/autosp \
	$prefix/bin/axohelp \
	$prefix/bin/bbox \
	$prefix/bin/bg5conv \
	$prefix/bin/bibtex \
	$prefix/bin/bibtex8 \
	$prefix/bin/bibtexu \
	$prefix/bin/cef5conv \
	$prefix/bin/cefconv \
	$prefix/bin/cefsconv \
	$prefix/bin/cfftot1 \
	$prefix/bin/chkdvifont \
	$prefix/bin/chktex \
	$prefix/bin/ctangle \
	$prefix/bin/ctie \
	$prefix/bin/ctwill \
	$prefix/bin/ctwill-refsort \
	$prefix/bin/ctwill-twinx \
	$prefix/bin/cweave \
	$prefix/bin/detex \
	$prefix/bin/devnag \
	$prefix/bin/disdvi \
	$prefix/bin/dt2dv \
	$prefix/bin/dv2dt \
	$prefix/bin/dvi2tty \
	$prefix/bin/dvibook \
	$prefix/bin/dviconcat \
	$prefix/bin/dvicopy \
	$prefix/bin/dvidvi \
	$prefix/bin/dvilj \
	$prefix/bin/dvilj2p \
	$prefix/bin/dvilj4 \
	$prefix/bin/dvilj4l \
	$prefix/bin/dvipng \
	$prefix/bin/dvipos \
	$prefix/bin/dvips \
	$prefix/bin/dviselect \
	$prefix/bin/dvispc \
	$prefix/bin/dvisvgm \
	$prefix/bin/dvitodvi \
	$prefix/bin/dvitype \
	$prefix/bin/epsffit \
	$prefix/bin/eptex \
	$prefix/bin/euptex \
	$prefix/bin/extconv \
	$prefix/bin/gftodvi \
	$prefix/bin/gftopk \
	$prefix/bin/gftype \
	$prefix/bin/gregorio \
	$prefix/bin/gsftopk \
	$prefix/bin/hbf2gf \
	$prefix/bin/kpseaccess \
	$prefix/bin/kpsereadlink \
	$prefix/bin/kpsestat \
	$prefix/bin/kpsewhich \
	$prefix/bin/lacheck \
	$prefix/bin/luahbtex \
	$prefix/bin/luajithbtex \
	$prefix/bin/luajittex \
	$prefix/bin/luatex \
	$prefix/bin/mag \
	$prefix/bin/makeindex \
	$prefix/bin/makejvf \
	$prefix/bin/mendex \
	$prefix/bin/mf \
	$prefix/bin/mf-nowin \
	$prefix/bin/mflua \
	$prefix/bin/mfluajit \
	$prefix/bin/mft \
	$prefix/bin/mmafm \
	$prefix/bin/mmpfb \
	$prefix/bin/mpost \
	$prefix/bin/msxlint \
	$prefix/bin/odvicopy \
	$prefix/bin/odvitype \
	$prefix/bin/omfonts \
	$prefix/bin/otangle \
	$prefix/bin/otfinfo \
	$prefix/bin/otftotfm \
	$prefix/bin/otp2ocp \
	$prefix/bin/outocp \
	$prefix/bin/patgen \
	$prefix/bin/pbibtex \
	$prefix/bin/pdftex \
	$prefix/bin/pdftosrc \
	$prefix/bin/pdvitype \
	$prefix/bin/pfb2pfa \
	$prefix/bin/pk2bm \
	$prefix/bin/pktogf \
	$prefix/bin/pktype \
	$prefix/bin/pltotf \
	$prefix/bin/pmpost \
	$prefix/bin/pmxab \
	$prefix/bin/pooltype \
	$prefix/bin/ppltotf \
	$prefix/bin/prepmx \
	$prefix/bin/ps2pk \
	$prefix/bin/psbook \
	$prefix/bin/psnup \
	$prefix/bin/psresize \
	$prefix/bin/psselect \
	$prefix/bin/pstops \
	$prefix/bin/ptex \
	$prefix/bin/ptftopl \
	$prefix/bin/scor2prt \
	$prefix/bin/sjisconv \
	$prefix/bin/synctex \
	$prefix/bin/t1dotlessj \
	$prefix/bin/t1lint \
	$prefix/bin/t1rawafm \
	$prefix/bin/t1reencode \
	$prefix/bin/t1testpage \
	$prefix/bin/t4ht \
	$prefix/bin/tangle \
	$prefix/bin/tex \
	$prefix/bin/tex2aspc \
	$prefix/bin/tex4ht \
	$prefix/bin/tftopl \
	$prefix/bin/tie \
	$prefix/bin/ttf2afm \
	$prefix/bin/ttf2pk \
	$prefix/bin/ttf2tfm \
	$prefix/bin/ttfdump \
	$prefix/bin/ttftotype42 \
	$prefix/bin/upbibtex \
	$prefix/bin/updvitype \
	$prefix/bin/upmendex \
	$prefix/bin/upmpost \
	$prefix/bin/uppltotf \
	$prefix/bin/uptex \
	$prefix/bin/uptftopl \
	$prefix/bin/vftovp \
	$prefix/bin/vlna \
	$prefix/bin/vptovf \
	$prefix/bin/weave \
	$prefix/bin/wofm2opl \
	$prefix/bin/wopl2ofm \
	$prefix/bin/wovf2ovp \
	$prefix/bin/wovp2ovf \
	$prefix/bin/xdvipdfmx \
	$prefix/bin/xetex \
	$prefix/bin/xml2pmx \
	$libDir/libkpathsea.so.$libkpathseaVersion \
	$libDir/libptexenc.so.$libptexencVersion \
	$libDir/libsynctex.so.$libsynctexVersion \
	$libDir/libtexlua53.so.$libtexluaVersion \
	$libDir/libtexluajit.so.$libtexluajitVersion

### Variables that TeX Live uses to control where files go
# This is the parent directory of our several trees, i.e.,
# /usr/local/texlive/YYYY in the original TeX Live distribution.
#
# All trees must be organized according to the TeX Directory Structure
# (http://tug.org/tds), or files may not be found.
#
# Redistributors will probably want $SELFAUTODIR/share, i.e., /usr/share.
# Kpathsea sets SELFAUTOLOC (the directory with the binary),
# SELFAUTODIR (its parent), and SELFAUTOPARENT (its grandparent).
#
###		TEXMFROOT = $SELFAUTOPARENT
#
# The main tree of distributed packages and programs:
#
###		TEXMFDIST = $TEXMFROOT/texmf-dist
#
# We used to have a separate /texmf tree with some core programs and files.
# Keep the variable name.
#
###		TEXMFMAIN = $TEXMFDIST
#
# Local additions to the distribution trees.
#
###		TEXMFLOCAL = $SELFAUTOGRANDPARENT/texmf-local
#
# TEXMFSYSVAR, where *-sys store cached runtime data.
#
###		TEXMFSYSVAR = $TEXMFROOT/texmf-var
#
# TEXMFSYSCONFIG, where *-sys store configuration data.
#
###		TEXMFSYSCONFIG = $TEXMFROOT/texmf-config
#
# Per-user texmf tree(s) -- organized per the TDS, as usual.  To define
# more than one per-user tree, set this to a list of directories in
# braces, as described above.  (This used to be HOMETEXMF.)  ~ expands
# to #USERPROFILE# on Windows, $HOME otherwise.
#
###		TEXMFHOME = ~/texmf
#
# TEXMFVAR, where texconfig/updmap/fmtutil store cached runtime data.
#
###		TEXMFVAR = ~/.texlive2014/texmf-var
#
# TEXMFCONFIG, where texconfig/updmap/fmtutil store configuration data.
#
###		TEXMFCONFIG = ~/.texlive2014/texmf-config
#
# List all the texmf trees. For an explanation of what they are, see the
# TeX Live manual.
#
# For texconfig to work properly, TEXMFCONFIG and TEXMFVAR should be named
# explicitly and before all other trees.
#
# TEXMFLOCAL precedes TEXMFDIST because locally-installed versions
# should take precedence over distribution files -- although it is
# generally a source of confusion to have different versions of a
# package installed, whatever the trees, so try to avoid it.
#
###		TEXMF = {$TEXMFCONFIG,$TEXMFVAR,$TEXMFHOME,!!$TEXMFSYSCONFIG,!!$TEXMFSYSVAR,!!$TEXMFLOCAL,!!$TEXMFDIST}
#
# Where to look for ls-R files.  There need not be an ls-R in the
# directories in this path, but if there is one, Kpathsea will use it.
# By default, this is only the !! elements of TEXMF, so that mktexlsr
# does not create ls-R files in the non-!! elements -- because if an
# ls-R is present, it will be used, and the disk will not be searched.
# This is arguably a bug in kpathsea.
#
###		TEXMFDBS = {!!$TEXMFSYSCONFIG,!!$TEXMFSYSVAR,!!$TEXMFLOCAL,!!$TEXMFDIST}
#
# The system trees.  These are the trees that are shared by all users.
# If a tree appears in this list, the mktex* scripts will use
# VARTEXFONTS for generated files, if the original tree isn't writable;
# otherwise the current working directory is used.
#
###		SYSTEXMF = $TEXMFSYSVAR;$TEXMFLOCAL;$TEXMFDIST
#
# First writable tree here is used by Lua(La)TeX for the font cache.
# LuaLaTeX uses the value here, while ConTeXt uses the same variable but
# from texmfcnf.lua; therefore the two values should be kept in sync.
# (As should everything else in texmf.cnf <-> texmfcnf.lua.)
#
###		TEXMFCACHE = $TEXMFSYSVAR;$TEXMFVAR
#
# Where generated fonts may be written.  This tree is used when the sources
# were found in a system tree and either that tree wasn't writable, or the
# varfonts feature was enabled in MT_FEATURES in mktex.cnf.
#
###		VARTEXFONTS = $TEXMFVAR/fonts
#
# On some systems, there will be a system tree which contains all the font
# files that may be created as well as the formats.  For example
#   TEXMFVAR = /var/lib/texmf
# is used in many distros.  In this case, set VARTEXFONTS like this
#VARTEXFONTS = $TEXMFVAR/fonts
# and do not mention it in TEXMFDBS (but _do_ mention TEXMFVAR).
#
# Remove $VARTEXFONTS from TEXMFDBS if the VARTEXFONTS directory is below
# one of the TEXMF directories (avoids overlapping ls-R files).
fixKSearchPaths()
{
	TEXMFCNF=$sourceDir/texk/kpathsea/texmf.cnf
	sed -i -e "s@TEXMFROOT =.*@TEXMFROOT = $dataDir/texlive@" $TEXMFCNF
	sed -i -e "s@TEXMFDIST =.*@TEXMFDIST = $dataDir/texlive/texmf-dist@" $TEXMFCNF
	sed -i -e "s@TEXMFMAIN =.*@TEXMFMAIN = $dataDir/texlive/texmf-dist@" $TEXMFCNF
	sed -i -e "s@TEXMFLOCAL =.*@TEXMFLOCAL = /boot/system/non-packaged/data/texmf-dist@" $TEXMFCNF
	sed -i -e "s@TEXMFSYSVAR =.*@TEXMFSYSVAR = $sharedStateDir/texlive@" $TEXMFCNF
	sed -i -e "s@TEXMFSYSCONFIG =.*@TEXMFSYSCONFIG = $sysconfDir/texlive@" $TEXMFCNF
	sed -i -e "s@TEXMFHOME =.*@TEXMFHOME = /boot/home/config/settings/texmf-dist@" $TEXMFCNF
	sed -i -e "s@TEXMFVAR =.*@TEXMFVAR = /boot/home/config/var/texmf@" $TEXMFCNF
	sed -i -e "s@TEXMFCONFIG =.*@TEXMFCONFIG = /boot/home/config/settings/texmf/config@" $TEXMFCNF
	sed -i -e "s@VARTEXFONTS =.*@VARTEXFONTS = /boot/home/config/settings/texmf/fonts@" $TEXMFCNF
	# rename current TEXMFCNF; easier than writing a more complex sed script!
	sed -i -e "s@^TEXMFCNF@IGNOREDTEXMFCNF@" $TEXMFCNF
	# redefine TEXMFCNF: {$SELFAUTOLOC,$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,}/web2c}
	sed -i -e "s@%TEXMFCNF.*@TEXMFCNF={$dataDir/texlive/texmf-dist/web2c,/boot/system/non-packaged/data/texmf-dist/web2c,/boot/home/config/settings/texmf-dist/web2c}@" $TEXMFCNF
}

PATCH()
{
	# disable the install-bin-links target
	sed -i -e 's/!WIN32/WIN32/g' am/bin_links.am

	./reautoconf

	# may need to run this super early to ensure everything gets the right value...
	fixKSearchPaths
}

BUILD()
{
	mkdir -p ../build && cd ../build

	if [ $targetArchitecture = x86_gcc2 ] || [ $targetArchitecture = x86 ]; then
		HOST=i586-pc-haiku
	else
		HOST=${targetArchitecture}-unknown-haiku
	fi

	runConfigure --omit-buildspec --omit-dirs "binDir sbinDir" \
		$sourceDir/configure \
		--bindir=$prefix/bin --sbindir=$prefix/bin \
		--disable-native-texlive-build \
		--enable-shared --disable-static \
		--with-banner-add="/Haiku" --with-editor='lpe +%d "%s"' \
		--with-system-harfbauzz \
		--with-system-icu \
		--with-system-graphite2 \
		--with-system-zziplib \
		--with-system-mpfr \
		--with-system-gmp \
		--with-system-cairo \
		--with-system-pixman \
		--with-system-gd \
		--with-system-freetype2 \
		--with-system-libpng \
		--with-system-libpaper \
		--with-system-zlib \
		--with-system-libgs \
		--with-system-harfbuzz \
		--with-system-teckit \
		--without-x \
		--disable-t1utils \
		--build=$HOST --host=$HOST

	# and make the damn thing!
	make all $jobArgs
}

INSTALL()
{
	cd ../build
	make install
	# make texlinks creates broken symlinks :( see comment in BUILD()
	make texlinks

	# remove useless libtool files
	rm -f $libDir/*.la

	prepareInstalledDevelLibs libkpathsea libptexenc libsynctex libtexlua53 libtexluajit
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	cd ../build
	make -k check
}
