setting CFLAGS in /etc/make.conf

Garance A Drosihn drosih at
Fri Aug 20 07:20:31 PDT 2004

At 2:08 PM +0200 8/20/04, Oliver Eikemeier wrote:
>Garance A Drosihn wrote:
>>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)
>>	${FIND} ${WRKSRC} -name Makefile.m4 \
>>	                  -exec ${REINPLACE_CMD} \
>>	                  -e 's/CFLAGS=/CFLAGS+=/' \{\} \;
>>	${FIND} ${WRKSRC} -name Makefile.m4 \
>>	                  -exec ${REINPLACE_CMD} \
>>	                  -e "s/CFLAGS=/CFLAGS+=${CAP_CFLAGS} /" \{\} \;
>Jup, but this is hard to generalize.

I think it would be easy to generalize, although for most ports
you probably have to create a patch for the Makefile(s) instead
of using a convenient ${REINPLACE_CMD} command.

In general:
    the port makefile should set <portname>_CFLAGS (like "CAP_CFLAGS")
    and then change the makefiles distributed with the package
        so they have the line "CFLAGS+=<portname>_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.
>Many do, but most just hardcode the CFLAGS value they see in the
>configuration step in the (generated) ports Makefile.

This has the perhaps-unwanted side-effect that you have to 'make clean'
a port any time you change CFLAGS in /etc/make.conf, and you want the
port to pick up that change.  That will probably be fine for most users
in most occasions, but occasionally it may cause some confusion.

Garance Alistair Drosehn            =   gad at
Senior Systems Programmer           or  gad at
Rensselaer Polytechnic Institute    or  drosih at

More information about the freebsd-current mailing list