Makefile WINAVR在包含路径中找不到带空格的文件

Makefile WINAVR在包含路径中找不到带空格的文件,makefile,winavr,Makefile,Winavr,当我为ExtraIncDir(在Makefile中,遵循WINAVR提供的示例)提供不带空格的路径时,编译器能够找到我的头文件,但当我使用包含空格的路径(如Makefile中的注释所示,用引号括起来)时,它会引发:错误:没有这样的文件或目录 "d:/dev/avr/atmega/shared/" # will search files in this dir "d:/dev/avr/atmega/sha ed/" # will not search this dir for files 我的意

当我为ExtraIncDir(在Makefile中,遵循WINAVR提供的示例)提供不带空格的路径时,编译器能够找到我的头文件,但当我使用包含空格的路径(如Makefile中的注释所示,用引号括起来)时,它会引发:
错误:没有这样的文件或目录

"d:/dev/avr/atmega/shared/" # will search files in this dir
"d:/dev/avr/atmega/sha ed/" # will not search this dir for files
我的意思是,评论说:

# List any extra directories to look for include files here.
#     Each directory must be seperated by a space.
#     Use forward slashes for directory separators.
#     For a directory that has spaces, enclose it in quotes.
知道如何让WINAVR正确处理这个问题吗

我正在Windows XP上使用程序员记事本(WINAVR)。以下是命令行命令:

avr-g++ -c -mmcu=atmega328p -I. -gdwarf-2 -DF_CPU=UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -I"d:/dev/avr/atmega/shared/" -I"d:/dev/avr/atmega/sha -Ied/" -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o

发生的事情是,我猜在makefile中的其他地方有一行代码,它执行以下操作:

INCLUDES = $(addprefix -I, $(INCDIRS))
发生这种情况时,addprefix将$(INCDIRS)变量中的任何空格视为下一个变量的分隔符,并将在其中添加-I。您可以做的是为空格使用一个特殊字符,比如“\\”,然后在生成命令之前调用一个替换函数来重新替换空格。类似于下面的示例:

SPACE = \\
INCDIRS = /home/posey/test$(SPACE)dir

INCLUDES = $(addprefix -I, $(INCDIRS))
REAL_INCLUDES = $(subst $(SPACE), ,$(INCLUDES))

.PHONY : all

all:
    $(info $(REAL_INCLUDES))

如果这没有意义,你可以发布整个makefile,我们可以向你展示到底发生了什么。一旦将空格替换回变量中,如果没有相同的行为发生,您就无法通过任何使用空格分隔符的make函数运行它。

谢谢。但是,有没有办法使用包含空格的通配符?如果可能的话,我会更容易使用像
“[^”]+”
这样的模式。如果您了解make的基本知识,请参阅gnu make手册中关于通配符的第4.4节。也许这会对您有所帮助