Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is the expected behavior.</p> <blockquote> <p>Conditional Statements</p> <p>All instances of conditional syntax are parsed immediately, in their entirety; this includes the ifdef, ifeq, ifndef, and ifneq forms. <strong>Of course this means that automatic variables cannot be used in conditional statements, as automatic variables are not set until the command script for that rule is invoked</strong>. If you need to use automatic variables in a conditional you must use shell conditional syntax, in your command script proper, for these tests, not make conditionals.</p> </blockquote> <p><strong><code>$(*D)</code> is an automatic variable.</strong></p> <p>Instead, consider doing:</p> <pre><code>.c.o .cpp.o .cc.o: $(CC) $(DEBUG_FLAGS) $(if $(subst mySpecialDirectory,,$(*D)),$(NOTTHATSPECIALFLAGS),$(MYSPECIALFLAGS)) -c $&lt; -o $@ </code></pre> <p>The idea is to abuse <code>$(subst)</code> into some equality testing by replacing <code>mySpecialDirectory</code> with the empty string. Then, if <code>$(*D)</code> expansion equals to <code>mySpecialDirectory</code>, it is fully replaced by the empty string and the else-part of <code>$(if)</code> gets evaluated as per:</p> <blockquote> <p><code>$(if condition,then-part[,else-part])</code></p> <p>The if function provides support for conditional expansion in a functional context (as opposed to the GNU make makefile conditionals such as ifeq (see Syntax of Conditionals).</p> <p>The first argument, condition, first has all preceding and trailing whitespace stripped, then is expanded. If it expands to any non-empty string, then the condition is considered to be true. If it expands to an empty string, the condition is considered to be false.</p> </blockquote> <p>Notice the flip in this hack between the <code>then-part</code> and the <code>else-part</code>.</p> <p>Hope this helps!</p>
 

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