Installing
----------

First try the following simple set of commands.
These may fail (depending on your environment)
in which case you should use the second set of
commands.

1. Place the file "KernSmooth.shar" in the directory
   of your choice.

   For explanatory purposes, we will suppose that
   the directory has the path name:

   /home/xyz/mylibrary

   This path name can be found by typing 'pwd' while
   in the directory.

2. Starting from this directory type the commands:

	sh KernSmooth.shar
	cd KernSmooth
	sh install1.KernSmooth
	sh install2.KernSmooth


If the above installation process fails, in particular
if it fails during the compilation of the module (ie. when
you execute the command 'sh install2.KernSmooth'), you may
need to make some changes to the files "Makefile" and
"S_makefile". 

The "S_makefile" defines which C and Fortran compilers are
used by Splus. The "Makefile", which is generated during the
execution of the command 'sh install1.KernSmooth', defines the
location of the "S_makefile" and the flags used by the
C and Fortran compiler and the linker.

If the compilation process aborts with a message complaining
that a C or Fortran compiler is not found then you need to make
changes to "S_makefile". Follow the installation procedure
below to create your own version of "S_makefile" and edit the
"Makefile" to make it point to your "S_makefile".
A typical error message looks like :

    sh: gcc: not found
    The error code from the last failed command is 1.
    Make Quitting.

The error message complains that it cannot find the GNU C
compiler which is the C compiler used by this SPlus system. 

If the compilation process aborts with message complaining
that there are some unresolved or undefined symbols detected,
you need to make changes to "Makefile" to add some flags
to the compilers or the linker.

A typical example is that when you use the sparc/Solaris
version of 'f2c' in place of the Fortran compiler, make sure
you include the library 'libF77.a' in the search libraries
for the linker by specifying the flags '-L/usr/local/lib -lF77'
on the line 'FLAGS=' in the "Makefile". (Assume that the 
library 'libF77.a' locates in the directory /usr/local/lib'.)


To make changes to "S_makefile" and "Makefile" during the
installation of the module KernSmooth, follow the installation
steps below.

1. Place the file "KernSmooth.shar" in the directory
   of your choice.

   For explanatory purposes, we will suppose that
   the directory has the path name:

   /home/xyz/mylibrary

   This path name can be found by typing 'pwd' while
   in the directory.

2. Starting from this directory type the commands:

        sh KernSmooth.shar

3. If you need to make changes to "S_makefile" and 
   you are loading this module for the first time
   (ie. you do not have your own version of the Splus
   makefile "S_makefile"), then:

   a.  Type the command

           Splus SHOME

       to find out the home directory of your SPlus
       system. For explanatory purposes, we will
       suppose that this is

           /usr/abc/splus

   b.  The Splus file "S_makefile" locates in the
       subdirectory "newfun/lib" under your Splus home
       directory. Copy the file to your directory by
       the command : 

           cp /usr/abc/splus/newfun/lib/S_makefile /home/xyz/mylibrary

       Note : Substitute /usr/abc/splus by your Splus
       home directory and /home/xyz/mylibrary by the
       directory you choose in step 1 in the above command.

   c.  Now you have your own copy of Splus makefile
       "S_makefile" in the directory "/home/xyz/mylibrary".

       Edit the file "/home/xyz/mylibrary/S_makefile"
       and change line referring to "CC" to a C compiler
       your machine supports.  Possibly do the same for
       Fortran compiler. (Change line referring to "F77".)

       For example, in S_makefile there is a line

           CC = gcc

       If you want to change the C compiler from GNU C
       compiler to the C compiler supplied by your UNIX
       vendor, change the line to

           CC = cc

4. Type the commands:

        cd KernSmooth
        sh install1.KernSmooth

5. If you have created your own copy of "S_makefile"
   in step 3, edit the file "Makefile" created in
   install1.KernSmooth ("Makefile" locates in
   the current directory) and change the line

        include $(SHOME)/newfun/lib/S_makefile

   to

        include /home/xyz/mylibrary/S_makefile

   Now the compilation will use your copy of "S_makefile"
   instead of the default "S_makefile" found in the
   directory '/usr/abc/splus/newfun/lib'.

6. If you need to make changes to the flags for the
   C and Fortran compiler and the linker, edit the
   file "Makefile" created in install1.KernSmooth and
   change lines starting with CFLAGS, FFLAGS and FLAGS.
   Flags for C compiler is defined in CFLAGS line.
   Flags for Fortran compiler is defined in FFLAGS line.
   Flags for linker is defined in FLAGS line.

   For example, to add library "libF77.a" located in
   directory "/usr/local/lib" to the search libraries for
   the linker, change the line

	FLAGS=

   to

	FLAGS=-L/usr/local/lib -lF77
        
7. Type the command

        sh install2.KernSmooth

If you encounter any other errors in compilation, most probably
you can fix it by making some changes to the "Makefile"
and "S_makefile". Consult your UNIX system administrator or
system support for the required changes in your case. Follow the
installation steps above and make changes to the "S_makefile"
and "Makefile" that suit your situation. We appreciate that
you inform us the changes you make to get the installation done
successfully so that we can share your experience with other
users in this installation guide.
 

Using
-----

1. Enter S-PLUS from any directory.

2. To make the KernSmooth functions available
   to the current session type:

       assign("lib.loc","/home/xyz/mylibrary",where=0)
       library(KernSmooth)



To save having to type the first command each time
you want to use KernSmooth it is suggested that
you create a .First function containing this
command. It is then activated each time you enter
S-PLUS.


Creating the manual
-------------------

Assuming that you have LaTeX, the manual
can be obtained by applying LateX to the
file "KernSmooth.tex" with the files
"S.sty" and "gray.ps" in the current
directory. You can then create the Postcript
file from the file "KernSmooth.dvi".


Known problems in installation
------------------------------

1. Problem : The C compiler Splus using is not
   found in the system.

   Solution : This is because "S_makefile" is
   outdated or not set up properly. The Splus 
   makefile "S_makefile" defines which C compiler
   Splus is going to use. In this case, "S_makefile"
   may point to a C compiler not supported by your
   UNIX system. To resolve, follow the second 
   installation procedure in the Installing
   section. Change the name of the C compiler to
   the C compiler supported by your UNIX system in
   the "CC" line in "S_makefile".

2. Problem : We do not use Fortran compiler and we
   use f2c (the sparc/Solaris version). When we 
   compile the module, error message comes out saying
   there are some unresolved symbols.

   Solution : This is because the 'libF77.a' library is
   not included in the search libraries for the linker.
   To solve, follow the second installation procedure 
   in the Installing section. Add the flags
	-L/usr/local/bin -lF77
   to the line starting with
	FLAGS=
   in the file "Makefile" created in the command
   install1.KernSmooth.

   Note: It is assumed that the library 'libF77.a' 
   locates in the directory /usr/local/lib. If your
   'libF77.a' locates in another directory, change the 
   -L  flag to point to the directory 'libF77.a' locates.
  

