|
Building Files
>From Source RPMs are an easy way to install,
query and uninstall programs in Linux. But, given that they're tougher for the
author to create than a .tar.gz file, you won't always find the file you'd like
to install in the .rpm format. Given that, it's useful to have some background
on building and installing files from the source code. You'll remember from an earlier
issue of Penguin Shell that .tar files are really just a collection of files
all stuck together. That's why it's commonly called a "tarball."
.tar.gz files are a cleaned up and lightly compressed version of .tar files. In
the form we're discussing today, these files contain all the source code you'll
need compile and install a program on your Linux system. It's useful to choose or create a
directory on your system to store all the source files you may download. On my
system, this directory is the /usr/local/src directory. It's easy to remember
and recognize as a directory that contains all the source I compile. So, first
download the file to your /home/$USER directory, then do the following: [tony@server tony]# su What you've done here is pretty
simple. You logged in as the root user, changed directories to the
/usr/local/src directory, and untarred/unzipped the downloaded_file.tar.gz file
into the current directory. If things have happened as they should, you'll have
seen files scrolling by as they were untarred. That's a function of the
"v" option to the tar
command - "do this in a verbose fashion." Now, you'll need to change to the
directory you just created, looking for a configuration file: [root@server /usr/local/src]# cd
downloaded_file The "ls" command
instructs the system to display a listing of all the files in the current
directory in short format - that is, without file type, permissions, file size,
etc. Most programs now include a configure
file that checks you system environment for sanity prior to installing the
program and creates the make file. This file should be executed first: ./configure You can watch as various
environment checks scroll past on the screen. In the end, a make file will be
created. This is really just a shell script that instructs the compiler in your
system on how to compile the program. Once you're returned to the shell prompt
(without error messages, of course), execute the make file as follows: make Again, you'll see your system in
action, calling various functions of the compiler (usually gcc) to
"build" the source into an executable program. At the end of this
process, you'll be returned to a shell script and should: make_install The make_install script places the
proper executable files in the path, allowing you to execute the program from
the command line simply by typing keying in the name, without including the
full path. Though the "configure, make,
make_install" routine is by far the most common, there are some variances.
Additionally, make can be used in conjunction with options to customize your
install. The make man page outlines these options and provides a
thorough view of make. Between rpms and .tar.gz files,
you're now completely armed to install most programs on your Linux system. |
