First get dpkg-dev, g++, gcc, libc, make:
sudo apt-get install build-essentials
Then get the full set of build dependencies for last emacs, emacs24:
sudo apt-get build-dep emacs24
Decide if you want to build just this version, or track emacs. I track from git, because. So I have a directory for emacs where I have master, emacs25, and build directories. I try to avoid building in src dirs. It makes it easier to try out different options without polluting the src.
mkdir -p ~/bld/emacs
cd ~/bld/emacs
git clone git://git.savannah.gnu.org/emacs.git
cd emacs.git
git worktree add ../emacs-25.1 emacs-25.1
cd ..
mkdir bld-25.1