respect CFLAGS: should I override optimizations?

Roman Neuhauser neuhauser at
Tue Jun 1 01:22:25 PDT 2004

# krion at / 2004-06-01 09:46:57 +0200:
> Hi,
> On Tue, Jun 01, 2004 at 01:31:06AM +0200, Roman Neuhauser wrote:
> > I'm updating biology/migrate, the upstream includes
> > 
> > CFLAGS = @CFLAGS@ ...
> > 
> > and configure says:
> > 
> > case "$GCC" in
> > 	yes) CFLAGS="-O3 -Wall -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations -D$CPUTYPE" ;;
> >  
> > If I was to take Porter's Hang^Hdbook literally, I would change the
> > set (=) to append (+=) and be done with it, but is that really what
> > I'm expected to do? Or should I filter out the -O3 on the assumption
> > that optimization levels are make.conf's business?
> If you need to switch on some optimizations, you can use
> WITH_OPTIMIZED_CFLAGS knob and define CFLAGS+=$optimized_cflags
> there.

    I was actually looking for advice on what to do with upstream
    configure / pair that sets CFLAGS without respect
    to my preference. There's lot of it, and there are two camps:
    "author knows it runs best with -O3 -fthis -fthat, so don't
    screw with it" and "I don't care if it runs for ages without it".

    I'm sitting on the fence on this, I'm just looking for really
    unambiguous information, and Kris' email has given me that.
> Porters Handbook expresses clearly:
> "The port should respect the CFLAGS variable. What we mean by
> this is that the port should not set the value of this variable
> absolutely, overriding the existing value; instead, it should
> append whatever values it needs to the existing value. This is
> so that build options that affect all ports can be set
> globally."

    Yes, that's *very clear*, and means that I should turn the

    CFLAGS = -O3 -Wall ...


    CFLAGS += -O3 -Wall ...

    That will make it "-O -pipe -O3 -Wall ..." on my computer, but that
    defeats the perceived purpose of the whole CFLAGS whacking, and is
    *clearly* opposite to what Kris said and what you meant, but is
    otherwise exactly what the Porter's Handbook says just below the
    quote above:

    An example of a Makefile respecting the CFLAGS variable follows.
    Note the +=:

    CFLAGS += -Wall -Werror

    Here is an example which does not respect the CFLAGS variable:

    CFLAGS = -Wall -Werror

    As far as I'm concerned, neither respects my local setting, local
    CFLAGS would have to be *appended*, += doesn't help.

If you cc me or remove the list(s) completely I'll most likely ignore
your message.    see

More information about the freebsd-ports mailing list