Skip to content

Commit

Permalink
Support for more languages.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@40010 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
hornik committed Nov 26, 2006
1 parent 8c694ef commit cc84426
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 43 deletions.
86 changes: 48 additions & 38 deletions doc/manual/R-exts.texi
Expand Up @@ -500,25 +500,31 @@ documented (@pxref{Package name spaces}).
The @file{R} and @file{man} subdirectories may contain OS-specific
subdirectories named @file{unix} or @file{windows}.

The C, C++, or FORTRAN@footnote{Note that Ratfor is not supported. If
you have Ratfor source code, you need to convert it to FORTRAN. Only
FORTRAN-77 (which we write in upper case) is supported on all platforms,
but some also support Fortran-95 (for which we use title case). If you
want to ship Ratfor source files, please do so in a subdirectory of
@file{src} and not in the main subdirectory.} source files for the
compiled code are in @file{src}, plus optionally file @file{Makevars} or
@file{Makefile}. When a package is installed using @code{R CMD
INSTALL}, Make is used to control compilation and linking into a shared
object for loading into @R{}. There are default variables and rules for
this (determined when @R{} is configured and recorded in
@file{@var{R_HOME}/etc/Makeconf}). These rules can be tweaked by
setting macros in a file @file{src/Makevars} (@pxref{Using Makevars}).
Note that this mechanism should be general enough to eliminate the need
for a package-specific @file{Makefile}. If such a file is to be
distributed, considerable care is needed to make it general enough to
work on all @R{} platforms. In addition, it should have a target
@samp{clean} which removes all files generated by Make. If necessary,
platform-specific files can be used, for example @file{Makevars.win} or
The sources and headers for the compiled code are in @file{src}, plus
optionally file @file{Makevars} or @file{Makefile}. When a package is
installed using @code{R CMD INSTALL}, Make is used to control
compilation and linking into a shared object for loading into @R{}.
There are default variables and rules for this (determined when @R{} is
configured and recorded in @file{@var{R_HOME}/etc/Makeconf}), providing
support for C, C++, FORTRAN 77, Fortran 9x@footnote{Note that Ratfor is
not supported. If you have Ratfor source code, you need to convert it
to FORTRAN. Only FORTRAN-77 (which we write in upper case) is supported
on all platforms, but some also support Fortran-95 (for which we use
title case). If you want to ship Ratfor source files, please do so in a
subdirectory of @file{src} and not in the main subdirectory.}, Objective
C and Objective C++ with associated extensions @file{.c}, @file{.cc} or
@file{.cpp} or @file{.C}, @file{.f}, @file{.f90} or @file{.f95},
@file{.m}, and @file{.mm} or @file{.M}, respectively. We recommend
using @file{.h} for headers, also for C++@footnote{Using @file{.hpp},
although somewhat popular, is not guaranteed to be portable.} or Fortran
9x include files. The default rules can be tweaked by setting macros in
a file @file{src/Makevars} (@pxref{Using Makevars}). Note that this
mechanism should be general enough to eliminate the need for a
package-specific @file{Makefile}. If such a file is to be distributed,
considerable care is needed to make it general enough to work on all
@R{} platforms. In addition, it should have a target @samp{clean} which
removes all files generated by Make. If necessary, platform-specific
files can be used, for example @file{Makevars.win} or
@file{Makefile.win} on Windows take precedence over @file{Makevars} or
@file{Makefile}.

Expand Down Expand Up @@ -1043,7 +1049,7 @@ or by setting the environment variables @code{ODBC_INCLUDE} and

@R{} currently does not distinguish between FORTRAN 77 and Fortran 90/95
code, and assumes all FORTRAN comes in source files with extension
@code{.f}. Commercial Unix systems tyically use a F95 compiler, but
@file{.f}. Commercial Unix systems tyically use a F95 compiler, but
only since the release of @code{gcc 4.0.0} in April 2005 have Linux and
other non-commercial OSes had much support for F95. The compiler used
for @R{} on Windows is a F77 compiler.
Expand All @@ -1060,8 +1066,8 @@ Configuring @R{} will try to find a compiler which (from its name)
appears to be a Fortran 90/95 compiler, and set it in macro @samp{FC}.
Note that it does not check that such a compiler is fully (or even
partially) compliant with Fortran 90/95. Packages making use of
Fortran 90/95 features should use file extension @samp{.f90} or
@samp{.f95} for the source files: the variable @code{PKG_FCFLAGS}
Fortran 90/95 features should use file extension @file{.f90} or
@file{.f95} for the source files: the variable @code{PKG_FCFLAGS}
specifies any special flags to be used. There is no guarantee that
compiled Fortran 90/95 code can be mixed with any other type of code,
nor that a build of @R{} will have support for such packages.
Expand Down Expand Up @@ -1098,7 +1104,7 @@ Using @code{R CMD check}, the @R{} package checker, one can test whether
more directories, or gzipped package @command{tar}
archives@footnote{This may require GNU @command{tar}: the command used
can be set with environment variable @env{TAR}.} with extension
@samp{.tar.gz} or @samp{.tgz}. This runs a series of checks, including
@file{.tar.gz} or @file{.tgz}. This runs a series of checks, including

@enumerate
@item
Expand Down Expand Up @@ -1339,7 +1345,7 @@ Default: false.
Initial setting for @option{--check-subdirs}.
Default: @samp{default} (which checks only tarballs, and checks in the
@file{src} only if there is no @file{configure} file).
@item R_check_force_suggests
@item $R_check_force_suggests
If true, give an error if suggested packages are not available.
Default: true.
@end table
Expand Down Expand Up @@ -2098,7 +2104,7 @@ will crash the application (here @R{}) if they are ever used. Some
(notably Windows) will not. Looking at the output of

@example
nm -pg mypkg.so # @r{or other extension such as @samp{.sl} or @samp{.dylib}}
nm -pg mypkg.so # @r{or other extension such as @file{.sl} or @file{.dylib}}
@end example

@noindent
Expand Down Expand Up @@ -4865,7 +4871,7 @@ Windows.

The first argument to both functions is a character string giving the
path to the object. Programmers should not assume a specific file
extension for the object/DLL (such as @samp{.so}) but use a construction
extension for the object/DLL (such as @file{.so}) but use a construction
like

@example
Expand Down Expand Up @@ -5153,23 +5159,27 @@ linked-to packages are added to the include paths for C and C++ code.

Shared objects for loading into @R{} can be created using @command{R CMD
SHLIB}. This accepts as arguments a list of files which must be object
files (with extension @file{.o}) or C, C++, or FORTRAN sources (with
extensions @file{.c}, @file{.cc} or @file{.cpp} or !@file{.C}, and
@file{.f} or @file{.f90} or @file{.f95}, respectively) or commands to be
passed to the linker. See @kbd{R CMD SHLIB --help} (or the on-line help
for @code{SHLIB}) for usage information. If compiling the source files
does not work ``out of the box'', you can specify additional flags by
setting some of the variables
files (with extension @file{.o}) or sources for C, C++, FORTRAN 77,
Fortran 9x, Objective C or Objective C++ (with extensions @file{.c},
@file{.cc} or @file{.cpp} or @file{.C}, @file{.f}, @file{.f90} or
@file{.f95}, @file{.m}, and @file{.mm} or @file{.M}, respectively), or
commands to be passed to the linker. See @kbd{R CMD SHLIB --help} (or
the on-line help for @code{SHLIB}) for usage information. If compiling
the source files does not work ``out of the box'', you can specify
additional flags by setting some of the variables
@vindex PKG_CPPFLAGS
@code{PKG_CPPFLAGS} (for the C preprocessor, typically @samp{-I} flags),
@vindex PKG_CFLAGS
@vindex PKG_CXXFLAGS
@vindex PKG_FFLAGS
@code{PKG_CFLAGS}, @code{PKG_CXXFLAGS}, and @code{PKG_FFLAGS} (for the
C, C++, and FORTRAN compilers, respectively) in the file @file{Makevars}
in the compilation directory, or write a @file{Makefile} in the
compilation directory containing the rules required (or, of course,
create the object files directly from the command line).
@vindex PKG_FCFLAGS
@vindex PKG_OBJCFLAGS
@code{PKG_CFLAGS}, @code{PKG_CXXFLAGS}, @code{PKG_FFLAGS},
@code{PKG_FCFLAGS}, and @code{PKG_OBJCFLAGS} (for the C, C++, FORTRAN
77, Fortran 9x, and Objective C compilers, respectively) in the file
@file{Makevars} in the compilation directory, or write a @file{Makefile}
in the compilation directory containing the rules required (or, of
course, create the object files directly from the command line).
@vindex PKG_LIBS
Similarly, variable @code{PKG_LIBS} in @file{Makevars} can be used for
additional @samp{-l} and @samp{-L} flags to be passed to the linker when
Expand Down
13 changes: 8 additions & 5 deletions src/scripts/COMPILE.in
Expand Up @@ -8,16 +8,19 @@ revision='$Rev$'
version=`set - ${revision}; echo ${2}`
version="R compilation front end ${version}
Copyright (C) 2000-2005 The R Core Development Team.
Copyright (C) 2000-2006 The R Core Development Team.
This is free software; see the GNU General Public Licence version 2 or
later for copying conditions. There is NO warranty."

usage="Usage: R CMD COMPILE [options] files
Compile the specified files for subsequent collection into a shared
library using 'R CMD SHLIB'. Currently, C, C++, and FORTRAN files
(with extensions '.c', '.cc' or '.cpp' or '.C', and '.f', respectively),
are supported.
library using 'R CMD SHLIB'. Currently, the following languages with
associated source file extensions are supported (provided that the
respective compilers are available and R was configured to use these):
C ('.c'), C++ ('.cc' or '.cpp' or '.C'), FORTRAN 77 ('.f'), FORTRAN 90
('.f90'), FORTRAN 95 ('.f95'), Objective C ('.m'), and Objective C++
('.M' or '.mm').
Options:
-h, --help print short help message and exit
Expand Down Expand Up @@ -45,7 +48,7 @@ while test -n "${1}"; do
echo "${usage}"; exit 0 ;;
-v|--version)
echo "${version}"; exit 0 ;;
*.[cfC]|*.cc|*.cpp)
*.[cfmCM]|*.cc|*.cpp|*.f90|*.f95|*.mm)
objs="${objs} `echo ${1} | sed 's/\.[^\.][^\.]*$/.o/'`" ;;
-D*)
MAKEFLAGS="${MAKEFLAGS} ${1}" ;;
Expand Down

0 comments on commit cc84426

Please sign in to comment.