gpt4 book ai didi

Makefile之谜: What is wrong with this particular use of pathsubst?

转载 作者:行者123 更新时间:2023-12-01 16:29:17 25 4
gpt4 key购买 nike

我的 makefile 包含这些片段(以及其他片段):

SRC = src
OBJ = obj

DEPS = $(wildcard $(SRC)/*.cpp)

# ...

all : $(BINARIES)
@echo $(pathsubst $(SRC)/%.cpp,$(OBJ)/%.d,$(DEPS))
@echo $(DEPS:$(SRC)/%.cpp=$(OBJ)/%.d)

当我make all时,只有第二个@echo输出一些内容:

$ make all 

obj/sample1.d obj/sample1_U.d

(gnu make)manual状态:

Another type of substitution reference lets you use the full power of the patsubst function. It has the same form ‘$(var:a=b)’ described above, except that now a must contain a single ‘%’ character. This case is equivalent to ‘$(patsubst a,b,$(var))’

根据这个解释,我希望两个 @echo 语句产生相同的输出,但它们显然不会产生相同的输出。使用显式 pathsubst 的第一种形式有什么问题?

(我在 OS X 上使用 gnu make 3.81。)

最佳答案

大概您需要 patsubst,而不是 pathsubst

关于Makefile之谜: What is wrong with this particular use of pathsubst?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5682474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com