Best way to override user's CFLAGS in a port?
Oliver Eikemeier
eikemeier at fillmore-labs.com
Tue Sep 7 11:29:02 PDT 2004
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. 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.
-Oliver
More information about the freebsd-ports
mailing list