Re: setting CFLAGS in /etc/make.conf

From: Garance A Drosihn <drosih_at_rpi.edu>
Date: Fri, 20 Aug 2004 10:19:01 -0400
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)
>>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} /" \{\} \;
>
>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_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 - 12:20:31 UTC

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