我的系统中所有机器都有/workarea/myjob
目录。但是,某些作业是分布式的,因此用户需要使用/net/<hostname>/workarea/myjob
如果用户尝试在路径中没有/net/<hostname>
的情况下进行构建,则作业最终会失败。
我想在开始构建之前检查pwd
是否在Makefile中返回/net/<hostname>/workarea
形式的路径。
这样做的好方法是什么?
答案 0 :(得分:4)
GNU make当前目录位于${CURDIR}
变量中。测试看起来像:
hostname := $(shell hostname)
ifeq ($(findstring /net/${hostname}/workarea, ${CURDIR}),)
$(error "Wrong current directory: ${CURDIR}")
endif