0

I've got the following in my Makefile,

dosomething:
    ifeq (, $(shell which python))
        $(error "Python not installed, please download and install Python to create database")
    else
        cd myfolder; python myfile.py
    endif

When I run make dosomething, it throws the error telling me to download and install python. But when I do which python in my shell, it says /usr/bin/python

Not sure what is going on here

3
  • 1
    Do the ifeq, else and endif lines begin with a tab character? If so, try removing it. Commented Aug 30, 2018 at 11:20
  • Just to simplify the problem, you could try $(info $(shell which python)). Commented Aug 30, 2018 at 16:27
  • @G.M. That fixed it! But why? Commented Aug 31, 2018 at 3:44

1 Answer 1

2

I'm guessing the indented lines begin with a tab character? If so then the ifeq, else and endif directives will be considered to be part of the command and passed to the shell for execution.

To ensure make evaluates those directives remove the leading tabs...

dosomething:
ifeq (, $(shell which python))
        $(error "Python not installed, please download and install Python to create database")
else
        cd myfolder; python myfile.py
endif
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.