1
使用GNU让4.1,在我的Makefile我可以创建这个::时间戳日志文件使用`date` Makefile中变量
flush_log:
@echo "==> flush logs"
cat file > file_`date +%FT%T%Z`.log
但是谁放:
file_`date +%FT%T%Z`.log
在Makefile中的var例如在它上面做一个wc
?
我已经尝试(没有成功):
flush_log:
@echo "==> flush logs"
logfile:=file_$(shell date +%FT%T%Z).log
cat my_log > $(logfile)
echo `wc -l $(logfile)`
我得到这个错误:
$ make flush_log
==> flush logs
logfile:=file_2016-12-24T20:09:52CET.log
/bin/sh: 1: logfile:=file_2016-12-24T20:09:52CET.log: not found
Makefile:7: recipe for target 'flush_log' failed
make: *** [flush_log] Error 127
$
我是从以下简单https://stackoverflow.com/a/14939434/3313834扩展型变量https://www.gnu.org/software/make/manual/html_node/Flavors.html#Flavors