BEST idea for getting all needed dependencies is to use command that will install development dependencies for given package. Oh howto there should be so example for it.
If you do not know how, than you can still try to find source package for mesa, and read dependencies and install them manually. (Did so on fedora!)
For ubuntu it should be:
sudo apt-get build-dep <package>
Change <package> for EVERY package starting with mesa in your system.
Yeah the real problem is trying to compile the 32bit version of Mesa with my 64bit version of Ubuntu (the 64bit mesa built fime). There is issues installing all of the multiarch packages. After wasting most of my Sunday afternoon trying to resolve dependencies I've decided to wipe my install and start again using Ubuntu 32bit. Just got to backup some files and finish the adventure game I'm in the middle of playing first.