Skip to content

Commit

Permalink
fix: Improve top level dir setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
ktras committed Jan 17, 2024
1 parent fa7f413 commit 79a0d2d
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ usage()
echo "./setup.sh [--help|-h]"
echo ""
echo " --help Display this help text"
echo " --prefix=PREFIX Install any binaries needed to build inference-engine in 'PREFIX/bin'"
echo " Default prefix='\$HOME/.local/bin'"
echo ""
}

Expand Down Expand Up @@ -45,35 +47,50 @@ if ! command -v gfortran > /dev/null ; then
exit 1
fi

install_fpm_from_source()
{
echo "Installing fpm in following location: $PREFIX/bin"
echo "Ensure $PREFIX/bin is in your path or rerun script with the --prefix=PREFIX flag"
if ! command -v curl > /dev/null ; then
echo "Need curl to download source file for fpm to install it"
echo "Please install curl and then rerun ./setup.sh"
exit 1
fi
mkdir temp-dir-to-build-fpm-for-inference-engine-installation
curl -L -o temp-dir-to-build-fpm-for-inference-engine-installation/fpm.F90 https://github.com/fortran-lang/fpm/releases/download/current/fpm.F90
gfortran -o $PREFIX/bin/fpm -Jtemp-dir-to-build-fpm-for-inference-engine-installation temp-dir-to-build-fpm-for-inference-engine-installation/fpm.F90
rm -rf temp-dir-to-build-fpm-for-inference-engine-installation
if command -v fpm > /dev/null ; then
echo "fpm installed"
else
echo "Some error has occured while trying to install fpm. Please install fpm, ensure it is in your path, and rerun script"
fi
}

# if no fpm, install either through homebrew, or gfortran compiling fpm.F90
if ! command -v fpm > /dev/null ; then
if ! command -v brew > /dev/null ; then
if ! command -v curl > /dev/null ; then
echo "Please install curl and then rerun ./setup.sh"
if ! command -v gfortran > /dev/null ; then
echo "Please install fpm, ensure it is in your path, and rerun script"
exit 1
else # has gfortran, but not homebrew
install_fpm_from_source
fi
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [ $(uname) = "Linux" ]; then
if [ -z "$PATH" ]; then
PATH=/home/linuxbrew/.linuxbrew/bin/
else
PATH=/home/linuxbrew/.linuxbrew/bin/:"$PATH"
fi
fi
else # has homebrew
brew tap fortran-lang/fortran
brew install fortran-lang/fortran/fpm
fi
brew tap fortran-lang/fortran # required for building fpm
brew install fortran-lang/fortran/fpm
fi

FPM_FC=${FC:-"gfortran-13"}
FPM_CC=${CC:-"gcc-13"}

mkdir -p build

fpm build --flag "-fcoarray=single -O3"
fpm test

echo ""
echo "____________________ Inference-Engine has been set up! _______________________"
echo "____________________ Inference-Engine has been set up! _______________________"
echo ""
echo "To run one of the programs in the example subdirectory, enter a command of the"
echo "following form at a shell command prompt after replacing <example-base-name>"
Expand Down

0 comments on commit 79a0d2d

Please sign in to comment.