title: GNU Make: How to export the SHELL variable to sub-makes?
body: <p>From the GNU Make manual:</p>
  
  <blockquote>
    <p>The value of the make variable SHELL
    is not exported. Instead, the value of
    the SHELL variable from the invoking
    environment is passed to the sub-make.
    You can force make to export its value
    for SHELL by using the export
    directive, described below.</p>
  </blockquote>
  
  <p>I must be doing something wrong, or not reading the manual properly, as this simple example doesn't work:</p>
  
  <pre><code># ./Makefile
  export SHELL := /bin/bash
  export VALUE := exported_variable
  $(info root makefile SHELL=$(SHELL))
  call_sub_make:
      $(MAKE) --directory=subdir
  </code></pre>
  
  <p>And subdir/Makefile:</p>
  
  <pre><code>$(info subdir makefile SHELL=$(SHELL))
  $(info subdir makefile VALUE=$(VALUE))
  do_nothing:
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>$ env | grep SHELL
  SHELL=/bin/bash
  $ make --version
  GNU Make 3.81
  $ make
  root makefile SHELL=/bin/bash
  make --directory=subdir
  subdir makefile SHELL=/bin/sh
  subdir makefile VALUE=exported_variable
  make[1]: Entering directory `/home/drtwox/C/make/export_shell/subdir'
  make[1]: Nothing to be done for `do_nothing'.
  make[1]: Leaving directory `/home/drtwox/C/make/export_shell/subdir'
  </code></pre>
  
  <p>VALUE is exported, why isn't SHELL?</p>