help-make
[Top][All Lists]
Advanced

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

Re: How to: organize application files and get GNU make to put theoutpu


From: Philip Guenther
Subject: Re: How to: organize application files and get GNU make to put theoutput files into the right place.
Date: Mon, 25 Jan 2010 13:16:57 -0800

On Mon, Jan 25, 2010 at 11:04 AM, Paul Smith <address@hidden> wrote:
> On Mon, 2010-01-25 at 13:14 -0500, Ted Byers wrote:
>> One last question.  Right now, I have:
>>
>> CPPFLAGS = -Wall -pedantic -I ../include
...
> In short, you should only be putting preprocessor flags into CPPFLAGS;
> that is -I, -D, and similar.
>
> Compiler flags like -Wall, -pedantic, etc. should go into CFLAGS (for C
> code) or CXXFLAGS (for C++ code).  Linker-specific flags go into LDFLAGS
> variable.

While the general statement is correct, I'm going to enable my own
-pedantic option and observe that Paul and Greg's claims that -Wall
and -pedantic belong in CFLAGS or CXXFLAGS are not always correct.
Yes, they *mainly* affect the compilation stage, but they *are* both
applicable to the preprocessor too and affect the warnings and errors
produced by the preprocessor.  To quote the "Preprocessor Options"
section of the gcc info pages:

`-Wall'
     Turns on all optional warnings which are desirable for normal
     code.  At present this is `-Wcomment' and `-Wtrigraphs'.  Note that
     many of the preprocessor's warnings are on by default and have no
     options to control them.
...
`-pedantic'
     Issue all the mandatory diagnostics listed in the C standard.
     Some of them are left out by default, since they trigger
     frequently on harmless code.

That suggests that they should be left in CPPFLAGS, at least if you're
actually using built-in rules that do preprocessing without C or C++
compilation, such as the "%.s: %.S.

Well, maybe.  The catch is that CPPFLAGS is also passed to lint, which
will probably choke on those options.  If you use preprocessing-only
rules *and* lint, then I suppose you would need to split out the
options suitable for both lint and cpp (-D, -U, -I, etc) into their
own variable, say, DEFINES, and redefine the lint rule to use that and
include it in CPPFLAGS too.

DEFINES = -Dwhatever -Isome/dir
CPPFLAGS = ${DEFINES} -Wall -pedantic
LINT.c = $(LINT) $(LINTFLAGS) $(DEFINES) $(TARGET_ARCH)

<shurg>


Philip Guenther




reply via email to

[Prev in Thread] Current Thread [Next in Thread]