user189035 user189035 -4 years ago 67
R Question

customize package compilation option R

So I'm building a package containing an old f77 code that should absolutely be build with the

optimization option.

So in the
of my package I added this line:

FFLAGS=-O0 -pipe -g $(LTO)

but when I compile my package, I see R is still using
the default compiling options from the

gfortran -fpic -O3 -pipe -g -c Babar.f -o Babar.o

how can I override the default compilation options for the FORTRAN files of my package in R?
(I intend to distribute that package through CRAN so the compilation option should be set from the Makevars file)

Answer Source

Ok, the best solution I found for this is to do it as is done in the quadprog package (ver 1.5-5). Here is what the relevant parts of the src/Makevars file look like:

all: $(SHLIB)
Babar.o: Babar.f
    $(F77) $(mypackage_FFLAGS) -O1 -pipe -g -c -o Babar.o Babar.f

So, for example when you send the package to the win-builder here is what the compiler output looks like (confirming that this solution does indeed work):

gfortran     -O1 -pipe -g -c -o Babar.o Babar.f
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download