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

			   Jan Wielemaker
			(jan@swi.psy.uva.nl)


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.


Building for multiple or different settings
===========================================

To build for a second architecture, you  should either clean the sources
using `make distclean' or make  a  new   directory  next  to  the source
directory and run configure in  this   directory.  The  latter procedure
requires GNU-MAKE.  For example:

	% mkdir rs6000
	% cd rs6000
	% ../src/configure
	% make
	% make test
	% make install


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


Building a runtime version
==========================

The runtime version has  no  tracer,   doesn't  handle  interrupts (just
exits), has no profiler and no readline   included.  To build it using a
separate directory:

	% mkdir rt
	% cd rt
	% ../src/configure --enable-runtime
	% make
	% make install

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 and 4.0 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

At the end  of  the  compilation,  the   Prolog  files  from  the  boot/
subdirectory are compiled using ./pl. On  some systems this installation
aborts with a segmentation fault (signal 11   on  most machines). If you
are knowledgeable with low-level  memory   management  using mmap(), you
might want to look as test/mmap.c  and pl-setup.c, where exception-based
handling of the stacks is defined. Otherwise,  remove all .o files, redo
the configuration using --disable-segv-handling and   recompile. If that
still doesn't solve the problem,   use  --disable-mapped-stacks. If that
doesn't fix the problem  you  found   something  new.  Please  report to
prolog-bugs@swi.psy.uva.nl.

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.


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.
