========================================================
(C)1993, 1994 Institute for New Generation Computer Technology
(Read COPYRIGHT for detailed information.)
========================================================

How to INSTALL KL1 to C compiler
================================
November 8, 1993
Last Revision: February 1, 1994
Takashi Chikayama (ICOT)

Installation of the current version of KLIC is probably not so
straightfoward if you don't have SICStus Prolog.

[1] Compilation Scheme

Understanding how KL1 programs are compiled and executed would help
understanding how to install it.

The system consists of the following three modules.

  - KLIC compiler

  - KLIC database manager

  - KLIC runtime system

KL1 programs are compiled using the KLIC compiler into C programs.  It
also generates files "FILE.ext" containing information on atoms and
functors used in the program.  The information in ".ext" files for
programs to be linked together is merged together later by the
database manager, into files "atom.h", "funct.h", "atom.c" and
"funct.c".

The object C program is then compiled by a C compiler, with headers
provided by the KLIC runtime system, "atom.h" and "funct.h".  The
"atom.c" and "funct.c" files are also compiled, and linked together
with the runtime system.

Compilation, database management and linkage are governed by a driver
program named "klic".  This program "klic" plays a role similar to
"cc" and "make" combined.  "Cc" controls the C preprocessor, the C
compiler kernel and the linker; "klic" controls the KL1-to-C compiler,
the C compiler, the KL1 program database manager and the linker.
"Make" selectively executes compilation only when needed by examining
the file dates; "klic" works similarly. 


[2] Basic Installation Procedure

[2.1] Editing the Makefile

This INSTALL file is at the KLIC system root directory.  You have to
edit the Makefile in this directory first.  What you are supposed to
edit are directory names and some compilation switches.  Terse
descriptions of each option are found near the top of the Makefile.

[2.2] Compiling the System

Simply run "make" after editing.  It will compile the compiler
(including above-mentioned "klic" driver and the database manager) and
the runtime library.

[2.3] Testing

To test the compiled system, do the following.

	% make tests

This will compile sample programs under the "test" subdirectory, run
them, and check whether the outputs are as expected.

[2.4] Installation

Input the following.

	% make install

[2.5] Cleaning Up

Input the following to delete files that is not in the distribution.

	% make distclean

[2.6] If Something Went Wrong

If something went wrong during the compilation, the problem is often
in the top level Makefile.  Check directory and program names or
options for installation procedure defined in it.

After fixing the problem, clean up everything by "make distclean"
before try compilation again.  Otherwise, some invalid intermediate
files remaining may confuse the installation procedure.

After re-installation of the system, please delete the file named
"klic.db", which is automatically generated by the KLIC system, as the
contents of the file becomes inconsistent with the re-installed
system.


[3] The Compiler is Written in Prolog

The current version of the compiler is written in Prolog.  SICStus
Prolog version 2.1#8 has been used for its development and testing.
The compiler is meant to run also on Edinburgh Prolog compatibles,
such as Quintus Prolog, but we are not much sure about that, as
SICStus Prolog is the only Prolog system on Unix that we have now.
The compiler will be rewritten in KL1 itself in future releases.

Hope your good luck.

Send bug reports and comments to:
	klic-bugs@icot.or.jp
