Makefile无法检测到Python

时间:2018-08-30 11:01:26

标签: shell makefile

我的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

当我运行make dosomething时,它引发错误,告诉我下载并安装python。但是当我在外壳中执行which python时,它会显示/usr/bin/python

不确定这是怎么回事

1 个答案:

答案 0 :(得分:2)

我猜缩进的行以制表符开头吗?如果是这样,那么ifeqelseendif伪指令将被视为命令的一部分,并传递给Shell执行。

要确保make评估这些指令,请删除前导制表符...

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