title: Why are my Makefile variables inconstant after using tr?
body: <p>I'm working on a Makefile which takes a command line parameter, runs a translation (<a href="http://linux.die.net/man/1/tr" rel="nofollow"><code>tr</code></a>) on it, then uses that variable to create a directory and also prints the result. When the variable is printed, it is as I expect (the translated name), however when the variable is used to create the directory, the results are incorrect.</p>
  
  <p>So for example, when I run:</p>
  
  <pre><code>make build=debug
  </code></pre>
  
  <p>I see:</p>
  
  <pre><code>Building...
  ***************************
  BuilD Type:       Debug
  Build Target:     x86
  </code></pre>
  
  <p>But the resultant file system is:</p>
  
  <pre><code>out/
   └─── debug | tr d D_x86
  </code></pre>
  
  <p>I <strong>thought</strong> that running the <a href="http://linux.die.net/man/1/tr" rel="nofollow">translation</a> on the input variable <code>build</code> and assigning it to <code>$BUILD_TYPE</code> would have set this new variable to <code>"Debug"</code> but it seems like that is not the case all the time... How does this actually work?</p>
  
  <hr>
  
  <p>Full Makefile:</p>
  
  <pre><code>BUILD_TYPE=Release
  BUILD_TARGET=Arm
  OUTPUT_DIR=out
  
  MKDIR_P = mkdir -p
  
  ifeq ($(build),debug)
      BUILD_TYPE='$(build) | tr d D'
  endif
  ifeq ($(target),x86)
      BUILD_TARGET=$(target)
  endif
  
  TT=$(BUILD_TYPE)_$(BUILD_TARGET)
  
  all: directories
      @echo 'Building...'
      @echo '***************************'
      @echo 'Build Type:       $(BUILD_TYPE)'
      @echo 'Build Target:     $(BUILD_TARGET)'
      @echo 'Output Directory: $(PWD)/$(OUTPUT_DIR)'
      @echo '***************************'
  
  directories:
      ${MKDIR_P} $(OUTPUT_DIR)
      ${MKDIR_P} $(OUTPUT_DIR)/$(TT)
  </code></pre>