Re: [cc65] Building with custom CC and CFLAGS

From: Per Olofsson <magervalp1gmail.com>
Date: 2009-09-11 10:31:02
On Thu, Sep 10, 2009 at 11:18 PM, Ullrich von Bassewitz
<uz@musoftware.de> wrote:
>
> On Thu, Sep 10, 2009 at 10:32:05PM +0200, Per Olofsson wrote:
>> Currently the gcc.mak files contain this:
>>
>> CFLAGS = -O4 -Wall -W -std=c89 -I$(COMMON)
> [...]
>
> It's -O2 but I see your point.

Ah, sorry, this is from my attempt att compiling with clang (and its
awesome link level optimization at -O4 :)

>> This can be replaced by:
>>
>> CFLAGS = -O4 -Wall -W -std=c89
>>
>> in the top level makefile, and:
>>
>> CFLAGS += -I$(COMMON)
> [...]
>> in the "child" makefiles.
>
> Maybe I'm not understanding this completely, but as already described in
> another mail, I'm not using the top level makefile when working on one of the
> tools (actually, the top level makefile is mostly used by the nightly build
> script). If the "normal" makefiles just contain "CFLAGS += -I$(COMMON)" how do
> they get "-O4 -Wall -W -std=c89" when called directly (which is their main
> use)?

With the ?= operator:

CFLAGS ?= -O2 -Wall -W -std=c89
CFLAGS +=  -I$(COMMON)

This would give CFLAGS a correct default if it isn't already set
(either on the commandline, in an environment variable, or a parent
makefile), and add -I$(COMMON).

>> CC does not need to be set at all, as the
>> system default is probably what you want. If you want to use an
>> alternate compiler, set CC yourself.
>
> Maybe, but I don't like the idea. If I would just compile the stuff for
> myself, this is acceptable. But you can think of my box as something like a
> production environment. And I don't like the idea that nightly builds or even
> stable versions depend on the settings someone "installs" on my system by
> means of an RPM of whatever. I'm developing software for a living (among other
> things) and I've learned that it is absolutely critical that I can tell
> exactly how a software was built. I have written commercial software that - on
> request - not only outputs the SVN version number, but also the compiler
> version that was used to compile it, and the SVN release of the compiler
> sources! Using "whatever compiler is installed on my system today" makes my
> toenails roll up.

Fair enough (though CC=gcc isn't exactly very specific either), as
long as it's only set once in the main makefile, and optionally set
with ?= in the sub makefiles.

> Is it possible to do something like "if it's defined on the command line, then
> use it, else use what the makefile says" for a variable? If this is possible,
> then I can change the makefiles accordingly. You would then have to define
> your own variables on the command line when calling make.

?=
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Sep 11 10:31:09 2009

This archive was generated by hypermail 2.1.8 : 2009-09-11 10:31:10 CEST