aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2017-04-28 17:49:50 +0200
committerTobias Brunner <tobias@strongswan.org>2017-05-23 18:29:12 +0200
commit4a0b6d659d2fb0473b75cf53bb1a0934983d270c (patch)
treedfe74308338c55e470c99af6221ee2f3193c6e3a /src/libcharon
parent8699275ed6954037f598a1824319f2cdf9deb4b1 (diff)
downloadstrongswan-4a0b6d659d2fb0473b75cf53bb1a0934983d270c.tar.bz2
strongswan-4a0b6d659d2fb0473b75cf53bb1a0934983d270c.tar.xz
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.
Diffstat (limited to 'src/libcharon')
-rw-r--r--src/libcharon/Makefile.am9
-rw-r--r--src/libcharon/daemon.c7
2 files changed, 16 insertions, 0 deletions
diff --git a/src/libcharon/Makefile.am b/src/libcharon/Makefile.am
index 8461d6230..3fcaedc3b 100644
--- a/src/libcharon/Makefile.am
+++ b/src/libcharon/Makefile.am
@@ -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
########################
diff --git a/src/libcharon/daemon.c b/src/libcharon/daemon.c
index eadc10a6a..8daea783f 100644
--- a/src/libcharon/daemon.c
+++ b/src/libcharon/daemon.c
@@ -118,6 +118,13 @@ struct private_daemon_t {
};
/**
+ * Register plugins if built statically
+ */
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+#include "plugin_constructors.c"
+#endif
+
+/**
* One and only instance of the daemon.
*/
daemon_t *charon;