# For Mac with M1 processor ## Install Homebrew which brew >/dev/null 2>/dev/null if [ $? -ne 0 ]; then /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" if [ "$(uname -a | sed 's/ /\n/g' | tail -n1)" = "arm64" ]; then echo 'if [ "$(uname -a | sed '\''s/ /\n/g'\'' | tail -n1)" = "arm64" ]; then' >> /Users/$USER/.zprofile echo ' eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/$USER/.zprofile echo 'fi' >> /Users/$USER/.zprofile source /Users/$USER/.zprofile fi fi ## Check installing homebrew if [ `which brew >/dev/null 2>/dev/null; echo $?` -ne 0 ]; then echo "Homebrew is not installed." 1>&2 exit 1 fi # For Homebrew GCC_VERSION="11" TARGET_PACKAGES=(wget emacs gcc@${GCC_VERSION}) CHECKED_PACKAGES=(wget emacs gcc gfortran) check_flag=1 ## Check installing homebrew if [ `which brew >/dev/null 2>/dev/null; echo $?` -ne 0 ]; then echo "Homebrew is not installed." 1>&2 exit 1 fi BREW_ROOT=`brew --prefix` ## Install each package echo "Install packages" for package in ${TARGET_PACKAGES[@]}; do echo ${package} done for package in ${TARGET_PACKAGES[@]}; do brew install ${package} done ## Use GCC instead of Clang if [ -f "${BREW_ROOT}/bin/gcc" ]; then rm "${BREW_ROOT}/bin/gcc" fi ln -s ${BREW_ROOT}/bin/gcc-${GCC_VERSION} ${BREW_ROOT}/bin/gcc if [ $? -ne 0 ]; then echo "Symbolic link of GCC cannot be created." 1>&2 exit 1 fi if [ "`readlink ${BREW_ROOT}/bin/gcc`" != "${BREW_ROOT}/bin/gcc-${GCC_VERSION}" ]; then echo "gcc command may use Clang or default GCC instead of GCC installed by Homebrew." 1>&2 fi ## Check whether each packages is installed or not. echo "" echo "" echo "Check packages" for package in ${CHECKED_PACKAGES[@]}; do ${package} --version >/dev/null 2>/dev/null if [ $? -ne 0 ]; then echo "${package} is not installed." 1>&2 check_flag=0 fi done echo "" if [ ${check_flag} -eq 1 ]; then echo "Completed!" else echo "Some packages are not installed correctly." fi