diff mbox series

[v2,5/8] build: provide an option to link examples dynamically

Message ID 1514714407-7846-6-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [v2,1/8] helper: link against libpthread and libodp-linux | expand

Commit Message

Github ODP bot Dec. 31, 2017, 10 a.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@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.ereminsolenikov@linaro.org>

---
/** Email created from pull request 377 (lumag:misc-fixes)
 ** https://github.com/Linaro/odp/pull/377
 ** Patch: https://github.com/Linaro/odp/pull/377.patch
 ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea
 ** Merge commit sha: 220e6aded9453e606a66be584a78d7d08718be8d
 **/
 configure.ac         | 10 ++++++++++
 example/Makefile.inc |  4 ++++
 test/Makefile.inc    |  4 ++++
 3 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index 177881a58..109eaea9e 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-link],
+	      [AS_HELP_STRING([--disable-static-link],
+			      [disable static linking of examples and tests])],
+	      [static_link=$enableval],
+	      [static_link=yes])
+AM_CONDITIONAL([STATIC_LINK], [test "x$static_link" != "xno"])
+
 ##########################################################################
 # Include m4 files
 ##########################################################################
diff --git a/example/Makefile.inc b/example/Makefile.inc
index 1609066e6..4cf5cfacc 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/test/Makefile.inc b/test/Makefile.inc
index f7c0da214..d7e435038 100644
--- a/test/Makefile.inc
+++ b/test/Makefile.inc
@@ -18,7 +18,11 @@  INCFLAGS = \
 AM_CPPFLAGS = $(INCFLAGS)
 AM_CFLAGS = $(CUNIT_CFLAGS)
 
+if STATIC_LINK
 AM_LDFLAGS = -L$(LIB) -static
+else
+AM_LDFLAGS =
+endif
 
 @VALGRIND_CHECK_RULES@