summaryrefslogtreecommitdiff
path: root/util/pkg-config.sh
diff options
context:
space:
mode:
Diffstat (limited to 'util/pkg-config.sh')
-rwxr-xr-xutil/pkg-config.sh64
1 files changed, 62 insertions, 2 deletions
diff --git a/util/pkg-config.sh b/util/pkg-config.sh
index d9e64d22d..22d2815b3 100755
--- a/util/pkg-config.sh
+++ b/util/pkg-config.sh
@@ -1,3 +1,63 @@
#!/bin/bash
-echo "$@" | grep -- --atleast >/dev/null && exit 0
-exec pkg-config "$@"
+
+#echo 1>&2
+#echo ::: "$@" 1>&2
+
+declare -a args
+declare -a pkgs
+unset dbpf
+
+while [[ $# -ne 0 ]]; do case "$1" in
+ (--atleast-pkgconfig-version)
+ exec pkg-config "$1" "$2"
+ ;;
+
+ (--cflags|--libs|--variable=*)
+ dbpf=
+ args[${#args[@]}]=$1
+ ;;
+
+ (--errors-to-stdout|--exists|--modversion|--print-errors|--short-errors|--uninstalled)
+ args[${#args[@]}]=$1
+ ;;
+
+ (--atleast-version|--exact-version|--max-version)
+ args[${#args[@]}]=$1
+ args[${#args[@]}]=$2
+ shift
+ ;;
+
+ (--*)
+ echo "unknown pkg-config option $1" 1>&2
+ exit 1
+ ;;
+
+ (*)
+ pkgs[${#pkgs[@]}]=$1
+ ;;
+esac; shift; done
+
+if [[ ${dbpf+@} ]]; then
+ source "${PKG_BASE}/folders.sh"
+fi
+
+outs=
+for pkg in "${pkgs[@]}"; do
+ args_=("${args[@]}")
+
+ if [[ ${dbpf+@} ]]; then
+ dest=$(for dep in $(find -L "${PKG_DATA}"/_metadata -name '*.dep' | cut -d '/' -f -); do
+ DEP_NAME=$(basename "${dep}" .dep)
+ DEP_DEST=$(PKG_DEST_ "${DEP_NAME}")
+
+ find "${DEP_DEST}" -name "${pkg}.pc" -printf "${DEP_DEST}\n"
+ done) && args_=(--define-variable=prefix="${dest}/usr" "${args_[@]}")
+ fi
+
+ #echo @@@ pkg-config "${args_[@]}" "${pkg}" 1>&2
+ out=$(pkg-config "${args_[@]}" "${pkg}") || exit $?
+ #echo "=== ${out}" 1>&2
+ outs+=\ ${out}
+done
+
+echo "${out#\ }"