I have a makefile, from where I'd like to call a shell-script, which does something and return back the result to makefile.
Detailed description :-
From my make-file, I call the shell-script as follows :-
source = $(PWD)
target = $(ROOT)
SCRIPT:= /home/........./temp.sh
FUNCTION:=$(shell $(SCRIPT $source $target))`
Shell Script "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"
I'm a newbie in this area.
Your invocation syntax is wrong; you want
FUNCTION:=$(shell $(SCRIPT) $(source) $(target))
Interpolated Makefile variables need to have a parenthesis around their name unless they are single-letter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With