Skip to content

Instantly share code, notes, and snippets.

@klingtnet
Last active January 12, 2017 11:38
Show Gist options
  • Save klingtnet/b250f2132aa48977fc8c4728b097a773 to your computer and use it in GitHub Desktop.
Save klingtnet/b250f2132aa48977fc8c4728b097a773 to your computer and use it in GitHub Desktop.
GNU Make: Branch if an environment variable is set
.PHONY: all

ifdef IFSETUSEMYVALUE
FOO:=$(IFSETUSEMYVALUE)
else
FOO:="another value"
endif

all:
  @echo $(FOO)
$ make
another value
$ IFSETUSEMYVALUE="Hi" make
Hi

Note: Variable assignments with colon equal (:=) will be expanded only once, whereas = assignments are expanded on each use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment