From a0cdfcf936bcccd15d08a22c9cf38013b6859ad2 Mon Sep 17 00:00:00 2001 From: David Marchand Date: Fri, 22 Nov 2013 11:24:55 +0100 Subject: [PATCH] pcap: use pcap-config to guess compilation flags Use pcap-config to populate CFLAGS and LDFLAGS. LIBPCAP_CFLAGS and LIBPCAP_LDFLAGS can be used to override this (useful when cross-compiling). Signed-off-by: David Marchand Acked-by: Thomas Monjalon --- app/test-pmd/Makefile | 4 ---- doc/build-sdk-quick.txt | 2 ++ mk/rte.app.mk | 5 ++++- mk/rte.sdkbuild.mk | 8 ++++++++ mk/target/generic/rte.vars.mk | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile index 4f80442cd4..761d1daefa 100644 --- a/app/test-pmd/Makefile +++ b/app/test-pmd/Makefile @@ -39,10 +39,6 @@ APP = testpmd CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) -ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) -LDFLAGS += -lpcap -endif - # # all source are stored in SRCS-y # diff --git a/doc/build-sdk-quick.txt b/doc/build-sdk-quick.txt index 8989a32a60..bf7c350fcc 100644 --- a/doc/build-sdk-quick.txt +++ b/doc/build-sdk-quick.txt @@ -11,6 +11,8 @@ Build variables EXTRA_CPPFLAGS preprocessor options EXTRA_CFLAGS compiler options EXTRA_LDFLAGS linker options + LIBPCAP_CFLAGS libpcap compiler options + LIBPCAP_LDFLAGS libpcap linker options RTE_KERNELDIR linux headers path CROSS toolchain prefix V verbose diff --git a/mk/rte.app.mk b/mk/rte.app.mk index ec8e24eebb..d90a0b0eaf 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -170,7 +170,10 @@ LDLIBS += -lrte_cmdline endif ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) -LDLIBS += -lrte_pmd_pcap -lpcap +LDLIBS += -lrte_pmd_pcap +LIBPCAP_LDFLAGS ?= $(shell pcap-config --libs) +$(if $(LIBPCAP_LDFLAGS),,$(error LIBPCAP_LDFLAGS is undefined)) +LDLIBS += $(LIBPCAP_LDFLAGS) endif LDLIBS += $(EXECENV_LDLIBS) diff --git a/mk/rte.sdkbuild.mk b/mk/rte.sdkbuild.mk index 2975ee413b..0b6a7df8b9 100644 --- a/mk/rte.sdkbuild.mk +++ b/mk/rte.sdkbuild.mk @@ -40,6 +40,14 @@ else include $(RTE_SDK)/mk/rte.vars.mk endif +ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) +LIBPCAP_CFLAGS ?= $(shell pcap-config --cflags) +$(if $(LIBPCAP_CFLAGS),,$(error LIBPCAP_CFLAGS is undefined)) +EXTERNAL_LIB_CFLAGS += $(LIBPCAP_CFLAGS) +endif + +export EXTERNAL_LIB_CFLAGS + # # include .depdirs and define rules to order priorities between build # of directories. diff --git a/mk/target/generic/rte.vars.mk b/mk/target/generic/rte.vars.mk index 796cca7da2..a163272949 100644 --- a/mk/target/generic/rte.vars.mk +++ b/mk/target/generic/rte.vars.mk @@ -108,7 +108,7 @@ include $(RTE_SDK)/mk/rte.cpuflags.mk # merge all CFLAGS CFLAGS := $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS) -CFLAGS += $(TARGET_CFLAGS) +CFLAGS += $(TARGET_CFLAGS) $(EXTERNAL_LIB_CFLAGS) # merge all LDFLAGS LDFLAGS := $(CPU_LDFLAGS) $(EXECENV_LDFLAGS) $(TOOLCHAIN_LDFLAGS) $(MACHINE_LDFLAGS) -- 2.20.1