12.10 Respect CFLAGS

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.

If it does not, please add NO_PACKAGE=ignores cflags to the Makefile.

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

The CFLAGS variable is defined on FreeBSD systems in /etc/make.conf. The first example appends additional flags to the CFLAGS variable, preserving any system-wide definitions. The second example clobbers anything previously defined.

You should remove optimization flags from the third party Makefiles. System CFLAGS contains system-wide optimization flags. An example from an unmodified Makefile:

CFLAGS= -O3 -funroll-loops -DHAVE_SOUND

Using system optimization flags, the Makefile would look similar to the following example:

CFLAGS+= -DHAVE_SOUND
For questions about the FreeBSD ports system, e-mail <[email protected]>.
For questions about this documentation, e-mail <[email protected]>.