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

			   Jan Wielemaker
		      (wielemak@science.uva.nl)

Last updated: Feb 2, 2007

Configuration, compilation and installation is based on the GNU autoconf
package and consists of two steps:  builting the basic SWI-Prolog system
and building the packages.

SWI-Prolog can only be built using   GNU-Make. On many non-linux systems
this is installed as gmake.

Although the system compiles using a  wide variety of C-compilers, using
GCC avoids a lot of trouble. The   configure  script has very incomplete
and sometimes aged default  compiler  settings   for  the  system native
compiler, so in most case you will need to modify the CFLAGS and LDFLAGS
definitions in the Makefile to reach at optimal results.


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/pl,  with the
libraries in /usr/local/lib/pl-<version>.

	% ./configure --prefix=PREFIX


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

	(Ensure the installed pl executable is in your path)
	% cd packages
	% ./configure
	% gmake
	% gmake install

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


Using the build.templ script
----------------------------

The  bash-script  build.templ  contains  the   default  build  procedure
outlined above and  some  comments   and  skeleton  environment changes.
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
libraryes, non-standard compiler settings, etc.


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

There is limited support to compile the Prolog kernel in a shared object
rather than an executable and static library.  This feature is tested on
Linux (SuSE 9.0) and activated using

	./configure --enable-shared

This creates $PLBASE/lib/$ARCH/libpl.so.<version> and   a  symbolic link
from $PLBASE/lib/$ARCH/libpl.so to  this  file.   The  executable  pl is
linked using -rpath=$PLBASE/lib/$ARCH.  This schema is likely to work on
other ELF-based platforms using GCC and GNU-ld.

Doing this causes the Prolog sources to be compiled with -fPIC (position
independent code). On  some  platform  this   can  lead  to  significant
performance  degradation.  The  approach   has    some   advantages  and
disadvantages:

	- `stand-alone' executables need the shared object
	- less performance for most processors
	+ Easier linking, especially for complicated embedded systems


Some things may need attention:
===============================

# GNU readline library

When present, SWI-Prolog will  automatically   include  the GNU readline
library. It is *strongly*  adviced  to   install  this  library  on your
system. It provides editing of previously  entered commands (history) as
well as completion on Prolog  atoms   and  filenames (for consult, etc.)
much like the bash and tcsh shells do.

SWI-Prolog has been linked with versions 1.1,   1.2, 2.0, 4.0 and 5.1 of
the readline library.

# Memory mapped stacks.  Segmentation faults during the installation.

Configure will see if mmap() may be used to allocate the stacks.  If you
think this should be possible, but Configure   says `no', please work on
test/mmap.c

Using mmapped stacks works on  most   modern  Unix  platforms, including
Linux, Solaris, OpenBSD, FreeBSD, IRIX, HP/UX and many more.

# Assembler warnings

If you get assembler warnings compiling pl-wam.c, try #define NO_ASM_NOP
1 in config.h. Should be  determined   automatically  by test/nop.c, but
sometimes appears to fail.

# Old include files

Old versions of SWI-Prolog   installed  $prefix/include/SWI-Prolog.h and
$prefix/include/SWI-Stream.h that are  incompatible   with  the  current
releases.     New     versions     install       these      files     in
$prefix/lib/pl-<version>/include. Please remove the old   files to avoid
the  compiler  picking  the  wrong  include  files  when  compiling  the
packages.


Platform specific notes
=======================

SCO OpenServer
--------------

According to Tamas Laufer, best  results   are  obtained  if you install
gcc-2.8.1 (latest version at time of   writing) from the original source
at prep.ai.mit.edu/pub/gnu or  one  of   its  mirrors.  Using  GNU-make.
installation is reported to work flawlessly.

Compilation using SCO `cc' is  possible   too,  though  requires special
attention to get alloca() and dlopen() working.  The result is about 20%
slower then the gcc-compiled executable.
