Skip to content

Instantly share code, notes, and snippets.

@ellisvalentiner
Created November 6, 2017 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ellisvalentiner/fb50134ff4266ac8759bab078b9ece29 to your computer and use it in GitHub Desktop.
Save ellisvalentiner/fb50134ff4266ac8759bab078b9ece29 to your computer and use it in GitHub Desktop.
Script to build Julia on Raspberry Pi
#!/usr/bin/env bash
# XXX - for making newly created files/directories less restrictive
umask 0022
# colors
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
RESET="\033[0m"
TEMP_DIR="/tmp"
OPT_DIR="/opt"
REPOSITORY="https://github.com/JuliaLang/julia.git"
BRANCH="master" # tag
JULIA_SRC_DIR="$TEMP_DIR/julia"
JULIA_INSTALL_DIR="$OPT_DIR/julia-$BRANCH"
JULIA_SYM_DIR="$OPT_DIR/julia"
function prep {
# install essential packages
echo -e "${YELLOW}>>> Installing essential packages...${RESET}"
sudo apt install -y libblas3 liblapack3 libarpack2 libfftw3-dev libgmp3-dev libmpfr-dev libblas-dev liblapack-dev cmake gcc-4.8 g++-4.8 gfortran libgfortran3 m4 libedit-dev
}
# install Julia
function install_julia {
# prepare for build
prep
# clone the repository
echo -e "${YELLOW}>>> Cloning repository...${RESET}"
sudo rm -rf "$JULIA_SRC_DIR"
git clone -b "$BRANCH" "$REPOSITORY" "$JULIA_SRC_DIR"
# build
echo -e "${YELLOW}>>> Building Julia...${RESET}"
cd "$JULIA_SRC_DIR"
sudo make all
# install
echo -e "${YELLOW}>>> Installing...${RESET}"
sudo rm -rf "$JULIA_INSTALL_DIR"
echo "prefix=${JULIA_INSTALL_DIR}" > Make.user
sudo make install
sudo chown -R "$USER" "$JULIA_INSTALL_DIR"
sudo ln -sfn "$JULIA_INSTALL_DIR" "$JULIA_SYM_DIR"
# clean
clean
echo -e "${GREEN}>>> Julia with branch/tag: $BRANCH was installed at: $JULIA_INSTALL_DIR${RESET}"
}
function clean {
# clean julia src
echo -e "${YELLOW}>>> Cleaning julia...${RESET}"
sudo rm -rf "$JULIA_SRC_DIR"
}
# do the actual job
install_julia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment