#!/bin/bash

set -eu

# Usage is like:
#   PKG_CONFIG_PATH="$(set -eu; build_pkg_config_path)"
#   export PKG_CONFIG_PATH

(
    # shellcheck disable=SC2154
    for directory in /usr/local/c"$which_python" /usr/lib /usr/lib64 /usr/share
    do
        if [ -d "$directory" ]
        then
            find "$directory" -name pkgconfig -print || true
        fi
    done

    # This gives us the OS' idea of what the PKG_CONFIG_PATH should be.
    /usr/bin/pkg-config --variable pc_path pkg-config | tr ':' '\012'
) \
    | tr '\012' ':' \
    | sed 's/:$//'
echo