Re: setting CFLAGS in /etc/make.conf

From: Ruslan Ermilov <ru_at_FreeBSD.org>
Date: Fri, 20 Aug 2004 15:36:05 +0300
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:
:         _at_echo global FOO: ${FOO}
:         _at_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

Received on Fri Aug 20 2004 - 10:37:34 UTC

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