In addition to all the tools (both optional and required) that are listed in Build Dependencies you will need:
Once you have the required tools installed, you can build Octave by doing
hg clone http://www.octave.org/hg/octave
cd octave
./autogen.sh
mkdir build cd build
By using a separate build directory, you will keep the source directory clean and it will be easy to completely remove all files generated by the build. You can also have parallel build trees for different purposes that all share the same sources. For example, one build tree may be configured to disable compiler optimization in order to allow for easier debugging while another may be configured to test building with other specialized compiler flags.
../configure
make
Once the build is finished, you will see a message like the following:
Octave successfully built. Now choose from the following: ./run-octave - to run in place to test before installing make check - to run the tests make install - to install (PREFIX=...)