Next: Standard Targets, Up: Use Cases
The most common installation procedure looks as follows.
~ % tar zxf amhello-1.0.tar.gz ~ % cd amhello-1.0 ~/amhello-1.0 % ./configure ... config.status: creating Makefile config.status: creating src/Makefile ... ~/amhello-1.0 % make ... ~/amhello-1.0 % make check ... ~/amhello-1.0 % su Password: /home/adl/amhello-1.0 # make install ... /home/adl/amhello-1.0 # exit ~/amhello-1.0 % make installcheck ...
The user first unpacks the package. Here, and in the following
examples, we will use the non-portable tar zxf
command for
simplicity. On a system without GNU tar installed, this
command should read gunzip -c amhello-1.0.tar.gz | tar xf -
.
The user then enters the newly created directory to run the configure script. This script probes the system for various features, and finally creates the Makefiles. In this toy example there are only two Makefiles, but in real-world projects, there may be many more, usually one Makefile per directory.
It is now possible to run make
. This will construct all the
programs, libraries, and scripts that need to be constructed for the
package. In our example, this compiles the hello program.
All files are constructed in place, in the source tree; we will see
later how this can be changed.
make check
causes the package's tests to be run. This step is
not mandatory, but it is often good to make sure the programs that
have been built behave as they should, before you decide to install
them. Our example does not contain any tests, so running make
check
is a no-op.
After everything has been built, and maybe tested, it is time to
install it on the system. That means copying the programs,
libraries, header files, scripts, and other data files from the
source directory to their final destination on the system. The
command make install
will do that. However, by default
everything will be installed in subdirectories of /usr/local:
binaries will go into /usr/local/bin, libraries will end up in
/usr/local/lib, etc. This destination is usually not writable
by any user, so we assume that we have to become root before we can
run make install
. In our example, running make install
will copy the program hello into /usr/local/bin
and README into /usr/local/share/doc/amhello.
A last and optional step is to run make installcheck
. This
command may run tests on the installed files. make check
tests
the files in the source tree, while make installcheck
tests
their installed copies. The tests run by the latter can be different
from those run by the former. For instance, there are tests that
cannot be run in the source tree. Conversely, some packages are set
up so that make installcheck
will run the very same tests as
make check
, only on different files (non-installed
vs. installed). It can make a difference, for instance when the
source tree's layout is different from that of the installation.
Furthermore it may help to diagnose an incomplete installation.
Presently most packages do not have any installcheck
tests
because the existence of installcheck
is little known, and its
usefulness is neglected. Our little toy package is no better: make
installcheck
does nothing.