Compiling Software on Solaris
This is quick and dirty explanation of how to get started compiling software on Solaris platforms with GNU software. I'll get around to filling in the details later. Do searches on the Internet for anything I haven't explained here.
As of May 15, 2004 the URL's in this document were correct. GNU reserves the right to change all file paths (dratted link-rot!).
- GET THE SUN MD5 PACKAGE & INSTALL
If sendmail can get trojanized, anything else can... Use MD5!
- Download Solaris Binaries for MD5
- Decompress and untar the archive
zcat md5.tar.Z | tar xvf -
- Change the permissions & ownership on the files
chmod 700 /opt/md5/*
chown root:root /opt/md5/*
- Verify ownership and permissions
- Verify the fingerprint of the archive against the MD5 has listed at the site.
- VERIFY THE AUTHENTICITY OF WHAT YOU DOWNLOAD
If you download it, verify the MD5 hash.
- GET GCC
If your version of Solaris has CC (ie. you did the full developer installation of Solaris), you CAN compile it yourself, otherwise, get the binary package from GNU.
- Browse to <http://www.gnu.org> - bookmark this site.
- Browse to <http://sunsolve.sun.com> - bookmark this site.
- Browse to <http://www.sunfreeware.com> - bookmark this site.
- From SunFreeware, select the appropriate "FTP/Mirror Sites" (sunfreeware is very, very busy)
- Select your Platform/OS version. If you don't know your architecture/OS, 'cat /etc/motd'. It's usually there.
- Download the latest stable gcc package. Versions are usually listed using major.minor.revision version numbering. Looking for the highest major and minor numbers and second highest revision number is your best bet as that is usually the stable code. If you're using Netscape, be sure to 'save target'. (Netscape under Solaris 8 and later auto-decompresses .gz files and displays them in the browser.)
- INSTALLING THE GCC PACKAGE
- If the file is still named .gz (ie Netscape didn't decompress it) decompress it yourself.
- Install the gcc compiler package using
pkgadd -d /file/path/to/package
Source bundles are often called distributions. Once GCC is installed, find and download whatever source distribution you need. Typically, these are available in tape archive files that have been compressed with gzip. The names of these files are of the format:
tar xvf archive-name.M.m.v.tar
- WHAT TO READ- Type more followed by the filename. Remember that Unix filenames are case-sensitive.
- more README
This is usually information about the package itself, what it's for and what it does and who wrote it.
- more INSTALL
This file has been included in nearly every distribution I have compiled. It has always contained a step by step set of instructions for building and installing the software. This will also contain information about different ways to compile the software, the two most important being the choice of creating a static binary or dynamic binary. Other options include features to add compatibility with other packages. The OpenSSH distribution has options for compatibility with PAM and TCPwrappers for instance).
- more BUGS - known software bugs and other errata
- more PROBLEMS - top ten problems the developers have had reported to them.
- Read anything else that looks even remotely interesting.
- more README
- RESOLVE DEPENDANCIES - Nearly all packages require certain libraries from the system or require other software libraries you might have to download. The website where the software is offered for download often has this information as does the README or INSTALL file in the software package.
- SET YOUR PATH & ENVIRONMENT VARIABLES - Make sure the appropriate library directories are in your path or the installation instructions are worthless.
This guesses settings for proper software compiling.
Make looks in the current directory for a file literally called "Makefile". This directive file contains targets which instruct make on how to build the software.
- make test
This tests the work make has done.
- make install
This copies (installs) the binaries and/or associated libraries into appropriate folders on the Sun system.
- make clean
Not always available, this cleans up the source and removes the binary files in the directory where it was built. Typically, you can remove the directory where the software was unpacked from. In fact, many administrators actually download the archive to /var/tmp and extract it there because the contents of /var/tmp is deleted when the system is rebooted.