
Chapter 12: Extending GNU make 137
Regardless of how many times an object file appears in a load directive, it will only be
loaded (and its setup function will only be invoked) once.
After an object has been successfully loaded, its file name is appended to the .LOADED
variable.
If you would prefer that failure to load a dynamic object not be reported as an error,
you can use the -load directive instead of load. GNU make will not fail and no message
will be generated if an object fails to load. The failed object is not added to the .LOADED
variable, which can then be consulted to determine if the load was successful.
12.2.2 How Loaded Objects Are Remade
Loaded objects undergo the same re-make procedure as makefiles (see Section 3.5 [How
Makefiles Are Remade], page 14). If any loaded object is recreated, then make will start
from scratch and re-read all the makefiles, and reload the object files again. It is not
necessary for the loaded object to do anything special to support this.
It’s up to the makefile author to provide the rules needed for rebuilding the loaded object.
12.2.3 Loaded Object Interface
Warning: For this feature to be useful your extensions will need to invoke various
functions internal to GNU make. The programming interfaces provided in this release
should not be considered stable: functions may be added, removed, or change calling
signatures or implementations in future versions of GNU make.
To be useful, loaded objects must be able to interact with GNU make. This interaction
includes both interfaces the loaded object provides to makefiles and also interfaces make
provides to the loaded object to manipulate make’s operation.
The interface between loaded objects and make is defined by the gnumake.h C header
file. All loaded objects written in C should include this header file. Any loaded object not
written in C will need to implement the interface defined in this header file.
Typically, a loaded object will register one or more new GNU make functions using the
gmk_add_function routine from within its setup function. The implementations of these
make functions may make use of the gmk_expand and gmk_eval routines to perform their
tasks, then optionally return a string as the result of the function expansion.
Loaded Object Licensing
Every dynamic extension should define the global symbol plugin_is_GPL_compatible to
assert that it has been licensed under a GPL-compatible license. If this symbol does not
exist, make emits a fatal error and exits when it tries to load your extension.
The declared type of the symbol should be int. It does not need to be in any allo-
cated section, though. The code merely asserts that the symbol exists in the global scope.
Something like this is enough:
int plugin_is_GPL_compatible;
Kommentare zu diesen Handbüchern