I'm trying to debug a package that I'm developing. I use a makefile for building, checking and installing the packages. The packages is an Rcpp package and so already has a makevars and makevars.win file in it. What I am looking for is a was to have CXXFLAGS changed just for a specific make rule. Then make debug
will run R CMD INSTALL
with CXXFLAGS= -Wall -pedantic -g -O0"
but regular make install
will run with CXXFLAGS=-O3
without any debugging info. is there a good way to dynamically change this without having to modify my package, personal or system makevars files?
I don't think so as there is only one CXXFLAGS
to go around. But you could reassign again in differnt 'make' vs `make debug' target portions.
You could just keep two versions ~/.R/Makevars.normal
amd ~/R/Makevars.debug
and use a script to flip a link between them...
For what it is worth. I just edit ~/.R/Makevars
and comment/uncomment different lines.
Edit: What about something like this, based on the Makefile
you posted:
install: $(PKG_NAME)_$(PKG_VERSION).tar.gz
CXXFLAGS+="-O3" R CMD INSTALL $(PKG_NAME)_$(PKG_VERSION).tar.gz
debuginstall: $(PKG_NAME)_$(PKG_VERSION).tar.gz
CXXFLAGS+="-Wall -g -O0" R CMD INSTALL $(PKG_NAME)_$(PKG_VERSION).tar.gz
Edit 2: I just played with this, and it works:
PKG_NAME=digest
PKG_VERSION=0.5.1
install: $(PKG_NAME)_$(PKG_VERSION).tar.gz
PKG_CFLAGS="-O6" R CMD INSTALL $(PKG_NAME)_$(PKG_VERSION).tar.gz
debuginstall: $(PKG_NAME)_$(PKG_VERSION).tar.gz
PKG_CFLAGS="-Wall -g -O0" R CMD INSTALL $(PKG_NAME)_$(PKG_VERSION).tar.gz
It still reads my ~/.R/Makevars
afterwards so certain vars cannot be set here. But you could just set MYDEBUG=...
in your Makefile
and then use that inside a definition in ~/.R/Makevars
.