如果这样做:
ECHOCMD:=/bin/echo -e
SHELL := /bin/bash
GITIGNORE_SOURCE_PATH := ../.gitignore
GITIGNORE_DESTINE_PATH := ./setup/.gitignore
start_syncing: "${GITIGNORE_DESTINE_PATH}"
printf '\n'
"${GITIGNORE_DESTINE_PATH}":
cp -vr "${GITIGNORE_SOURCE_PATH}" ./setup/
每次调用"${GITIGNORE_DESTINE_PATH}"
时,Make都会继续运行规则make
,但是只有在修改源文件../.gitignore
时,它才应调用它。
这是我建议在评论中使用的Make文件:
ECHOCMD:=/bin/echo -e
SHELL := /bin/bash
GITIGNORE_SOURCE_PATH := ../.gitignore
GITIGNORE_DESTINE_PATH := ./setup/.gitignore
start_syncing: "${GITIGNORE_DESTINE_PATH}"
printf '\n'
${GITIGNORE_DESTINE_PATH}: ${GITIGNORE_SOURCE_PATH}
cp -vr "${GITIGNORE_SOURCE_PATH}" ./setup/
运行它,它说:
$ ls -l ../.gitignore
-rwx---r-x+ 1 User None 488 Apr 27 23:23 ../.gitignore
$ ls -l ./setup/.gitignore
-rwx---r-x+ 1 User None 488 Apr 28 07:41 ./setup/.gitignore
$ make
make: *** No rule to make target '"./setup/.gitignore"', needed by 'start_syncing'. Stop.
答案 0 :(得分:0)
解决方案是从目标规则中删除双引号。如果名称上有空格,除了使用\
ECHOCMD:=/bin/echo -e
SHELL := /bin/bash
GITIGNORE_SOURCE_PATH := ../.gitignore
GITIGNORE_DESTINE_PATH := ./setup/.gitignore
start_syncing: ${GITIGNORE_DESTINE_PATH}
printf '\n'
${GITIGNORE_DESTINE_PATH}: ${GITIGNORE_SOURCE_PATH}
cp -vr "${GITIGNORE_SOURCE_PATH}" ./setup/