This is getting a bit complicated, because you aren't giving much detail at any given point, so the questions and answers are stretching out over many posts.
I would suggest a couple of things. First, tell us what it is that you are trying to do and why. Give us some background on where you are starting from -- the system you have and your own background.
Then, I would probably suggest that you go to http://www.sunfreeware.com
and get packages from there unless you have some particular reason you want/need to build your own. If you do need to build your own, then you might start by getting all the build tools you need from Sunfreeware. This also has the advantage that the entries there will tell you all the dependencies so that you know what other things you have to get and install.
Finally, if you do get into building your own stuff from source, you will want to have a proper environment. This will depend on your particular system and needs. I have some E250s running Solaris 9, and I have a file /usr/local/src/env that contains the following:
When I'm going to be building something, I start out by doing
$ . /usr/local/src/env
That syntax (note that there is a space after the dot) makes it execute that code in place in your current environment rather than making a subprocess. Thus, the environment variables are set.
I have some other systems that are T5220s running Solaris 10, and I'm using the Sun CoolTools gccfss compiler. That build environment is a bit more complex and the env file is different. I need to build things there that will tap the unique capabilities of the T2 chip and get me into the crypto accelerators if I'm building something that needs them.
Also, for whatever you are building, the Makefile should tell you what environment variables it respects -- for example, certain values for CPPFLAGS. Check that if you need to. But, be sure to look at the files README and/or INSTALL that come along with the source.