summaryrefslogtreecommitdiffstats
path: root/scripts/pkg-config-wrapper
blob: 927693aa695dbe6958dcc3c51788195d227740fa (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
#!/bin/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}/~/~"
fi

"${PKG_CONFIG}" "${@}" | sed "${args[@]}"
check_pipe_status