help-make
[Top][All Lists]
Advanced

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

Re: $(file ...) function and other tools writing to the same file


From: Paul Smith
Subject: Re: $(file ...) function and other tools writing to the same file
Date: Mon, 14 Mar 2016 09:43:02 -0400

On Mon, 2016-03-14 at 14:32 +0100, Martin Reinders wrote:
>   $ cat Makefile
>   all:
>         /bin/echo "LINE FROM ECHO COMMAND" > file.txt
>         $(file >>file.txt,LINE FROM FILE FUNCTION)

> I expected that the echo command writes one line to the file, and the
> $(file ...) function appends another line. But as one can see, the 
> file contains the output from the echo command only. It seems to me 
> that the echo command is executed _after_ executing the $(file ...)
> function.

> Perhaps I am misunderstanding something completely? Any insight is
> highly appreciated.

The thing you're missing is that GNU make will always expand the ENTIRE
recipe, before it starts ANY part of the recipe.  So, all variables and
functions, including $(file ...), will be expanded first, then make will
start to run the recipe lines.  So the $(file ...) function happens
before the echo command, as you've seen.



reply via email to

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