setting CFLAGS in /etc/make.conf

Ruslan Ermilov ru at FreeBSD.org
Fri Aug 20 05:37:34 PDT 2004


On Fri, Aug 20, 2004 at 02:08:33PM +0200, Oliver Eikemeier wrote:
> I run into this recently with mail/exim. Of course it was possible to 
> work around this too, but it happened only when certain configuration 
> options where given *and* CFLAGS was set in /etc/make.conf. There must 
> be a better way to deal with this.
> 
Facts:

1. In FreeBSD, CFLAGS (if not explicitly set, or set in /etc/make.conf)
   is the global make(1) variable.

2. FreeBSD make(1) knows about environment and global variables, and
   global variables take precedence over environment variables.

3. If CFLAGS is not explicitly set in /etc/make.conf, and CFLAGS is
   set in environment instead, its value becomes a value of the CFLAGS
   make(1) global variable:

: $ cat makefile
: FOO+=   bar
: 
: all:
:         @echo global FOO: ${FOO}
:         @echo env FOO: $${FOO}
: $ FOO=foo make
: global FOO: foo bar
: env FOO: foo

So, if you need to change another makefile's idea of the initial value
of CFLAGS, you basically have two reliable choices:

a) Don't use /etc/make.conf to avoid the possibility of setting
   CFLAGS in /etc/make.conf.

b) Modify this another makefile to add things you want to CFLAGS;
   the modification may be either hardcoded, or using another
   macro whose value you can then pass as environment variable.

There's no other reliable way, and FreeBSD make(1) doesn't provide
you a way to initialize a variable in the global context on the
command line or from environment, except for -D which would set it
to "1".  You can only modify global variables from makefile or
from its included sources.

P.S.  I start to hate command-line variable in make(1).  ;)


Cheers,
-- 
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20040820/de3cc6d6/attachment.bin


More information about the freebsd-current mailing list