我有一个makefile,从那里我想调用一个shell脚本,它会做一些事情并将结果返回给makefile。
详细说明: -
从我的make文件中,我按如下方式调用shell脚本: -
source = $(PWD)
target = $(ROOT)
SCRIPT:= /home/........./temp.sh
FUNCTION:=$(shell $(SCRIPT $source $target))`
Shell脚本“temp.sh”: -
source=$1
target=$2
echo There are $# arguments to $0: $*
common_part=$source # for now
result="" # for now
while [[ "${target#$common_part}" == "${target}" ]]; do
common_part="$(dirname $common_part)"
if [[ -z $result ]]; then
result=".."
else
result="../$result"
fi
done
if [[ $common_part == "/" ]]; then
result="$result/"
fi
forward_part="${target#$common_part}"
if [[ -n $result ]] && [[ -n $forward_part ]]; then
result="$result$forward_part"
elif [[ -n $forward_part ]]; then
result="${forward_part:1}"
fi
echo "Result=$result"
我是这个领域的新手。
答案 0 :(得分:2)
您的调用语法错误;你想要
FUNCTION:=$(shell $(SCRIPT) $(source) $(target))
插值的Makefile变量需要在其名称周围加上括号,除非它们是单字母。