#!/bin/sh

LMTXSERVER=lmtx.contextgarden.net,lmtx.pragma-ade.com,lmtx.pragma-ade.nl
LMTXINSTANCE=install-lmtx
LMTXEXTRAS=

libc=glibc
PLATFORM="linux"

# "" are needed for WLS because of (86) in the variable
export PATH="$PWD/bin:$PWD/tex/texmf-$PLATFORM/bin:$PATH"
chmod +x bin/mtxrun

$PWD/bin/mtxrun --script ./bin/mtx-install.lua --update --server="$LMTXSERVER" --instance="$LMTXINSTANCE" --platform="$PLATFORM" --erase --extras="$LMTXEXTRAS"

cp $PWD/tex/texmf-$PLATFORM/bin/mtxrun                        $PWD/bin/mtxrun
cp $PWD/tex/texmf-context/scripts/context/lua/mtxrun.lua      $PWD/bin/mtxrun.lua
cp $PWD/tex/texmf-context/scripts/context/lua/mtx-install.lua $PWD/bin/mtx-install.lua

# echo "  export PATH=$PWD/tex/texmf-$PLATFORM/bin:$PATH"

echo ""
echo "If you want to run ConTeXt everywhere, you need to adapt the path, like:"
echo ""
echo "  export PATH=$PWD/tex/texmf-$PLATFORM/bin:"'$PATH'
echo ""
echo "If you run from an editor you can specify the full path to mtxrun:"
echo ""
echo "  $PWD/tex/texmf-$PLATFORM/bin/mtxrun --autogenerate --script context --autopdf ..."
echo ""
echo "The following settings were used:"
echo ""
echo "  server   : $LMTXSERVER"
echo "  instance : $LMTXINSTANCE"
echo "  extras   : $LMTXEXTRAS"
echo "  ownpath  : $PWD"
echo "  platform : $PLATFORM"
echo ""
