summaryrefslogtreecommitdiff
path: root/devdocs/gnu_make/override-directive.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/gnu_make/override-directive.html
new repository
Diffstat (limited to 'devdocs/gnu_make/override-directive.html')
-rw-r--r--devdocs/gnu_make/override-directive.html18
1 files changed, 18 insertions, 0 deletions
diff --git a/devdocs/gnu_make/override-directive.html b/devdocs/gnu_make/override-directive.html
new file mode 100644
index 00000000..bcf6d42e
--- /dev/null
+++ b/devdocs/gnu_make/override-directive.html
@@ -0,0 +1,18 @@
+ <h1 class="section">The override Directive</h1> <p>If a variable has been set with a command argument (see <a href="overriding">Overriding Variables</a>), then ordinary assignments in the makefile are ignored. If you want to set the variable in the makefile even though it was set with a command argument, you can use an <code>override</code> directive, which is a line that looks like this: </p> <div class="example"> <pre class="example">override <var>variable</var> = <var>value</var>
+</pre>
+</div> <p>or </p> <div class="example"> <pre class="example">override <var>variable</var> := <var>value</var>
+</pre>
+</div> <p>To append more text to a variable defined on the command line, use: </p> <div class="example"> <pre class="example">override <var>variable</var> += <var>more text</var>
+</pre>
+</div> <p>See <a href="appending">Appending More Text to Variables</a>. </p> <p>Variable assignments marked with the <code>override</code> flag have a higher priority than all other assignments, except another <code>override</code>. Subsequent assignments or appends to this variable which are not marked <code>override</code> will be ignored. </p> <p>The <code>override</code> directive was not invented for escalation in the war between makefiles and command arguments. It was invented so you can alter and add to values that the user specifies with command arguments. </p> <p>For example, suppose you always want the ‘<samp>-g</samp>’ switch when you run the C compiler, but you would like to allow the user to specify the other switches with a command argument just as usual. You could use this <code>override</code> directive: </p> <div class="example"> <pre class="example">override CFLAGS += -g
+</pre>
+</div> <p>You can also use <code>override</code> directives with <code>define</code> directives. This is done as you might expect: </p> <div class="example"> <pre class="example">override define foo =
+bar
+endef
+</pre>
+</div> <p>See <a href="multi_002dline">Defining Multi-Line Variables</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/Override-Directive.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Override-Directive.html</a>
+ </p>
+</div>