Add plugin constructor registration for all libraries that provide plugins
Unfortunately, we can't just add the generated C file to the sources in Makefile.am as the linker would remove that object file when it notices that no symbol in it is ever referenced. So we include it in the file that contains the library initialization, which will definitely be referenced by the executable. This allows building an almost stand-alone static version of e.g. charon when building with `--enable-monolithic --enable-static --disable-shared` (without `--disable-shared` libtool will only build a version that links the libraries dynamically). External libraries (e.g. gmp or openssl) are not linked statically this way, though.
This commit is contained in:
@@ -184,6 +184,15 @@ if USE_ME
|
||||
sa/ikev2/tasks/ike_me.c sa/ikev2/tasks/ike_me.h
|
||||
endif
|
||||
|
||||
if STATIC_PLUGIN_CONSTRUCTORS
|
||||
BUILT_SOURCES = $(srcdir)/plugin_constructors.c
|
||||
CLEANFILES = $(srcdir)/plugin_constructors.c
|
||||
|
||||
$(srcdir)/plugin_constructors.c: $(top_srcdir)/src/libstrongswan/plugins/plugin_constructors.py
|
||||
$(AM_V_GEN) \
|
||||
$(PYTHON) $(top_srcdir)/src/libstrongswan/plugins/plugin_constructors.py ${c_plugins} > $@
|
||||
endif
|
||||
|
||||
# build optional plugins
|
||||
########################
|
||||
|
||||
|
||||
@@ -117,6 +117,13 @@ struct private_daemon_t {
|
||||
refcount_t ref;
|
||||
};
|
||||
|
||||
/**
|
||||
* Register plugins if built statically
|
||||
*/
|
||||
#ifdef STATIC_PLUGIN_CONSTRUCTORS
|
||||
#include "plugin_constructors.c"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* One and only instance of the daemon.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user