bug-make
[Top][All Lists]
Advanced

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

Re: Bug with $(info xxx) in 4.2.1


From: Paul Smith
Subject: Re: Bug with $(info xxx) in 4.2.1
Date: Fri, 08 Dec 2023 13:38:05 -0500
User-agent: Evolution 3.50.1 (by Flathub.org)

On Thu, 2023-12-07 at 11:38 -0500, Dmitry Goncharov wrote:
> On Tue, Dec 5, 2023 at 12:01 AM Aaron Williams
> <awilliams@marvell.com> wrote:
> 
> > What is happening is I will get the error:
> > *** recipe commences before first target.  Stop.
> > At the line with $(info xxx) unless I do not precede it with a tab.
> 
> This error is expected. A tab precedes a recipe.
> It does not matter what the recipe contains info or no info. It is
> still a recipe and should be preceded by a rule definition.

I don't think it's quite that simple.

In make it's fine to have a make line indented with a TAB, that is not
part of a recipe.  If a line appears outside of the context of a rule,
then leading whitespace is ignored.

This can be seen by the example given, where the variable assignment
line did not generate an error.  You can do this simpler experiment
without the ifeq, which is irrelevant for this issue:

          FOO = bar
          $(info baz)
  all:;

(where the first two lines are indented with TAB).  Here you will see
that make accepts the first line but fails on the second line:

  $ make
  Makefile:2: *** recipe commences before first target.  Stop.

The reason for this is that make tries to understand what kind of line
it has, BEFORE it expands the line.  You can tell it is not expanded
because the info function's output is not shown.  So in the first line,
make sees that it's a variable assignment and it accepts it.

However make doesn't know what kind of line the second line is, and
before it expands the content and realizes that the result would be the
empty string it generates this error.

Just as a point of order, it's a really, REALLY bad idea to indent non-
recipe lines with TAB.  While it's not technically illegal it will
cause your makefiles to be very brittle; if someone were to add a rule
line before this ifeq, then all of a sudden these lines would become
part of a recipe and could lead to a lot of frustration and confusion.
I recommend, in the strongest of terms, that you do not ever use TAB in
makefiles anywhere other than for indenting recipe lines.

However, this behavior should probably be considered a bug.  Aaron, it
would be helpful if you could file this as a bug in Savannah:

https://savannah.gnu.org/bugs/?group=make&func=additem

you don't have to make an account there, if you don't want to.



reply via email to

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