From: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org> Distributions won't like statically-linked binaries. Provide configure switch to link examples and tests dynamically.
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org> --- /** Email created from pull request 390 (lumag:dynamic-link-tests) ** https://github.com/Linaro/odp/pull/390 ** Patch: https://github.com/Linaro/odp/pull/390.patch ** Base sha: 520c170d758f2d37554631bf1467ec50e027cd3e ** Merge commit sha: 99e3ea3ce3180085458e6433d371763dec004329 **/ configure.ac | 11 +++++++++++ example/Makefile.inc | 4 ++++ platform/linux-generic/test/ring/Makefile.am | 5 +++++ test/Makefile.inc | 11 ++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 177881a58..3242c453c 100644 --- a/configure.ac +++ b/configure.ac @@ -172,6 +172,16 @@ AS_IF([test "${with_platform}" = "linux-generic"], AC_DEFINE_UNQUOTED([IMPLEMENTATION_NAME], ["$IMPLEMENTATION_NAME"], [Define to the name of the implementation]) +########################################################################## +# Build examples/tests dynamically +########################################################################## +AC_ARG_ENABLE([static-tests], + [AS_HELP_STRING([--disable-static-tests], + [disable static linking of examples and tests] + [ with ODP])], [], + [enable_static_tests=yes]) +AM_CONDITIONAL([STATIC_LINK], [test "x$enable_static_tests" != "xno"]) + ########################################################################## # Include m4 files ########################################################################## @@ -383,6 +393,7 @@ AC_MSG_RESULT([ Deprecated APIs: ${deprecated} debug: ${enable_debug} cunit: ${cunit_support} + static tests linkage: ${enable_static_tests} test_vald: ${test_vald} test_perf: ${test_perf} test_perf_proc: ${test_perf_proc} diff --git a/example/Makefile.inc b/example/Makefile.inc index fa1224338..829977ce8 100644 --- a/example/Makefile.inc +++ b/example/Makefile.inc @@ -13,4 +13,8 @@ AM_CFLAGS = \ -I$(top_srcdir)/platform/@with_platform@/arch/@ARCH_DIR@ \ -I$(top_builddir)/include +if STATIC_LINK AM_LDFLAGS = -L$(LIB) -static +else +AM_LDFLAGS = +endif diff --git a/platform/linux-generic/test/ring/Makefile.am b/platform/linux-generic/test/ring/Makefile.am index 8287c7e04..637d08e6a 100644 --- a/platform/linux-generic/test/ring/Makefile.am +++ b/platform/linux-generic/test/ring/Makefile.am @@ -1,3 +1,7 @@ +# ring test uses internal symbols from libodp-linux which are not available +# when linking test with libodp-linux.so +if STATIC_LINK + include $(top_srcdir)/test/Makefile.inc test_PROGRAMS = ring_main @@ -7,3 +11,4 @@ ring_main_SOURCES = \ ring_basic.c ring_stress.c PRELDADD += $(LIBCUNIT_COMMON) +endif diff --git a/test/Makefile.inc b/test/Makefile.inc index b0a8749dc..91c278302 100644 --- a/test/Makefile.inc +++ b/test/Makefile.inc @@ -11,9 +11,14 @@ LIBTHRMASK_COMMON = $(COMMON_DIR)/libthrmask_common.la #in the following line, the libs using the symbols should come before #the libs containing them! The includer is given a chance to add things #before libodp by setting PRELDADD before the inclusion. -LDADD = $(PRELDADD) $(LIBODP) $(DPDK_LIBS_LT) +LDADD = $(PRELDADD) $(LIBODP) PRELDADD = +# Do not link to DPDK twice in case of dynamic linking with ODP +if STATIC_LINK +LDADD += $(DPDK_LIBS_LT) +endif + INCFLAGS = \ -I$(top_builddir)/platform/@with_platform@/include \ -I$(top_srcdir)/helper/include \ @@ -28,7 +33,11 @@ AM_CPPFLAGS = $(INCFLAGS) AM_CPPFLAGS += -I$(top_srcdir)/test/common AM_CFLAGS = $(CUNIT_CFLAGS) +if STATIC_LINK AM_LDFLAGS = -L$(LIB) -static +else +AM_LDFLAGS = +endif @VALGRIND_CHECK_RULES@