openvswitch: only libopenvswitch depends on libunbound, libunwind

This is to make explicit the conditional select of libunwind is only
needed for libopenvswitch.  If we spill it over other packages, the
generated kconfig will have recursive dependency issue.  2 new patches
were made for this goal

The other thing is that "+libunwind" will cause it to be built if any of the
packages defined in this Makefile is enabled (y or m).  This is at the moment
by-design of the build system.

Libunwind does not support architectures like arc.  Use conditional select To
avoid (libunwind) build failures like the following,

  checking for ELF helper width... configure: error: Unknown ELF target: arc
  make[3]: *** [Makefile:65: /data/openwrt/build_dir/target-arc_arc700_uClibc/
  libunwind-1.3.1/.configured_68b329da9893e34099c7d8ad5cb9c940] Error 1

Things like "+PACKAGE_openvswitch-libopenvswitch:libunwind" will also result in
recursive deps error for chains of 3 nodes.  Kconfig construct like the
following will be made

	config A
		tristate
		select B
		depends on !(C) || (x)

	config B
		tristate
		select C

	config C
		tristate

	config x
		bool

Other changes include

 - Shared use of variable ovs__common_depends was removed
 - Ovn doc build was patched out

Link: https://github.com/openwrt/packages/pull/12959#issuecomment-665021413
Reported-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
This commit is contained in:
Yousong Zhou
2020-07-29 17:30:38 +08:00
parent f69f4f3fae
commit 52e074411b
7 changed files with 115 additions and 22 deletions
@@ -0,0 +1,60 @@
From 6324f0c594e3773c754861e630fff694d1bec15a Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Wed, 29 Jul 2020 17:29:14 +0800
Subject: [PATCH] build: only link libopenvswitch with libunwind, libunbound
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
lib/automake.mk | 2 ++
lib/libopenvswitch.pc.in | 2 +-
m4/openvswitch.m4 | 6 ++++--
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/automake.mk b/lib/automake.mk
index 95925b57c..df95bea10 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -10,6 +10,8 @@ lib_LTLIBRARIES += lib/libopenvswitch.la
lib_libopenvswitch_la_LIBADD = $(SSL_LIBS)
lib_libopenvswitch_la_LIBADD += $(CAPNG_LDADD)
lib_libopenvswitch_la_LIBADD += $(LIBBPF_LDADD)
+lib_libopenvswitch_la_LIBADD += $(LIBUNBOUND_LDADD)
+lib_libopenvswitch_la_LIBADD += $(LIBUNWIND_LDADD)
if WIN32
lib_libopenvswitch_la_LIBADD += ${PTHREAD_LIBS}
diff --git a/lib/libopenvswitch.pc.in b/lib/libopenvswitch.pc.in
index 2a3f2ca7b..c8d02eb5a 100644
--- a/lib/libopenvswitch.pc.in
+++ b/lib/libopenvswitch.pc.in
@@ -7,5 +7,5 @@ Name: libopenvswitch
Description: Open vSwitch library
Version: @VERSION@
Libs: -L${libdir} -lopenvswitch
-Libs.private: @LIBS@
+Libs.private: @LIBS@ @SSL_LIBS@ @CAPNG_LDADD@ @LIBBPF_LDADD@ @LIBUNBOUND_LDADD@ @LIBUNWIND_LDADD@
Cflags: -I${includedir}/openvswitch
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index ada31c491..6165cc7b1 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -623,7 +623,8 @@ AC_DEFUN([OVS_CHECK_UNBOUND],
[AC_CHECK_LIB(unbound, ub_ctx_create, [HAVE_UNBOUND=yes], [HAVE_UNBOUND=no])
if test "$HAVE_UNBOUND" = yes; then
AC_DEFINE([HAVE_UNBOUND], [1], [Define to 1 if unbound is detected.])
- LIBS="$LIBS -lunbound"
+ LIBUNBOUND_LDADD="-lunbound"
+ AC_SUBST(LIBUNBOUND_LDADD)
fi
AM_CONDITIONAL([HAVE_UNBOUND], [test "$HAVE_UNBOUND" = yes])
AC_SUBST([HAVE_UNBOUND])])
@@ -635,7 +636,8 @@ AC_DEFUN([OVS_CHECK_UNWIND],
[HAVE_UNWIND=no])
if test "$HAVE_UNWIND" = yes; then
AC_DEFINE([HAVE_UNWIND], [1], [Define to 1 if unwind is detected.])
- LIBS="$LIBS -lunwind"
+ LIBUNWIND_LDADD="-lunwind"
+ AC_SUBST(LIBUNWIND_LDADD)
fi
AM_CONDITIONAL([HAVE_UNWIND], [test "$HAVE_UNWIND" = yes])
AC_SUBST([HAVE_UNWIND])])