To expand on
tobik's reply, for the benefit of any lurkers who might be newbies like me, this is how to download, modify, and install the source for a base application or library, if you're running FreeBSD 10.0 or 10.1. (But see
tobik's useful observations in the next comment of this thread.)
Step one: Bring up your Internet connection, if it's not up already. (Many will use
dhclient
for this.)
Step two: Install subversion if you have not done so already. (If you don't know whether you have, do it again; it won't hurt.)
pkg install subversion
Step three: Choose the most appropriate subversion mirror site. A list is
here. Where you see
svn-mirror below, insert the name of the subversion mirror site you've chosen. Be sure to precede the name of the site with
svn://, as the examples below show.
Step four: Pick the name of a directory where you want the source files to go. The directory must not already exist, but its parent must. For example, if you want the source files to go to directory
/alpha/beta/gamma, directory
/alpha/beta must already exist, but directory
/alpha/beta/gamma must
not exist. Where you see
gamma below, insert the name of the (so far) nonexistent directory to hold the source code.
Step five: Download the source. The form of the command depends on whether you're working with an application or a library, and if it's an application, where the object code normally sits; to find that out for application
fetch, for example, do this:
which fetch
In this case, you'll see:
Our examples below use
dmesg, which is in directory
/sbin;
pkg, which is in directory
/usr/sbin;
ls, which is in directory
/bin; and
fetch, which is in directory
/usr/bin. So to download the source, pick one of these commands:
svn checkout svn://svn-mirror/base/stable/10/lib/libfetch gamma # for any library
svn checkout svn://svn-mirror/base/stable/10/sbin/dmesg gamma # for apps in /sbin
svn checkout svn://svn-mirror/base/stable/10/usr.sbin/pkg gamma # for apps in /usr/sbin
svn checkout svn://svn-mirror/base/stable/10/bin/ls gamma # for apps in /bin
svn checkout svn://svn-mirror/base/stable/10/usr.bin/fetch gamma # for apps in /usr/bin
Step six: Position yourself in the destination directory and modify the source. No need to copy it elsewhere. You'll just be using it privately, right? Then forget that you're in a subversion directory. Just splash and play.
Step seven: Set the destination directory for the application.
This is not done for libraries. Do something like this for normal shells:
export BINDIR=/usr/bin
or, for C shells like tcsh:
setenv BINDIR /usr/bin
If you're working with an application and you forget this step, you'll find your compiled application at the root directory. For example
fetch will be placed at
/fetch.
Step eight: Position yourself in the directory that contains the Makefile, and do this:
make # (and make sure there are no fatal errors; warnings should be OK)
make install
Boom. You're done.
For extra credit, consider downloading the whole base source tree, wandering through it, and letting your imagination go wild:
rm -rf /usr/src
svn checkout svn://svn-mirror/base/stable/10 /usr/src