make: load Directive
1
1 12.2.1 The 'load' Directive
1 ---------------------------
1
1 Objects are loaded into GNU 'make' by placing the 'load' directive into
1 your makefile. The syntax of the 'load' directive is as follows:
1
1 load OBJECT-FILE ...
1
1 or:
1
1 load OBJECT-FILE(SYMBOL-NAME) ...
1
1 The file OBJECT-FILE is dynamically loaded by GNU 'make'. If
1 OBJECT-FILE does not include a directory path then it is first looked
1 for in the current directory. If it is not found there, or a directory
1 path is included, then system-specific paths will be searched. If the
1 load fails for any reason, 'make' will print a message and exit.
1
1 If the load succeeds 'make' will invoke an initializing function.
1
1 If SYMBOL-NAME is provided, it will be used as the name of the
1 initializing function.
1
1 If no SYMBOL-NAME is provided, the initializing function name is
1 created by taking the base file name of OBJECT-FILE, up to the first
1 character which is not a valid symbol name character (alphanumerics and
1 underscores are valid symbol name characters). To this prefix will be
1 appended the suffix '_gmk_setup'.
1
1 More than one object file may be loaded with a single 'load'
1 directive, and both forms of 'load' arguments may be used in the same
1 directive.
1
1 The initializing function will be provided the file name and line
1 number of the invocation of the 'load' operation. It should return a
1 value of type 'int', which must be '0' on failure and non-'0' on
1 success. If the return value is '-1', then GNU make will _not_ attempt
11 to rebuild the object file (⇒How Loaded Objects Are Remade
Remaking Loaded Objects.).
1
1 For example:
1
1 load ../mk_funcs.so
1
1 will load the dynamic object '../mk_funcs.so'. After the object is
1 loaded, 'make' will invoke the function (assumed to be defined by the
1 shared object) 'mk_funcs_gmk_setup'.
1
1 On the other hand:
1
1 load ../mk_funcs.so(init_mk_func)
1
1 will load the dynamic object '../mk_funcs.so'. After the object is
1 loaded, 'make' will invoke the function 'init_mk_func'.
1
1 Regardless of how many times an object file appears in a 'load'
1 directive, it will only be loaded (and its setup function will only be
1 invoked) once.
1
1 After an object has been successfully loaded, its file name is
1 appended to the '.LOADED' variable.
1
1 If you would prefer that failure to load a dynamic object not be
1 reported as an error, you can use the '-load' directive instead of
1 'load'. GNU 'make' will not fail and no message will be generated if an
1 object fails to load. The failed object is not added to the '.LOADED'
1 variable, which can then be consulted to determine if the load was
1 successful.
1