summaryrefslogtreecommitdiffstats
path: root/scripts/pkg-config-wrapper
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2018-09-03 10:40:49 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2018-09-06 08:47:38 +0200
commit4c6e7fa28b66dee069d10b514d5e1317173da250 (patch)
tree9a8a85efbcfe36fe8842f5e0ad3e819b73ae3b61 /scripts/pkg-config-wrapper
parenta7d93ba352b42652f275a946bc4473f2f47bf908 (diff)
downloadptxdist-4c6e7fa28b66dee069d10b514d5e1317173da250.tar.gz
ptxdist-4c6e7fa28b66dee069d10b514d5e1317173da250.tar.xz
pkg-config: cleanup and improve path and dependency handling
- move all search path magic into the wrapper script - use the wrapper script for host packages as well - enforce the dependencies for host packages - make it possible to overwrite the script in the BSP - track host and target dependencies separately Needed e.g. by barebox to build host tools Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts/pkg-config-wrapper')
-rwxr-xr-xscripts/pkg-config-wrapper55
1 files changed, 31 insertions, 24 deletions
diff --git a/scripts/pkg-config-wrapper b/scripts/pkg-config-wrapper
index 80656ddd4..11e586a20 100755
--- a/scripts/pkg-config-wrapper
+++ b/scripts/pkg-config-wrapper
@@ -1,8 +1,33 @@
#!/usr/bin/env bash
-declare -a PKG_CONFIG_ARRAY
-PKG_CONFIG_ARRAY=( $(type -a -P pkg-config) )
-PKG_CONFIG="${PKG_CONFIG_ARRAY[1]}"
+basedir="$(basename "$(dirname "$(dirname "$0")")")"
+
+declare -a prefix
+if [ "${basedir}" = "sysroot-cross" ]; then
+ prefix="$(dirname "$(dirname "$(dirname "$0")")")/sysroot-target/usr"
+ whitelist="${PKGCONFIG_WHITELIST_TARGET}"
+elif [ "${basedir}" = "sysroot-host" ]; then
+ prefix="$(dirname "$(dirname "$0")")"
+ whitelist="${PKGCONFIG_WHITELIST_HOST}"
+else
+ echo "$(basename ${0}): failed to determine prefix" >&2
+ exit 1
+fi
+
+declare -a libdir system_path system_incpath
+libdir=( "${prefix/%//lib/pkgconfig}" "${prefix/%//share/pkgconfig}" )
+system_libpath=( "${libdir[@]/%//../../lib}" "${libdir[@]/%//../lib}" "/usr/lib" "/lib" )
+system_incpath=( "${libdir[@]/%//../../include}" "${libdir[@]/%//../include}" "/usr/include" "/include" )
+
+orig_IFS="${IFS}"
+IFS=":"
+# default pkg-config searchs
+export PKG_CONFIG_LIBDIR="${libdir[*]}"
+# default search path that will be dropped from --cflags
+export PKG_CONFIG_SYSTEM_LIBRARY_PATH="${system_libpath[*]}"
+# default search path that will be dropped from --libs
+export PKG_CONFIG_SYSTEM_INCLUDE_PATH="${system_incpath[*]}"
+IFS="${orig_IFS}"
for ((i = 1; i <= ${#}; i++)); do
case "${!i}" in
@@ -34,24 +59,6 @@ if [ -n "${PTXDIST_PKG_CONFIG_VAR_NO_SYSROOT}" -a \
#
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
check_pipe_status() {
@@ -63,13 +70,13 @@ check_pipe_status() {
}
if [ -n "${PKGCONFIG_WHITELIST_SRC}" ]; then
- pkgs="$("${PKG_CONFIG}" --print-provides "${@}" 2>/dev/null | awk '{print $1}' && check_pipe_status)" &&
+ pkgs="$(pkg-config.real --print-provides "${@}" 2>/dev/null | awk '{print $1}' && check_pipe_status)" &&
for pkg in ${pkgs}; do
- if [[ ! " ${PKGCONFIG_WHITELIST} " =~ " ${pkg} " && ! "${pkg}" =~ '-uninstalled' ]]; then
+ if [[ ! " ${whitelist} " =~ " ${pkg} " && ! "${pkg}" =~ '-uninstalled' ]]; then
echo "$(basename ${0}): warning: blocking '${pkg}': not selected by '${PKGCONFIG_WHITELIST_SRC}'" >&2
exit 1
fi
done
fi
-"${PKG_CONFIG}" "${@}" | sed "${args[@]}"
+pkg-config.real "${@}" | sed "${args[@]}"
check_pipe_status