title: Checking valid values for overriden variables in GNU Make
body: <p>What I'm interested in doing is checking the value of a variable that's been overridden on the command-line has one of several valid values. Specifically, I have part of my makefile that looks like so:</p>
  <pre><code>ifndef BUILD
      BUILD ::= release
  endif
  
  # Set flags for $(CC), based on the value of $(BUILD) 
  CFLAGS ::= -Wall -pthread -std=c17 -I./src/include
  CFLAGS.debug ::= -g
  CFLAGS.release ::= -O3
  CFLAGS ::= $(CFLAGS.$(BUILD)) $(CFLAGS)
  </code></pre>
  <p>My goal is to be able to run something like <code>make BUILD=debug</code> without having to write a seperate debug target and adding a bunch of mess to my recipies.</p>
  <p>What I want is a way to do something like <code>$(warn Invalid BUILD option)</code> if something like <code>make BUILD=production</code> is specified. Is there a better/more idiomatic way of doing this than just nesting a bunch of <code>ifneq</code>?</p>