Bash snippet doesn't work in makefile
<p>I have one version file <code>verfile</code> which contains below version string<br>
<code>V1.1.2</code></p>

<p>And in Makefile I intend to read this version string,
So I wrote Makefile as follows,</p>

<pre><code>filepath        :=      $(PWD)
versionfile     :=      $(filepath)/verfile

all:
        cat $(versionfile)
        version=$(shell cat $(versionfile))
        echo "version=$(version)"
</code></pre>

<p>Now when I run the make file I get following ouput</p>

<pre><code>cat /home/ubuntu/ankur/verfile
v1.1.2
version=v1.1.2
echo "version="
version=
</code></pre>

<p>So I am not able to store version string in the variable and use it later,
I am not sure what am I doing wrong?</p>

<p>Any suggestion/pointer ?</p>

<p>After reading answer from "Didier Trosset" I changed my makefile as follows,</p>

<pre><code>filepath        :=      $(PWD)
versionfile     :=      $(filepath)/verfile
myversion       :=      ""

all:

ifeq ($(wildcard $(versionfile)),)
all:
        echo "File not present"
else
all: myversion = $(shell cat $(versionfile))
endif
all:
        echo "myversion = $(myversion)"
</code></pre>

<p>and below is output for the </p>

<pre><code>echo "myversion = v1.1.2"
myversion = v1.1.2
</code></pre>