			Installing SWI-Prolog
			=====================

Last updated: Feb 2, 2014

This installation assumes you are looking   at a freshly unpacked source
tarball,  downloaded  from  http://www.swi-prolog.org/Download.html.  In
many scenarios it is better to obtain   the  sources using GIT. The file
README.git explains how to get and update all sources using GIT.

Prerequisites
-------------

SWI-Prolog depends on a lot of other   (open source) tools and libraries
that are not bundled and must be  installed seperately. We maintain a OS
specific hints at this address:

    http://www.swi-prolog.org/build/

Please consult the above link first.  Below   is  a an extensive list of
dependencies if your OS is not covered   by the instructions at the link
above.  Please  consider  adding  or    updating   the  descriptions  at
http://www.swi-prolog.org/build/.

  - Tools:

    * gcc (with some effort, other C compilers may work as well)
    * GNU-make
    * autoconf (when building from GIT, see README.git)
    * LaTeX (optional for documentation, see README.doc)
    * perl (optional for documentation, see README.doc)

  - Libraries (core system):

    * gmp (http://gmplib.org/)
    Provides unbounded integers and rational numbers.  Although
    the system compiles without it we strongly encourage you do
    use GMP.  Libraries and other software written for SWI-Prolog
    may fail to work properly without GMP.
    * GNU readline library
    Optional, provides commandline editing and completion.  You
    really want this!
    * libunwind (http://www.nongnu.org/libunwind)
    Not available on all platforms.  If it is supported, it enhances
    crash reports generated by the system.


  - Libraries (packages):

    * unixODBC (http://www.unixodbc.org/)
    Optional for building package odbc, providing database access.
    * OpenSSL (www.openssl.org/)
    Optional for building package ssl (Secure Socket layer)
    * zlib
    Optional for building package zlib (compressed streams)
    * OSSP UUID library (http://www.ossp.org/pkg/lib/uuid/)
    Needed for library(uuid).  Used by various packages.
    * SUN Java SDK or OpenSDK
    Optional for building JPL (Java interface).  Note that auto-detection
    of JPL prerequisites often fails.  See DISABLE_PKGS in build.templ
    * libXt, X11 core libraries, libjpeg and libxpm
    Required libraries for XPCE, the SWI-Prolog graphics layer that
    provides the built-in editor, graphical debugger and many other
    developers tools.
    * libXft, libfontconfig and pkg-config
    Provide proper Unicode font support for XPCE.  Without, XPCE may work
    or not, depending on locale and installed fonts.


Building SWI-Prolog with the build.templ script
-----------------------------------------------

The bash-script build.templ contains  the   default  build procedure and
some comments and  skeleton  environment   changes  marked  with [EDIT].
Especially for those who  want  to   update  SWI-Prolog  regulary, it is
recommended to copy this file to 'build' and edit it to suit your needs.
The file also gives some  hints   dealing  with non-default locations of
libraries, non-standard compiler settings, etc. The normal procedure is:

    % cp build.templ build
    % <edit> build
    % ./build

A  complete  log  of  the  build   process    is   saved  to  the  files
`configure.out`, `make.out` and `make-install.out`. A quick verification
that all went right is to run this command:

    % grep -i error: *.out

If you edited build, consider preserving it because you can normally use
it with the next release.


If the build script fails
-------------------------

If using the build script  fails  and   this  is  not easily resolved by
installing all dependencies,  considering   following  the  step-by-step
instructions below to get everything  in   place.  The main advantage is
that the process proceeds in  small  steps,   so  you  can  much quicker
re-iterate parts of the building process.

Building SWI-Prolog lite
------------------------

In normal cases, the following should do:

    % cd src
    % ./configure
    % gmake
    % gmake check
    % gmake install

By default, the system is installed   as  /usr/local/bin/swipl, with the
libraries in /usr/local/lib/swipl-<version>.  Use the `--prefix=` option
of `configure` to overrule this.

    % ./configure --prefix=PREFIX


Building the SWI-Prolog packages
--------------------------------

After building and  installing  the  core   system,  you  can  build the
extension packs:

    % cd packages
    % ./configure
    % gmake
    % gmake install

The packages can also be  configured   and  build  individually from the
package itself. Individual packages are   installed with the ./configure
&& make && make install sequence in the package directory.


Put the Prolog kernel in a shared object
========================================

On most modern platforms, the SWI-Prolog kernel  is compiled as a shared
object (DLL) called libswipl.so (the extensions depends on OS). Explicit
enabling or disabling of using a shared  object is accomplished with one
of the commands below for configure in   the `src` directory. When using
`build`, see the variable EXTRACFG.

    % ./configure --enable-shared
    % ./configure --disable-shared

Using a shared object has advantages and disadvantages:

  - `stand-alone' executables need the shared object
  - less performance for some processors (notably IA32, Intel/AMD 32-bits)
  + On many platforms, shared objects are required to enable linking
    foreign libraries.  One of the few exceptions is 32-bit PC/Linux,
    where this is not needed.
  + Easier linking, especially for embedded systems

Using a shared object is default, except for 32-bit PC/Linux.
