测试是否在Makefile中安装了python3

时间:2019-02-23 17:53:36

标签: makefile

如何获得类似的效果?

PYTHON3_OK = $(shell python3 --version 2> /dev/null | wc -l)
ifeq ($(PYTHON3_OK), 0)
    $(error package 'python3' not found)

错误始终显示

1 个答案:

答案 0 :(得分:0)

计算输出线的数量是反模式。怎么样

PYTHON3_OK := $(shell python3 --version 2>&1)
ifeq ('$(PYTHON3_OK)','')
    $(error package 'python3' not found)
endif

或者当然更标准

PYTHON3_OK := $(shell type -P python3)
ifeq ('$(PYTHON3_OK)','')
    $(error package 'python3' not found)
endif