Using GNU tools on Solaris 10

As you’ll probably guess from the previous post, you probably can do quite well without installing any extra GNU tools on a Solaris 10 box. Of course you’re going to need the full set of SUNW developer packages to have a fighting chance.

Having said that, I’m a big fan of Sunfreeware, and have set up a number of build environments using the packages found there. Their gcc is good, but it depends on Sun’s own ld found in /usr/ccs/bin (going with the native linker was a good idea: just remember to rename any ld outside /usr/ccs/bin so it can’t be executed by accident, e.g. “/usr/local/bin/ld.gnu”). See the comments on gcc at the site for more details.

My strong recommendation is to standardize on either a Sun or gcc build environment. If you’ve got lots of stuff coming over from Solaris 7 or 8 boxes where GNU support from Sun was almost nonexistent you’ll probably lean towards using gcc. If you go that way, you can either build it from scratch or use the sunfreeware packages (keeping in mind that gcc from there will still require some Sun developer tools). The thing I like about using packages is that upgrading is much easier than if everything is done using source.

Most applications, including staples like perl and theApache HTTP Server, build pretty easily using gnu gcc and its accompanying tools. One key detail is to make sure the build user’s environment is set up correctly.

If you’re using a Sun build environment, you’ll need to make sure that the bin and lib directories under /usr/sfw and /usr/ccs are at the beginning of the $PATH and $LD_LIBRARY_PATH — in that order. For the GNU environment sunfreeware provides you still need /usr/ccs, but after /usr/local to avoid calling out the Sun version of tools like make.

Here are some examples:

Sun Developer Build Environment

PATH=/usr/sfw/bin:/usr/ccs/bin:$PATH
LD_LIBRARY_PATH=/usr/sfw/lib:/usr/ccs/lib:$LD_LIBRARY_PATH

Sunfreeware GNU Build Environement

PATH=/usr/local/bin:/usr/ccs/bin:$PATH
LD_LIBRARY_PATH=/usr/local/lib:/usr/ccs/lib:$PATH

Of course if you have packages like sunfreeware’s openssll installed you’d also need to add it to your PATH and LD_LIBRARY_PATH (e.g. /usr/local/ssl/bin, /usr/local/ssl/lib by default).

Note:

Although the sunfreeware package for gcc (full version) comes with its own make, I also install the standalone make (currently v3.81 for Sparc Solaris 10) from sunfreeware as well. What other GNU packages you’ll need beyond these will depend on what you’re building, but I’ve found the following usually wind up being installed at some point:

gzip
tar
zlib
bzip2
libiconv
libintl
libtool
readline
ncurses

Some of my other favorites (in no particular order):

coreutils
curl
cvs
db-4.x
gd
gmp
gnupg
libidn
libxml2
lsof
lynx
ncftp
openldap
openssl
rsync
sasl
sharutils
sudo
wget
xpm

What not to install? My number one candidate would be the Sunfreeware binutils package. In the past I’ve found that the native Sun versions of these utilities (a partial list would be: ld, as, ar, nm, strings, strip; see full description on project site). As usual, YMMV.