[R] using MAKEFLAGS in compiling C code as a shared library using R CMD SHLIB

Faheem Mitha faheem at email.unc.edu
Thu Jun 13 19:57:29 CEST 2002

Dear R People,

in the R FAQ (in the R Programming section) it says


How can I change compilation flags?

   Suppose you have C code file for dynloading into R, but you want to
use `R CMD SHLIB' with compilation flags other than the default ones
(which were determined when R was built).  You could change the file
``R_HOME'/etc/Makeconf' to reflect your preferences.  If you are a
Bourne shell user, you can also pass the desired flags to Make (which
is used for controlling compilation) via the Make variable `MAKEFLAGS',
as in



Now, something like

MAKEFLAGS="CC=gcc-3.0" R CMD SHLIB rc.c -o rc.so

works fine, and something like

MAKEFLAGS="CC=gcc-3.0 PKG_CFLAGS= -Wall" R CMD SHLIB rc.c -o rc.so

also works fine.


MAKEFLAGS="CC=gcc-3.0 PKG_CFLAGS= -Wall -pedantic" R CMD SHLIB rc.c -o

does not work fine. Make throws a fit and spews forth gibberish.

My understanding of MAKEFLAGS is that it is for passing flags to some
submake process, in this case R CMD SHLIB. The documentation (make manual)
says that

"Words in the value of `MAKEFLAGS' that contain `=', `make' treats as
variable definitions just as if they appeared on the command line."

However, there seems to be a problem when the variable definition contains
blanks, as PKG_CFLAGS does above. Can anyone advise on what is the correct
syntax for this? I tried various possibilities and none of them worked,
and I cannot find any documentation that is helpful.

I realise that this is more a question about make, but I thought someone
here might know, and since I am using it in the context of R...

It would probably be a good idea if the answer to this was added to the
above section of the FAQ, since it doesn't seem immediately obvious, at
least to me.

                                       Sincerely, Faheem Mitha.

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list