Created
May 2, 2014 08:07
-
-
Save shhong/789fe47f3602c74b1703 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
IVVER=18 | |
NRNVER=r1059 | |
XQVER=2.7.5 | |
READLINE=/usr/local/opt/readline/ | |
PYTHONBIN=/usr/bin/python | |
NRNDIR=/Applications/NEURON-$NRNVER | |
PROFILE=$HOME/.profile | |
source $PROFILE | |
#Check compilers | |
/usr/bin/clang --version | |
/usr/bin/python --version | |
/usr/bin/ruby --version | |
## Check if X11 is installed. | |
if [ ! -d /opt/X11 ]; then | |
echo -e '\n\nXQuartz not found.' | |
# echo -e 'XQuartz will be first installed and then you will be logged out.' | |
# echo -e '\nPlease rerun this script after that.' | |
echo -e "Downloading XQuartz.....\n" | |
curl -LO http://xquartz.macosforge.org/downloads/SL/XQuartz-$XQVER.dmg | |
hdiutil attach XQuartz-$XQVER.dmg | |
echo -e '\n\nEnter the admin password if you are asked.' | |
sudo installer -verboseR -pkg /Volumes/XQuartz-$XQVER/XQuartz.pkg -target / | |
hdiutil detach /Volumes/XQuartz-$XQVER | |
rm XQuartz-$XQVER.dmg | |
fi | |
## Check essential brew packages. | |
echo -e "\n\nInstalling essential homebrew packages..." | |
### readline | |
if [ ! -d $READLINE ]; then | |
## Check if homebrew is installed. | |
if [ ! -f /usr/local/bin/brew ]; then | |
echo -e "\n\nHomebrew not found. Installing homebrew..." | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" | |
touch $PROFILE | |
echo -e '\n\nexport PATH=/usr/local/bin:$PATH' >> $PROFILE | |
source $PROFILE | |
fi | |
echo -e "\n\nInstalling readline...\n" | |
brew install readline | |
READLINE=/usr/local/opt/readline/ | |
fi | |
### Do we need gfortran? ### | |
# if [ ! -d $BREWCELLAR/gfortran ]; then | |
# echo -e "\n\nInstalling gfortran...\n" | |
# brew install gfortran | |
# fi | |
### openmpi | |
if [ ! -f /usr/local/bin/mpirun ]; then | |
if [ ! -f /usr/local/bin/brew ]; then | |
echo -e "\n\nHomebrew not found. Installing homebrew..." | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" | |
touch $PROFILE | |
echo -e '\n\nexport PATH=/usr/local/bin:$PATH' >> $PROFILE | |
source $PROFILE | |
fi | |
echo -e "\n\nInstalling openmpi...\n" | |
brew install open-mpi | |
fi | |
## Get the sources. | |
echo -e "\n\nDownloading NEURON sources...\n" | |
curl -L -O http://raw2.github.com/shhong/CNS-starterpack/master/NEURON/NEURON.tar.gz | |
tar zxvf NEURON.tar.gz | |
echo -e '\n\nNEURON will be installed in '$NRNDIR'.\n' | |
export CC='clang' | |
export OMPI_CC='clang' | |
export CXX='clang++' | |
export OMPI_CXX='clang++' | |
export CFLAGS='-Ofast -msse3 -Wno-return-type -Wno-implicit-function-declaration -Wno-implicit-int -fPIC' | |
export CXXFLAGS=$CFLAGS | |
## Compile and install IV | |
cd NEURON/iv | |
./configure --prefix=$NRNDIR/iv | |
make -j4 | |
make install | |
cd .. | |
## Compile and install NEURON | |
cd nrn | |
echo -e "Starting to compile NEURON...\n\n" | |
./configure --prefix=$NRNDIR/nrn --with-iv=$NRNDIR/iv --with-pic --with-nrnpython=$PYTHONBIN --with-paranrn --with-x --with-readline=$READLINE | |
make -j4 | |
make install | |
### Compile and install nrnpython | |
echo -e '\n\nInstalling nrnpython module....\n' | |
cd src/nrnpython | |
python setup.py install | |
if [ $? -ne 0 ]; then { echo -e '\n\nFailed to install the python module. Now trying again with sudo...\n'; sudo python setup.py install; } fi | |
cd ../../../../ | |
### Add the environment variables | |
touch $PROFILE | |
echo -e '\n\n## NEURON\nNEURON=/Applications/NEURON' >> $PROFILE | |
echo -e 'PLATFORM=x86_64\nexport DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$NEURON/iv/$PLATFORM/lib\nexport PATH=$NEURON/iv/$PLATFORM/bin:$PATH' >> $PROFILE | |
echo -e 'export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$NEURON/nrn/$PLATFORM/lib\nexport PATH=$NEURON/nrn/$PLATFORM/bin:$PATH' >> $PROFILE | |
## Clean up and quit | |
cd /Applications/ | |
rm -rf NEURON | |
ln -s $NRNDIR NEURON | |
## Kick out the user and ask to come back again. | |
echo -e '\n\n\nAll done! Please log out and come back again.' | |
osascript -e 'tell application "System Events" to log out' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment