\input texinfo
@c %**start of header
@setfilename R-admin.info
@settitle R Installation and Administration
@setchapternewpage on
@c %**end of header

@syncodeindex fn vr

@dircategory Programming
@direntry
* R Administration: (R-admin).      R Installation and Administration.
@end direntry

@finalout

@include R-defs.texi
@include version.texi

@ifinfo
This is a guide to installation and administration for R.

@Rcopyright{2001}

@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries a copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).

@end ignore

@permission{}
@c ---------- ^- read that
@end ifinfo

@titlepage
@title R Installation and Administration
@subtitle Version @value{VERSION}
@author R Development Core Team
@page
@vskip 0pt plus 1filll
@permission{}

@Rcopyright{2001}
@end titlepage

@ifnothtml
@contents
@end ifnothtml

@ifnottex
@node Top, Obtaining R, (dir), (dir)
@top R Installation and Administration

This is a guide to installation and administration for R.

The current version of this document is @value{VERSION}.
@end ifnottex

@menu
* Obtaining R::                 
* Installing R under Unix::     
* Installing R under Windows::  
* Installing R on Classic MacOS::  
* Add-on packages::             
* Essential and useful other programs::  
* Configuration on Unix::       
* New platforms::               
* Function and variable index::  
* Concept index::               
@end menu

@node Obtaining R, Installing R under Unix, Top, Top
@chapter Obtaining R
@cindex Obtaining R

Sources, binaries and documentation for @R{} can be obtained via
@acronym{CRAN}, the ``Comprehensive R Archive Network''.  See the file
@file{RESOURCES} for information on @acronym{CRAN}.

@menu
* Getting and unpacking the sources::  
* Using rsync::                 
@end menu

@node Getting and unpacking the sources, Using rsync, Obtaining R, Obtaining R
@section Getting and unpacking the sources
@cindex Sources for R

The simplest way is to download the most recent
@file{R-@var{x}.@var{y}.@var{z}.tgz} file, and unpack it with

@smallexample
tar xvfz R-@var{x}.@var{y}.@var{z}.tgz
@end smallexample

@noindent
on systems that have GNU @command{tar} installed.  On other systems you
need at least to have the @command{gzip} program installed.  Then you
can use

@smallexample
gzip -dc R-@var{x}.@var{y}.@var{z}.tgz | tar xvf -
@end smallexample

If you need to transport the sources on floppy disks, you can download
the @file{R-@var{x}.@var{y}.@var{z}.tgz-split.*} files and paste them
together at the destination with (Unix)

@smallexample
cat R-@var{x}.@var{y}.@var{z}-split.* > R-@var{x}.@var{y}.@var{z}.tgz
@end smallexample

@noindent
and proceed as above.  If you want the build to be usable by a group of
users, set @code{umask} before unpacking so that the files will be
readable by the target group (e.g., @code{umask 022} to be usable by all
users).

@cindex Patch files
Finally, for minor-minor releases (@samp{@var{x}.@var{y}.@var{z}} with
@var{z} != 0), a patch against the preceding release is made available
in
@file{R-@var{x}.@var{y}.@var{@{z-1@}}-@var{x}.@var{y}.@var{z}.diff.gz}
(e.g., @file{R-1.2.2-1.2.3.diff.gz}), which is generally a much smaller
file that the @file{.tgz} files.  Such a file can be applied to the
sources of the previous version by changing to the top directory of it
and

@smallexample
gzip -dc /path/to/it/R-@var{x}.@var{y}.@var{@{z-1@}}-@var{x}.@var{y}.@var{z}.diff.gz | patch -E -p1
@end smallexample

@noindent
Beware that this does not necessarily work if the older sources have
been modified (e.g., by building in their directories).

@node Using rsync,  , Getting and unpacking the sources, Obtaining R
@section Using rsync
@findex rsync

Sources are also available via anonymous rsync.  Use

@example
rsync -rC rsync.r-project.org::@var{module} R
@end example

@noindent
to create a copy of the source tree specified by @var{module} in the
subdirectory @file{R} of the current directory, where @var{module}
specifies one of the four existing flavors of the R sources, and can be
one of @samp{r-release} (current released version), @samp{r-patched}
(patched released version), and @samp{r-devel} (development version,
less stable), and @samp{r-ng} (next generation, unstable).  The rsync
trees are created directly from the master CVS archive and are updated
hourly.  The @option{-C} option in the @command{rsync} command is to
cause it to skip the CVS directories.  Further information on
@command{rsync} is available at @uref{http://rsync.samba.org/rsync/}.


@node Installing R under Unix, Installing R under Windows, Obtaining R, Top
@chapter Installing R under Unix
@cindex Installing under Unix

@R{} will configure and build from source under a number of common
Unix-like platforms, including @code{i386-freebsd}, @code{i386-linux},
@code{i386-sun-solaris}, @code{ppc-linux}, @code{mips-sgi-irix},
@code{alpha-linux}, @code{alpha-dec-osf4}, @code{rs6000-ibm-aix},
@code{hppa-hp-hpux}, @code{sparc-linux} and @code{sparc-sun-solaris}.

@cindex Linux
@cindex MacOS X
In addition, binary distributions are available for most common Linux
distributions, Compaq Alpha systems running OSF/Tru64, and for MacOS X
(Darwin) with X11.  See the @acronym{FAQ} for current details.  These
are installed in platform-specific ways.  So for the rest of this
chapter we consider only building from the sources.

@menu
* Simple compilation::          
* Making the manuals::          
* Installation::                
@end menu


@node Simple compilation, Making the manuals, Installing R under Unix, Installing R under Unix
@section Simple compilation

First review the essential and useful tools and libraries in
@ref{Essential and useful other programs}, and install those you want or
need.

@findex R_HOME
Choose a place to install the @R{} tree (@R{} is not just a binary, but
has additional data sets, help files, font metrics etc).  Let us call
this place @file{R_HOME}.  Untar the source code.  This should create
directories @file{src}, @file{doc}, and several more.  Issue the
following commands:

@findex configure

@smallexample
./configure
make
@end smallexample

@noindent
(See @ref{Using make} if your make is not called @samp{make}.)

Then check the built system works correctly, by

@smallexample
make check
@end smallexample

@noindent
Failures are not necessarily problems as they might be caused by missing
functionality, but you should look carefully at any reported
discrepancies.  To re-run the tests you would need
@smallexample
make check FORCE=FORCE
@end smallexample


If these commands execute successfully, the @R{} binary will be copied
to the @file{$@{R_HOME@}/bin} directory.  In addition, a shell-script
front-end called @file{R} will be created and copied to the same
directory.  You can copy this script to a place where users can invoke
it, for example to @file{/usr/local/bin/R}.  You could also copy the man
page @file{R.1} to a place where your @command{man} reader finds it,
such as @file{/usr/local/man/man1}.  If you want to install the complete
@R{} tree to, e.g., @file{/usr/local/lib/R}, see @ref{Installation}.
Note: you do not @emph{need} to install @R{}: you can run it from where
it was built.

You do not necessarily have to build @R{} in the top-level source
directory (say, @file{TOP_SRCDIR}).  To build in @file{BUILDDIR}, run

@findex configure

@smallexample
cd BUILDDIR
TOP_SRCDIR/configure
make
@end smallexample

@noindent
and so on, as described further below.  This has the advantage of always
keeping your source tree ``clean''.  (You may need GNU @command{make} to
allow this.)

@cindex Help pages
Make will also build plain text help pages as well as @acronym{HTML} and
La@TeX{} versions of the @R{} object documentation (the three kinds can
also be generated separately using @code{make help}, @code{make html}
and @code{make latex}).  Note that you need Perl version 5: if this is
not available on your system, you can obtain PDF versions of the
documentation files via @acronym{CRAN}.

Now @code{rehash} if necessary, type @kbd{R}, and read the @R{} manuals
and the @R{} @acronym{FAQ} (files @file{FAQ} or
@file{doc/html/faq.html}, or
@uref{http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html} which always has
the latest version).

@node Making the manuals, Installation, Simple compilation, Installing R under Unix
@section Making the manuals
@cindex Manuals

There is a set of manuals that can be built from the sources,

@table @code
@item refman
Printed versions of all the help pages.
@item R-FAQ
R @acronym{FAQ} (which is already built for you).
@item R-intro
``An Introduction to R''.
@item R-data
``R Data Import/Export''.
@item R-admin
``R Installation and Administration'', this manual.
@item R-exts
``Writing R Extensions''.
@item R-lang
``The R Language Definition''.
@end table

@noindent
To make these, use

@smallexample
make dvi      @r{to create DVI versions}
make pdf      @r{to create PDF versions}
make info     @r{to create info files (not @code{refman}).}
@end smallexample

You will not be able to build the info files unless you have
@command{makeinfo} version 4 or later installed (and some Linux
distributions have 3.12).

The DVI versions can be previewed and printed using standard programs
such as @command{xdvi} and @command{dvips}.  The PDF versions can be
viewed using Acrobat Reader or (recent versions of) ghostscript: they
have hyperlinks that can be followed in Acrobat Reader.  The info files
are suitable for reading online with Emacs or the standalone GNU Info.

@node Installation,  , Making the manuals, Installing R under Unix
@section Installation
@cindex Installation

After

@findex configure
@smallexample
./configure
make
make check
@end smallexample

@noindent
have been completed successfully, you can install the complete @R{} tree
to your system by typing

@smallexample
make install
@end smallexample

@noindent
This will install to the following directories:

@table @file
@item $@{prefix@}/bin
the front-end shell script
@item $@{prefix@}/man/man1
the man page
@item $@{prefix@}/lib/R
all the rest (libraries, on-line help system, @dots{})
@end table

@noindent
where @code{prefix} is determined during configuration (typically
@file{/usr/local}) and can be set by running @command{configure} with
the option @option{--prefix}, as in

@findex configure
@smallexample
./configure --prefix=/where/you/want/R/to/go
@end smallexample

@noindent
This causes @command{make install} to install the @R{} executable to
@file{/where/you/want/R/to/go/bin}, and so on.  The prefix of the
installation directories can be seen in the status message that is
displayed at the end of @command{configure}.  You can install into
another directory by using

@smallexample
make prefix=/path/to/here install
@end smallexample

@cindex Manuals, installing

To install DVI, info and PDF versions of the manuals, use one or more of

@smallexample
make install-dvi
make install-info
make install-pdf
@end smallexample

@noindent
To ensure that the installed tree is usable by the right group of users,
set @code{umask} appropriately (perhaps to @code{022}) before unpacking
the sources and throughout the build process.


@node Installing R under Windows, Installing R on Classic MacOS, Installing R under Unix, Top
@chapter Installing R under Windows
@cindex Installing under Windows

The @file{bin/windows} directory of a @acronym{CRAN} site contains
binaries for a base distribution and a large number of add-on packages
from @acronym{CRAN} to run on Windows 95, 98, NT4, 2000 and ME (at
least) on Intel and clones (but not on other platforms).

You do need one of those Windows versions: Windows 3.11+win32s will not
work. 

Your file system must allow long file names (as is likely except
perhaps for some network-mounted systems).

The simplest way is to use @file{SetupR.exe} or @file{miniR.exe}.  Just
double-click on the icon and follow the instructions.  If you installed
R this way you can uninstall it from the Control Panel or Start Menu
(unless you suppressed making a group for @R{}).

See the @uref{http://www.stats.ox.ac.uk/pub/R/rw-FAQ.html, R Windows
@acronym{FAQ}} for more details.

@menu
* Building from source::        
@end menu

@node Building from source,  , Installing R under Windows, Installing R under Windows
@section Building from source

If you want to build this port from the sources, see the file
@file{src/gnuwin32/INSTALL} in the source distribution.  You will need
to collect, install and test an extensive set of tools: see
@uref{http://www.stats.ox.ac.uk/pub/Rtools/} for the current locations.

You may need to compile under a case-honouring file system: we found
that a @command{samba}-mounted file system (which maps all file names to
lower case) did not work.  Open a commands window at a directory whose
path does not contain spaces, and run something like

@smallexample
tar zxvf R-1.3.0.tgz
cd R-1.3.0\src\gnuwin32
make
@end smallexample

@noindent
sit back and wait (for about 5 minutes on 1GHz PIII with a fast local
disc).

For further details, including how to make the documentation and how to
cross-compile, see @file{src/gnuwin32/INSTALL}.

@node Installing R on Classic MacOS, Add-on packages, Installing R under Windows, Top
@chapter Installing R on Classic MacOS
@cindex Installing under MacOS

The @file{bin/macos} directory of a @acronym{CRAN} site contains
@command{bin-hex}ed (@file{hqx}) and @command{stuffit} (@file{sit})
archives for a base distribution and a large number of add-on packages
to run under MacOS 8.6 to MacOS 9.1 or MacOS X natively.  Just extract
one of these archives in a suitable folder using standard utilities like
Aladdin Stuffit Expander (tm).

@cindex MacOS X
There is also a port to MacOS X which is considered to be a Unix variant
in this document.  You can find it in the @file{bin/macosx} directory at
of a @acronym{CRAN} site. 

@node Add-on packages, Essential and useful other programs, Installing R on Classic MacOS, Top
@chapter Add-on packages
@cindex Packages

@menu
* Installing packages::         
* Updating packages::           
* Removing packages::           
@end menu

This chapter applies to Unix-like and Windows versions of @R{}, but not
to the Classic MacOS port.

It is helpful to use the correct terminology.  A @emph{package} is
loaded from a @emph{library} by the function @code{library}.  Thus a
library is a directory containing installed packages; the main library
is @file{R_HOME/library}, but others can be used, for example by setting
the environment variable @env{R_LIBS} or the @R{} object
@code{.lib.loc}.

@node Installing packages, Updating packages, Add-on packages, Add-on packages
@section Installing packages
@cindex Packages, installing

Note that you need to specify implicitly or explicitly the library to
which the package is to be installed.  This is only an issue if you have
more than one library, of course.

To install packages from source on Unix use

@smallexample
R CMD INSTALL -l /path/to/library pkg1 pkg2 ...
@end smallexample

@noindent
The part @samp{-l /path/to/library} can be omitted, when the first
library in @env{R_LIBS} is used if set, otherwise the main library
@file{R_HOME/library}.

The Windows equivalent is@footnote{if you have Perl and the source-code
package files installed}

@smallexample
Rcmd INSTALL -l /path/to/library pkg1 pkg2 ...
@end smallexample

@findex install.packages 
Alternatively, packages can be downloaded and installed from within
@R{}.  First set the option @code{CRAN} to your nearest @acronym{CRAN}
mirror, for example

@smallexample
> options(CRAN = "http://cran.us.r-project.org/")
@end smallexample

@noindent
Then download and install package @strong{foo} by

@smallexample
> install.packages("foo")
@end smallexample

@noindent
Unless the library is specified (argument @code{lib}) the first library
in @code{.lib.loc} is used.

What this does is different on Unix and Windows.  On Unix it consults
the list of available source packages on @acronym{CRAN}, downloads the
latest version of the @strong{foo} sources, and installs it (via @code{R
CMD INSTALL}).  On Windows it looks at the list of @emph{binary}
versions of packages and downloads the latest version (if any).

On Windows @code{install.packages} can also install a binary package
from a local @file{zip} file by setting argument @code{CRAN} to
@code{NULL}.   @code{RGui.exe} has a menu @code{Packages} with a GUI
interface to @code{install.packages}, @code{update.packages} and
@code{library}.


@node Updating packages, Removing packages, Installing packages, Add-on packages
@section Updating packages
@findex update.packages
@cindex Packages, updating

The command @code{update.packages()} is the simplest way to ensure that
all the packages on your system are up to date.  Set the @code{CRAN}
option as in the previous section.  The @code{update.packages()}
downloads the list of available packages and their current versions,
compares it with those installed and offers to fetch and install any
that have later versions on @acronym{CRAN}.

@node Removing packages,  , Updating packages, Add-on packages
@section Removing packages
@findex remove.packages
@cindex Packages, removing

Packages can be removed in a number of ways.  From a command prompt they
can be removed by

@smallexample
R CMD REMOVE -l /path/to/library pkg1 pkg2 ...
@end smallexample
@noindent
(Unix) or
@smallexample
Rcmd REMOVE -l /path/to/library pkg1 pkg2 ...
@end smallexample
@noindent
(Windows).

From a running @R{} process they can be removed by

@smallexample
> remove.packages(c("pkg1", "pkg2"), lib="/path/to/library")
@end smallexample

Finally, in most installations one can just remove the package directory
from the library.

@node Essential and useful other programs, Configuration on Unix, Add-on packages, Top
@appendix Essential and useful other programs

This appendix gives details of programs you will need to build @R{} on
Unix-like platforms, or which will be used by @R{} if found by
@code{./configure}.

@menu
* Essential programs::          
* Useful libraries and programs::  
@end menu

@node Essential programs, Useful libraries and programs, Essential and useful other programs, Essential and useful other programs
@section Essential programs

You need a means of compiling C and FORTRAN (see @ref{Using FORTRAN}).
Some add-on packages also need a C++ compiler.

You will need Perl version 5, available via
@uref{http://www.perl.com/CPAN/}, to build any of the on-line
documentation.

You will not be able to build the info files unless you have
@command{makeinfo} version 4 or later installed (and some Linux
distributions have 3.12).

The typeset documentation needs @command{tex} and @command{latex}, or
@command{pdftex} and @command{pdflatex}.

@menu
* Building on MacOS X::         
@end menu

@node Building on MacOS X,  , Essential programs, Essential programs
@subsection Building on MacOS X

You can build @R{} as a Unix application on MacOS X.  You will need the
DevTools, @command{f2c}
(@uref{ftp://netlib.bell-labs.com/netlib/f2c.tar}@footnote{compile with
@command{c++} or comment out @code{sigcatch(0)} in line 520 of
@file{main.c}}) and the @code{dlcompat} libraries@footnote{e.g.@:
@uref{http://fink.sourceforge.net/files/dlcompat-20010123.tar.gz}}.

You will also need to install a X sub-system or configure with
@option{--without-x}.


@node Useful libraries and programs,  , Essential programs, Essential and useful other programs
@section Useful libraries and programs

The command-line editing depends on the @code{readline} library
available from any GNU mirror: you will need a fairly recent version.

Use of @code{gzfile} connections needs @code{zlib} (version 1.1.3 or later).

The bitmapped graphics devices @code{jpeg()} and @code{png()} need the 
appropriate libraries installed: @code{jpeg} (version 6b or later) or
@code{libpng} (version 1.0.5 or later)
and @code{zlib} (version 1.1.3 or later) respectively.

The @code{bitmap} and @code{dev2bitmap} devices make use of ghostscript
(@uref{http://www.cs.wisc.edu/~ghost}).

@menu
* Tcl/Tk::                      
* Linear algebra::              
@end menu

@node Tcl/Tk, Linear algebra, Useful libraries and programs, Useful libraries and programs
@subsection Tcl/Tk

The @pkg{tcltk} package needs Tcl/Tk installed: the sources are
available at @uref{http://dev.scriptics.com/}.  To specify the locations
of the Tcl/Tk files you may need the configuration options

@table @option
@item --with-tcltk
use Tcl/Tk, or specify its library directory
@item --with-tcl-config=@var{TCL_CONFIG}
specify location of @file{tclConfig.sh}
@item --with-tk-config=@var{TK_CONFIG}
specify location of @file{tkConfig.sh}
@end table

@node Linear algebra,  , Tcl/Tk, Useful libraries and programs
@subsection Linear algebra

The linear algebra routines in @R{} can make use of enhanced BLAS (Basic
Linear Algebra Subprograms, @uref{http://www.netlib.org/blas/faq.html})
routines.  Some are compiler-system-specific (@code{libsunperf} on Sun
Sparc@footnote{Using the SunPro @command{cc} and @command{f95}
compilers}, @code{libessl} on IBM) but ATLAS
(@uref{http://www.netlib.org/atlas/}) is a `tuned' BLAS that runs on a
wide range of Unix-alike platforms.  If no more specific library is
found, a @code{libblas} library in the library path will be used.  You
can specify a specific BLAS library by the configuration option
@option{--with-blas} and not to use an external BLAS library by
@option{--without-blas}.

Note that the BLAS library will be used for several add-on packages as
well as for @R{} itself.  This means that it is better to use a shared
BLAS library, as most of a static library will be compiled into the @R{}
executable and each BLAS-using package.

You will need double-precision and double-complex versions of the BLAS,
but not single-precision nor complex routines.

Optimized versions of LAPACK are available, but no provision is made for
using them with @R{} as the likely performance gains are thought to be
small.

As with all libraries, you need to ensure that they and @R{} were
compiled with compatible compilers and flags.  For example, this means
that on Sun Sparc using the native compilers the flag @option{-dalign} is
needed so @code{libsunperf} can be used.

An ATLAS `tuned' BLAS can also be used on Windows: see
@file{src/gnuwin32/INSTALL} for how to enable this.


@node Configuration on Unix, New platforms, Essential and useful other programs, Top
@appendix Configuration on Unix

@menu
* Configuration options::       
* Configuration variables::     
* Using make::                  
* Using FORTRAN::               
* Compile and load flags::      
* Building the GNOME interface::  
@end menu

@node Configuration options, Configuration variables, Configuration on Unix, Configuration on Unix
@section Configuration options

@command{configure} has many options: running

@smallexample
./configure --help
@end smallexample

@noindent
will give a list.  Probably the most important ones not covered
elsewhere are (defaults in brackets)

@table @option
@item --with-x
use the X Window System
@item --x-includes=@var{DIR}
X include files are in @var{DIR}
@item --x-libraries=@var{DIR}
X library files are in @var{DIR}
@item --with-readline
use readline library (if available) [yes]
@item --enable-R-profiling
attempt to compile support for @code{Rprof()} [yes]
@item --enable-R-shlib
build R as a shared library [no]
@end table

@noindent
You can use @option{--without-foo} or @option{--disable-foo} for the
negatives.

You will want to use @option{--disable-R-profiling} if you are building
a profiled executable of @R{} (e.g. with @samp{-pg)}.

Flag @option{--enable-R-shlib} causes the make process to build R as a
shared library, typically called @file{libR.so}, and to take
considerably longer, so you probably only want this if you will be using
an application which embeds @R{}.

@node Configuration variables, Using make, Configuration options, Configuration on Unix
@section Configuration variables

@findex configure
If you need or want to set certain configure variables to something
other than their default, you can do that by either editing the file
@file{config.site} (which documents all the variables you might want to
set) or on the command line as

@smallexample
VAR="..." ./configure              @r{# Bourne shell compatibles}
(setenv VAR "..."; ./configure)	   @r{# C shell}
@end smallexample

@noindent
One common variable to change is @env{R_PAPERSIZE}, which defaults to
@samp{a4}, not @samp{letter}.

If you have libraries and header files, e.g., for GNU readline, in
non-system directories, use the variables @code{LIBS} (for libraries)
and @code{CPPFLAGS} (for header files), respectively, to specify these
locations.  These default to @file{/usr/local/lib} and
@file{/usr/local/include} to catch the most common cases.  If libraries
are still not found, then maybe your compiler/linker does not support
re-ordering of @option{-L} and @option{-l} flags (this has been reported
to be a problem on HP-UX with the native @command{cc}).  In this case,
use a different compiler (or a front end shell script which does the
re-ordering).

If you find you need to alter configure variables, it is worth noting
that some settings are cached in the file @file{config.cache}, and it is
a good idea to remove that file before re-configuring.

@node Using make, Using FORTRAN, Configuration variables, Configuration on Unix
@section Using make
@findex make

To compile @R{}, you will most likely find it easiest to use GNU
@command{make}.  On Solaris 2.6/7/8 in particular, you need a version of
GNU @command{make} different from 3.77; 3.79 works fine, as does the Sun
@command{make}.

To build in a separate directory you need a @command{make} that uses the
@code{VPATH} variable, for example GNU @command{make}, or Sun
@command{make} on Solaris 2.7/8 (but not earlier).

If you want to use a @command{make} by another name, for example if your
GNU @command{make} is called @code{gmake}, you need to set the
environment variable @env{MAKE} at configure time, for example

@findex configure
@smallexample
MAKE=gmake ./configure        @r{(sh, bash)}
env MAKE=gmake ./configure    @r{(csh)}
@end smallexample

@node Using FORTRAN, Compile and load flags, Using make, Configuration on Unix
@section Using FORTRAN
@cindex FORTRAN

To compile @R{}, you need a FORTRAN compiler or @command{f2c}, the
FORTRAN-to-C converter (@uref{http://www.netlib.org/f2c}).  The default
is to search for @command{g77}, @command{f77}, @command{xlf},
@command{cf77}, @command{cft77}, @command{pgf77}, @command{fl32},
@command{af77}, @command{fort77}, @command{f90}, @command{xlf90},
@command{pgf90}, @command{epcf90}, @command{f95}, @command{xlf95},
@command{lf9}5, @command{g95}, and @command{fc} (in that order), and
then for @command{f2c}, and use whichever is found first; if none is
found, @R{} cannot be compiled.  The search mechanism can be changed
using the @option{--with-g77}, @option{--with-f77}, and
@option{--with-f2c} command line options to @command{configure}.  If
your FORTRAN compiler is in a non-standard location, you should set the
environment variable @env{PATH} accordingly before running
@command{configure}.

If your FORTRAN libraries are in slightly peculiar places, you should
also look at @env{LD_LIBRARY_PATH} or your system's equivalent to make
sure that all libraries are on this path.

You must set whatever compilation flags (if any) are needed to ensure
that FORTRAN @code{integer} is equivalent to a C @code{int} pointer and
FORTRAN @code{double precision} is equivalent to a C @code{double}
pointer.  This is checked during the configuration process.

Some of the FORTRAN code makes use of @code{COMPLEX*16} variables, which
is a FORTRAN 90 extension.  This is checked for at configure
time@footnote{as well as its equivalence to the @code{Rcomplex}
structure defined in @file{R_ext/Complex.h}.}, but you may need to avoid
compiler flags@footnote{In particular, avoid @command{g77}'s
@option{-pedantic}, which gives confusing error messages.} asserting
FORTRAN 77 compliance.

For performance reasons@footnote{e.g., to use an optimized BLAS on
Sun/Sparc} you may want to choose a FORTRAN 90/95 compiler.

@node Compile and load flags, Building the GNOME interface, Using FORTRAN, Configuration on Unix
@section Compile and load flags

A wide range of flags can be set in the file @file{config.site} or via
environment variables.  We have already mentioned

@table @code
@item	CPPFLAGS
extra include flags
@item	LIBS
libraries and @option{-L/lib/path} flags
@end table

@noindent
and others include

@table @code
@item CFLAGS
debugging and optimization flags, C
@item MAIN_CFLAGS
ditto, for compiling the main program
@item SHLIB_CFLAGS
for shared libraries
@item FFLAGS
debugging and optimization flags, FORTRAN
@item MAIN_FFLAGS
ditto, for compiling the main program
@item SHLIB_FFLAGS
for shared libraries
@item MAIN_LDFLAGS
additional flags for the main link
@item SHLIB_LDFLAGS
additional flags for linking the shared libraries
@end table

@noindent
Library paths specified as @option{-L/lib/path} in @code{LIBS} are
collected together and prepended to @env{LD_LIBRARY_PATH} (or your
system's equivalent), so there should be no need for @option{-R} or
@option{-rpath} flags.

To compile a profiling version of @R{}, one might for example want to
use @samp{MAIN_CFLAGS=-pg}, @samp{MAIN_FFLAGS=-pg},
@samp{MAIN_LDFLAGS=-pg} on platforms where @samp{-pg} cannot be used
with position-independent code.

@strong{Beware:} it may be necessary to set @code{CFLAGS} and
@code{FFLAGS} in ways compatible with the libraries to be used: one
possible issue is the alignment of doubles, another is the way
structures are passed.


@node Building the GNOME interface,  , Compile and load flags, Configuration on Unix
@section Building the @acronym{GNOME} interface

This interface is experimental, incomplete and not currently being
developed.  It provides a console and a graphics device @code{(gtk()};
the @code{x11()} device can also be used).  Many of the `features' of
the console are currently stubs.

The @acronym{GNOME} interface for @R{} will only be built if you specify
it by running configure with the @option{--with-gnome} option.  For
example, you might run

@smallexample
./configure --with-gnome
@end smallexample

@noindent
but please check you have all the requirements first.  It is advisable
to have reasonably-up-to-date versions of the @code{gnome} and
@code{gtk+} libraries.  You can find the versions you have by

@smallexample
gnome-config --version
gtk-config --version
@end smallexample

@noindent
We know 1.0.10 and 1.2.3 suffice.  On Red Hat systems, you need the
following RPMs and their dependencies installed:

@smallexample
gnome-libs
gnome-libs-devel
gtk+
gtk+-devel
glib
glib-devel
@end smallexample

You will need also @code{libglade} 0.5 or later for correct behaviour.
For more information on @code{libglade} and to download the source, see
@uref{http://www.daa.com.au/~james/gnome/}.  The sources are also
available from the @acronym{GNOME} ftp site (@uref{ftp://ftp.gnome.org/}
and mirrors).  RPMs are in RedHat 6.1 and later.

Library @code{libglade} needs @code{libxml} 1.4 or later, the source for
which is available from the @acronym{GNOME} ftp site
(@uref{ftp://ftp.gnome.org/} and mirrors).

The locations of some of these libraries can be set as configuration
options, by (defaults in brackets)

@table @option
@item  --with-gnome
use @acronym{GNOME}, or specify its prefix [no]
@item  --with-gnome-includes=@var{DIR}
specify location of @acronym{GNOME} headers
@item  --with-gnome-libs=@var{DIR}
specify location of @acronym{GNOME} libs
@item  --with-libglade-config=@var{LIBGLADE_CONFIG}
specify location of @command{libglade-config}
@end table


@node New platforms, Function and variable index, Configuration on Unix, Top
@appendix New platforms

There are a number of sources of problems when installing R on a new
hardware/OS platform. These include

@strong{Floating Point Arithmetic}: @R{} supports the @acronym{POSIX},
SVID and @acronym{IEEE} models for floating point arithmetic.  The
@acronym{POSIX} and SVID models provide no problems.  The @acronym{IEEE}
model however can be a pain.  The problem is that there is no agreement
on how to set the signalling behaviour; Sun/Sparc, SGI/IRIX and ix86
Linux require no special action, FreeBSD requires a call to (the macro)
@code{fpsetmask(0)} and OSF1 requires that computation be done with a
@option{-ieee_with_inexact} flag etc.  On a new platform you must find
out the magic recipe and add some code to make it work.  This can often
be done via the file @file{config.site} which resides in the top level
directory.

Beware of using high levels of optimization, at least initially.  On
many compilers these reduce the degree of compliance to the
@acronym{IEEE} model. For example, using @code{-fast} on the Solaris
SunPro compilers causes @R{}'s @code{NaN} to be set incorrectly.

@strong{Shared Libraries}: There seems to be very little agreement
across platforms on what needs to be done to build shared libraries.
there are many different combinations of flags for the compilers and
loaders.  The technique we use is to first interrogate the X window
system about what it does (using @command{xmkmf}), and maybe override
this in situations where we know better.  This often works, but you may
have to manually override the results.  Scanning the @command{cc(1)} and
@command{ld(1)} manual entries usually reveals the correct incantation.
Once you know the recipe you can modify the file @file{config.site}
(following the instructions therein) so that the build will use these
options.

If you do manage to get @R{} running on a new platform please let us
know about it so we can modify the configuration procedures to include
that platform.

If you are having trouble getting @R{} to work on your platform please
feel free to get in touch to ask questions.  We've had a fair amount
of practice at porting R to new platforms @enddots{}


@node Function and variable index, Concept index, New platforms, Top
@unnumbered Function and variable index

@printindex vr

@node Concept index,  , Function and variable index, Top
@unnumbered Concept index

@printindex cp

@bye

@c Local Variables: ***
@c mode: TeXinfo ***
@c End: ***
