Re: [PATCH] honor CFLAGS & friends from environment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 15, 2019 at 02:18:44AM +0000, Ramsay Jones wrote:
> On 14/02/2019 23:34, Luc Van Oostenryck wrote:
> > From: Uwe Kleine-König <uwe@xxxxxxxxxxxxxxxxx>
> > 
> > Debian build scripts pass CFLAGS in the environment.
> > However, this is ignored by Sparse's Makefile since 'CFLAGS'
> > is unconditionaly initialized.
> > 
> > Fix this by initializing CFLAGS to their default value using '?='.
> > Do the same for PKG_CONFIG, CHECKER, CHECKER_FLAGS and
> > DESTDIR, BINDIR, MANDIR & MAN1DIR.
> > 
> > Note: It's useless to try to do the same for CC, LD & AR since
> >       they're builtin variables so '?= ...' is a no-op for them
> >       (unless make is called with -R).
> 
> BTW, I have seen (a long time ago) an ugly hack to try and
> get around this 'special behaviour' of the variables from
> make's built-in database. It is very ugly, ...

Yes, for a few seconds I considered using $(origin) after
having realized that "CC ?= gcc" was useless but indeed,
it's very ugly.

> Suppose you wanted to set 'CC ?= gcc' in the Makefile, but
> because CC is 'special', you don't get the 'use the value
> from the environment if set, else default to this value'.

It seemed logical to allow CC, LD & AR to be configurable
from the environment, like CFLAGS is now. But it's already
possible to do it via the command line (and personnaly, I always
do this via a local config file like local.mk).

>   $ make CC=cmd fred
>   make: cmd: Command not found
>   Makefile:128: Your system does not have libxml, disabling c2xml
>   Makefile:150: Your system does not have gtk3/gtk2, disabling test-inspect
>   Makefile:183: Your system does not have llvm, disabling sparse-llvm
>   CC is cmd, origin:  command line
>   $ 
> 
>   $ CC=env make fred
>   env: unrecognised option '--print-file-name='
>   Try 'env --help' for more information.
>   Makefile:128: Your system does not have libxml, disabling c2xml
>   Makefile:150: Your system does not have gtk3/gtk2, disabling test-inspect
>   Makefile:183: Your system does not have llvm, disabling sparse-llvm
>   CC is env, origin:  environment
>   $ 
>   
> [Note: the 'make: cmd: Command not found' and similar message
> about the 'env' invocation comes from the '$(shell $(CC) ...)'
> further down the makefile (see line 100, setting GCC_BASE).]
> 
> Hmm, it may be possible to create a define ... :-P

Well, a "2>/dev/null" could be added but I think it's preferable to
have these kind of messages.

Best regards,
-- Luc



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux