On Fri, May 3, 2019 at 2:48 PM Kaz Kylheku (gmake)
<729-670-0...@kylheku.com> 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.

_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to