Make

Command detection

It can be useful to check if a missing piece of software is available on the build system.

This wraps everything into a single function for easier use:

assert-command-present = $(if $(shell which $1),,$(error '$1' missing and needed for this build))

$(call assert-command-present,curl)
$(call assert-command-present,curly)

Checking for binaries

# Example with `ls`:
# $(call assert-command-present,ls)
assert-command-present = $(if $(shell which $1),,$(error '$1' missing and needed for this build))

Showing help

# Default target if not specified.
.DEFAULT_GOAL := help

# Define the non-file targets to avoid confusion with files
.PHONY: help

help: ## Show a list of available targets.
  @echo Available targets:
  @grep -E '^[\.a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
      | sed -n 's/^\(.*\): \(.*\)##\(.*\)/\1\{}\3/p' \
      | sort \
      | column -t -s '{}'