# 2 - Building EPM

This chapter shows how to configure, build, and install the ESP Package Manager.

## Requirements

EPM requires very little pre-installed software to work. Most items will likely be provided as part of your OS. Your development system will need a C compiler, the `make(1)` program (GNU, BSD, and most vendor `make` programs should work), the Bourne (or Korn or Bash) shell (`sh(1)`), and `gzip(1)`.

The optional graphical setup program requires a C++ compiler, the FLTK library, version 1.1.x, and (for UNIX/Linux) the X11 libraries. FLTK is available at the following URL:

    http://www.fltk.org/

Your end-user systems will require the Bourne (or Korn or Bash) shell (`sh`), the `df(1)` program, the `tar(1)` program, and the `gzip(1)` program to install portable distributions. All but the last are standard items, and most vendors include `gzip` as well.

> Note:
> The `gzip` program is only required to uncompress the software distribution .tar.gz file. If you supply the uncompressed .tar file or its contents, then `gzip` is not required on the end-user system.

EPM can also generate vendor-specific distributions. These require the particular vendor tool, such as `rpm(8)` and `dpkg(8)`, to generate the software distribution on the development system and load the software distribution on the end-user system.

## Configuring the Software

EPM uses GNU `autoconf(1)` to configure itself for your system. The `configure` script is used to configure the EPM software, as follows:

    ./configure ENTER

### Choosing Compilers

If the `configure` script is unable to determine the name of your C or C++ compiler, set the `CC` and `CXX` environment variables to point to the C and C++ compiler programs, respectively. You can set these variables using the following commands in the Bourne, Korn, or Bash shells:

    export CC=/foo/bar/gcc ENTER
    export CXX=/foo/bar/gcc ENTER

If you are using C shell or TCsh, use the following commands instead:

    setenv CC /foo/bar/gcc ENTER
    setenv CXX /foo/bar/gcc ENTER

Run the `configure` script again to use the new commands.

### Choosing Installation Directories

The default installation prefix is /usr, which will place the EPM programs in /usr/bin, the setup GUI in /usr/lib/epm, and the man pages in /usr/man. Use the `--prefix` option to relocate these files to another directory:

    ./configure --prefix=/usr/local ENTER

The `configure` script also accepts the `--bindir`, `--libdir`, and `--mandir` options to relocate each directory separately, as follows:

    ./configure --bindir=/usr/local/bin --libdir=/usr/local/lib \
        --mandir=/usr/local/share/man ENTER

### Options for the Setup GUI

The setup GUI requires the FLTK library. The configure script will look for the `fltk-config` utility that comes with FLTK 1.1.x. Set the FLTKCONFIG environment variable to the full path of this utility if it cannot be found in the current path:

    setenv FLTKCONFIG /foo/bar/bin/fltk-config ENTER

or:

    FLTKCONFIG=/foo/bar/bin/fltk-config ENTER
    export FLTKCONFIG

## Building the Software

Once you have configured the software, type the following command to compile it:

    make ENTER

Compilation should take a few minutes at most. Then type the following command to determine if the software compiled successfully:

    make test ENTER
    Portable distribution build test PASSED.
    Native distribution build test PASSED.

The `test` target builds a portable and native distribution of EPM and reports if the two distributions were generated successfully.

## Installing the Software

Now that you have compiled and tested the software, you can install it using the `make` command or one of the distributions that was created. You should be logged in as the super-user unless you specified installation directories for which you have write permission. The `su(8)` command is usually sufficient to install software:

    su ENTER

### Installing Using the `make` Command

Type the following command to install the EPM software using the `make` command:

    make install ENTER
    Installing EPM setup in /usr/lib/epm
    Installing EPM programs in /usr/bin
    Installing EPM manpages in /usr/man/cat1 and /usr/man/man1
    Installing EPM documentation in /usr/share/doc/epm

### Installing Using the Portable Distribution

The portable distribution can be found in a subdirectory named using the operating system, version, and architecture. For example, the subdirectory for a Linux 2.4.x system on an Intel-based system would be linux-2.4-intel. The subdirectory name is built from the following template:

    os-major.minor-architecture

The `os` name is the common name for the operating system. Table 2.1 lists the abbreviations for most operating systems:

Table 2.1: Operating System Name Abbreviations
Operating System | Name
--- | ---
AIX | `aix`
Compaq Tru64 UNIX Digital UNIX OSF/1 | `tru64`
Darwin | `darwin`
FreeBSD | `freebsd`
HP-UX | `hpux`
IRIX | `irix`
Linux | `linux`
MacOS X | `darwin`
NetBSD | `netbsd`
OpenBSD | `openbsd`
Solaris | `solaris`

The `major.minor` string is the operating system version number. Any patch revision information is stripped from the version number, as are leading characters before the major version number. For example, HP-UX version B.11.11 will result in a version number string of `11.11`.

The `architecture` string identifies the target processor. Table 2.2 lists the supported processors:

Table 2.2: Processor Architecture Abbreviations
Processor(s) | Abbreviation
--- | ---
Compaq Alpha | `alpha`
HP Precision Architecture | `hppa`
INTEL 80x86 | `intel`
MIPS RISC | `mips`
IBM Power PC | `powerpc`
SPARC MicroSPARC UltraSPARC | `sparc`

Once you have determined the subdirectory containing the distribution, type the following commands to install EPM from the portable distribution:

    cd os-major.minor-architecture ENTER
    ./epm.install ENTER

The software will be installed after answering a few yes/no questions.

### Installing Using the Native Distribution

The `test` target also builds a distribution in the native operating system format, if supported. Table 2.3 lists the native formats for each supported operating system and the command to run to install the software.

Table 2.3: Native Operating System Formats
Operating System | Format | Command
--- | --- | ---
AIX | `aix` | `installp -ddirectory epm`
Compaq Tru64 UNIX Digital UNIX OSF/1 | `setld` | `setld -a directory???`
FreeBSD NetBSD OpenBSD | `bsd` | `cd directory pkg_add epm`
HP-UX | `depot` | `swinstall -f directory`
IRIX | `inst` | `swmgr -f directory`
Linux | `rpm` | `rpm -i directory/epm-3.0.rpm`
MacOS X | `osx` | Double-click on the `.pkg` folder in the finder.
Solaris | `pkg` | `pkgadd -d directory epm`