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:
parent
8699275ed6
commit
4a0b6d659d
|
@ -27,6 +27,7 @@ libtool
|
||||||
y.tab.[ch]
|
y.tab.[ch]
|
||||||
lex.yy.c
|
lex.yy.c
|
||||||
*keywords.c
|
*keywords.c
|
||||||
|
plugin_constructors.c
|
||||||
Doxyfile
|
Doxyfile
|
||||||
apidoc/
|
apidoc/
|
||||||
*~
|
*~
|
||||||
|
|
|
@ -184,6 +184,15 @@ if USE_ME
|
||||||
sa/ikev2/tasks/ike_me.c sa/ikev2/tasks/ike_me.h
|
sa/ikev2/tasks/ike_me.c sa/ikev2/tasks/ike_me.h
|
||||||
endif
|
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
|
# build optional plugins
|
||||||
########################
|
########################
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,13 @@ struct private_daemon_t {
|
||||||
refcount_t ref;
|
refcount_t ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register plugins if built statically
|
||||||
|
*/
|
||||||
|
#ifdef STATIC_PLUGIN_CONSTRUCTORS
|
||||||
|
#include "plugin_constructors.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One and only instance of the daemon.
|
* One and only instance of the daemon.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -221,6 +221,15 @@ $(srcdir)/crypto/proposal/proposal_keywords_static.c: $(srcdir)/crypto/proposal/
|
||||||
$(GPERF) -N proposal_get_token_static -m 10 -C -G -c -t -D < \
|
$(GPERF) -N proposal_get_token_static -m 10 -C -G -c -t -D < \
|
||||||
$(srcdir)/crypto/proposal/proposal_keywords_static.txt > $@
|
$(srcdir)/crypto/proposal/proposal_keywords_static.txt > $@
|
||||||
|
|
||||||
|
if STATIC_PLUGIN_CONSTRUCTORS
|
||||||
|
BUILT_SOURCES += $(srcdir)/plugin_constructors.c
|
||||||
|
CLEANFILES = $(srcdir)/plugin_constructors.c
|
||||||
|
|
||||||
|
$(srcdir)/plugin_constructors.c: $(srcdir)/plugins/plugin_constructors.py
|
||||||
|
$(AM_V_GEN) \
|
||||||
|
$(PYTHON) $(srcdir)/plugins/plugin_constructors.py ${s_plugins} > $@
|
||||||
|
endif
|
||||||
|
|
||||||
if MONOLITHIC
|
if MONOLITHIC
|
||||||
SUBDIRS =
|
SUBDIRS =
|
||||||
else
|
else
|
||||||
|
|
|
@ -93,6 +93,13 @@ void library_add_namespace(char *ns)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register plugins if built statically
|
||||||
|
*/
|
||||||
|
#ifdef STATIC_PLUGIN_CONSTRUCTORS
|
||||||
|
#include "plugin_constructors.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* library instance
|
* library instance
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,6 +26,15 @@ tnc/tnccs/tnccs_manager.h tnc/tnccs/tnccs_manager.c
|
||||||
|
|
||||||
EXTRA_DIST = Android.mk
|
EXTRA_DIST = Android.mk
|
||||||
|
|
||||||
|
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 ${t_plugins} > $@
|
||||||
|
endif
|
||||||
|
|
||||||
# build optional plugins
|
# build optional plugins
|
||||||
########################
|
########################
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,13 @@ struct private_tnc_t {
|
||||||
refcount_t ref;
|
refcount_t ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register plugins if built statically
|
||||||
|
*/
|
||||||
|
#ifdef STATIC_PLUGIN_CONSTRUCTORS
|
||||||
|
#include "plugin_constructors.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Single instance of tnc_t.
|
* Single instance of tnc_t.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,6 +33,15 @@ else
|
||||||
SUBDIRS = .
|
SUBDIRS = .
|
||||||
endif
|
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 ${p_plugins} > $@
|
||||||
|
endif
|
||||||
|
|
||||||
if USE_TPM
|
if USE_TPM
|
||||||
SUBDIRS += plugins/tpm
|
SUBDIRS += plugins/tpm
|
||||||
if MONOLITHIC
|
if MONOLITHIC
|
||||||
|
|
|
@ -17,6 +17,13 @@
|
||||||
#include "tpm_tss_tss2.h"
|
#include "tpm_tss_tss2.h"
|
||||||
#include "tpm_tss_trousers.h"
|
#include "tpm_tss_trousers.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register plugins if built statically
|
||||||
|
*/
|
||||||
|
#ifdef STATIC_PLUGIN_CONSTRUCTORS
|
||||||
|
#include "plugin_constructors.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Described in header.
|
* Described in header.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue