help-make
[Top][All Lists]
Advanced

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

Re: Turning warning into errors


From: Duane Griffin
Subject: Re: Turning warning into errors
Date: Fri, 3 May 2019 17:17:21 +1200

On Fri, May 3, 2019 at 2:48 PM Kaz Kylheku (gmake)
<address@hidden> wrote:
> Let's try it in a project of mine:
>
>    ~/txr$ make --warn-undefined-variables --silent --dry-run clean 2>&1
>  > /dev/null
>    Makefile:32: warning: undefined variable `CFLAGS'
>    Makefile:33: warning: undefined variable `EXTRA_FLAGS'
>    Makefile:37: warning: undefined variable `LDFLAGS'
>    Makefile:38: warning: undefined variable `EXTRA_LDFLAGS'
>
> Good. These should be undefined; if the user sets these, we use them.
> Glad to see there are no others. :)

We had this sort of issue initially with "legitimate" undefined
variables. We added e.g. "CFLAGS ?=#" or "ifdef <blah>" blocks, which
eliminated them and allowed us to fail the build if others were
introduced. My experience is that if the build doesn't fail warnings
tend to be overlooked...

One other thing to keep in mind (I'm sure you know this, but for
others reading along at home): you might need to be careful about
which targets you give. In complex makefiles specifying different
targets may change which variables are defined/used, which is why in
our code it specified several targets, not just "clean".

Cheers,
Duane.



reply via email to

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