


# Compiler Hell on MAC:
#
# Mac 10.14 Apple-clang do not support older C code that uses std:experimental:optional
# since it has been turned into std:optional
#
# The workaround is to use gcc
#
# gcc > 6 is not working because recent header files are missing in the CommandlineTools
#
# gcc-6 is working properly

# Installed gcc-6 using homebrew.
# All or most of following libraries need to be compiled manually with gcc-6
# since homebrew ships Apple-clang compiled packages
COMP_PATH=/usr/local/Cellar/gcc@6/6.5.0_6

# set gcc-6 to default compiler
export CC=gcc-6
export CXX=g++-6
export FC=gfortran-6

# link gcc and commandlinetools
export PATH="$COMP_PATH/bin:$PATH"
export LDFLAGS="-L$COMP_PATH/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib -L/usr/local/lib/ $LDFLAGS"
export CPPFLAGS="-I$COMP_PATH/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/include/ $CPPFLAGS"

#
# MPI
#
# Install PREFIX of OPENMPI, built with gcc-6
export OMPI_DIR=/usr/local/opt/ompi

# set PATH and linker
export PATH=$OMPI_DIR/bin:$PATH
export LD_LIBRARY_PATH=$OMPI_DIR/lib:$LD_LIBRARY_PATH
export MANPATH=$OMPI_DIR/share/man:$MANPATH
export LDFLAGS="-L$OMPI_DIR/lib $LDFLAGS"
export CPPFLAGS="-I$OMPI_DIR/include $CPPFLAGS"

# probably unnecessary, because there is only one mpicc around
export MPICC=$OMPI_DIR/bin/mpicc
export MPICXX=$OMPI_DIR/bin/mpicxx

# install FFTW
export FFTWDIR="/usr/local/lib/"

# Select homebrew installed python
export PATH=/usr/local/opt/python@3.8/libexec/bin:$PATH

export LDFLAGS="-L/usr/local/opt/python@3.8/lib $LDFLAGS"
export PKG_CONFIG_PATH="/usr/local/opt/python@3.8/lib/pkgconfig:$PKG_CONFIG_PATH"

export LDFLAGS="-L/usr/local/lib/python3.8/site-packages/ $LDFLAGS"
export LD_LIBRARY_PATH="/usr/local/lib/python3.8/site-packages/:$LD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="/usr/local/lib/python3.8/site-packages/:$DYLD_LIBRARY_PATH"