Using MacPorts ( http://macports.org/ ), with insight from instructions at http://blog.hani-ibrahim.de/en/octave4-mac-os-x-el-capitan-install.html (as well as http://blog.hani-ibrahim.de/en/octave-mac-os-x-el-capitan-install.html and http://blog.hani-ibrahim.de/en/octave4-upgrade-via-macports.html) as well as the Octave wiki at http://wiki.octave.org/Octave_for_MacOS_X#MacPorts
It seems as though MacPort's default
atlas variant doesn't play nice with Octave, and
qrupdate also have issues with their default installion, needing specific "variants" to properly build. Basically to get all of Octave 4 running, I did:
sudo port install atlas +gcc5
sudo port install arpack -accelerate+atlas+gfortran
sudo port install qrupdate -accelerate+atlas+gcc5
sudo port install octave -gcc5+gfortran-accelerate+atlas+docs+fltk+graphicsmagick+java-gui-metis-qtgui+app+qt4gui+sound
Probably some of the octave variant flags are unneeded for some people, but I went with the options suggested by hani-ibrahim.de and it works for me to get command line Octave up and running, as well as giving a nifty Octave.app in the /Applications/MacPorts directory.
If you need Java support with the Java variant (+java) as above, you probably need a JDK (Java Development Kit) to get the necessary command line suff for that magic to work, so go to ( http://www.oracle.com/technetwork/java/javase/index.html ) for a download. Maybe the smaller JRE (Java Runtime Environment) would be sufficient, but I have installed the full JDK. Omitting the (+java) flag removes this requirement.
I just tested it (2016/09/01) on Mac OS X 10.11.6 and was able to intall via MacPorts with no errors, ending up with atlas @3.10.2_2, arpack @3.3.0_3, qrupdate @1.1.2_4 and octave @4.0.3_0
On about 2016/12/05, with just the xcode command line tools installed (not the full XCode), I was able to use the above to install on macOS 10.12.1 Sierra: arpack @3.3.0_3, atlas @3.10.2_2, qrupdate @1.1.2_4, and octave @4.2.0_1. I initially was not able to get 4.2.0_0 installed, but 0_1 finally did. The installation ended with the warning "unless octave is run with –no-gui-libs, graphics_toolkit(“fltk”) will cause a crash" but I have not investigated this issue.