[07/10] build/zdtm: Use pkg-config to find includes/libs

Submitted by Dmitry Safonov on Nov. 21, 2019, 9:56 p.m.

Details

Message ID 20191121215643.275552-8-dima@arista.com
State Accepted
Series "build: Test and support armv7 cross"
Commit 3793cef5007b9b40d43c32bac99a62bb93bea644
Headers show

Commit Message

Dmitry Safonov Nov. 21, 2019, 9:56 p.m.
Helps to cross-compile zdtm tests in case somebody needs it.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 test/zdtm/Makefile.inc    | 13 +++++++++++++
 test/zdtm/static/Makefile |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/Makefile.inc b/test/zdtm/Makefile.inc
index d132ca98175c..32fc72d320d6 100644
--- a/test/zdtm/Makefile.inc
+++ b/test/zdtm/Makefile.inc
@@ -53,12 +53,25 @@  endif
 RM := rm -f --one-file-system
 
 ifeq ($(COMPAT_TEST),y)
+        # Firstly look for 32-bit libs and then in standard path.
+        PKG_CONFIG_PATH := $(shell pkg-config --variable pc_path pkg-config)
+        PKG_CONFIG_PATH := /usr/lib32/pkgconfig:$(PKG_CONFIG_PATH)
 ifeq ($(ARCH),x86)
         export CFLAGS += -m32
         export LDFLAGS += -m32
+        PKG_CONFIG_PATH := /usr/lib/i386-linux-gnu/pkgconfig:$(PKG_CONFIG_PATH)
 endif
+        export PKG_CONFIG_PATH
 endif
 
+define pkg-libs
+        $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --libs $(1))
+endef
+
+define pkg-cflags
+        $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --cflags $(1))
+endef
+
 %.d: %.c
 	$(E) " DEP      " $@
 	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -MM -MP -c $< -o $@
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index e0d4d2c5cbb9..36d00ca5c84f 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -528,8 +528,8 @@  stopped12:		CFLAGS += -DZDTM_STOPPED_KILL -DZDTM_STOPPED_TKILL
 clone_fs:		LDLIBS += -pthread
 # As generating dependencies won't work without proper includes,
 # we have to explicitly specify both .o and .d for this case:
-netns_sub_veth.o netns_sub_veth.d:	CPPFLAGS += -I/usr/include/libnl3
-netns_sub_veth:		LDLIBS += -lnl-3 -l nl-route-3
+netns_sub_veth.o netns_sub_veth.d: CPPFLAGS += $(call pkg-cflags, libnl-3.0)
+netns_sub_veth:		LDLIBS += $(call pkg-libs, libnl-route-3.0 libnl-3.0)
 
 socket-tcp-fin-wait1:	CFLAGS += -D ZDTM_TCP_FIN_WAIT1
 socket-tcp-fin-wait2:	CFLAGS += -D ZDTM_TCP_FIN_WAIT2