<html>#332: Cactus should not interpret environment variables as configuration options
<table style='border-spacing: 1ex 0pt; '>
<tr><td style='text-align:right'> Reporter:</td><td>Ian Hinder</td></tr>
<tr><td style='text-align:right'>   Status:</td><td>new</td></tr>
<tr><td style='text-align:right'>Milestone:</td><td></td></tr>
<tr><td style='text-align:right'>  Version:</td><td></td></tr>
<tr><td style='text-align:right'>     Type:</td><td>bug</td></tr>
<tr><td style='text-align:right'> Priority:</td><td>minor</td></tr>
<tr><td style='text-align:right'>Component:</td><td>Cactus</td></tr>
</table>

<p>Comment (by Roland Haas):</p>
<p>Rewriting the top level Makefile will not actually prevent Cactus from interpreting (and giving precedence to) ENV variables over what is in option lists. That behaviour is explicitly coded in the <code>ProcessConfiguration</code> subroutine in <code>ib/sbin/ProcessConfiguration.pl</code> (and more specifically in <code>AmalgamateOptions</code> in <code>CSTUtils.pl</code>).</p>
<p>It is related to make indeed passes variables specified on its command line as ENV variables to its children, ie:</p>
<div class="codehilite language-shell"><pre><span></span>make <span class="nv">FOO</span><span class="o">=</span>bar
</pre></div>


<p>makes a variable <code>FOO</code> available to sub-shells. In particular he ExternalLibaries' use of <code>configure.sh</code> scripts relies then on (a subset those in <code>@allowed_options</code> in <code>CST</code> and <code>ProcessConfiguration.pl</code>) of those being passed as ENV variables which is where <code>ENV{HDF5_DIR}</code> messing up <code>HDF5_DIR</code> in an option list actually comes from.</p>
<p>If one wants to use only command line options instead of all ENV variables as a source for those <code>@allowed_options</code> then one can parse <code>MAKEFLAGS</code> the way that <code>lib/make/setup_configuration.pl</code> does:</p>
<div class="codehilite language-perl"><pre><span></span><span class="c1"># parse make command line options FOO=BAR</span>
<span class="c1"># Set variables from makefile command line first</span>
<span class="k">my</span> <span class="nv">%MAKEFLAGS</span><span class="p">;</span>
<span class="k">my</span> <span class="nv">$commandline</span> <span class="o">=</span> <span class="nv">$ENV</span><span class="p">{</span><span class="s">&quot;MAKEFLAGS&quot;</span><span class="p">};</span>
<span class="nv">$commandline</span> <span class="o">=~</span> <span class="sr">s/^.*? -- //</span><span class="p">;</span>
<span class="k">while</span> <span class="p">(</span><span class="nv">$commandline</span> <span class="o">=~</span><span class="sr"> /^(
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/332/cactus-should-not-interpret-environment'>https://bitbucket.org/einsteintoolkit/tickets/issues/332/cactus-should-not-interpret-environment</a></p>
</html>