The following describes how to derive a patch for a modification you need to make to the source code of a program, and apply that patch during the RPM building process.
1. Setup
By default, at least on a Red Hat box, rpm uses /usr/src/redhat as the location of the %_topdir macro, which specifies where most of the work involved in building an RPM takes place.
The BUILD directory is where sources will be extracted and compiled, and as such is more or less a temporary working directory. SOURCES is for source tarballs, patches, and additional files, which are extracted from SRPM packages you install, and used and included in packages you build. The RPMS and SRPMS directories are where packages you build will end up. The SPECS directory is where the specfile included with an SRPM will be placed.