Create a directory where files are expected to be downloaded. Move into the directory (e.g., ~/Downloads) and do as follows:

$ mkdir src
$ cd src
$ wget "ftp://ftp.scc.u-tokai.ac.jp/pub/gmt/gmt-5.1.1-src.tar.bz2"
$ sudo apt-get install cmake
$ sudo apt-get install libnetcdf-dev
$ sudo apt-get install g++
$ sudo apt-get install gdal-bin
$ sudo apt-get install libgdal-dev
$ tar xvf gmt-5.1.1-src.tar.bz2
$ cd gmt-5.1.1/
$ cp cmake/ConfigUserTemplate.cmake cmake/ConfigUser.cmake
$ vi cmake/ConfigUser.cmake

In ConfigUser.cmake, you should edit as follows:

set (CMAKE_INSTALL_PREFIX "/usr/local/GMT-5.1.1")
set (GSHHG_ROOT "/usr/local/GMT-5.1.1/share/coast")

gshhg should be downloaded and copied onto /usr/local/GMT-5.1.1/share/coast/

$ cd /usr/local
$ sudo mkdir GMT-5.1.1
$ cd GMT-5.1.1
$ sudo mkdir share
$ cd share
$ sudo mkdir coast
$ cd coast
$ sudo wget ftp://ftp.scc.u-tokai.ac.jp/pub/gmt/gshhg-gmt-2.3.0.tar.gz
$ sudo tar xvf gshhg-gmt-2.3.0.tar.gz

Then, the created files should be copied in ./coast

Again come back to the directory where source codes are copied (e.g., ~/Downloads).

$ mkdir build
$ cd build
$ cmake ../
$ make all
$ sudo make install