【发布时间】:2018-07-05 20:43:31
【问题描述】:
我正在尝试将“sub-make”命令发送到子目录。我有一个带有“top_level” Makefile 的父目录和一个带有自己的 Makefile 的子目录。
我的父 Makefile 有一个目标行如下:
target%:
make -C sub_dir $(patsubst target-%,%,$@)
我可以在父文件夹中做:
使目标干净 && 使目标全部
它将被解释为:
make -C sub_dir clean && make -C sub_dir all
我希望能够做到:
制作目标
但在这种情况下,我得到:
make -C sub_dir target.o
我期待虽然“patsubst”没有找到模式,但它不会返回任何内容或测试的表达式。但它返回这个“target.o”。
谁能给我解释一下?我怎么可能一无所获?
我尝试了这些表达式但没有成功:
make -C sub_dir $(patsubst target%,%,$@)
make -C sub_dir $(patsubst -%,%,$(patsubst target%,%,$@))
make -C sub_dir $($(patsubst -%,%,$(patsubst target%,%,$@)):.o=)
最后一个很棘手,它给出了:
make -C sub_dir
make[1]: 进入目录/home/aurelien/Documents/Projects/parent/sub_dir'
make[1]: 'subtarget' 是最新的。
make[1]: 离开目录 '/home/aurelien/Documents/Projects/parent/sub_dir'
cc 目标.o -o 目标
cc: target.o: 没有这样的文件或目录
cc: 没有输入文件
make: *** [目标] 错误 1
【问题讨论】:
标签: makefile