diff mbox series

[5/6] config: discover libpcap on Windows

Message ID 20210214012013.23165-6-dmitry.kozliuk@gmail.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers show
Series net/pcap: build on Windows | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Dmitry Kozlyuk Feb. 14, 2021, 1:20 a.m. UTC
WinPcap or Npcap, can be installed anywhere.
Add a Meson option to specify SDK path.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 config/meson.build | 21 ++++++++++++++++++---
 meson_options.txt  |  6 ++++--
 2 files changed, 22 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/config/meson.build b/config/meson.build
index 3cf560b8a..6aae8276c 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -178,9 +178,24 @@  if not pcap_dep.found()
 	# pcap got a pkg-config file only in 1.9.0
 	pcap_dep = cc.find_library('pcap', required: false)
 endif
-if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
-	dpdk_conf.set('RTE_PORT_PCAP', 1)
-	dpdk_extra_ldflags += '-lpcap'
+if is_windows
+	# npcap SDK can be installed anywhere
+	pcap_sdk = get_option('pcap_sdk')
+	if pcap_sdk != ''
+		pcap_ldflags = ['-L@0@/Lib/x64'.format(pcap_sdk), '-lwpcap']
+		pcap_dep = declare_dependency(
+			compile_args: ['-I@0@/Include'.format(pcap_sdk)],
+			link_args: pcap_ldflags)
+	endif
+	if pcap_dep.found()
+		dpdk_conf.set('RTE_PORT_PCAP', 1)
+		dpdk_extra_ldflags += pcap_ldflags
+	endif
+else
+	if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
+		dpdk_conf.set('RTE_PORT_PCAP', 1)
+		dpdk_extra_ldflags += '-lpcap'
+	endif
 endif
 
 # for clang 32-bit compiles we need libatomic for 64-bit atomic ops
diff --git a/meson_options.txt b/meson_options.txt
index 6eff62e47..d74146d3a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -10,6 +10,8 @@  option('enable_docs', type: 'boolean', value: false,
 	description: 'build documentation')
 option('enable_kmods', type: 'boolean', value: false,
 	description: 'build kernel modules')
+option('enable_trace_fp', type: 'boolean', value: false,
+	description: 'enable fast path trace points.')
 option('examples', type: 'string', value: '',
 	description: 'Comma-separated list of examples to build by default')
 option('flexran_sdk', type: 'string', value: '',
@@ -28,8 +30,8 @@  option('max_lcores', type: 'integer', value: 128,
 	description: 'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 32,
 	description: 'maximum number of NUMA nodes supported by EAL')
-option('enable_trace_fp', type: 'boolean', value: false,
-	description: 'enable fast path trace points.')
+option('pcap_sdk', type: 'string', value: '',
+	description: 'Path to libpcap SDK used on Windows')
 option('tests', type: 'boolean', value: true,
 	description: 'build unit tests')
 option('use_hpet', type: 'boolean', value: false,