pcap: use pcap-config to guess compilation flags
authorDavid Marchand <david.marchand@6wind.com>
Fri, 22 Nov 2013 10:24:55 +0000 (11:24 +0100)
committerDavid Marchand <david.marchand@6wind.com>
Wed, 26 Feb 2014 10:07:28 +0000 (11:07 +0100)
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 <david.marchand@6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
app/test-pmd/Makefile
doc/build-sdk-quick.txt
mk/rte.app.mk
mk/rte.sdkbuild.mk
mk/target/generic/rte.vars.mk

index 4f80442..761d1da 100644 (file)
@@ -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
 #
index 8989a32..bf7c350 100644 (file)
@@ -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
index ec8e24e..d90a0b0 100644 (file)
@@ -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)
index 2975ee4..0b6a7df 100644 (file)
@@ -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.
index 796cca7..a163272 100644 (file)
@@ -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)