# 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), a POSIX shell (Bourne, Korn, Bash, etc.), and `gzip(1)`.

The optional graphical setup program requires a C++ compiler, the FLTK library, version 1.1.x or 1.3.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 a POSIX shell, 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.

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/local, which will place the EPM programs in /usr/local/bin, the setup GUI in /usr/local/lib/epm, and the man pages in /usr/local/share/man. Use the `--prefix` option to relocate these files to another directory:

    ./configure --prefix=/example/path ENTER

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

    ./configure --bindir=/example/path/bin --libdir=/example/path/lib \
        --mandir=/example/path/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. 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

Operating systems such as macOS do not enable the root account by default. The `sudo(8)` command is used instead:

    sudo installation command 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/local/lib/epm
    Installing EPM programs in /usr/local/bin
    Installing EPM manpages in /usr/local/share/man/man1
    Installing EPM documentation in /usr/local/share/doc/epm

Use the `sudo` command to install on macOS:

    sudo make install ENTER
    Installing EPM setup in /usr/local/lib/epm
    Installing EPM programs in /usr/local/bin
    Installing EPM manpages in /usr/local/share/man/man1
    Installing EPM documentation in /usr/local/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.

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`.

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

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

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

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-4.1.rpm`
macOS | `osx` | `open directory/`epm-4.1.pkg``
Solaris | `pkg` | `pkgadd -d directory epm`