We strongly recommend that you use binary snapshots to do this. 4-STABLE snapshots are available at ftp://releng4.FreeBSD.org/.
Because of the many changes between 3.X and 4-STABLE, a direct upgrade from source will probably fail. A source upgrade can be done, but only in stages. First, upgrade to the latest 3-STABLE (RELENG_3). Then upgrade to 4.1.1-RELEASE (RELENG_4_1_1_RELEASE). Finally, upgrade to 4-STABLE (RELENG_4).
If you wish to upgrade using source, please see the FreeBSD Handbook for more information.
Caution: Upgrading via source is never recommended for new users, and upgrading from 3.X to 4.X is even less so; make sure you have read the instructions carefully before attempting to upgrade via source.