help-make
[Top][All Lists]
Advanced

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

Using empty $(else) variable for readability


From: Tony Theodore
Subject: Using empty $(else) variable for readability
Date: Sat, 17 Oct 2015 22:40:21 +1100

Hi,

I’m looking at tidying up some existing makefile logic and noticed there isn’t 
a lot of consistency in the format of conditionals - especially from myself 
over the years. We use make for build automation, not directly for compilation, 
and don’t use any pre-processor conditionals in this context, only the inline 
functions.

I’ve started replacing constructs like:

    $(if $(value foo)…

with:

    $(and $(foo)…

the short-circuit `and` and `or` are really helpful for most cases when `if` 
doesn’t have an `else` or `else` is a longer list.

When there is an `else` in a complex section, it sometimes looks like:

    $(if <condition>, \
        <do something> \
    , \
        <do something else>)

These can be deeply nested and the dangling `, \` can get really hard to parse. 
Constructs like:

    $(if <condition>, \
        <do something> \
    $(else), \
        <do something else>)

help readability and seem to work. I know I can use any misspelling or mangling 
of `else`, or something like $(otherwise), but `else` is really easy to read 
and parse.

Is this a reasonable idea and is there any chance $(else) will have some 
defined value in the future?

Cheers,

Tony






reply via email to

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