build: replace meson OS detection with variable
[dpdk.git] / buildtools / options-ibverbs-static.sh
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
12 lib='libibverbs'
13 deps='pthread|nl'
14
15 pkg-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