Once you are inside the directory with all of the source code, begin looking for documentation. Always read the documentation that comes with the source code! If there are any special compile directions, notes, or warnings, they will most likely be mentioned here. You will save yourself a great deal of agony by reading the relevant files first.
So then, what are the relevant files? Typically there are two files in a distribution, README and INSTALL, both of which are located in the root of the source code directory. The README file generally includes a description of the package, references to additional documentation (including the installation documentation), and references to the author of the package. The INSTALL file typically has directions for compiling and installing the package.
These are not, of course, absolutes. Every package has its quirks. The best way to find out is to simply list the directory contents and look for obvious signs of additional documentation. Some packages use different capitalization: readme, README, ReadMe, and so on. Some introduce variations on a theme, such as README.1ST or README.NOW, and so on.
Another common place for additional information is a subdirectory that is appropriately called “doc” or “documentation.”
To view a text file, use the more command:
To view the text file in the pico editor, use the pico command:
TIP To get a quick list of all the directories in a source tree, enter the command [root@ford hello-1.3]# ls -l | grep drwx.
Configuring and Compiling the Package
Most packages ship with an autoconfiguration script; it is safe to assume they do unless their documentation says otherwise. These scripts are typically named configure, and they take parameters. There are a handful of stock parameters that are available across all configure scripts, but the interesting stuff occurs on a program-by-program basis. Each package will have a handful of features that can be enabled or disabled or that have special values set at compile time, and they must be set up via configure.
To see what configure options come with a package, simply run:
[root@ford hello-1.3]# ./configure --help
Yes, those are two hyphens (--) before the word “help.”
One commonly available option is --prefix. This option allows you to set the base directory where the package gets installed. By default, most packages use /usr/local. Each component in the package will install into the appropriate directory in /usr/local.
With all of the options you want set up, a final run of configure will create a special type of file called a makefile. Makefiles are the foundation of the compilation phase. Generally, if configure fails you will not get a makefile. Make sure that the configure command did indeed complete without any errors.
Compiling Your Package
Compiling your package is the easy part. All you need to do is run make, like so:
[root@ford hello-1.3]# make
The make tool reads all of the makefiles that were created by the configure script. These files tell make which files to compile and the order in which to compile them--which is crucial since there could be hundreds of source files.
Depending on the speed of your system, the available memory, and how busy it is doing other things, the compilation process could take a while to complete, so don’t be surprised.
As make is working, it will display each command it is running and all of the parameters associated with it. This output is usually the invocation of the compiler and all of the parameters passed to the compiler—it’s pretty tedious stuff that even the programmers were inclined to automate!
If the compile goes through smoothly, you won’t see any error messages. Most compiler error messages are very clear and distinct, so don’t worry about possibly missing an error. If you do see an error, don’t panic. Most error messages don’t reflect a problem with the program itself, but usually with the system in some way or another. Typically, these messages are the result of inappropriate file permissions (see the chmod command in Module 6) or files that cannot be found. In the latter case, make sure your path has at the very least the /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin, and /usr/X11R6/bin directories in it. You can see your path by issuing the following command:
[root@ford hello-1.3]# echo $PATH
See Module 6 for information on environment variables so that you can set your path correctly.
In general, slow down and read the error message. Even if the format is a little odd, it may explain what is wrong in plain English, thereby allowing you to quickly fix it. If the error is still confusing, look at the documentation that came with the package to see if there is a mailing list or e-mail address you can contact for help. Most developers are more than happy to provide help, but you need to remember to be nice and to the point. (In other words, don’t start an e-mail with a rant about why their software is terrible.)
blog comments powered by Disqus