Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the best way to write a makefile from a makefile
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COThe added info here doesn't help much. There's no way that the makefile you show above can work, so that can't be "the way to build it". For example, the prerequisite `$(PYTHON3:%=build-python%)` can't work. It will expand to the value `build-python$(shell py3versions -vr)` which, as we've seen, will fail because the `-r` option requires an argument. What are you _actually_ trying to run here? What would a _successful_ invocation of `py3versions` look like?
      singulars
    2. COTo make it easier for both of us: Forget about py3versions command (It is called through debuild command instead of make, when I use debuild, the rules file run well). Say we have a shell command DATE=$(shell date) (instead of that PYTHON3=$(shell py3versions -vr). I tried DATE=$(shell date) in the define part, I got output dates from the command in the rules file. But what I really want is to have just DATE=$(shell date) (not output of execution) Can it be done? Thanks.
      singulars
    3. COIf what you're asking is how to show the static string `$(shell date)` rather than having make run the function `$(shell date)`, that's what I explained in my answer below: escape the `$`, then make will not expand it: `echo 'PYTHON3 = $$(shell date)'`
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload