This is a snippet I use on all my machines, if you don't always use brew you could always wrap it in an outer check. And yes the -O2 might not be for everybody, then just skip it :)
This one will adhere to whatever location you might have used for Linux Homebrew, on Darwin you would always use /usr/local, since otherwise a lot of brew stuff fails, and it would be a pointless pain to workaround.
comment: Darwin doesn't set this variable, Linux HomeBrew does
if [ "$HOMEBREW_PREFIX" = "" ]; then
HOMEBREW_PREFIX="/usr/local"
fi
comment: Set the env to ensure brew can build stuff
This is a snippet I use on all my machines, if you don't always use brew you could always wrap it in an outer check. And yes the -O2 might not be for everybody, then just skip it :)
This one will adhere to whatever location you might have used for Linux Homebrew, on Darwin you would always use /usr/local, since otherwise a lot of brew stuff fails, and it would be a pointless pain to workaround.
comment: Darwin doesn't set this variable, Linux HomeBrew does
if [ "$HOMEBREW_PREFIX" = "" ]; then
HOMEBREW_PREFIX="/usr/local"
fi
comment: Set the env to ensure brew can build stuff
export LDFLAGS="-L$HOMEBREW_PREFIX/opt/zlib/lib -L$HOMEBREW_PREFIX/opt/bzip2/lib"
export CPPFLAGS="-I$HOMEBREW_PREFIX/opt/zlib/include -I$HOMEBREW_PREFIX/opt/bzip2/include"
export CFLAGS="-O2"