bug-make
[Top][All Lists]
Advanced

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

[bug #64185] *** only one 'else' per conditional. Stop. due to else in r


From: Dmitry Goncharov
Subject: [bug #64185] *** only one 'else' per conditional. Stop. due to else in recipe
Date: Sat, 13 May 2023 13:21:12 -0400 (EDT)

Follow-up Comment #1, bug #64185 (project make):

The same behavior can be demonstrated with the following makefile


ifdef blah
junk:
    else
else
endif


The parser does not perform variable expansion and ignores rule definitions
in
conditional branches which are not taken to avoid redundant work.
In this case, the ifdef branch is not taken and the parser ignores 'junk:'
rule
definition . The parser keeps looking for conditional keywords and finds
'else'
in the junk recipe. Because the parser ignored the definition of rule 'junk:'
earlier, the parser does not know that this else is a part of a rule recipe.

The error check should stay, because it is useful, it catches a missing
ifdef.
The parser should not waste efforts of processing branches which are not
taken.
It is unfortunate that make conditional keyword 'else' is also used by shell.
bsd make is more fortunate in this regards, their keyword is '.else'.
The only thing that comes to mind is to introduce a set of synonym keywords
like '.ifdef', '.else', etc.

To work around you can move the definition of junk recipe to a variable.


define junk_recipe
    else
endef

ifdef blah
junk:
    $(junk_recipe)
else
endif




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64185>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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