blob: b19a845d01f77b4c45fe84c6a9e5a54bca0c9b5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/usr/bin/env bash
declare -a PKG_CONFIG_ARRAY
PKG_CONFIG_ARRAY=( $(type -a -P pkg-config) )
PKG_CONFIG="${PKG_CONFIG_ARRAY[1]}"
for ((i = 1; i <= ${#}; i++)); do
case "${!i}" in
--variable*)
found_var=true
break
;;
*)
;;
esac
done
#
# this sed will sanitize pkg-config's output. it will remove:
#
# "/usr/lib/pkgconfig/../../.."
# "/lib/pkgconfig/../.."
#
declare -a args
args=( \
"-e" "s~/usr/lib/pkgconfig/\.\./\.\./\.\.~~g" \
"-e" "s~/lib/pkgconfig/\.\./\.\.~~g" \
)
if [ -n "${PTXDIST_PKG_CONFIG_VAR_NO_SYSROOT}" -a \
-n "${found_var}" ]; then
#
# remove sysroot for variables that return a path
#
args[${#args[@]}]="-e"
args[${#args[@]}]="s~^${SYSROOT}/~/~"
else
declare -a sysroot_prefix
#
# this shell/sed magic removes "-I$SYSROOT/include" from
# pkg-config's output
#
#
# transform from PATH to array: /foo:/bar -> /foo /bar
#
sysroot_prefix=( ${PTXDIST_PATH_SYSROOT_PREFIX//:/ } )
#
# make sed expression: -e s~-I/foo/include\(\s\|$\)~~
# remove whitespace
#
sysroot_prefix=( ${sysroot_prefix[@]/%//include\\(\\s\\|$\\)~~} )
args=( ${args[@]} ${sysroot_prefix[@]/#/-e s~-I} -e "s~\s\+~ ~g" -e "s~^\s\+$~~")
fi
"${PKG_CONFIG}" "${@}" | sed "${args[@]}"
for _pipe_status in "${PIPESTATUS[@]}"; do
if [ ${_pipe_status} -ne 0 ]; then
exit ${_pipe_status}
fi
done
|