From kre@munnari.oz Wed Jun  4 09:16:01 AEST 1986

Notes for making SunIII compile on a PC-AT running Xenix.

1) make easily runs out of memory.  3 things to do to help

	a) remove all unnecessary baggage from the top level Makefile
	   (that is, the stuff that's there for "make print", "make lint",
	   "make clean" "make clobber").  This will get it small enough
	   that "make certain", "make install" etc will all work.

	b) remove everything that isn't essential from NNdaemon/Makefile
	   (that is all the stuff related to printing, linting, cyntax,
	   clean, .DEFAULT, ...).  That will almost get it small enough,
	   it will be small enough for ...

	c) when a make fails because of running out of memory (make
	   in Lib and NNdaemon will both do that, as will "make install")
	   just run it again.  That is, keep doing "make certain" over
	   and over till it ends up doing nothing.  Then do the same
	   for "make install".  "make directories" and "make special"
	   should each work, but they don't if you try
	   "make directories special"

2) cpp can't handle macro calls of the form
	Trace3
	(
		arg,
		arg,
	)
it needs the '(' on the same line as the macro name.

This affects the macros DODEBUG Trace[0-9] Report[0-9] and Fatal[0-9]
which occur all over the place.  The egrep command

	egrep '(Trace.|Fatal.|Report.|DODEBUG)$' *.c

in every directory will find the files that need fixing.  Lots of them...

3) the C compiler can't handle the use of enums where int's are
expected.  This affects the "typedef bool { false, true };" in
Include/global.h.  Remove it.  Replace it with
	typedef int bool;
	#define false 0
	#define true  1

4) cpp will scream about "wrong number of macro parameters" for
lots of uses of the XXXDIR() macros.  Ignore that, it does the
right thing anyway.

5) <termio.h> doesn't include <sys/ioctl.h> nor does it define the
ioctl commands, Include/global.h assumes that it does.

Solution:  include the following lines in Include/global.h after
the #include <termio.h>

	#ifndef TCSETA
	#include <sys/ioctl.h>
	#endif

7) NNcall/shell.c includes <sys/param.h>.  That includes <sys/types.h>.
But shell.c has TERMIOCTL defined, and that causes <sys/types.h> to be
loaded in global.h (before <sys/param.h> so the conditionals in there
don't save it).  Lots of redefinitions.

Solution:  comment out the code that includes <sys/param.h> and
the code that uses BSHIFT in the ulimit() call.  That's not likely
to be very important on a PC.  A better fix could probably be found.

8) NNdaemon/main.c causes a compiler error, "string too big for buffer".
(This won't happen unless DEBUG is defined, but surely everyone defines
DEBUG?).  Solution, replace the initialization of Usage with..

	char *Usage = "...";

9) ENproto doesn't seem to compile correctly with VCBUFSIZE undefined
(though Makefile says not to define it).  Solution, just define it...


(10) The Xenix locking system calls require a process to open a file so
that it can write it (even if it doesn't actually want to) 
{ ie fopen (file_name, "r+") } in order to deny permission for other
processes to be able to write.

Solution: change the relevant files so that all file opens are r+ not r. 
Then, EITHER make the statefile publically writeable (UGH) so that
the changed fopen now runs, OR change acsstate (the only program affected)
to setuid ==> daemon.


Apart from that, it all compiles & runs OK.  (1) and (2) are the
only really annoying ones, and Piers could easily fix (2) for
all systems if he was willing to give up his revolting coding
style...

Several of the other problems could easily be fixed in the
generic source too.

For reference, here are the (non obvious) Makefile definitions I used:

NODE	= nodename
	(so it will us the _lib/nodename file)  Xenix has uname,
	but I don't know how its supposed to be set.  uucp uses the
	/etc/systemid file.

CONSOLE = /dev/console
	(or ln /dev/console /dev/net/console)

FUZZ	= root
#NCC_MANAGER =

CFLAGS	= -O
LDFLAGS = -i

	This uses the "small model".  Medium model won't help
	anything, code size is no problem.  PNdaemon and ENdaemon
	will probably not work well, if at all, they only just
	fit into the 64K data space, a few malloc's are likely
	to blow them away.  Changing to the large model would
	fix that, but everything would need to be large model
	then, and its not worth it.

BINMAIL = /usr/lib/mail/mail.local
#BINMAILARGS
MAILER	= /usr/lib/mail/mail.local
MAILERARGS = "-r","&F@&O"

	(this solves the problem of getting mail delivered to
	the PC, getting it from there is a whole other question...)

IGNMAILERSTATUS=0
VALIDATEMAIL=1
MAIL_FROM=1	(this is probably not required, the -r arg seems to work)
UNSAFEMAILER=1	(all systems should do this!)

POSTMASTER=root

FCNTL	= 1
KILL_0	= 1
LOCKF	= 1
MINSLEEP= 2
PGRP	= 1
SYSTEM	= 3
UNAME	= 0

LORDER	= echo
RANLIB	= ranlib
TSORT	= cat

The PC seems to be able to handle 2400 baud (-p10 in the node/params file)
OK as long as its not doing much else.  Errors start happening if it
gets a little busy.  1200 is probably safe.
