文件名中的空格似乎使makefile很难(for example here)。
我们可以控制文件名,但是项目所在的不是目录名。
如何在使用~/Downloads/OREN ISH
的$(shell pwd)
中修复此makefile:
BASEDIR = $(shell pwd)
${BASEDIR}/main: ${BASEDIR}/main.c
gcc $< -o $@
我们收到以下错误(删除${BASEDIR}
后消失:]
make: Circular /home/oren/Downloads/OREN <- /home/oren/Downloads/OREN dependency dropped.
make: *** No rule to make target 'ISH/main.c', needed by '/home/oren/Downloads/OREN'. Stop.
ifneq (1,$(words $(CURDIR)))
$(error Containing path cannot contain whitespace: '$(CURDIR)')
endif
或者第二(这还是我的建议,即使在路径名中完美地使处理的空格成为空白),也仅使用相对路径来编写makefile,因此您无需担心源树根目录的路径是什么样子或它可能包含哪些魔术人物。