From 6e9d8fb22cbb8024307075e12b7abf20ff7955fd Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Tue, 10 May 2011 10:57:42 +0000 Subject: [PATCH] - bug#386: --enable-allsymbols option links all binaries to libunbound and reduces install size significantly. git-svn-id: file:///svn/unbound/trunk@2413 be551aaa-1e26-0410-a405-d3ace91eadb9 --- Makefile.in | 46 ++++++++++++++++++++++++++++++++++------------ configure | 20 ++++++++++++++++++++ configure.ac | 11 +++++++++++ doc/Changelog | 4 ++++ 4 files changed, 69 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index e9bce72aa..326c9385a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -45,6 +45,7 @@ UB_ON_WINDOWS=@UB_ON_WINDOWS@ WITH_PYTHONMODULE=@WITH_PYTHONMODULE@ WITH_PYUNBOUND=@WITH_PYUNBOUND@ PYTHON_SITE_PKG=@PYTHON_SITE_PKG@ +EXPORT_ALL_SYMBOLS=@EXPORT_ALL_SYMBOLS@ SWIG=@SWIG@ YACC=@YACC@ @@ -102,13 +103,25 @@ UNITTEST_SRC=$(patsubst $(srcdir)/%,%, \ testcode/readhex.c testcode/ldns-testpkts.c smallapp/worker_cb.c \ $(COMMON_SRC) UNITTEST_OBJ=$(addprefix $(BUILD),$(UNITTEST_SRC:.c=.lo)) $(COMPAT_OBJ) -DAEMON_SRC=$(patsubst $(srcdir)/%,%, $(wildcard $(srcdir)/daemon/*.c)) \ - $(COMMON_SRC) + +DAEMON_SRC=$(patsubst $(srcdir)/%,%, $(wildcard $(srcdir)/daemon/*.c)) +ifneq "$(EXPORT_ALL_SYMBOLS)" "yes" +DAEMON_SRC+=$(COMMON_SRC) +endif DAEMON_OBJ=$(addprefix $(BUILD),$(DAEMON_SRC:.c=.lo)) $(COMPAT_OBJ) -CHECKCONF_SRC=smallapp/unbound-checkconf.c smallapp/worker_cb.c $(COMMON_SRC) + +CHECKCONF_SRC=smallapp/unbound-checkconf.c smallapp/worker_cb.c +ifneq "$(EXPORT_ALL_SYMBOLS)" "yes" +CHECKCONF_SRC+=$(COMMON_SRC) +endif CHECKCONF_OBJ=$(addprefix $(BUILD),$(CHECKCONF_SRC:.c=.lo)) $(COMPAT_OBJ) -CONTROL_SRC=smallapp/unbound-control.c smallapp/worker_cb.c $(COMMON_SRC) + +CONTROL_SRC=smallapp/unbound-control.c smallapp/worker_cb.c +ifneq "$(EXPORT_ALL_SYMBOLS)" "yes" +CONTROL_SRC+=$(COMMON_SRC) +endif CONTROL_OBJ=$(addprefix $(BUILD),$(CONTROL_SRC:.c=.lo)) $(COMPAT_OBJ) + HOST_SRC=smallapp/unbound-host.c HOST_OBJ=$(addprefix $(BUILD),$(HOST_SRC:.c=.lo)) $(filter-out $(BUILD)compat/ctime_r.lo, $(COMPAT_OBJ)) UBANCHOR_SRC=smallapp/unbound-anchor.c @@ -224,10 +237,19 @@ else ldnslib= endif +UBSYMS+=-export-symbols $(srcdir)/libunbound/ubsyms.def +CLUBSYMS=-export-symbols $(BUILD)clubsyms.def +EXTRALINK= +ifeq "$(EXPORT_ALL_SYMBOLS)" "yes" +UBSYMS= +CLUBSYMS= +EXTRALINK=-L. -L.libs -lunbound +endif + libunbound.la: $(LIBUNBOUND_OBJ) $(ldnslib) $(INFO) Link $@ ifeq ($(CHECKLOCK_SRC),) - $Q$(LINK_LIB) -export-symbols $(srcdir)/libunbound/ubsyms.def -o $@ $(sort $(LIBUNBOUND_OBJ)) -rpath $(libdir) $(LIBS) + $Q$(LINK_LIB) $(UBSYMS) -o $@ $(sort $(LIBUNBOUND_OBJ)) -rpath $(libdir) $(LIBS) else cp $(srcdir)/libunbound/ubsyms.def $(BUILD)clubsyms.def echo lock_protect >> $(BUILD)clubsyms.def @@ -240,20 +262,20 @@ else echo checklock_init >> $(BUILD)clubsyms.def echo checklock_thrcreate >> $(BUILD)clubsyms.def echo checklock_thrjoin >> $(BUILD)clubsyms.def - $Q$(LINK_LIB) -export-symbols $(BUILD)clubsyms.def -o $@ $(sort $(LIBUNBOUND_OBJ)) -rpath $(libdir) $(LIBS) + $Q$(LINK_LIB) $(CLUBSYMS) -o $@ $(sort $(LIBUNBOUND_OBJ)) -rpath $(libdir) $(LIBS) endif -unbound$(EXEEXT): $(DAEMON_OBJ) $(ldnslib) +unbound$(EXEEXT): $(DAEMON_OBJ) libunbound.la $(ldnslib) $(INFO) Link $@ - $Q$(LINK) -o $@ $(sort $(DAEMON_OBJ)) -lssl $(LIBS) + $Q$(LINK) -o $@ $(sort $(DAEMON_OBJ)) $(EXTRALINK) -lssl $(LIBS) -unbound-checkconf$(EXEEXT): $(CHECKCONF_OBJ) $(ldnslib) +unbound-checkconf$(EXEEXT): $(CHECKCONF_OBJ) libunbound.la $(ldnslib) $(INFO) Link $@ - $Q$(LINK) -o $@ $(sort $(CHECKCONF_OBJ)) $(LIBS) + $Q$(LINK) -o $@ $(sort $(CHECKCONF_OBJ)) $(EXTRALINK) -lssl $(LIBS) -unbound-control$(EXEEXT): $(CONTROL_OBJ) $(ldnslib) +unbound-control$(EXEEXT): $(CONTROL_OBJ) libunbound.la $(ldnslib) $(INFO) Link $@ - $Q$(LINK) -o $@ $(sort $(CONTROL_OBJ)) -lssl $(LIBS) + $Q$(LINK) -o $@ $(sort $(CONTROL_OBJ)) $(EXTRALINK) -lssl $(LIBS) unbound-host$(EXEEXT): $(HOST_OBJ) libunbound.la $(ldnslib) $(INFO) Link $@ diff --git a/configure b/configure index 815900723..aa5110c16 100755 --- a/configure +++ b/configure @@ -607,6 +607,7 @@ enable_option_checking=no ac_subst_vars='LTLIBOBJS subdirs ldnsdir +EXPORT_ALL_SYMBOLS WINDRES UB_ON_WINDOWS CHECKLOCK_SRC @@ -763,6 +764,7 @@ enable_lock_checks enable_alloc_checks enable_alloc_lite enable_alloc_nonregional +enable_allsymbols with_ldns with_ldns_builtin ' @@ -1416,6 +1418,9 @@ Optional Features: enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes + --enable-allsymbols export all symbols from libunbound and link binaries + to it, smaller install size but libunbound export + table is polluted by internal symbols Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -16626,6 +16631,21 @@ fi +# Check whether --enable-allsymbols was given. +if test "${enable_allsymbols+set}" = set; then : + enableval=$enable_allsymbols; +fi + +case "$enable_allsymbols" in + no) + EXPORT_ALL_SYMBOLS=no + ;; + yes) + EXPORT_ALL_SYMBOLS=yes + ;; +esac + + # check this after all other compilation checks, since the linking of the lib # may break checks after this. use_ldns_builtin="no" diff --git a/configure.ac b/configure.ac index 7c3e2aff6..56597a9be 100644 --- a/configure.ac +++ b/configure.ac @@ -695,6 +695,17 @@ AC_REPLACE_FUNCS(memmove) AC_REPLACE_FUNCS(gmtime_r) AC_REPLACE_FUNCS(ctime_r) +AC_ARG_ENABLE(allsymbols, AC_HELP_STRING([--enable-allsymbols], [export all symbols from libunbound and link binaries to it, smaller install size but libunbound export table is polluted by internal symbols])) +case "$enable_allsymbols" in + no) + EXPORT_ALL_SYMBOLS=no + ;; + yes) + EXPORT_ALL_SYMBOLS=yes + ;; +esac +AC_SUBST(EXPORT_ALL_SYMBOLS) + # check this after all other compilation checks, since the linking of the lib # may break checks after this. use_ldns_builtin="no" diff --git a/doc/Changelog b/doc/Changelog index 2fd885674..9272b67c8 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +10 May 2011: Wouter + - bug#386: --enable-allsymbols option links all binaries to libunbound + and reduces install size significantly. + 14 April 2011: Wouter - configure created with newer autoconf 2.66. -- 2.47.2