Migrated Gentoo support to OCaml

Untested.