manpagez: man pages & more
info make
Home | html | info | man

File: make.info,  Node: load Directive,  Next: Remaking Loaded Objects,  Prev: Loading_Objects.php">Loading Objects,  Up: Loading_Objects.php">Loading Objects

12.2.1 The 'load' Directive
---------------------------

Objects are loaded into GNU 'make' by placing the 'load' directive into
your makefile.  The syntax of the 'load' directive is as follows:

     load OBJECT-FILE ...

   or:

     load OBJECT-FILE(SYMBOL-NAME) ...

   The file OBJECT-FILE is dynamically loaded by GNU 'make'.  If
OBJECT-FILE 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, 'make' will print a message and exit.

   If the load succeeds 'make' will invoke an initializing function.

   If SYMBOL-NAME is provided, it will be used as the name of the
initializing function.

   If no SYMBOL-NAME is provided, the initializing function name is
created by taking the base file name of OBJECT-FILE, 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 '_gmk_setup'.

   More than one object file may be loaded with a single 'load'
directive, and both forms of 'load' arguments may be used in the same
directive.

   The initializing function will be provided the file name and line
number of the invocation of the 'load' operation.  It should return a
value of type 'int', which must be '0' on failure and non-'0' on
success.  If the return value is '-1', then GNU Make will _not_ attempt
to rebuild the object file (*note How Loaded Objects Are Remade:
Remaking Loaded Objects.).

   For example:

     load ../mk_funcs.so

   will load the dynamic object '../mk_funcs.so'.  After the object is
loaded, 'make' will invoke the function (assumed to be defined by the
shared object) 'mk_funcs_gmk_setup'.

   On the other hand:

     load ../mk_funcs.so(init_mk_func)

   will load the dynamic object '../mk_funcs.so'.  After the object is
loaded, 'make' will invoke the function 'init_mk_func'.

   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.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.