This directory contains
	the C source code for C-Prolog (*.c and *.h files)
	a makefile
	a startup script used by the makefile
	a directory bmark
	    containing some benchmark files
	    the main Edinburgh benchmark files are NOT here
	a directory pl
	    containing the parts of the Prolog system
	    which are defined in Prolog
	some other junk

To make a new Prolog system,
	check the makefile to see that the FinalVn is right.

	if the C part of the system has changed,
	    "make prolog"
	if the Prolog part of the system has changed,
	or if the format of a saved state has changed,
	    "make startup"

	Run the new Prolog system on some examples to become confident
	that it works.  I generally play with a new version for a couple
	of weeks before releasing it.  ALWAYS keep the code and SOURCES
	of the previous version around.

	"make install; make clean"

You are now on your own.

C Prolog depends on a number of options.

1.  Machine type.

	The types that are currently known are
		perq	-- The 3Rivers Perq with ICL's microcode for C
		vax	-- The DEC VAX-11 under Unix or VMS
		orion	-- High-Level Hardware's Orion machine
		m68000	-- M68000 boxes with C
		gec63	-- the GEC Series 63
	It is the responsibility of the C Pre-processor to define the
	appropriate flag, NOT yours.  The name should be in lower case,
	and should identify the machine *family*, not model.  If your
	C preprocessor doesn't define such a flag, sue your supplier.

	The main thing these options are for is to set default values
	for the options IEEE, BACKWARDS, and DatAlign.

		IEEE	- does the machine use the IEEE single precision
			  floating point format?  There is machine-
			  specific code for the VAX and GEC 63, as they
			  don't.  Look at the end of arith.c.

		BACKWARDS C Prolog assumes that the memory space managed
			  by sbrk() all has the same sign.  It doesn't
			  matter if, as on the Perq or Orion, the stack
			  has the opposite sign.  If the sbrk space is
			  positive as on all the machines above except the
			  GEC63, ignore this option.  If the sbrk space is
			  negative, set it by adding your machine type to
			  the #if in pl.h (where #if gec63 appears).

		DatAlign- sort of like a page size.  It is quite a bit more
			  efficient on most machines if you allocate your
			  data areas to start on some multiple of a page size.
			  This is particularly true on machines with large
			  hardware or software pages (e.g. the Perq with its
			  64k, the Orion with its 64k *option*, or the GEC63).
			  This might also be a function of the operating system.

	It is VITAL that you get BACKWARDS right, but once you've done that
	C Prolog can carry on from there.  It isn't important about DatAlign,
	and 1kbyte is a good default.  If you don't define IEEE and the
	machine isn't one of the types listed above, arith.c won't compile.
	If your machine does not support the IEEE format, you will almost
	certainly have to write new code, to steal the 3 least significant
	bits out of a single precision floating point word.  If you get this
	wrong, floating point arithmetic will go crazy, but that won't hurt
	Prolog too much.

2.  Operating system.

	The two that are currently understood are
		unix		-- any flavour
		vms		-- you don't want to know
	Again, it is the responsibility of the C Preprocessor to define a
	suitable name in lower case.  The main reason we want to know is
	to decide what to do about
		cd(Directory)	-- Change Directory (Set Default in VMS)
		delete(File)
		rename(Old,New)	-- change the name of a file
		shell(Command)
		sh		-- call the Command Interpreter
		expand_file_name   (NB: the VMS code is not written for this)
	and also what set of default file names to use.  If your operating
	system is none of these, none of these features will be available,
	and C Prolog will only use the C standard I/O library, some of the
	strings library, and sbrk().  If you write code to implement these
	functions on some other operating system (such as AEGIS), please
	let's have it so that it can be distributed.

	There is actually a test in one place for v7.  This is to cope with
	a change in the standard I/O library.   There is another change in
	4.2, but the patch for that doesn't do any harm in other versions.

	There is another option which might be set depending on the operating
	system, and is an operating system dependency, and that is FOLD.
	Some versions of UNIX (those using the EUUG terminal driver, basically)
	know how wide and how tall your screen is, and will automatically fold
	lines that are too long, and if asked nicely will pause when a single
	output would overflow the screen (no need for a nasty hack like "more").
	Vanilla V7, 32V, Sys III, Sys V, and 4.? BSD do not keep track of this
	information.  If you are using an operating system of this sort, and
	even your terminals don't fold (wrap) long lines -- and we are still
	in this unhappy situation, at least in part -- you can tell Prolog to
	FOLD lines.  The default is that it doesn't.

	Programming tip: if C Prolog is folding lines, and you want to send
	cursor control commands to the terminal, do something like this on
	a Unix system:
		send_string(S) :-
			writef('/dev/tty', '%s%f', [S]).
	where writef is the library predicate.


3.  Compiler features or bugs.

	NO_STRUCT_ASSIGN	use this if your compiler can't handle
				struct {...} x, y; ... x = y; ...

	NO_UNSIGNED_SHIFTS	use this if your compiler has a bug and
				generates signed shifts all the time.

	ASM			the file space.c has some functions with
				a wee bit of VAX assembly code in them.
				This is conditional on it being a VAX/UNIX
				system and this option being on.  In fact
				these functions are no longer used and are
				commented out, but if you find a use for
				assembly code inserts this is the option to use.
			
	There is a potential problem if your compiler understands UNsigned
	shifts but not signed shifts, but as no-one has yet reported that
	their C compiler gets this wrong, I haven't put in an option for it.
	See the comment near XtrInt in pl.h, I give alternative code.


4.  Debugging and development options.

	debugging	- CHANGE THIS TO WHAT <assert.h> USES

	ERRCHECK	- this does rather more thorough checking
			  in space.c, e.g. to make sure that space
			  isn't freed twice.  Space.c is based on
			  work in the public domain, so you could
			  well use it in another program.

	COUNTING	- this is used to gather statistics on how
			  deep the stacks get, how much space is
			  turned over, how often each primitive is
			  called, and so on.  You might find it of
			  interest, but it is not for production use.

	Normally NONE of these options should be defined.



Parms.c.

	You will need to edit parms.c.
	The default area sizes may need changing.  As distributed they
	add up to about a megabyte.  It is just possible to run Chat-80
	in this size, but not to save it and reload it.  Half a megabyte
	is about as small as there is any point in making it.
	The first thing that is likely to run out is the Atom area; if
	you double it that should be enough.  The amount of space in use
	in each area is reported by "statistics/0", the heapused and
	stackused arithmetic "constants" may be useful too.  Whatever the
	defaults, C Prolog will expand itself to accomodate any file you
	load, and you can over-ride the defaults in the command line (see
	the manual).  Experiment with sizes in the command line before
	recompiling the interpreter.

The other things you may have to change in this file are

savemagic:	on a BSD system, this should be !#xxxx\n
		where xxxx is the complete unambiguous path name of
		the object code of the Prolog interpreter.  The point
		of this is that you can then treat a saved state as an
		executable program.  If a (possibly relative) name for
		a saved state is "fred", and you give the command "fred args",
		a BSD system will treat this as "xxxx fred args" which is
		exactly what we want.

		on a non-BSD system there is not the least point in
		changing it as it has only to be distinctive.

saveversion:	if you make a change to the format of a saved state, you
		should change this number so that old saved states will
		be rejected instead of crashing the interpreter.  But you
		really shouldn't need to make such a change.

version:	this is the message which gets printed when C Prolog
		starts up.  Please ADD to it only, do NOT remove the
		indication that it came from DAI Edinburgh (EdAI).
		There really isn't any need to change it; if you want
		more of a banner, hack the appropriate place in main.c.

BootFile:	this is the name of the default bootstrap file.  In
		practice you may as well ignore it, as the startup
		script provided supplies an explicit name for this file.
		(./prolog -b pl/init <startupscript)

InitFile:	this you SHOULD change.  If Prolog is run without any
		arguments, this is the name of the file it restores.
		On a UNIX system, it should be in /usr/lib/prolog/something
		or /usr/local/lib/prolog/something.

		On any sort of system, the shared saved states should be
		in a subdirectory of the library that lib/1 (see the file
		pl/lib) searches.

UserFile:	when there is no argument, Prolog will try to restore this
		file before trying to restore the InitFile.  The idea is
		that each user can have his own
			.prolog		-- saved state
			.prologrc	-- source file
		If there is a .prolog (a UserFile) that will be loaded.  If
		not, the standard shared saved state will be loaded, and it
		will consult .prologrc if there is one.  But the name of the
		.prologrc file is built into the startup script and is not
		in the C component.

SavedFmt:	if you say "prolog foo", Prolog will first of all try to
		find a saved state called foo.  If that doesn't work, it
		will plug foo into the SavedFmt (where the %s is) and try
		again.  So if you have a shared library of saved states
		(maybe various medium sized AI programs, or more to the
		point the utilities package or the cross referencer),
		users don't have to know or be bothered with typing the
		full name of a file in that directory, they can just type
		the last component.  If this can't be made to work on your
		system, you'll have to change the code in parms.c.

There are a couple of file names in Prolog code.  All I can recall at the
moment are
	.prologrc		-- in the startup script
	/usr/lib/prolog		-- in pl/lib
	/usr/lib/prolog/teach	-- in pl/lib
PLEASE, if you decide to put the library somewhere else, root it at
	$something/lib/prolog
/usr/lib is a good place, or failing that /usr/local/lib.

