Before you build WebKit, you'll need to check out sources. Next make sure that you have Xcode, preferably the latest version, which is 2.2 at this point. You will need at least Xcode 2.1 to be able to build WebKit.
To start a build, use the build-webkit script.
It's handy to put the WebKitTools/Scripts directory in your shell path so you can type commands like build-webkit without specifying the path to the script.
Once the frameworks are built, you'll probably want to run Safari using the newly-built WebKit. To do that, use the run-safari script.
This script sets up the DYLD_FRAMEWORK_PATH environment variable, which will cause the system loader to use the frameworks you built from your Xcode build products directory instead of the ones installed in /System/Library/Frameworks, so it will start the version of Safari from the Applications directory with the WebKit frameworks you just built.
If you have specified custom location for the build products directory in Xcode preferences, the frameworks will be built in that directory. If you haven't, the build products will be put in a directory named WebKitBuild alongside the source code directories.
By default, the scripts will do a Deployment build, which is optimized and doesn't have development-only code, like assertions, compiled in. If you're prefer to do a Development build, then do execute this command:
You can also pass the configuration on the command line to any of the build commands.
More information about building WebKit can be found on its wiki.