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