[Rd] suppressing "global" cppflags in an individual package

Simon Urbanek simon.urbanek at r-project.org
Tue May 9 23:49:48 CEST 2006


On May 9, 2006, at 1:11 PM, Kasper Daniel Hansen wrote:

> It is indeed the case that after updating to GCC 4 the package  
> gets  broken using -O2. I agree this needs to be fixed, but the error
> [...]
> unfortunately), but reading your comment about CPPFLAGS and  
> CXXFLAGS makes me think I can indeed override it using the package  
> Makevars file. The flags I was passing to the compiler were library  
> locations anyway which was for the preprocessor.
>

AFAIR you cannot override CPPFLAGS/CXXFLAGS in Makevars, because it  
gets included first. You can, however, use something like this:

all: $(SHLIB)

MYCFLAGS=-O0

%.o: %.c
         $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(MYCFLAGS) -c $< -o $@

for C, or for C++ accordingly:

%.o: %.cc
         $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(MYCXXFLAGS) -c $< - 
o $@

However, don't ask me how portable this is ;). It exploits the fact  
that old-style rules .c.o used by Makeconf are overridden by the new- 
style rules regardless of their position. Nevertheless, you could  
still use specific rules if desired without a full-blown Makefile. (I  
always recommend the use of Makevars as far as possible, because most  
writers of Makefiles get the shlib compilation wrong).

Cheers,
Simon



More information about the R-devel mailing list