title: Global variable in makefile
body: <p>I am trying to assign one unique number to each file which is getting compiled through make and sub makes. For this I exported the variable in top level make using <code>export varName = 1</code> and then this is getting incremented for each <code>.c</code> file which is compiled using following</p>
  
  <pre><code>$(eval varName=$(shell echo $$(($(varName)+1))))
  </code></pre>
  
  <p>Problem is <code>varName</code> is again initialized to <code>1</code> when the sub make file is called from the top level makefile.</p>
  
  <p>How can I retain the last updated value while calling the sub makefiles?</p>