-
Notifications
You must be signed in to change notification settings - Fork 85
/
R-admin.texi
5975 lines (4931 loc) · 241 KB
/
R-admin.texi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\input texinfo
@c %**start of header
@setfilename R-admin.info
@settitle R Installation and Administration
@defcodeindex en
@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
@copying
This manual is for R, version @value{VERSION}.
@Rcopyright{2001}
@quotation
@permission{}
@end quotation
@end copying
@titlepage
@title R Installation and Administration
@subtitle Version @value{VERSION}
@author R Core Team
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@ifplaintext
@insertcopying
@end ifplaintext
@c @ifnothtml
@contents
@c @end ifnothtml
@ifnottex
@node Top
@top R Installation and Administration
This is a guide to installation and administration for R.
@insertcopying
@end ifnottex
@node Obtaining R
@chapter Obtaining R
@cindex Obtaining R
Sources, binaries and documentation for @R{} can be obtained via
@acronym{CRAN}, the ``Comprehensive R Archive Network'' whose current
members are listed at @uref{https://CRAN.R-project.org/mirrors.html}.
@node Getting and unpacking the sources
@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}.tar.gz} file, and unpack it with
@example
tar -xf R-@var{x}.@var{y}.@var{z}.tar.gz
@end example
@noindent
on systems that have a suitable@footnote{e.g.@: @acronym{GNU}
@command{tar} version 1.15 or later, or that from the @samp{libarchive}
(as used on macOS) or `@I{Heirloom Toolchest}' distributions.}
@command{tar} installed. On other systems you need to have the
@command{gzip} program installed, when you can use
@example
gzip -dc R-@var{x}.@var{y}.@var{z}.tar.gz | tar -xf -
@end example
The pathname of the directory into which the sources are unpacked should
not contain spaces, as most @command{make} programs (and specifically
@acronym{GNU} @command{make}) do not expect spaces.
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). Keep this
setting of @code{umask} whilst building and installing.
If you use a fairly recent @acronym{GNU} version of @command{tar} and do
this as a root account (which on Windows includes accounts with
administrator privileges) you may see many warnings about changing
ownership. In which case you can use
@example
tar --no-same-owner -xf R-@var{x}.@var{y}.@var{z}.tar.gz
@end example
@noindent
and perhaps also include the option @option{--no-same-permissions}.
@enindex TAR_OPTIONS
(These options can also be set in the @env{TAR_OPTIONS} environment
variable: if more than one option is included they should be separated
by spaces.)
@node Getting patched and development versions
@section Getting patched and development versions
A patched version of the current release, @samp{r-patched}, and the
current development version, @samp{r-devel}, are available as daily
tarballs and via access to the @R{} Subversion repository. (For the two
weeks prior to the release of a minor (4.x.0) version, @samp{r-patched}
tarballs may refer to beta/release candidates of the upcoming release,
the patched version of the current release being available via
Subversion.)
The tarballs are available from
@uref{https://cran.r-project.org/src/base-prerelease/}. Download
@file{R-patched.tar.gz} or @file{R-devel.tar.gz} (or the @file{.tar.bz2}
versions) and unpack as described in the previous section. They are
built in exactly the same way and on the same platform as distributions
of @R{} releases. Notice, that you probably want to use the CRAN master
site for this, due to propagation delays. An
alternative source of daily snapshots is maintained at @uref{https://stat.ethz.ch/R/daily/}.
@c Keep this single-item menu to avoid a spurious warning about
@c an unreferenced node when making info with Texinfo 6.8 and 7.0.
@menu
* Using Subversion and rsync::
@end menu
@node Using Subversion and rsync
@subsection Using Subversion and @I{rsync}
@cindex Subversion
Sources are also available via @uref{https://svn.R-project.org/R/}, the
R Subversion repository. If you have a Subversion client (see
@uref{https://subversion.apache.org/}), you can check out and update the
current @samp{r-devel} from
@uref{https://svn.r-project.org/R/trunk/} and the current
@samp{r-patched} from
@samp{https://svn.r-project.org/@/R/@/branches/@/R-@var{x}-@var{y}-branch/}
(where @var{x} and @var{y} are the major and minor number of the current
released version of R). E.g., use
@example
svn checkout https://svn.r-project.org/R/trunk/ @var{path}
@end example
@noindent
to check out @samp{r-devel} into directory @var{path} (which will be
created if necessary). The alpha, beta and RC versions of an upcoming
@var{x.y.0} release are available from
@samp{https://svn.r-project.org/R/branches/R-@var{x}-@var{y}-branch/} in
the four-week period prior to the release.
Note that @samp{https:} is required@footnote{for some Subversion clients
@samp{http:} may appear to work, but requires continual redirection.},
and that the @abbr{SSL} certificate for the Subversion server of the @R{}
project should be recognized as from a trusted source.
Note that retrieving the sources by e.g.@: @command{wget -r} or
@command{svn export} from that URL will not work (and will give a error
early in the @command{make} process): the Subversion information is
needed to build @R{}.
The Subversion repository does not contain the current sources for the
recommended packages, which can be obtained by @command{rsync} or
downloaded from @acronym{CRAN}. To use @code{rsync} to install the
appropriate sources for the recommended packages, run
@code{./tools/rsync-recommended} from the top-level directory of the
@R{} sources.
If downloading manually from @acronym{CRAN}, do ensure that you have the
correct versions of the recommended packages: if the number in the file
@file{VERSION} is @samp{@var{x}.@var{y}.@var{z}} you need to download
the contents of @samp{https://CRAN.R-project.org/src/contrib/@var{dir}},
where @var{dir} is @samp{@var{x}.@var{y}.@var{z}/Recommended} for
r-devel or @file{@var{x}.@var{y}-patched/Recommended} for r-patched,
respectively, to directory @file{src/library/Recommended} in the sources
you have unpacked. After downloading manually you need to execute
@command{tools/link-recommended} from the top level of the sources to
make the requisite links in @file{src/library/Recommended}. A suitable
incantation from the top level of the @R{} sources using @command{wget}
might be (for the correct value of @file{@var{dir}})
@example
wget -r -l1 --no-parent -A\*.gz -nd -P src/library/Recommended \
https://CRAN.R-project.org/src/contrib/@var{dir}
./tools/link-recommended
@end example
@node Installing R under Unix-alikes
@chapter Installing R under Unix-alikes
@cindex Installing under Unix-alikes
@R{} will configure and build under most common Unix and Unix-alike
platforms including @samp{@var{cpu}-*-linux-gnu} for the
@cputype{alpha}, @cputype{arm64} (also known as @cputype{aarch64},
@cputype{ix86}, @cputype{mips}, @cputype{mipsel}#, @cputype{ppc64},
@cputype{riscv64}, @cputype{s390x}, @cputype{sparc64}, and
@cputype{x86_64} @acronym{CPU}s,
@c (see e.g.@: @uref{https://buildd.debian.org/build.php?&pkg=r-base}),
@c Actually, see https://packages.debian.org/unstable/math/r-base-core as
@c the build daemon is not used for all platforms; note also that Debian
@c has x86_64 <=> amd64, ix86 <=> i386.
@samp{aarch64-@/apple-@/darwin}@footnote{aka `Apple Silicon', known to
some as @samp{arm64-@/apple-@/darwin}.} and
@samp{x86_64-@/apple-@/darwin} as well as perhaps (it is
tested less frequently on these platforms) @samp{x86_64-@/*-@/freebsd},
@samp{x86_64-@/*-@/openbsd} and @samp{powerpc-@/ibm-@/aix6*}
Only 64-bit platforms are tested regularly, and @command{configure}
will warn if it encounters a 32-bit one.
@cindex Linux
@cindex macOS
In addition, binary distributions are available for some common Linux
distributions (see the @acronym{FAQ} for current details) and for
macOS. These are installed in platform-specific ways, so for the rest
of this chapter we consider only building from the sources.
Cross-building is not possible: installing @R{} builds a minimal version
of @R{} and then runs many @R{} scripts to complete the build.
@node Simple compilation
@section Simple compilation
First review the essential and useful tools and libraries in
@ref{Essential and useful other programs under a Unix-alike}, and install
those you
@enindex TMPDIR
want or need. Ensure that either the environment variable @env{TMPDIR}
is either unset (and @file{/tmp} exists and can be written in and
scripts can be executed from) or points to the absolute path to a valid
temporary directory (one from which execution of scripts is allowed)
which does not contain spaces.
@findex R_HOME
Choose a directory 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 @var{R_HOME}. Untar the source code. This should create
directories @file{src}, @file{doc}, and several more under a top-level
directory: change to that top-level directory (At this point North
American readers should consult @ref{Setting paper size}.) Issue the
following commands:
@findex configure
@example
./configure
make
@end example
@noindent
(See @ref{Using make} if your make is not called @samp{make}.) Users of
Debian-based 64-bit systems@footnote{which use @file{lib} rather than
@file{lib64} for their primary 64-bit library directories: attempts are
made to detect such systems.} may need
@example
./configure LIBnn=lib
make
@end example
Then check the built system works correctly by
@example
make check
@end example
@noindent
Failures are not necessarily problems as they might be caused by missing
functionality, but you should look carefully at any reported
discrepancies. (Some non-fatal errors are expected in locales that do
not support Latin-1, in particular in true @code{C} locales and
non-UTF-8 non-Western-European locales.) A failure in
@file{tests/ok-errors.R} may indicate inadequate resource limits
(@pxref{Running R}).
More comprehensive testing can be done by
@example
make check-devel
@end example
@noindent
or
@example
make check-all
@end example
@noindent
see @ref{Testing a Unix-alike Installation}
for the possibilities of doing this in parallel. Note that these checks
are only run completely if the recommended packages are installed. If
you have a local CRAN mirror, these checks can be speeded up by either
setting environment variable @env{R_CRAN_WEB} to its URL, or having a
file @file{.R/repositories} specifying it (see @code{?setRepositories}).
@command{make check-devel} checks the included packages' @file{tests}
directories. For @pkg{grDevices} more complete checks will be run if
the environment variable @env{R_GRDEVICES_COMPARE_PS_PDF} is set: those
checks are skipped on platforms using @code{musl} such as Alpine Linux, and
it knows about differences from transliterations in macOS 14 and later.
Parallel make is supported for building @R{} but not for the
@samp{check} targets (as the output is likely to be unreadably
interleaved, although where supported@footnote{not by the version
supplied by macOS.} GNU make's @option{-O} may help).
If the @command{configure} and @command{make} commands execute
successfully, a shell-script front-end called @file{R} will be created
and copied to @file{@var{R_HOME}/bin}. You can link or 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{@var{TOP_SRCDIR}}). To build in
@file{@var{BUILDDIR}}, run
@findex configure
@example
cd @var{BUILDDIR}
@var{TOP_SRCDIR}/configure
make
@end example
@noindent
and so on, as described further below. This has the advantage of always
keeping your source tree clean and is particularly recommended when you
work with a version of @R{} from Subversion. (You may need
@acronym{GNU} @command{make} to allow this, and you will need no spaces
in the path to the build directory. It is unlikely to work if the
source directory has previously been used for a build.)
There are many settings which can be customized when building @R{} and
most are described in the file @file{config.site} in the top-level
source directory. This can be edited, but for an installation using
@file{@var{BUILDDIR}} it is better to put the changed settings in a
newly-created file @file{config.site} in the build directory.
@c For those obtaining @R{} @emph{via} Subversion, one additional step is
@c necessary:
@c @cindex Vignettes
@c @cindex Subversion
@c @example
@c make vignettes
@c @end example
@c @noindent
@c which makes the @pkg{grid} vignettes (which are contained in the
@c tarballs): it make take several minutes.
Now @code{rehash} if necessary, type @kbd{R}, and read the @R{} manuals
and the @R{} @acronym{FAQ} (files @file{FAQ} or
@file{doc/manual/R-FAQ.html}, or
@uref{https://CRAN.R-project.org/doc/FAQ/R-FAQ.html} which always
has the version for the latest release of @R{}).
Note: if you already have @R{} installed, check that where you installed
@R{} replaces or comes earlier in your path than the previous
installation. Some systems are set up to have @file{/usr/bin} (the
standard place for a system installation) ahead of @file{/usr/local/bin}
(the default place for installation of @R{}) in their default path, and
some do not have @file{/usr/local/bin} on the default path.
@node Help options
@section Help options
@R{} by default provides help pages as plain text displayed in a pager,
with the options (see the help for @code{help}) of displaying help as
HTML or PDF.
By default @HTML{} help pages are created when needed rather than being
built at install time.
If you need to disable the server and want @HTML{} help, there is the
option to build @HTML{} pages when packages are installed
(including those installed with @R{}). This is enabled by the
@command{configure} option @option{--enable-prebuilt-html}. Whether
@command{R CMD INSTALL} (and hence @code{install.packages}) pre-builds
@HTML{} pages is determined by looking at the @R{} installation and is
reported by @command{R CMD INSTALL --help}: it can be overridden by
specifying one of the @command{INSTALL} options @option{--html} or
@option{--no-html}.
The server is disabled by setting the environment variable
@enindex R_DISABLE_HTTPD
@env{R_DISABLE_HTTPD} to a non-empty value, either before @R{} is
started or within the @R{} session before @HTML{} help (including
@code{help.start}) is used. It is also possible that system security
measures will prevent the server from being started, for example if the
loopback interface has been disabled. See
@code{?tools::startDynamicHelp} for more details.
@node Making the manuals
@section Making the manuals
@cindex Manuals
There is a set of manuals that can be built from the sources,
@table @samp
@item fullrefman
Printed versions of all the help pages for base and recommended packages
(around 3900 pages).
@item refman
Printed versions of the help pages for selected base packages (around
2300 pages)
@item R-FAQ
R @acronym{FAQ}
@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-ints
``R Internals''.
@item R-lang
``The R Language Definition''.
@end table
@noindent
To make these (with @samp{fullrefman} rather than @samp{refman}), use
@c FIXME: mention HTML versions built by default from make docs
@example
make pdf @r{to create PDF versions}
make info @r{to create info files (not @samp{refman} nor @samp{fullrefman}).}
@end example
@c texi2any from Feb 2016.
You will not be able to build any of these unless you have
@command{texi2any} version 6.1 or later installed, and for PDF you must
have @command{texi2dvi} and @file{texinfo.tex} installed (which are part
of the @acronym{GNU} @I{Texinfo} distribution but are, especially
@file{texinfo.tex}, often made part of the @TeX{} package @pkg{texinfo} in
re-distributions). The path to @command{texi2any} can be set by macro
@samp{TEXI2ANY} in @file{config.site}. NB: @command{texi2any} requires
@command{perl}.
The PDF versions can be viewed using any recent PDF viewer: they have
hyperlinks that can be followed. The info files are suitable for
reading online with Emacs or the standalone @acronym{GNU} @command{info}
program. The PDF versions will be created using the paper size selected
at configuration (default ISO a4): this can be overridden by setting
@env{R_PAPERSIZE}
@enindex R_PAPERSIZE
on the @command{make} command line, or setting @env{R_PAPERSIZE} in the
environment and using @command{make -e}. (If re-making the manuals for
a different paper size, you should first delete the file
@file{doc/manual/version.texi}. The usual value for North America would
be @samp{letter}.)
There are some issues with making the PDF reference manual,
@file{fullrefman.pdf} or @file{refman.pdf}. The help files contain both
non-ASCII characters (e.g.@: in @file{text.Rd}) and upright quotes,
neither of which are contained in the standard @LaTeX{} Computer Modern
fonts. We have provided the following alternatives:
@table @code
@item times
(The default.) Using standard PostScript fonts, Times Roman, Helvetica
and Courier. This works well both for on-screen viewing and for
printing. One disadvantage is that the Usage and Examples sections may
come out rather wide: this can be overcome by using @emph{in addition}
either of the options @code{inconsolata} (on a Unix-alike only if found
by @command{configure}) or @code{beramono}, which replace the Courier
monospaced font by @I{Inconsolata} or @I{Bera Sans Mono} respectively. (You
will need the @LaTeX{} package @pkg{inconsolata}@footnote{Instructions
on how to install the latest version are at
@uref{https://www.ctan.org/tex-archive/fonts/inconsolata/}.} or
@pkg{bera} installed.)
Note that in most @LaTeX{} installations this will not actually use the
standard fonts for PDF, but rather embed the URW clones @I{NimbusRom},
@I{NimbusSans} and (for Courier, if used) @I{NimbusMon}.
This needs @LaTeX{} packages @pkg{times}, @pkg{helvetic} and (if used)
@pkg{courier} installed.
@item lm
Using the @emph{Latin Modern} fonts. These are not often installed as
part of a @TeX{} distribution, but can obtained from
@uref{https://www.ctan.org/tex-archive/fonts/ps-type1/lm/} and
mirrors. This uses fonts rather similar to Computer Modern, but is not
so good on-screen as @code{times}.
@c @item cm-super
@c Using type-1 versions of the Computer Modern fonts by Vladimir Volovich.
@c This is a large installation, obtainable from
@c @uref{https://www.ctan.org/tex-archive/fonts/ps-type1/cm-super/}
@c and its mirrors. These type-1 fonts have poor hinting and so are
@c nowhere near as readable on-screen as the other three options.
@end table
The default can be overridden by setting the environment variable
@enindex R_RD4PDF
@env{R_RD4PDF}. (On Unix-alikes, this will be picked up at install time
and stored in @file{etc/Renviron}, but can still be overridden when the
manuals are built, using @command{make -e}.) The usual@footnote{on a
Unix-alike, @samp{inconsolata} is omitted if not found by
@command{configure}.} default value for @env{R_RD4PDF} is
@samp{times,inconsolata,hyper}: omit @samp{inconsolata} if you do not have
@LaTeX{} package @pkg{inconsolata} installed.
@samp{hyper} is always enabled (with a fallback if @LaTeX{} package
@pkg{hyperref} is not installed).
Further options, e.g@: for @pkg{hyperref}, can be included in a file
@file{Rd.cfg} somewhere on your @LaTeX{} search path. For example, if
you prefer to hyperlink the text and not the page number in the table of
contents use
@example
\ifthenelse@{\boolean@{Rd@@use@@hyper@}@}@{\hypersetup@{linktoc=section@}@}@{@}
@end example
@noindent
or
@example
\ifthenelse@{\boolean@{Rd@@use@@hyper@}@}@{\hypersetup@{linktoc=all@}@}@{@}
@end example
@noindent
to hyperlink both text and page number.
Any generated PDF manuals can be compacted by
@example
make compact-pdf
@end example
@noindent
provided @command{qpdf} and @command{gs} are available (see
@code{?tools::compactPDF} for how to specify them if not on the path).
E-book versions of most of the manuals in one or both of @file{.epub} and
@file{.mobi} formats can be made by running in @file{doc/manual} one of
@example
make ebooks
make epub
make mobi
@end example
@noindent
This requires @command{ebook-convert} from
@uref{https://calibre-ebook.com/download, @command{Calibre}}, or from
most Linux distributions. If necessary the path to
@command{ebook-convert} can be set as make macro @env{EBOOK} by editing
@file{doc/manual/Makefile} (which contains a commented value suitable
for macOS) or using @command{make -e}.
@node Installation
@section Installation
@cindex Installation
To ensure that the installed tree is usable by the right group of users,
set @code{umask} appropriately (perhaps to @samp{022}) before unpacking
the sources and throughout the build process.
After
@findex configure
@example
./configure
make
make check
@end example
@noindent
(or, when building outside the source,
@code{@var{TOP_SRCDIR}/configure}, etc) have been completed
successfully, you can install the complete @R{} tree to your system by
typing
@example
make install
@end example
@noindent
A parallel make can be used (but run @command{make} before @command{make
install}). Those using GNU @command{make} 4.0 or later may want to use
@command{make -j @var{n} -O} to avoid interleaving of output.
This will install to the following directories:
@table @asis
@item @file{@var{prefix}/bin} or @file{@var{bindir}}
the front-end shell script and other scripts and executables
@item @file{@var{prefix}/man/man1} or @file{@var{mandir}/man1}
the man page
@item @file{@var{prefix}/@var{LIBnn}/R} or @file{@var{libdir}/R}
all the rest (libraries, on-line help system, @dots{}). Here
@var{LIBnn} is usually @samp{lib}, but may be @samp{lib64} on some
64-bit Linux systems. This is known as the @R{} home directory.
@end table
@noindent
where @var{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
@example
./configure --prefix=/where/you/want/R/to/go
@end example
@noindent
where the value should be an absolute path. This causes @command{make
install} to install the @R{} script 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}. The installation may need
to be done by the owner of @file{@var{prefix}}, often a root account.
There is the option of using @command{make install-strip} (@pxref{Debugging
Symbols}).
You can install into another directory tree by using
@example
make prefix=/path/to/here install
@end example
@noindent
at least with @acronym{GNU} @command{make} (but not some other Unix
makes).
More precise control is available at configure time via options: see
@command{configure --help} for details. (However, most of the `Fine
tuning of the installation directories' options are not used by @R{}.)
Configure options @option{--bindir} and @option{--mandir} are supported
and govern where a copy of the @command{R} script and the @command{man}
page are installed.
The configure option @option{--libdir} controls where the main @R{}
files are installed: the default is @samp{@var{eprefix}/@var{LIBnn}},
where @var{eprefix} is the prefix used for installing
architecture-dependent files, defaults to @var{prefix}, and can be set
via the configure option @option{--exec-prefix}.
Each of @code{bindir}, @code{mandir} and @code{libdir} can also be
specified on the @command{make install} command line (at least for
@acronym{GNU} @command{make}).
The @command{configure} or @command{make} variables @code{rdocdir} and
@code{rsharedir} can be used to install the system-independent
@file{doc} and @file{share} directories to somewhere other than
@code{libdir}. The C header files can be installed to the value of
@code{rincludedir}: note that as the headers are not installed into a
subdirectory you probably want something like
@code{rincludedir=/usr/local/include/R-@value{VERSIONno}}.
If you want the @R{} home to be something other than
@file{@var{libdir}/R}, use @option{rhome}: for example
@example
make install rhome=/usr/local/lib64/R-@value{VERSIONno}
@end example
@noindent
will use a version-specific @R{} home on a non-Debian Linux 64-bit
system.
If you have made @R{} as a shared/static library you can install it in
your system's library directory by
@example
make prefix=/path/to/here install-libR
@end example
@noindent
where @code{prefix} is optional, and @code{libdir} will give more
precise control.@footnote{This will be needed if more than one
sub-architecture is to be installed.} However, you should not install
to a directory mentioned in @env{LDPATHS} (e.g.@:
@file{/usr/local/lib64}) if you intend to work with multiple versions of
@R{}, since that directory may be given precedence over the @file{lib}
directory of other @R{} installations.
@example
make install-strip
@end example
@noindent
will install stripped executables, and on platforms where this is
supported, stripped libraries in directories @file{lib} and
@file{modules} and in the standard packages.
Note that installing @R{} into a directory whose path contains spaces is
not supported, and some aspects (such as installing source packages)
will not work.
@c The main problem is the Makefile include in etc/Makeconf
@cindex Manuals, installing
To install info and PDF versions of the manuals, use one or both of
@example
make install-info
make install-pdf
@end example
@noindent
Once again, it is optional to specify @code{prefix}, @code{libdir} or
@code{rhome} (the PDF manuals are installed under the @R{} home
directory).
More precise control is possible. For info, the setting used is that of
@code{infodir} (default @file{@var{prefix}/info}, set by configure
option @option{--infodir}). The PDF files are installed into the @R{}
@file{doc} tree, set by the @command{make} variable @code{rdocdir}.
A staged installation is possible, that it is installing @R{} into a
temporary directory in order to move the installed tree to its final
destination. In this case @code{prefix} (and so on) should reflect the
@enindex DESTDIR
final destination, and @env{DESTDIR} should be used: see
@uref{https://www.gnu.org/prep/standards/html_node/DESTDIR.html}.
You can optionally install the run-time tests that are part of
@command{make check-all} by
@example
make install-tests
@end example
@noindent
which populates a @file{tests} directory in the installation.
@node Uninstallation
@section @I{Uninstallation}
You can uninstall @R{} by
@example
make uninstall
@end example
@noindent
optionally specifying @code{prefix} etc in the same way as specified for
installation.
This will also uninstall any installed manuals. There are specific
targets to uninstall info and PDF manuals in file
@file{doc/manual/Makefile}.
Target @code{uninstall-tests} will uninstall any installed tests, as
well as removing the directory @file{tests} containing the test results.
An installed shared/static @code{libR} can be uninstalled by
@example
make prefix=/path/to/here uninstall-libR
@end example
@node Sub-architectures
@section Sub-architectures
Now 32-bit builds are unsupported, this section is only of historical
interest, although in future the mechanisms could be used for different
CPU types on the same OS (e.g. @cputype{x86_64} and @cputype{aarch64}).
Some platforms can support closely related builds of @R{} which can
share all but the executables and dynamic objects. Examples include
builds under Linux for different @acronym{CPU}s or 32- and 64-bit
builds.
@R{} supports the idea of architecture-specific builds, specified by
adding @samp{r_arch=@var{name}} to the @command{configure} line. Here
@var{name} can be anything non-empty, and is used to name subdirectories
of @file{lib}, @file{etc}, @file{include} and the package @file{libs}
subdirectories. Example names from other software are the use of
@file{sparcv9} on @I{Sparc} Solaris and @file{32} by @command{gcc} on
@cputype{x86_64} Linux.
If you have two or more such builds you can install them over each other
(and for 32/64-bit builds on one architecture, one build can be done
without @samp{r_arch}). The space savings can be considerable: on
@cputype{x86_64} Linux a basic install (without debugging symbols) took
74Mb, and adding a 32-bit build added 6Mb. If you have installed
multiple builds you can select which build to run by
@example
R --arch=@var{name}
@end example
@noindent
and just running @samp{R} will run the last build that was installed.
@code{R CMD INSTALL} will detect if more than one build is installed and
try to install packages with the appropriate library objects for each.
This will not be done if the package has an executable @code{configure}
script or a @file{src/Makefile} file. In such cases you can install for
extra builds by
@example
R --arch=@var{name} CMD INSTALL --libs-only @var{pkg1} @var{pkg2} @dots{}
@end example
If you want to mix sub-architectures compiled on different platforms
(for example @cputype{x86_64} Linux and @cputype{i686} Linux), it is
wise to use explicit names for each, and you may also need to set
@option{libdir} to ensure that they install into the same place.
When sub-architectures are used the version of @command{Rscript} in
e.g.@: @file{/usr/bin} will be the last installed, but
architecture-specific versions will be available in e.g.@:
@file{/usr/lib64/R/bin/exec$@{@var{R_ARCH}@}}. Normally all installed
architectures will run on the platform so the architecture of
@command{Rscript} itself does not matter. The executable
@command{Rscript} will run the @command{R} script, and at that time the
@enindex R_ARCH
setting of the @env{R_ARCH} environment variable determines the
architecture which is run.
When running post-install tests with sub-architectures, use
@example
R --arch=@var{name} CMD make check[-devel|all]
@end example
@noindent
to select a sub-architecture to check.
Sub-architectures were also used on Windows, but by selecting executables
within the appropriate @file{bin} directory such as
@file{@var{R_HOME}/bin/x64}. As from @R{} 4.2.0 only the @samp{x64}
subdirectory is used.
@node Other Options
@section Other Options
There are many other installation options, most of which are listed by
@command{configure --help}. Almost all of those not listed elsewhere in
this manual are either standard @command{autoconf} options not relevant
to @R{} or intended for specialist uses by the @R{} developers.
One that may be useful when working on @R{} itself is the option
@option{--disable-byte-compiled-packages}, which ensures that the base
and recommended packages are not byte-compiled. (Alternatively the
(make or environment) variable @env{R_NO_BASE_COMPILE} can be set to a
non-empty value for the duration of the build.)
Option @option{--with-internal-tzcode} makes use of @R{}'s own code and
copy of the @abbr{IANA} database for managing timezones. This will be
preferred where there are issues with the system implementation, usually
involving times after 2037 or before 1916. An alternative time-zone
directory@footnote{How to prepare such a directory is described in file
@file{src/extra/tzone/Notes} in the @R{} sources.} can be used, pointed
to by environment variable @env{TZDIR}: this should contain files such
as @file{Europe/London}. On all tested OSes the system timezone was
deduced correctly, but if necessary it can be set as the value of
environment variable @env{TZ}.
Options @option{--with-internal-iswxxxxx},
@option{--with-internal-towlower} and @option{--with-internal-wcwidth}
control the replacement of the system wide-character classification
(such as @code{iswprint}), case-changing (@code{wctrans}) and width
(@code{wcwidth} and @code{wcswidth}) functions by ones contained in the
@R{} sources. Replacement of the classification functions has been done
for many years on macOS and @abbr{AIX} (and Windows): option
@option{--with-internal-iswxxxxx} allows this to be suppressed on those
platforms or used on others. Replacing the case-changing functions is
the default on macOS and Windows. Replacement of the width functions
has also been done for many years and remains the default. These
options will only matter to those working with non-ASCII character data,
especially in languages written in a non-Western script@footnote{But on
Windows problems have been seen with case-changing functions on accented
Latin-1 characters.} (which includes `symbols' such as emoji). Note
that one of those @code{iswxxxxx} is @code{iswprint} which is used to
decide whether to output a character as a glyph or as a
@samp{\U@{xxxxxx@}} escape---for example, try @samp{"\U1f600"}, an
emoji. The width functions are of most importance in East Asian locale:
their values differ between such locales. (Replacing the system
functions provides a degree of platform-independence (including to OS
updates) but replaces it with a dependence on the @R{} version.)
@node Debugging Symbols
@subsection Debugging Symbols
By default, @command{configure} adds a flag (usually @option{-g}) to the
compilation flags for C, Fortran and C++ sources. This will slow down
compilation and increase object sizes of both @R{} and packages, so it
may be a good idea to change those flags (set @samp{CFLAGS} etc in
@file{config.site} before configuring, or edit files @file{Makeconf}
and @file{etc/Makeconf} between running @command{configure} and
@command{make}).
Having debugging symbols available is useful both when running @R{} under a
debugger (e.g., @command{R -d gdb}) and when using sanitizers and
@command{valgrind}, all things intended for experts.
Debugging symbols (and some others) can be `stripped' on installation by
using
@example
make install-strip
@end example
@noindent
How well this is supported depends on the platform: it works best on
those using GNU @code{binutils}. On @cputype{x86_64} Linux a typical
reduction in overall size was from 92MB to 66MB. On macOS debugging
symbols are not by default included in @file{.dylib} and @file{.so}
files, so there is negligible difference.
@node OpenMP Support
@subsection @abbr{OpenMP} Support
By default @command{configure} searches for suitable flags@footnote{for
example, @option{-fopenmp}, @option{-fiopenmp}, @option{-xopenmp} or
@option{-qopenmp}. This includes for @command{clang} and the Intel and
Oracle compilers.} for @abbr{OpenMP} support for the C, C++ (default standard)
and Fortran compilers.
Only the C result is currently used for @R{} itself, and only if
@code{MAIN_LD}/@code{DYLIB_LD} were not specified. This can be
overridden by specifying
@example
R_OPENMP_CFLAGS
@end example
Use for packages has similar restrictions (involving @code{SHLIB_LD} and
similar: note that as Fortran code is by default linked by the C (or
C++) compiler, both need to support @abbr{OpenMP}) and can be overridden by
specifying some of
@example
SHLIB_OPENMP_CFLAGS
SHLIB_OPENMP_CXXFLAGS
SHLIB_OPENMP_FFLAGS
@end example
@noindent
Setting these to an empty value will disable @abbr{OpenMP} for that compiler
(and configuring with @option{--disable-openmp} will disable all
detection@footnote{This does not necessarily disable @emph{use} of
@abbr{OpenMP} -- the @command{configure} code allows for platforms where @abbr{OpenMP}
is used without a flag. For the @command{flang} compiler in late 2017,
the Fortran runtime always used @abbr{OpenMP}.} of @abbr{OpenMP}). The
@command{configure} detection test is to compile and link a standalone
@abbr{OpenMP} program, which is not the same as compiling a shared object and
loading it into the C program of @R{}'s executable. Note that
overridden values are not tested.
@node C++ Support
@subsection C++ Support
C++ is not used by @R{} itself, but support is provided for installing
packages with C++ code via @command{make} macros defined in file
@file{etc/Makeconf} (and with explanations in file @file{config.site}):
@example
CXX
CXXFLAGS
CXXPICFLAGS
CXXSTD
CXX11
CXX11STD
CXX11FLAGS
CXX11PICFLAGS
CXX14
CXX14STD
CXX14FLAGS
CXX14PICFLAGS
CXX17