I keep running into this same situation, so I figured I would write a post for everyone's benefit. When trying to build recent mongrels or some other gem dependencies such as fastthread on a Solaris system the automatically generated Makefile is all sorts of messed up.
This testing was done on two different Joyent Accelerators, your milelage may vary on other Solaris installations.
The steps are pretty easy:
1. Attempt to install the gem via the normal 'gem install mongrel'
2. This will fail, but will download the gem for you.
3. Move into your gems directory. On these sytems that is /opt/csw/lib/ruby/gems/1.8/gems/
4. Move into the particular gem you are building that is causing you trouble. In this case mongrel-1.1.3
5. Move into the ext/ directory and the subdirectory that can't be built. You'll see it in the error messages from step 1.
6. Edit the generated Makefile as such:
Make sure CC is pointing to your C compiler, I had to edit this to reference gcc rather than cc. Make sure LD is pointing to a real ld tool. On this system that meant I changed ld -G to gld -G Edit CFLAGS to be CFLAGS= -03 -I/path/to/libs Essentially you just need to remove the -KPIC and all -x es from the generated file.
7. Run make install
8. Copy the gemspec file to /opt/csw/lib/ruby/gems/1.8/specifications so it will be registered with the gem tools.
Hope this helps.