OCaml native on android!
NB since termux updated to binutils >= 2.29 only OCaml versions >= 4.06.0 will work (thx Kyle Stemen).
Use pre-built OPAM for aarch64 to build OCaml
Install OPAM
echo "deb [arch=all,aarch64] http://ygrek.org/files/debian/termux ./" >> "$PREFIX/usr/etc/apt/sources.list"
apt-get update # repository is not signed for now :]
apt install opamInstall OCaml
apt install make clang
opam init --comp=4.06.1+termuxBuild OCaml to build OPAM to build OCaml
NB termux lacks /bin/sh (and all other standard unix file paths for that matter), so the main problem during builds is hardcoded shell path in shebangs. To overcome it - remember to use sh ./script instead of ./script.
Remove opam and ocaml packages if present, remove ~/.opam to have clean state
Prepare proper build environment. NB termux comes with busybox, hence many utilities are present, but with limited features, need to install separate packages.
apt install coreutils clang curl dash diffutils grep m4 make ncurses patch pkg-config
Build OCaml
mkdir ~/tmp
export TMPDIR="$HOME/tmp" # add to ~/.profile
git clone https://github.com/ygrek/ocaml.git -b termux-4.06.1
cd ocaml
sh ./configure -prefix "$PREFIX"
make world.opt installBuild OPAM
curl -LO https://github.com/ocaml/opam/releases/download/1.2.2/opam-full-1.2.2.tar.gz
tar -xzf opam-full-1.2.2.tar.gz
cd opam-full-1.2.2/
sed -i 's|/bin/sh|sh|' src/core/opamSystem.ml OCamlMakefile
CONFIG_SHELL=sh sh ./configure -prefix "$PREFIX"
OCAMLPARAM="safe-string=0,_" make lib-ext all installInit OPAM (will use compiler built in step 3 as system switch)
opam initInstall OCaml via OPAM and remove system OCaml (built in step 3) to avoid confusion with OPAM switches
opam sw 4.06.1+termux
rm "$PREFIX"/usr/man/man1/ocaml*
rm "$PREFIX"/usr/bin/ocaml*
rm -rf /data/data/com.termux/files/usr/lib/ocaml
opam sw remove system2018-06-25