Linux 用另一个makefile包装GNU makefile
这是下面的内容 我有Linux 用另一个makefile包装GNU makefile,linux,compilation,makefile,gnu-make,Linux,Compilation,Makefile,Gnu Make,这是下面的内容 我有Makefile.real(Makefile来自上一篇): 现在我想创建Makefile,它是Makefile.real的简单包装: 它使用与调用时相同的参数调用Makefile.real 它应该打印错误消息idMakefile.real失败 这是我的目标-在并行生成结束时打印错误消息 (见附件) 因此,以下命令应以错误消息终止: make -j1 a b (1) make -j2 a b (2) 我怀疑Makefile应该与以下内容接近: %: $(MAK
Makefile.real
(Makefile
来自上一篇):
现在我想创建Makefile
,它是Makefile.real的简单包装:
- 它使用与调用时相同的参数调用
Makefile.real
- 它应该打印错误消息id
Makefile.real
失败
这是我的目标-在并行生成结束时打印错误消息
(见附件)
因此,以下命令应以错误消息终止:
make -j1 a b (1)
make -j2 a b (2)
我怀疑Makefile
应该与以下内容接近:
%:
$(MAKE) -f Makefile.real $(MAKECMDGOALS); \
res=$$?; if [ $$res != 0 ]; then echo "Failed!!!"; fi; exit $$res
问题是对a
和b
分别调用两次目标“%”(2)
有什么想法吗?这是我最后提出的解决方案
ifneq ($(REAL_MAKE),1)
# run_make will be called once (it's .PHONY target),
# even if make is called with several targets
%: run_make
@:
.PHONY: run_make
run_make:
$(MAKE) $(MAKECMDGOALS) REAL_MAKE=1; \
if [ $$? -ne 0 ]; then \
echo "*** Error ***" >&2; \
exit 1; \
fi
else # REAL_MAKE defined (actual makefile)
### HERE comes original make we want to wrap ###
endif # # REAL_MAKE defined (actual makefile)
您是否考虑过包含Makefile.real
?@Beta不知道它如何解决我的问题-我试图克服的是,在并行编译的情况下,make结束时没有错误消息。问题编辑
ifneq ($(REAL_MAKE),1)
# run_make will be called once (it's .PHONY target),
# even if make is called with several targets
%: run_make
@:
.PHONY: run_make
run_make:
$(MAKE) $(MAKECMDGOALS) REAL_MAKE=1; \
if [ $$? -ne 0 ]; then \
echo "*** Error ***" >&2; \
exit 1; \
fi
else # REAL_MAKE defined (actual makefile)
### HERE comes original make we want to wrap ###
endif # # REAL_MAKE defined (actual makefile)