Check if a program exists from a Makefile

后端 未结 12 1098
时光取名叫无心
时光取名叫无心 2020-12-12 20:20

How can I check if a program is callable from a Makefile?

(That is, the program should exist in the path or otherwise be callable.)

It could be used to chec

12条回答
  •  孤城傲影
    2020-12-12 20:27

    Cleaned up some of the existing solutions here...

    REQUIRED_BINS := composer npm node php npm-shrinkwrap
    $(foreach bin,$(REQUIRED_BINS),\
        $(if $(shell command -v $(bin) 2> /dev/null),$(info Found `$(bin)`),$(error Please install `$(bin)`)))
    

    The $(info ...) you can exclude if you want this to be quieter.

    This will fail fast. No target required.

提交回复
热议问题