Differences between revisions 93 and 94
Deletions are marked like this. Additions are marked like this.
Line 69: Line 69:
brew install gcc
brew postinstall gcc
brew install gcc49
brew postinstall gcc49
Line 72: Line 72:

There may be gcc tools installed in /usr/bin, so you will want to make sure that the gcc 4.9 installed by Homebrew is used, so first run this in bash:
{{{
VER=4.9
LN_APPS="c++-$VER cpp-$VER g++-$VER gcc-$VER gcc-ar-$VER gcc-nm-$VER gcc-ranlib-$VER gcov-$VER gfortran-$VER"
cd /usr/local/bin
for app in $LN_APPS
do
 LN_NAME=$(echo $app | sed 's/\(.*\)-4.9/\1/')
 echo "ln -s $app $LN_NAME"
 ln -s $app $LN_NAME
done
}}}

Then make sure that /usr/local/bin is first in your default path. Put this (for tsch) in your .cshrc:
{{{
setenv USR_LOCAL /usr/local
if (-e $USR_LOCAL) then
  setenv PATH "$USR_LOCAL/bin":"$PATH"
endif
}}}

You should now be setup with the gnu tools to build freesurfer.

This page is targeted at those who wish to develop and build the freesurfer source code on their OSX platform. These instructions have been tested for 10.13 (High Sieraa). See the linux build page for instructions on how to build on linux platform.

Those who wish to add a binary to the FreeSurfer software suite should consult the 'Adding a new binary to the tree' section of the Developers Guide.

1. Get the Source Code

The Freesurfer source code can be cloned from the official Freesurfer github page:

git clone https://github.com/freesurfer/freesurfer.git

1.1. Get the Data Files (optional)

The Freesurfer repository contains a large number data files which are not included with a default git clone of the repo. Instead, these data files are distributed via the git-annex software. Users who only want the repository for the purposes of compiling binaries and/or inspecting source code, the git clone command from above is all you need to do. Users who want to run build time checks, or perform a full local installation, or just want all the contents of the repository, will need to add a special data store remote repository in order to retrieve these files.

To add the data store repository (this only needs to be done once):

cd freesurfer
git remote add datasrc  https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/repo/annex.git
git fetch datasrc

And to retrieve data files:

git annex get <filename>

The data files have been broken down into categories, those being required for build time checks, those required for a local installation, and everything else. Use one of the following commands depending on your needs:

## Get only the data files required for build time checks (1.9 GB)
git annex get --metadata fstags=makecheck .

## Get only the data files required for local installation (4.3 GB)
git annex get --metadata fstags=makeinstall .

## Just give me everything! Not Recommended (6.8 GB)
git annex get .

2. Install System Libraries

In order to build Freesurfer, the following prerequisite software will need to be downloaded and installed on your OSX system. !Homebrew is preferred over MacPorts. !Homebrew needs to be installed first. However, if your Mac is polluted with various stuff in /usr/local and /opt/local, a recommendation is to delete those directories entirely. To do so:

sudo rm -Rf /usr/local/*
sudo rm -Rf /opt/local/*

This is safe to do on Mac High Sierra. Reboot once this is done, then install Homebrew, open a Terminal, then type 'bash' (if that is not your default):

bash-3.2$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Test it:

brew install wget
brew postinstall wget
wget --help

You should get wget help instructions, which means Homebrew is working. The brew install may output some error-looking stuff, but if wget --help works, then your set. Now use it to install autoconf, automake, libtool, and gcc:

brew install libtool
brew install automake
brew postinstall automake
brew install gcc49
brew postinstall gcc49

There may be gcc tools installed in /usr/bin, so you will want to make sure that the gcc 4.9 installed by Homebrew is used, so first run this in bash:

VER=4.9
LN_APPS="c++-$VER cpp-$VER g++-$VER gcc-$VER gcc-ar-$VER gcc-nm-$VER gcc-ranlib-$VER gcov-$VER gfortran-$VER"
cd /usr/local/bin
for app in $LN_APPS
do
        LN_NAME=$(echo $app | sed 's/\(.*\)-4.9/\1/')
        echo "ln -s $app $LN_NAME"
        ln -s $app $LN_NAME
done

Then make sure that /usr/local/bin is first in your default path. Put this (for tsch) in your .cshrc:

setenv USR_LOCAL  /usr/local
if (-e $USR_LOCAL) then
  setenv PATH      "$USR_LOCAL/bin":"$PATH"
endif

You should now be setup with the gnu tools to build freesurfer.

3. Library Dependencies

In order to compile freesurfer, you will need to download and install our prebuilt bundle of 3rd party dependencies. Download the package and extract its content. Remember the extraction location as you will need to pass that directory to the configure script.

$> mkdir ~/osx-lion-packages
$> cd ~/osx-lion-packages
$> curl -O ftp://surfer.nmr.mgh.harvard.edu/pub/dist/fs_supportlibs/prebuilt/OSX/osx-lion-packages.tar.gz
$> tar -xzvf osx-lion-packages.tar.gz

4. Setup, Configure, Make

Determine the location you want Freesurfer to be installed. For example, in case case we will assume the user wants Freesurfer to be installed in /home/USER/freesurfer. Type the following commands in the top-level Freesurfer directory (the directory that contains configure.in and all the mri_* and mris_* directories.):

$> cd ~/freesurfer
$> ./setup_configure
$> ./configure --with-pkgs-dir=/Users/USERNAME/osx-lion-packages --disable-Werror --prefix=/Users/username/fs_install
$> make -j4
$> make install

Done!

5. Contributing Changes

Users who with to make contributions to the Freesurfer code base should see the following page which describes how to fork the Freesurfer repository and submit pull requests:


Send your comments/questions/feedback to zkaufman@nmr.mgh.harvard.edu