%* glpk07.tex *%

\chapter{Installing GLPK on Your Computer}
\label{install}

\section{Obtaining GLPK distribution file}

The distrubution file for the most recent version of the GLPK package
can be downloaded from $<$\verb|ftp://ftp.gnu.org/gnu/glpk/|$>$ or from
some mirror GNU ftp sites; for details see
$<$\verb|http://www.gnu.org/order/ftp.html|$>$.

\section{Unpacking the distribution file}

The GLPK package (like all other GNU software) is distributed in the
form of packed archive. This is one file named \verb|glpk-x.y.tar.gz|,
where {\it x} is the major version number and {\it y} is the minor
version number.

In order to prepare the distribution for installation you should:

1. Copy the GLPK distribution file to some subdirectory.

2. Enter the command \verb|gzip -d glpk-x.y.tar.gz| in order to unpack
the distribution file. After unpacking the name of the distribution file
will be automatically changed to \verb|glpk-x.y.tar|.

3. Enter the command \verb|tar -x < glpk-x.y.tar| in order to unarchive
the distribution. After this operation the subdirectory \verb|glpk-x.y|,
which is the GLPK distribution, will be automatically created.

\section{Configuring the package}

After you have unpacked and unarchived GLPK distribution you should
configure the package, i.e. automatically tune it for your computer
(platform).

Normally, you should just \verb|cd| to the subdirectory
\verb|glpk-x.y| and enter the command \verb|./configure|. If you are
using \verb|csh| on an old version of System V, you might need to type
\verb|sh configure| instead to prevent \verb|csh| from trying execute
\verb|configure| itself.

The \verb|configure| shell script attempts to guess correct values for
various system-dependent variables used during compilation, and creates
\verb|Makefile|. It also creates a file \verb|config.status| that you
can run in the future to recreate the current configuration.

Running \verb|configure| takes about a few minutes. While it is running,
it displays some informational messages that tell you what it is doing.
If you don't want to see these messages, run \verb|configure| with its
standard output redirected to \verb|dev/null|; for example,
\verb|./configure >/dev/null|.

\section{Compiling and checking the package}

Normally, in order to compile the package you should just enter the
command \verb|make|. This command reads \verb|Makefile| generated by
\verb|configure| and automatically performs all necessary job.

The result of compilation is:

$\bullet$ the file \verb|libglpk.a|, which is a library archive that
contains object code for all GLPK routines; and

$\bullet$ the program \verb|glpsol|, which is a stand-alone LP/MIP
solver.

If you want, you can override the \verb|make| variables \verb|CFLAGS|
and \verb|LDFLAGS| like this:

\verb|make CFLAGS=-O2 LDFLAGS=-s|

To compile the package in a different directory from the one containing
the source code, you must use a version of \verb|make| that supports
\verb|VPATH| variable, such as GNU make. \verb|cd| to the directory
where you want the object files and executables to go and run the
\verb|configure| script. \verb|configure| automatically checks for the
source code in the directory that \verb|configure| is in and in
`\verb|..|'. If for some reason \verb|configure| is not in the source
code directory that you are configuring, then it will report that it
can't find the source code. In that case, run \verb|configure| with the
option \verb|--srcdir=DIR|, where \verb|DIR| is the directory that
contains the source code.

On systems that require unusual options for compilation or linking the
package's \verb|configure| script does not know about, you can give
\verb|configure| initial values for variables by setting them in the
environment. In Bourne-compatible shells you can do that on the command
line like this:

\verb|CC='gcc -traditional' LIBS=-lposix ./configure|

Here are the \verb|make| variables that you might want to override with
environment variables when running \verb|configure|.

For these variables, any value given in the environment overrides the
value that \verb|configure| would choose:

$\bullet$ variable \verb|CC|: C compiler program. The default is
\verb|cc|.

$\bullet$ variable \verb|INSTALL|: program to use to install files. The
default value is \verb|install| if you have it, otherwise \verb|cp|.

For these variables, any value given in the environment is added to the
value that \verb|configure| chooses:

$\bullet$ variable DEFS: configuration options, in the form
`\verb|-Dfoo -Dbar| \dots'.

$\bullet$ variable LIBS: libraries to link with, in the form
`\verb|-lfoo -lbar| \dots'.

In order to check the package (running some tests included in the
distribution) you can just enter the command \verb|make check|.

\section{Installing the package}

Normally, in order to install the GLPK package (i.e. copy GLPK library,
header files, and the solver to the system places) you should just enter
the command \verb|make install| (note that you should be the root user
or a superuser).

By default, \verb|make install| will install the package's files in
the subdirectories \verb|usr/local/bin|, \verb|usr/local/lib|, etc. You
can specify an installation prefix other than \verb|/usr/local| by
giving \verb|configure| the option \verb|--prefix=PATH|. Alternately,
you can do so by consistently giving a value for the \verb|prefix|
variable when you run \verb|make|, e.g.

\verb|make prefix=/usr/gnu|

\verb|make prefix=/usr/gnu install|

After installing you can remove the program binaries and object files
from the source directory by typing \verb|make clean|. To remove all
files that \verb|configure| created (\verb|Makefile|,
\verb|config.status|, etc.), just type the command
\verb|make distclean|.

The file \verb|configure.in| is used to create \verb|configure| by a
program called \verb|autoconf|. You only need it if you want to remake
\verb|configure| using a newer version of \verb|autoconf|.

\section{Uninstalling the package}

In order to uninstall the GLPK package (i.e. delete all GLPK files from
the system places) you can enter the command \verb|make uninstall|.

%* eof *%
