diff options
Diffstat (limited to 'devdocs/gnu_make/testing-flags.html')
| -rw-r--r-- | devdocs/gnu_make/testing-flags.html | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/devdocs/gnu_make/testing-flags.html b/devdocs/gnu_make/testing-flags.html new file mode 100644 index 00000000..a87777df --- /dev/null +++ b/devdocs/gnu_make/testing-flags.html @@ -0,0 +1,14 @@ + <h1 class="section">Conditionals that Test Flags</h1> <p>You can write a conditional that tests <code>make</code> command flags such as ‘<samp>-t</samp>’ by using the variable <code>MAKEFLAGS</code> together with the <code>findstring</code> function (see <a href="text-functions">Functions for String Substitution and Analysis</a>). This is useful when <code>touch</code> is not enough to make a file appear up to date. </p> <p>Recall that <code>MAKEFLAGS</code> will put all single-letter options (such as ‘<samp>-t</samp>’) into the first word, and that word will be empty if no single-letter options were given. To work with this, it’s helpful to add a value at the start to ensure there’s a word: for example ‘<samp>-$(MAKEFLAGS)</samp>’. </p> <p>The <code>findstring</code> function determines whether one string appears as a substring of another. If you want to test for the ‘<samp>-t</samp>’ flag, use ‘<samp>t</samp>’ as the first string and the first word of <code>MAKEFLAGS</code> as the other. </p> <p>For example, here is how to arrange to use ‘<samp>ranlib -t</samp>’ to finish marking an archive file up to date: </p> <div class="example"> <pre class="example">archive.a: … +ifneq (,$(findstring t,$(word 1,-$(MAKEFLAGS)))) + +touch archive.a + +ranlib -t archive.a +else + ranlib archive.a +endif +</pre> +</div> <p>The ‘<samp>+</samp>’ prefix marks those recipe lines as “recursive” so that they will be executed despite use of the ‘<samp>-t</samp>’ flag. See <a href="recursion">Recursive Use of <code>make</code></a>. </p><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Free Software Foundation, Inc. <br>Licensed under the GNU Free Documentation License.<br> + <a href="https://www.gnu.org/software/make/manual/html_node/Testing-Flags.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Testing-Flags.html</a> + </p> +</div> |
