Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Sep 2004 11:47:25 -0700 (PDT)
From:      John Polstra <jdp@polstra.com>
To:        Oliver Eikemeier <eikemeier@fillmore-labs.com>
Cc:        ports@freebsd.org
Subject:   Re: Best way to override user's CFLAGS in a port?
Message-ID:  <XFMail.20040907114725.jdp@polstra.com>
In-Reply-To: <C7CBC4CE-00FB-11D9-A5DE-00039312D914@fillmore-labs.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 07-Sep-2004 Oliver Eikemeier wrote:
> John Polstra wrote:
> 
>> The ezm3 port has to be built with an optimization level of -O, and
>> that's not likely to change any time soon.  Some users, especially
>> users of -current where -O2 is officially supported, are getting
>> burned by that.  What is the best way for me to change the ezm3 port's
>> Makefile so that -O will be used regardless of the user's environment
>> or /etc/make.conf settings?
> 
> The Porters Handbook 
> <http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-
> handbook/dads-cflags.html> tells you to respect CFLAGS, which means you 
> should add
> 
> .if defined(CFLAGS) && !empty(CFLAGS:M-O[2-9]*)
> BROKEN=               "Doesn't build with ${CFLAGS:M-O[2-9]*}"
> .endif
> 
> to your port, so that a user could use a workaround in make.conf(5) when 
> necessary.

I'm afraid if I do that, I'll get even more bug reports.  More and
more -current users are adding -O2 to their CFLAGS in /etc/make.conf.
Surely all of them would prefer having the port build properly than
having it fail intentionally.

The Porter's Handbook text seems mainly to say that the port should
append to CFLAGS with "+=" rather than simply clobbering it with "=".
That makes sense.  But it seems reasonable for the port to remove a
specific setting (-O[2-9]) from CFLAGS if the porter knows that that
setting will break the port.  It's not quite the same as clobbering
CFLAGS totally.

> Specifying CFLAGS in make.conf(5) is problematic for ports 
> anyways, see <http://lists.freebsd.org/pipermail/freebsd-
> current/2004-August/034763.html> (an example for a problematic port is 
> net/obnc, which misses -DIPSEC).
> 
> If you just want a dirty hack, you could use
> 
> CFLAGS:=              ${CFLAGS:N-O*} -O
> 
> but this won't work with recent make(1)s when CFLAGS is specified on the 
> command line, and might lead to other problems. I guess the first 
> solution is preferred.

The ezm3 port's Makefile is already a bit strange, because it invokes
${GMAKE} itself in a special do-install target.  I can strip off the
-O[2-9] there.  I was just wondering if there was a more official
way to do it.

John



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20040907114725.jdp>