Unfortunately, in some old FreeBSD environments I can't use "gmake", so I need to write a Makefile which will work with FreeBSD make also. And the last problem I can't solve - use shell commands, for example, I need to get full path to Python executable:
PYTHON := $(shell which python2.7 || which python)
But FreeBSD make simply ignores this.
test:
echo == $(PYTHON) ==
Then I run make test:
$ make test
echo == ==
== ==
Can anyone help, please?
Update #1: To those who can't read closely and accidentally downvotes the question:
Whole test script:
PYTHON != which python2.7 || which python
test:
$(PYTHON) -c 'print "hello world"'
Run on FreeBSD:
make
/usr/bin/python -c 'print "hello world"'
hello world
Run on CentOS:
make
test_make:1: *** missing separator. Stop.
And if I use command $(shell ...) it works on CentOS and doesn't work on FreeBSD. So, is there any solution without gmake?
Update #2: Eventually I found solution (put command in backticks):
PYTHON ?= `which python2.7 || which python`
I don't know why it prints itself:
make
`which python2.7 || which python` -c 'print "hello world"'
hello world
But it works! You can use it, guys :)
PYTHON
to the correct Python path outside of the Makefile? Also, the use ofwhich
is superfluous; ifpython
can be found in thePATH
, then just usepython
(orpython2.7
). Having the absolute path is usually not needed.