How to build and install XBoard
-------------------------------

To build and install xboard on your system, you will need to generate a
properly customized Makefile for it, probably using imake, a program that
comes with the X Window System.

Before you do this, you may need to edit the Imakefile.  xboard has special
code for certain systems that is enabled or disabled by ifdefs in xboard.c.  A
few systems do not automatically define a symbol that can be used to select
the right ifdef, so you have to define it yourself in the Imakefile.  Here is
a list of ifdef symbols used in xboard.  To add one of these, for example FOO,
to your Imakefile, add the string -DFOO to the end of the DEFINES line,
separated by a space from what's already there.

IRIX or sgi		-- Silicon Graphics IRIX.
IRIS			-- Old version of SGI Iris code; try IRIX first.
AIXV3			-- IBM AIX, version 3.
IBMRTAIX		-- AIX for the IBM RT.  I don't know how this differs
			     from AIXV3.  Use what works for you. 
ESIX			-- The ESIX operating system.
SYSTEM_FIVE		-- Unix System V.
SYSV			-- Unix System V.
SVR4			-- Unix System V, release 4.
HPUX or hpux		-- Hewlett-Packard HPUX. (**see below**)
UNIPLUS			-- Uniplus Unix.
sun			-- SUN Microsystems. (**see below**)
RTU			-- I don't know what this is for!
__STDC__		-- Automatically defined by ANSI C compilers.
ATTENTION		-- Define this if your version of gnuchess requires
	                     you to get its attention by hitting ^C when you
			     want to move while it is thinking on your time.
			     Remove it if your version of gnuchess dies when
			     you hit ^C.
HAS_GETTIMEOFDAY	-- Remove this if you don't have the getttimeofday()
			     system call.
HAS_FTIME		-- Add this if you don't have gettimeofday() but you
			     do have ftime().  If you don't define either
			     HAS_GETTIMEOFDAY or HAS_FTIME, xboard will keep
			     time only to the nearest second.
FLEX			-- Add this if you are using "flex" instead of Unix
			     "lex" to process parser.l.  Needed by linux.  If
			     Unix lex is installed on your system under the
			     name "lex", but nevertheless you want to use flex
			     instead, add the line "LEX = flex" to the
			     Imakefile as well as adding -DFLEX to the
			     DEFINES.  If flex is installed under the name
			     "lex", as it is on linux, you don't need the 
			     "LEX = flex" line, but you do need to add -DFLEX
			     to the DEFINES.
OMIT_SOCKETS		-- Add this if you want to omit the code in xboard
			     that uses sockets.  If you do so, xboard will not
			     be able to communicate with the ICS by opening a
			     direct TCP connection, but the -useTelnet and
			     -gateway options will still work.

After editing the Imakefile, you should be able to generate a correct Makefile
by typing the command "xmkmf" in the xboard source directory.  This command is
supposed to run imake with the right flags for your site.  If you get "Command
not found," make sure the directory containing xmkmf is on your search path.
(It is /usr/local/X11/bin on many systems.)

If xmkmf doesn't work, you can try running imake directly.  One of the
following command lines may work, or you may be able to get one of them to
work by editing the file names to reflect where the X release is installed on
your system:

	imake -DUseInstalled -I/usr/local/lib/X11/config

	imake -DUseInstalled -I/usr/local/X11/mit/config

	/usr/local/X11/mit/config/imake \
		-I/usr/local/X11/mit/config -DTOPDIR=/usr/local/X11/mit

If all else fails, you can try using the file Makefile.simple as your
makefile.  Do "cp Makefile.simple Makefile" to try this.  You may have to edit
this makefile considerably to make it work at your site.  Please don't ask me
questions about how to do this; instead, get a Unix wizard at your site to
help you, and/or find a copy of imake and use the Imakefile instead.  (HP
users, see the special instructions further down in this file.)

Once you have made a working Makefile from your Imakefile, if you need to make
further changes to the Imakefile, you can use the command "make Makefile" to
update the Makefile after you edit the Imakefile.

After you have a working Makefile, you of course need to type "make" to build
xboard.

(If the "make" fails because you cannot get lex or flex to work on your
system, try using the prebuilt parser.c.lex or parser.c.flex.  These are
versions of parser.c built on a DECstation 5000 using lex and flex
respectively.  To use them, either do "cp parser.c.lex parser.c", or add
-DFLEX to the DEFINES in the Imakefile and do "cp parser.c.flex parser.c".)

Typing "make install" will try to install xboard, cmail, and their manual
pages for public use on your system.  If you aren't a system administrator,
you may not have the necessary privileges to do this.  Instead, just copy them
to your personal bin directory, or run them from the xboard source directory.

If you want to read the manual pages without actually installing them where
the "man" command can find them, look in the files xboard.doc and cmail.doc,
which should be created when you do "make".  Or type the command "nroff -man
xboard.man | more" or "nroff -man cmail.man | more".  Or look directly at
xboard.man and cmail.man if you get "Command not found" when you try to run
nroff.


********** Information for linux users **************************************
If you have problems building and running xboard on linux, be sure you have
added -DFLEX to the DEFINES line in the Imakefile (see above), and be sure you
have the latest versions of linux and its X package.  xboard is known to work
with "the SLS 1.03 package with the linux 0.99pl12 kernel and Xfree 1.3".
(This is Greek to me; hope it makes sense to you.)

Also, you may need to add "-lfl" to the SYS_LIBRARIES line in the Imakefile.


********** Information for HP users *****************************************
HP-UX does not provide imake or xmkmf, and it is missing some X header
files that are needed for building xboard.  You can get the missing
pieces by anonymous FTP.  (But first check with your system manager to
see if someone else at your site has already done this.)  Get the
archive files /hpux9/X11R5/Core/imake-5.03.tar.gz (imake and xmkmf)
and /hpux9/X11R5/Core/Xaw-5.00.tar.gz (Xaw header files) via anonymous
FTP from the site ftp.csc.liv.ac.uk (138.253.42.172), or one of its
mirrors---Germany: hpux.ask.uni-karlsruhe.de (129.13.200.57), US:
ftp.cae.wisc.edu (144.92.4.15), or France: hpux.cict.fr
(192.70.79.53).  Unpack the archives using gunzip and follow the
instructions in their README and Install files.

Thanks to Richard Lloyd for this information.


********** Information for Sun users ****************************************
There are lots of different kinds of Suns with different operating
system and window system versions that run on them.  I don't
personally have access to any of them, but xboard is known to work on
at least some.  I would like to collect more information about what
has to be put in the Imakefile to build xboard for each type of Sun
and each operating system/window system, so please send mail if these
instructions don't work for you---especially if you find out how to
fix them!  (See the READ_ME file for the mail address to use.)

** Solaris 2.x *************************
For Solaris 2.x (SunOS 5.x) you need to do the following:

1) Edit the DEFINES line in the Imakefile to read as follows:

	DEFINES = -DHAS_GETTIMEOFDAY -Dsun -DSVR4 -DATTENTION

The -DATTENTION flag works around an unidentified bug that prevents
the FIONREAD ioctl in gnuchess from working, causing gnuchess to hang
when it is trying to think on your time after it gets out of its
opening book.  The -DSVR4 flag allows xboard to work without needing
the UCB compatibility package.

2) Remove the "#" from in front of the SYS_LIBRARIES line in the
Imakefile and edit it to read as follows:

	SYS_LIBRARIES = -lsocket -lnsl -lelf -lm

3) Ignore any compiler messages you get that start with the word
"warning."  I try to eliminate those, but there is only so much I can
do to accomodate the many different C compilers in the world.  Sun's
ANSI C compiler is especially picky.

Thanks to Pete Hartman for corrections to this information.

** SunOS 4.x (Solaris 1.x) ***************************
On SunOS 4.1.3 with OpenWindows, you need to do the following:

1) Edit the Imakefile to add -Dsun to the DEFINES and (if necessary)
to uncomment the XMULIB line (delete the # at the front of the line):

         DEFINES = -DHAS_GETTIMEOFDAY -Dsun
...

# If you get the following linker error messages on SunOS, you have
# hit a known bug in the SunOS linker (ld).
#	ld: Undefined symbol 
#	  _get_wmShellWidgetClass 
#	  _get_applicationShellWidgetClass 
# To work around it,  try uncommenting this if you are using Sun's C compiler:
         XMULIB = -Bstatic -lXmu -Bdynamic
# ... or this if you are using gcc:
#        XMULIB = -static -lXmu -dynamic
# Ask Sun for patches 100512-02 and 100573-03 to get the real fix.

2) The xmkmf in at least some versions of OpenWindows is broken.
Instead of running xmkmf, try this:

  /usr/openwin/bin/imake -DStandardIncludes=-I/usr/openwin/include \
	-DUseInstalled -I/usr/openwin/lib/config \
	-DDefaultCCOptions=-L/usr/openwin/lib

Without this, the Makefile will not know about the include files and
libraries in /usr/openwin.

Thanks to Ed Hanway for some of this information, and thanks to Jim
Daly for letting me log onto his machine and figure out the rest of it
myself.

I currently don't know how to make xboard run on SunOs 4.1.3 with
Motif (as opposed to OpenWindows).  Contact me if you can help. 

********** Information for NCR users ****************************************
One user with the following system reported a problem with gnuchess:

  NCR system 3300 (486DX2-66 Microchannel box), with operating system
  "UNIX System V/386/486 Release 4.0 Version 2.0"

Symptom: When gnuchess is thinking on your time, it does not accept
commands unless you hit ^C first.  That causes xboard to hang as soon
as gnuchess gets out of book and starts thinking on your time.  This
seems to reflect an operating system bug in the FIONREAD ioctl.

You can easily work around this bug by adding -DATTENTION to the
DEFINES line in the Imakefile before you build xboard.

********** Information for Convex users ONLY ********************************
From: Richard Mathar
Date: Sun, 13 Jun 1993 16:52:37 +0200

xboard-2.0 patchlevel 21 could be compiled using
	imake -I/usr/X11/lib/config -DTOPDIR=/usr/X11/lib
and editing some lines in the Makefile to read afterwards

        CONFIGSRC = $(LIBSRC)/config
     EXTENSIONSRC = $(INCDIR)/extensions
         XILIBSRC = $(EXTENSIONSRC)/Xinput
      PHIGSLIBSRC = $(EXTENSIONSRC)/PEX
  DEPEXTENSIONLIB =  $(LIBSRC)/libXext.a
          DEPXLIB = $(DEPEXTENSIONLIB)  $(LIBSRC)/libX11.a
             XLIB = $(EXTENSIONLIB)   $(LIBSRC)/libX11.a
        DEPXMULIB =  $(LIBSRC)/libXmu.a
      DEPXTOOLLIB =  $(LIBSRC)/libXt.a
************************************************************************
