1

I'm attempting to create a single log file that tracks and reports the results of each recipe as the make process moves through the makefile.

To do this, I'm creating an environment variable to hold my logfile reference like so:

LOGDIR = logs
LOGFILE = $(LOGDIR)/$(shell date --iso=seconds).log

The intention is then to add relevant messaging to the log file by using
echo "message" >> $(LOGFILE)

Trouble is, when processing moves from one recipe to the next, the environment variable is re-evaluated, resulting in a new log file from every recipe in my makefile.

Why does the environment variable get re-evaluated, and how can I prevent this to use a single global reference to a logfile?

I thought that using the $(shell operator) syntax prevents re-evaluation of the variable, based on Aaron's answer here.

4

1 回答 1

1

如果您使用的是 GNU make 然后编写

LOGFILE := $(LOGDIR)/$(shell date --iso=seconds).log

应该只对表达式求值一次。这能解决你的问题吗?

于 2013-09-28T22:12:22.590 回答