From khansen at stat.Berkeley.EDU  Thu May 11 06:37:01 2006
From: khansen at stat.Berkeley.EDU (Kasper Daniel Hansen)
Date: Wed, 10 May 2006 21:37:01 -0700
Subject: [Rd] suppressing "global" cppflags in an individual package
In-Reply-To: <B99D44A2-42C4-4BAA-828D-F7A6DEE648CE@r-project.org>
References: <9294B498-A4DB-47B1-AE99-71C1559EABB3@stat.berkeley.edu>
	<4460C819.6090407@cimr.cam.ac.uk>
	<8315342E-192B-4BF4-86BC-8F947769530E@stat.Berkeley.EDU>
	<B99D44A2-42C4-4BAA-828D-F7A6DEE648CE@r-project.org>
Message-ID: <7B99B6C0-B4AC-47D4-9912-9238585C5311@stat.Berkeley.EDU>

Thank you Simon, a little comment below

On May 9, 2006, at 2:49 PM, Simon Urbanek wrote:

> 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 $@

Actually you do not need the all: line, and since I use .cpp as C++  
extension, all I needed was

%.o: %.cpp
<TAB>$(CXX) $(ALL_CPPFLAGS) -O0 -c $< -o $@

Note that I needed to delete the $(ALL_CXXFLAGS) which basically  
reads R's flags.

Now, is there any way to (in the Makevars file) operate on $ 
(ALL_CXXFLAGS), since all I want is to delete any -O* flag? Or is  
defining rules and variables all I can do?

Actually, where do I read about the Makevars syntax. Is it from  
autoconf (of which I only now the name). The section on it in R-exts  
is useful (hey, I managed to make one in the first place), but not  
comprehensive.

/Kasper


> 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



[Rd] suppressing "global" cppflags in an individual package
Kasper Daniel Hansen