make 不解析目标名称的绝对路径
make does not resolve absolute path to target name
我的 Makefile 中有一个简单的目标:
file1:
touch $@
我可以使用以下方法构建此目标:make file1
如果我说:make ./file1
('file1' 是最新的)
,它也会构建
但是如果我说:make $HOME/file1
然后它告诉我:
make: Nothing to be done for '/home/jesaremi/file1'
有没有办法无论我使用什么路径都能获得一致的结果?
您可以添加另一条规则:
$(shell pwd)/%: %
@:
这将使 file1
规则适用于 "file1"、“./file1”、“/home/jesaremi/path_to_cwd/file1”、“~jesaremi/path_to_cwd/file1”和“~/path_to_cwd/file1”。
我的 Makefile 中有一个简单的目标:
file1:
touch $@
我可以使用以下方法构建此目标:make file1
如果我说:make ./file1
('file1' 是最新的)
但是如果我说:make $HOME/file1
然后它告诉我:
make: Nothing to be done for '/home/jesaremi/file1'
有没有办法无论我使用什么路径都能获得一致的结果?
您可以添加另一条规则:
$(shell pwd)/%: %
@:
这将使 file1
规则适用于 "file1"、“./file1”、“/home/jesaremi/path_to_cwd/file1”、“~jesaremi/path_to_cwd/file1”和“~/path_to_cwd/file1”。