【发布时间】:2012-11-05 09:17:59
【问题描述】:
我有一个makefile,我想从中调用一个shell脚本,它会做一些事情并将结果返回给makefile。
详细说明:-
从我的 make-file 中,我调用 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"
- 我没有看到 Shell-Script 的“echo statements”,可能是什么原因?
- 如何将结果返回到 makefile?
- 这是从 make-file 调用脚本的正确方法吗?
我是这方面的新手。
【问题讨论】: