STATIC_SIL README
Overview
There are several ways to build the server binaries. The server source code is required to build server binaries.
STATIC=1
STATIC=1 STATIC_SERVER=1
STATIC=1 STATIC_SERVER=1 NETCONFD_LIB=1
Mode 1: STATIC=1
In this mode, only the flag STATIC=1 is added. This will build and link the YumaPro libraries as static libraries instead of shared libraries.
The "dl" library will be used and "dlopen" will be used to load dynamic shared SIL libraries for libyp-system and all SIL libraries using the --module or --bundle parameter.
Mode 2: STATIC=1 STATIC_SERVER=1
In this mode, the 2 flags STATIC=1 and STATIC_SERVER=1 are used. This will build and link the YumaPro libraries as static libraries instead of shared libraries.
The "dl" library will not be used and "dlopen" will not be used. No dynamic shared libraries are possible at all. Instead static SIL libraries can be linked into the image using a customized Makefile (out of scope here).
The "agt_sil_lib_register_statlib" function can be used to easily integrate the static SIL into the server. With this approach, as many static SIL libraries can be loaded as you want, but they will only be used if enabled by the operator (e.g. --module or --bundle parameter).
The raw "init", "init2", and "cleanup" entry points for the static SIL library can also be invoked manually. This procedure is out of scope.
In this mode even the libyp-system library is expected to be statically linked. This is handled automatically by the Makefile, if the libsystem directory is used to build this library.
Mode 3: STATIC=1 STATIC_SERVER=1 NETCONFD_LIB=1
In this mode, the 3 flags STATIC=1 and STATIC_SERVER=1 and NETCONFD_LIB=1 are used. This mode is similar to mode 2, except the "netconfd_static.c" module is added to the netconfd-pro server. This module allows static SIL libraries to be easily integrated into the server without any changes to core server files.
The file netconf/src/netconfd-pro/netconfd_static.c can be renamed and used in a build, to make sure future releases do not overwrite your edits to this file. This module contains a callback function called "static_sil_cbfn". This can contain function calls to agt_sil_register_statlib for any number of static SIL libraries. The server will initialize the SIL registry in the correct order. The netconfd_main file will be linked with netconfd_static.c and other libraries to produce the netconfd-pro binary.
IMPORTANT info on Using Static SIL Libraries
Assume a SIL library is setup
> make_sil_dir_pro test2
This could also be a bundle (make_sil_bundle)
Build a static version of the SIL library
> cd test2 > make STATIC=1
Copy the static library to a common directory if desired. This is not required but may make using the STATIC_SIL variable easier.
> cp lib/libtest2.a $HOME/sil/libtest2.a
Use the macro STATIC_SIL when building netconfd-pro
Option 1: Change in Makefile:
STATIC_SIL=-L /home/andy/sil -ltest2
Option 2: set from command line:
> make STATIC_SIL='-L /home/andy/sil -ltest2'
Note that the -L part must be first and it must specify where the static libraries are located. One or more -l parts can follow. The -l parameter does not use the full name. Instead libtest2.a can be specified as -ltest2.
Register the static library in the netconfd-pro program
Example from netconfd-pro/netconfd_static.c:
/* extern definitions for the 3 expected callbacks */
AGT_SIL_LIB_EXTERN(test2)
/* initialization hook to make STATIC_SIL libraries available
* to the server.
*
* ncx_static_sil_cbfn_t
*
* See netconfd_static.c for details
*
* RETURNS:
* status
*
*/
static status_t static_sil_cbfn (void)
{
status_t res = NO_ERR;
/* example: module=test2;
* need to use in Makefile (example)
* STATIC_SIL=-L /home/andy/sil -ltest2
* The actual library names are not needed in this code
*/
res =
agt_sil_lib_register_statlib((const xmlChar *)"test2",
y_test2_init,
y_test2_init2,
y_test2_cleanup);
return res;
} /* static_sil_cbfn */
The SIL library will not be used unless the module or bundle is loaded.
> netconfd-pro module=test2