是否可以实现使用Addsuffix&#x27创建的自动完成目标。或ADDPREFIX?
当然使用GNU。
我有以下设置:
Makefile
subdir1
--- Makefile
--- source1.c
--- binary1
subdir2
--- Makefile
--- source2.c
--- binary2
两个子段中的两个makefiles都有一个运行目标,该目标可以执行自身生成的二进制目标。 root makefile包含all
target,该目标运行make -c subir1&& make -c subdir2
:
SUBDIRS = subdir1 subdir2
all:
@for DIR in $(SUBDIRS); do \
$(MAKE) -C $$DIR; \
done
clean:
@for DIR in $(SUBDIRS); do \
$(MAKE) -C $$DIR clean; \
done
$(SUBDIRS):
$(MAKE) -C $@
底部钻头让我执行使单个子dir
全部。 我想要制作运行
的类似目标,由$(subdirs)
生成。 我尝试了
run-$(SUBDIRS):
make -C $(subst run-,,$@) run
,但是目标将扩展到run-subdir1 subdir2
,并且不会在$(subdirs)中的第二个项目中添加前缀,
如果我添加了新的var run_targets = $(addprefix run-,$(subdirs)
,它有效,但make not bects不识别utocomplettion的目标。是否有任何选项可以让您知道必须扩展run_targets或任何其他方法要
为我编辑
问题的列表是我的shell,ZSH,而不是做正确的。
Using GNU Make of course.
I have the following setup:
Makefile
subdir1
--- Makefile
--- source1.c
--- binary1
subdir2
--- Makefile
--- source2.c
--- binary2
Both makefiles in the subdirs have a run target, which executes the binary generated by itself.
The root makefile contains the all
target, which runs make -C subir1 && make -C subdir2
:
SUBDIRS = subdir1 subdir2
all:
@for DIR in $(SUBDIRS); do \
$(MAKE) -C $DIR; \
done
clean:
@for DIR in $(SUBDIRS); do \
$(MAKE) -C $DIR clean; \
done
$(SUBDIRS):
$(MAKE) -C $@
The bottom bit lets me execute make all
for a single subdir.
I want a similar target for make run
, generated by $(SUBDIRS)
.
I tried
run-$(SUBDIRS):
make -C $(subst run-,,$@) run
but the target expands to run-subdir1 subdir2
, and doesn't add the prefix to the second item in $(SUBDIRS)
If i add a new var RUN_TARGETS = $(addprefix run-, $(SUBDIRS)
, it works, but make doesn't recognize the targets for utocompletion. Is there any option to let make know that is has to expand RUN_TARGETS or any other method to prefix a list of item?
EDIT
The issue for me is my shell, zsh, and not make itself. Bash completion gets it right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用“ nofollow noreferrer”>“模式规则
”希望更明确,a
You can use a pattern rule:
or if you prefer to be more explicit, a static pattern rule:
补充@madscientist的解决方案:
使用简化代码(如果您熟悉此概念)。
To complement the solution by @MadScientist:
Use Substitution References to simplify the code (if you're familiar with this concept).