Re: setting CFLAGS in /etc/make.conf

From: Garance A Drosihn <drosih_at_rpi.edu>
Date: Fri, 20 Aug 2004 06:51:23 -0400
At 10:44 AM +0200 8/20/04, Oliver Eikemeier wrote:
>
>Basically, when a port tries to pass CFLAGS to the distribution
>Makefile, this is done by
>   env CFLAGS="${CFLAGS}" make
>which is effectively overwritten by users setting CFLAGS in
>make.conf(5). OTOH when += is used, it inherits the previous
>values, so when someone would do
>CFLAGS+=	-O -pipe
>in make.conf(5) the effective value passed is
>"-O -pipe -O -pipe ${_CPUCFLAGS}",
>which is not harmful, but not good either. This is especially
>problematic when the port uses CFLAGS="${PTHREAD_CFLAGS}" or
>CFLAGS="-DMY_OPTION", and a lot of ports use CFLAGS. This is
>no problem when the port has USE_GMAKE, since gmake doesn't
>read make.conf(5).

Back in March I was working on an updated version of the net/cap
port, and I noticed this problem with CFLAGS in /etc/make.conf vs
CFLAGS in the makefile of a port.  (So I am pretty sure this issue
has nothing to do with the recent changes to `make'.)

What I ended up doing was changing the net/cap/Makefile to set
CAP_CFLAGS instead of CFLAGS.  The distributed net/cap source has
a bunch of Makefile.m4 files which are used to generate the real
makefiles, and those Makefile.m4 files were already adding a bunch
of values to CFLAGS.  So, I changed a line (in net/cap/Makefile)
from:

${FIND} ${WRKSRC} -name Makefile.m4 \
                   -exec ${REINPLACE_CMD} \
                   -e 's/CFLAGS=/CFLAGS+=/' \{\} \;

to:

${FIND} ${WRKSRC} -name Makefile.m4 \
                   -exec ${REINPLACE_CMD} \
                   -e "s/CFLAGS=/CFLAGS+=${CAP_CFLAGS} /" \{\} \;

I meant to follow up on this issue on the freebsd-ports mailing
list, but I guess I never got around to mentioning it.  As near as
I could tell, it is just a bad idea for a ports-makefile to depend
on setting CFLAGS.  The fix I went with for net/cap probably will
not make sense for many other ports, but it was the easy fix based
on what net/cap/Makefile was already doing.

[note that I have not sent in that updated CAP port.  What I have
seems to work fine on FreeBSD-5.x on i386, but I wanted to see if
I could get it working on sparc64, and to also include some bug
fixes that I have made to cap at RPI]

-- 
Garance Alistair Drosehn            =   gad_at_gilead.netel.rpi.edu
Senior Systems Programmer           or  gad_at_freebsd.org
Rensselaer Polytechnic Institute    or  drosih_at_rpi.edu
Received on Fri Aug 20 2004 - 08:52:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:07 UTC