我正在使用以下Makefile,它应检查文件是否在某个目录*.rpm
中,如果找不到文件我将执行某些命令(运行脚本或制作转)
这是我的Makefile的片段
include /home/user/workspace/test/exec_recipe.mk
export BUILD_LOGS_DIR = $(CURDIR)/build_logs
.PHONY: my_rpm
libpdutil_rpm:
@echo "Making target 'libpdutil_rpm'. Time: $$(date +%T)"
cd /home/user/workspace/test/build/test && $(call exec_recipe,$(ls /home/user/workspace/test/build/test/rpmbuild/RPMS/x86_64d/*.rpm) || $(./test.sh),test.log,)
@echo "Finished making target 'my_rpm'. Time: $$(date +%T)"
这是exec_recipe.mk
SHELL:=/bin/bash
exec_recipe = \
echo "The logs dir is: $$BUILD_LOGS_DIR"; \
log_name="$(2)"; \
echo "The log name is $$log_name"; \
cmd="$(1)"; \
eval "$$cmd" 2>&1 | tee -a "$$BUILD_LOGS_DIR/$$log_name"; rc="$${PIPESTATUS[0]}"; \
if [ $$rc = 0 ]; then \
res="PASS"; \
else \
res="FAIL"; \
fi; \
flock $(SUMMARY) echo "Making target '$@': $$res" >> $(SUMMARY); \
exit $$rc
所以问题是当它到达执行exec_recipe.mk
时它会给我一些错误:
/bin/bash: eval: line 0: syntax error near unexpected token
||'
/bin/bash: eval: line 0:
|| “
我确定我做错了什么.. 我需要帮助器make文件,因为我也将它用于其他目的
答案 0 :(得分:2)
你必须逃避所有你想要解释的美元符号。您已经忘记了$(call exec_recipe,...)
的论据中的美元符号:
cd /home/user/workspace/test/build/test && $(call exec_recipe,$$(ls /home/user/workspace/test/build/test/rpmbuild/RPMS/x86_64d/*.rpm) || $$(./test.sh),test.log,)
我不确定最终的逗号是什么,但无论如何。