summaryrefslogtreecommitdiff
path: root/devdocs/gnu_make/load-directive.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/gnu_make/load-directive.html')
-rw-r--r--devdocs/gnu_make/load-directive.html14
1 files changed, 14 insertions, 0 deletions
diff --git a/devdocs/gnu_make/load-directive.html b/devdocs/gnu_make/load-directive.html
new file mode 100644
index 00000000..fedce503
--- /dev/null
+++ b/devdocs/gnu_make/load-directive.html
@@ -0,0 +1,14 @@
+ <h1 class="subsection">The load Directive</h1> <p>Objects are loaded into GNU <code>make</code> by placing the <code>load</code> directive into your makefile. The syntax of the <code>load</code> directive is as follows: </p> <div class="example"> <pre class="example">load <var>object-file</var> …
+</pre>
+</div> <p>or: </p> <div class="example"> <pre class="example">load <var>object-file</var>(<var>symbol-name</var>) …
+</pre>
+</div> <p>The file <var>object-file</var> is dynamically loaded by GNU <code>make</code>. If <var>object-file</var> does not include a directory path then it is first looked for in the current directory. If it is not found there, or a directory path is included, then system-specific paths will be searched. If the load fails for any reason, <code>make</code> will print a message and exit. </p> <p>If the load succeeds <code>make</code> will invoke an initializing function. </p> <p>If <var>symbol-name</var> is provided, it will be used as the name of the initializing function. </p> <p>If no <var>symbol-name</var> is provided, the initializing function name is created by taking the base file name of <var>object-file</var>, up to the first character which is not a valid symbol name character (alphanumerics and underscores are valid symbol name characters). To this prefix will be appended the suffix <code>_gmk_setup</code>. </p> <p>More than one object file may be loaded with a single <code>load</code> directive, and both forms of <code>load</code> arguments may be used in the same directive. </p> <p>The initializing function will be provided the file name and line number of the invocation of the <code>load</code> operation. It should return a value of type <code>int</code>, which must be <code>0</code> on failure and non-<code>0</code> on success. If the return value is <code>-1</code>, then GNU make will <em>not</em> attempt to rebuild the object file (see <a href="remaking-loaded-objects">How Loaded Objects Are Remade</a>). </p> <p>For example: </p> <div class="example"> <pre class="example">load ../mk_funcs.so
+</pre>
+</div> <p>will load the dynamic object <samp>../mk_funcs.so</samp>. After the object is loaded, <code>make</code> will invoke the function (assumed to be defined by the shared object) <code>mk_funcs_gmk_setup</code>. </p> <p>On the other hand: </p> <div class="example"> <pre class="example">load ../mk_funcs.so(init_mk_func)
+</pre>
+</div> <p>will load the dynamic object <samp>../mk_funcs.so</samp>. After the object is loaded, <code>make</code> will invoke the function <code>init_mk_func</code>. </p> <p>Regardless of how many times an object file appears in a <code>load</code> directive, it will only be loaded (and its setup function will only be invoked) once. </p> <p>After an object has been successfully loaded, its file name is appended to the <code>.LOADED</code> variable. </p> <p>If you would prefer that failure to load a dynamic object not be reported as an error, you can use the <code>-load</code> directive instead of <code>load</code>. GNU <code>make</code> will not fail and no message will be generated if an object fails to load. The failed object is not added to the <code>.LOADED</code> variable, which can then be consulted to determine if the load was successful. </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/load-Directive.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/load-Directive.html</a>
+ </p>
+</div>