[Make] Choose between values with ifeq

Created on November 30, 2026

Use ifeq in a makefile to compare two values. This example chooses a message based on ENV.

ENV ?= dev

ifeq ($(ENV),prod)
MESSAGE = deploy to production
else
MESSAGE = deploy to development
endif

message:
    @echo $(MESSAGE)

Run make message to use the default value, dev.

deploy to development

Run make ENV=prod message to take the other branch.

deploy to production

End the conditional with endif. The quoted form of ifeq is also useful when the values may contain spaces.

ifeq ("$(ENV)","prod")
  MESSAGE = deploy to production
endif
Make