The location defined by the Filesystem Hierarchy Standard to keep source code is /usr/src
. I suppose you could also use /usr/local/src
, as that is a bit more descriptive of where the software came from (that is, you built it; the distro didn't).
Note, however, that the FHS actually mentions that source code should not be built from this directory, likely because you're not supposed to compile things as root, so I suppose that you'd move the source tree there after installation. In practice, though, I don't bother; I keep everything I build in ~/Code
, which is on a roomier partition. Basically, there isn't a widely accepted convention; you just do what works for you.
You should also look at checkinstall, a great little piece of software that makes a rudimentary package from a command. (It will probably be in your distribution's repository.) Essentially, instead of running
sudo make install
you would run something along the lines of
sudo checkinstall make install
which quizzes you about the package you're making, watches make install
install everything, then builds a package that can then be cleanly installed and uninstalled with a package manager. I believe that checkinstall can build packages for dpkg-based systems (Ubuntu, Debian, etc.), RPM-based systems (Fedora, RHEL, etc.) and Slackware-based systems. If you're running Arch, don't bother with checkinstall; instead, consider using a PKGBUILD.
Hope that helps!