Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm assuming that the example you show is the recipe for some rule. By the syntax here it looks like you're trying to set a make variable COMPILER_CMD from within a recipe based on the value of some shell boolean test, which is of course impossible. You have to be very clear in your mind how make works: make is not interpreting the recipes you write, in any way. Make is simply passing those recipes to another program (the shell) and the other program is interpreting those commands. Thus, you can't change the behavior of make, including setting make variables, from within a recipe: that recipe is being run in a completely different program.</p> <p>As others have said, you don't give enough information about what you REALLY want to do, at a higher level, for us to give a complete solution. Having a boolean like <code>1==1</code> doesn't give any hint whatsoever as to why you're doing this. Also your shell syntax contains syntax errors, so we can tell you didn't actually cut and paste this from a real, working example.</p> <p>You can, as piokuc implies, use a shell variable COMPILER_CMD (you have to remove the whitespace around the <code>=</code> to make it a shell variable assignment) but that value takes effect only while that one recipe line is running. For the next recipe line a new shell is started and any values set in the previous shell are lost:</p> <pre><code>all: @ if [[ 1 == 1 ]]; then COMPILER_CMD=-fpic; fi; \ echo COMPILER_CMD=$$COMPILER_CMD @ echo COMPILER_CMD=$$COMPILER_CMD </code></pre> <p>will give:</p> <pre><code>COMPILER_CMD=-fpic COMPILER_CMD= </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload