gpt4 book ai didi

makefile - 隐式规则先决条件中的通配符

转载 作者:行者123 更新时间:2023-12-02 05:10:21 27 4
gpt4 key购买 nike

BUILT_DIR = /tmp/obj 
SRC = /source/dir

/tmp/obj/%/builtin.o : $(SRC)/%/*.c
gcc $^ -o $@

但是你知道:

In order for the pattern rule to apply, its target pattern must match the file name under consideration and all of its prerequisites (after pattern substitution) must name files that exist or can be made.

如果我执行 make/tmp/obj/hfa/builtin.o,make 会报错:

make: *** No rule to make target/tmp/obj/hfa/builtin.o'.停止。`

如何修改 Makefile 以满足我的要求?

最佳答案

可以使用二级扩展

BUILT_DIR = /tmp/obj 
SRC = /source/dir
.SECONDEXPANSION:
/tmp/obj/%/builtin.o : $$(wildcard $(SRC)/%/*.c)
gcc $^ -o $@

关于makefile - 隐式规则先决条件中的通配符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15562909/

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