title: What is the best way to write a makefile from a makefile
body: <p>I am trying to write a rules file (makefile) from a makefile, I used echo command to do it, 
  but when I come to the part with $, I cannot figure out how to do it right. </p>
  
  <p>I tried :</p>
  
  <pre><code>$(shell echo -e "#!/usr/bin/make -f \nPYTHON3=\"$(shell py3versions -vr)\"" &gt;&gt;text.txt
  </code></pre>
  
  <p>But I got error message saying that: </p>
  
  <pre><code> py3versions: error parsing Python-Version attribute
  </code></pre>
  
  <p>The code I want to write to a rules file: </p>
  
  <pre><code> #!/usr/bin/make -f 
  
   PYTHON3=$(shell py3versions -vr)
  
   %:
       dh $@   python3 --buildsystem=python_distutils
  
   override_dh_auto_build: $(PYTHON3:%=build-python%)
  
   ......
  </code></pre>
  
  <p>Anyone can give some suggestions about which command I should use to create such file? 
  If use echo command, what is the way to input $?   </p>
  
  <p>To update my situation:</p>
  
  <p>I am trying to build a python debian package. The rules file shown above is the way to build it. (of course after calling other functions like </p>
  
  <pre><code>python  setup.py sdist 
  </code></pre>
  
  <p>and </p>
  
  <pre><code>py2dsc,
  </code></pre>
  
  <p>then this rules (it is called rules instead of makefile) file will be called to build the debian package.</p>
  
  <p>The rules file can be automatically generated by py2dsc command, but I need to modify it to make it work for different versions of python (say, python2.* and python3.* ) . So I am thinking just write the rules file from makefile (which will call python setup.py sdist and py2dsc and this rules file) for python2.* and python3.* . </p>
  
  <p>Now I am facing the problem : how Can I write the shell command the way it is to the rules file. Thanks a lot!</p>