R :: override C compiler with Makevars

Our R installation defines:

R$HOME/etc/Makeconf that CC = gcc -std=gnu99 

I have one specific package (a combination of C ++ and C code) that needs to be compiled with

  CC = gcc  

without -std=gnu99

As I understand it, I have three ways to do this:
1) in the system, edit R $ HOME / etc / Makeconf
2) for each user, play with ~ / .R / Makevars
3) for each package, set PACKAGE / src / Makevars

Even if 1 and 2 are not what I want, I tested 3 options using 1 and 2

R CMD INSTALL -l pack.tgz OK "gcc -std = gnu99" is replaced by "gcc"

But when using the approach PACKAGE/src/Makevarsit fails

I have to admit that I was lost at this moment, where should I look?

. R- GCC . , Makevars

, PACKAGE/src/Makevars CC = , .

+4
1

fortran. , . , PACKAGE/src/Makevars . , Makevars:

MY_PKG_LIBS =
MY_PKG_CCLAGS = -I/usr/share/R/include -DNDEBUG -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g

all: $(SHLIB)                      
hello.o: hello.c
        gcc $(MY_PKG_CCLAGS) -c hello.c -o hello.o $(MY_PKG_LIBS)

PKG_LIB = -std=gnu++11

, hello.c your_file_name.c. CC, , , .so PKG_CFLAGS PKG_CPPFLAGS, R- ( Makevars). (Ubuntu 15.04, R 3.1.2) , /etc/R/Makeconf:

ALL_CFLAGS = $(R_XTRA_CFLAGS) $(PKG_CFLAGS) $(CPICFLAGS) $(SHLIB_CFLAGS) $(CFLAGS)
ALL_CPPFLAGS = $(R_XTRA_CPPFLAGS) $(PKG_CPPFLAGS) $(CPPFLAGS) $(CLINK_CPPFLAGS)

, -shared, ( fortran) PKG_LIB = -std=gnu++11 PACKAGE/src/Makevars. :

Installing package into ‘/home/home/R/x86_64-pc-linux-gnu-library/3.1
(as ‘lib’ is unspecified)
* installing *source* package ‘question1’ ...
** libs
gcc -I/usr/share/R/include -DNDEBUG -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c hello.c -o hello.o 
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o question1.so hello.o -std=gnu++11 -L/usr/lib/R/lib -lR
installing to /home/dgarolini/R/x86_64-pc-linux-gnu-library/3.1/question1/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (question1)
+2

Source: https://habr.com/ru/post/1655397/


All Articles