Reputation: 887
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.
I tried :
$(shell echo -e "#!/usr/bin/make -f \nPYTHON3=\"$(shell py3versions -vr)\"" >>text.txt
But I got error message saying that:
py3versions: error parsing Python-Version attribute
The code I want to write to a rules file:
#!/usr/bin/make -f
PYTHON3=$(shell py3versions -vr)
%:
dh $@ python3 --buildsystem=python_distutils
override_dh_auto_build: $(PYTHON3:%=build-python%)
......
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 $?
To update my situation:
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
python setup.py sdist
and
py2dsc,
then this rules (it is called rules instead of makefile) file will be called to build the debian package.
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.* .
Now I am facing the problem : how Can I write the shell command the way it is to the rules file. Thanks a lot!
Upvotes: 0
Views: 399
Reputation: 100876
Use two dollar signs ($$
) to escape the dollar sign from make:
all:
@echo 'VAR = $$VAR'
By the way, you shouldn't use $(shell ...)
for this I don't think. You don't give a complete example of your makefile, but if your echo
command is part of a recipe just write it directly, don't use $(shell ...)
.
Also just a note: echo -e
is not portable and won't work on all POSIX systems. I recommend you use printf
instead, which can do the same thing and is portable.
Upvotes: 2