xref: /dpdk/buildtools/options-ibverbs-static.sh (revision 2cca60310a0bca86483e3b62a1143a50f7484069)
1#! /bin/sh
2# SPDX-License-Identifier: BSD-3-Clause
3#
4# Print link options -l for static link of ibverbs.
5#
6# Static flavour of ibverbs and the providers libs are explicitly picked,
7# thanks to the syntax -l:libfoo.a
8# Other libs (pthread and nl) are unchanged, i.e. linked dynamically by default.
9#
10# PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
11
12lib='libibverbs'
13deps='pthread|nl'
14
15pkg-config --libs --static $lib |
16	tr '[:space:]' '\n' |
17	sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a," |   # explicit .a
18	sed -n '/^-[Ll]/p' |   # extra link options may break with make
19	tac |
20	awk "/^-l:$lib.a/&&c++ {next} 1" | # drop first duplicates of main lib
21	tac
22