12.9. Respect CFLAGS

The port must respect the CFLAGS variable. What we mean by this is that the port must not set the value of this variable absolutely, overriding the existing value; instead, it may 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

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.