Define more dependencies between libs

Change-Id: Ia74699bad15c1c583571944458fc8a5c3ded574b
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/Makefile.am b/src/Makefile.am
index 227accc..5e24897 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,7 +45,7 @@
 if ENABLE_DPDK_SHARED
 DPDK_LD_FLAGS = -Wl,--whole-archive,-ldpdk,--no-whole-archive
 else
-DPDK_LD_FLAGS = -Wl,--whole-archive,-l:libdpdk.a,--no-whole-archive
+DPDK_LD_FLAGS = -Wl,--whole-archive,-l:libdpdk.a,--no-whole-archive,-lm,-ldl
 endif
 if WITH_DPDK_CRYPTO
 DPDK_LD_ADD = -L$(AESNI_MULTI_BUFFER_LIB_PATH) -lIPSec_MB
diff --git a/src/vlib-api.am b/src/vlib-api.am
index 128cc07..6312f93 100644
--- a/src/vlib-api.am
+++ b/src/vlib-api.am
@@ -11,21 +11,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-lib_LTLIBRARIES += libvlibapi.la libvlibmemory.la libvlibmemoryclient.la \
+lib_LTLIBRARIES += libvlibmemory.la libvlibapi.la libvlibmemoryclient.la \
 	           libvlibsocket.la
 
-libvlibapi_la_LIBADD = libvppinfra.la
-libvlibapi_la_DEPENDENCIES = libvppinfra.la libvlib.la
-libvlibapi_la_SOURCES = 			\
-	vlibapi/api.h				\
-        vlibapi/api_helper_macros.h		\
-	vlibapi/api_shared.c			\
-	vlibapi/node_serialize.c
-
-nobase_include_HEADERS += vlibapi/api.h vlibapi/api_helper_macros.h
-
-libvlibmemory_la_LIBADD = libvppinfra.la libsvm.la -lpthread
 libvlibmemory_la_DEPENDENCIES = libvppinfra.la libsvm.la libvlib.la
+libvlibmemory_la_LIBADD = $(libvlibmemory_la_DEPENDENCIES) -lpthread
 libvlibmemory_la_SOURCES =			\
 	vlibmemory/api.h			\
 	vlibmemory/memclnt.api			\
@@ -36,8 +26,18 @@
 	vlibmemory/unix_shared_memory_queue.c	\
 	vlibmemory/unix_shared_memory_queue.h
 
-libvlibmemoryclient_la_LIBADD = libvppinfra.la libsvm.la -lpthread
-libvlibmemoryclient_la_DEPENDENCIES = libvppinfra.la libsvm.la libvlib.la
+libvlibapi_la_DEPENDENCIES = libvppinfra.la libvlib.la libvlibmemory.la
+libvlibapi_la_LIBADD = $(libvlibapi_la_DEPENDENCIES)
+libvlibapi_la_SOURCES = 			\
+	vlibapi/api.h				\
+        vlibapi/api_helper_macros.h		\
+	vlibapi/api_shared.c			\
+	vlibapi/node_serialize.c
+
+nobase_include_HEADERS += vlibapi/api.h vlibapi/api_helper_macros.h
+
+libvlibmemoryclient_la_DEPENDENCIES = libvppinfra.la libsvm.la libvlib.la libvlibmemory.la libvlibapi.la
+libvlibmemoryclient_la_LIBADD = $(libvlibmemoryclient_la_DEPENDENCIES) -lpthread
 libvlibmemoryclient_la_SOURCES = 		\
 	vlibmemory/api.h			\
 	vlibmemory/memclnt.api			\
@@ -55,8 +55,8 @@
 	vlibmemory/unix_shared_memory_queue.h 	\
 	vlibmemory/memclnt.api.h
 
-libvlibsocket_la_LIBADD = libvppinfra.la
-libvlibsocket_la_DEPENDENCIES = libvppinfra.la
+libvlibsocket_la_DEPENDENCIES = libvppinfra.la libvlib.la libvlibmemory.la libvlibapi.la
+libvlibsocket_la_LIBADD = $(libvlibsocket_la_DEPENDENCIES)
 libvlibsocket_la_SOURCES =			\
 	vlibsocket/api.h			\
 	vlibsocket/sockclnt.api			\
diff --git a/src/vlib.am b/src/vlib.am
index c21f88c..111dcfa 100644
--- a/src/vlib.am
+++ b/src/vlib.am
@@ -88,7 +88,6 @@
   vlib/unix/plugin.h				\
   vlib/unix/unix.h
 
-if !WITH_DPDK
 noinst_PROGRAMS += vlib_unix
 
 vlib_unix_SOURCES =				\
@@ -97,6 +96,5 @@
 
 vlib_unix_LDADD = libvlib.la \
 	          libvppinfra.la -lpthread -lm -ldl -lrt
-endif
 
 # vi:syntax=automake
diff --git a/src/vnet.am b/src/vnet.am
index 47c5eda..76824fd 100644
--- a/src/vnet.am
+++ b/src/vnet.am
@@ -14,9 +14,17 @@
 lib_LTLIBRARIES += libvnet.la
 
 libvnet_la_SOURCES =
+libvnet_la_DEPENDENCIES = \
+	libvppinfra.la		\
+	libvlib.la		\
+	libsvmdb.la		\
+	libsvm.la 		\
+	libvlibapi.la		\
+	libvlibmemory.la	\
+	libvlibmemoryclient.la
 
-libvnet_la_LIBADD = libvppinfra.la libsvm.la
-libvnet_la_DEPENDENCIES = libvppinfra.la libvlib.la libsvmdb.la libsvm.la libvlibapi.la libvlibmemory.la libvlibmemoryclient.la
+libvnet_la_LIBADD = $(libvnet_la_DEPENDENCIES) -lm -lpthread -ldl -lrt $(DPDK_LD_ADD)
+libvnet_la_LDFLAGS = $(DPDK_LD_FLAGS)
 
 if WITH_IPV6SR
 libvnet_la_LIBADD += -lcrypto
@@ -579,7 +587,7 @@
   libsvmdb.la \
   libvlibapi.la \
   libvlibmemory.la \
-  -lpthread -ldl -lrt -lm -lcrypto
+  -lpthread -ldl -lrt -lm
 
 TESTS += test_cp_serdes test_lisp_types
 
@@ -597,10 +605,8 @@
 test_cp_serdes_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
 test_lisp_types_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
 
-test_cp_serdes_LDFLAGS = $(DPDK_LD_FLAGS)
-test_cp_serdes_LDADD = $(LDS) $(DPDK_LD_ADD)
-test_lisp_types_LDFLAGS = $(DPDK_LD_FLAGS)
-test_lisp_types_LDADD = $(LDS) $(DPDK_LD_ADD)
+test_cp_serdes_LDADD = $(LDS)
+test_lisp_types_LDADD = $(LDS)
 endif
 
 ########################################
diff --git a/src/vpp-api-test.am b/src/vpp-api-test.am
index c788666..3261005 100644
--- a/src/vpp-api-test.am
+++ b/src/vpp-api-test.am
@@ -33,7 +33,6 @@
   vat/json_format.c	\
   vat/json_test.c
 
-vpp_api_test_LDFLAGS = $(DPDK_LD_FLAGS)
 vpp_api_test_LDADD = \
   libvlib.la				\
   libvlibmemoryclient.la		\
@@ -42,8 +41,7 @@
   libvppinfra.la 			\
   libvlibapi.la				\
   libvlibmemory.la			\
-  libvnet.la \
-  $(DPDK_LD_ADD)			\
+  libvnet.la				\
   -lpthread -lm -lrt -ldl -lcrypto
 
 vpp_json_test_LDADD = libvppinfra.la -lm
diff --git a/src/vpp.am b/src/vpp.am
index be55c40..425f1e3 100644
--- a/src/vpp.am
+++ b/src/vpp.am
@@ -75,10 +75,8 @@
   libvnet.la \
   libsvm.la \
   libsvmdb.la \
-  -lrt
-
-bin_vpp_LDFLAGS = $(DPDK_LD_FLAGS)
-bin_vpp_LDADD += libvppinfra.la -lm -lpthread -ldl $(DPDK_LD_ADD)
+  libvppinfra.la \
+  -lrt -lm -lpthread -ldl
 
 if ENABLE_TESTS
 noinst_PROGRAMS += bin/test_client