Skip to content

Instantly share code, notes, and snippets.

@mikekwright
Created November 16, 2013 22:47
Show Gist options
  • Select an option

  • Save mikekwright/7506393 to your computer and use it in GitHub Desktop.

Select an option

Save mikekwright/7506393 to your computer and use it in GitHub Desktop.
Ocaml 4.01.0 and opam 1.1.0 install helper.
#!/bin/bash
# Sample of this executing located below
#
# INSTALL_PREFIX=$HOME/Development/ocaml CODE_DIR=$HOME/Development/src ./ocaml-install.sh
#
function installOcaml
{
local codeDir=$1
local installDir=$2
cd $codeDir
wget http://caml.inria.fr/pub/distrib/ocaml-4.01/ocaml-4.01.0.tar.gz
tar -xvf ocaml-4.01.0.tar.gz
cd ocaml-4.01.0
./configure -prefix $installDir
make world.opt
make install
export PATH=$PATH:$installDir/bin
}
function installOpam
{
local codeDir=$1
local installDir=$2
cd $codeDir
wget http://www.ocamlpro.com/pub/opam-full-1.1.0.tar.gz
tar -xvf opam-full-1.1.0.tar.gz
cd opam-full-1.1.0
./configure -prefix $installDir
make
make install
$installDir/bin/opam init
$installDir/bin/opam config setup -a
echo ". $HOME/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true" >> ~/.bashrc
}
installPrefix=${INSTALL_PREFIX:-"/usr/local"}
codeDir=${CODE_DIR:-"/usr/local/src"}
set -o nounset
installOcaml $codeDir $installPrefix
installOpam $codeDir $installPrefix
echo "Ocaml and Opam now installed, you can install utop by doing the following two things"
echo ""
echo " 1. source $HOME/.opam/opam-init/init.sh"
echo " 2. opam install --yes utop"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment