< Day Day Up > |
Many of the programs listed in Chapter 2 are available in source code form from the Internet. For GNU/Linux and Mac OS X, you may be able to use a package manager to download and install the software (see Chapter 6). Similarly, for Solaris, you may be able to get a precompiled version of the program from http://www.sunfreeware.com/. However, it's possible, particularly on a commercial Unix system, that you will want (or need) to download the source and build the program yourself if you don't have it, or if you wish to obtain the very latest version. This section outlines the conventional build process. Most Internet software is written in C or C++. To compile it you will need a compiler. See the previous section for a discussion of where to get a compiler if you don't have one. Today's programs usually use the GNU Project's Autoconf software suite for managing portability issues. Autoconf generates a shell script named configure, which tests various aspects of the target system. The end result of running configure is a Makefile custom-tuned to the particular system (see Chapter 16), and a header file describing the features available, or missing, from the system. As a result, the recipe for building software is usually quite simple, consisting of the following:
The following example uses GNU sed to illustrate the process. The steps are similar or identical for all GNU software, and for most other freely-available programs as well. First, we obtain the program using wget: $ wget ftp://ftp.gnu.org/gnu/sed/sed-4.1.4.tar.gz Retrieve the latest version --15:00:04-- ftp://ftp.gnu.org/gnu/sed/sed-4.1.4.tar.gz => 'sed-4.1.4.tar.gz' Resolving ftp.gnu.org... 199.232.41.7 Connecting to ftp.gnu.org[199.232.41.7]:21... connected. Logging in as anonymous ... Logged in! ==> SYST ... done. ==> PWD ... done. ==> TYPE I ... done. ==> CWD /gnu/sed ... done. ==> PASV ... done. ==> RETR sed-4.1.4.tar.gz ... done. Length: 794,257 (unauthoritative) 100%[==================================>] 794,257 60.04K/s ETA 00:00 15:00:29 (38.86 KB/s) - 'sed-4.1.4.tar.gz' saved [794257] The next step is to decompress and extract the software: $ gzip -d < sed-4.1.4.tar.gz | tar -xpvf - Extract source code sed-4.1.4/ sed-4.1.4/ABOUT-NLS sed-4.1.4/AUTHORS sed-4.1.4/BUGS ... Next we change into the directory and run configure: $ cd sed-4.1.4 Change directory $ ./configure && make Run configure and make checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes ... The && construct runs make only if configure finishes successfully (see Chapter 4). Next, we run the test suite, to ensure that there were no problems: $ make check Test the build Making check in intl Lots of output omitted ... PASS: dc =================== All 71 tests passed =================== Finally, we install the software. This may require administrative privileges: $ su root Change to superuser Password: Password is not echoed # make install Install GNU sed into /usr/local ... |
< Day Day Up > |