There are some guides to making your own build of MAME on the net, but most if not all of those that I could find are outdated. Here are some of my notes to remember the tricks that will in their turn get outdated soon and confuse other people as well.
The process is mostly automatic, however I had several problems that I had to resolve by hand. The command line for compiling on my system (OS X 10.7.5 Lion) was:
CFLAGS="-I/Users/svo/tmpsrc/mess/mame/src/lib/util -I/opt/local/include" make SUBTARGET=mess NOWERROR=1 TARGETOS=macosx