49 lines
1.5 KiB
Bash
49 lines
1.5 KiB
Bash
# Setup PKG_CONFIG_PATH for Apple Silicon Homebrew on macOS and LSB/standard paths on Linux
|
|
_setup_pkgconfig() {
|
|
[ -n "$ZSH_VERSION" ] && setopt localoptions nonomatch nullglob
|
|
|
|
_add_pkg_config_path() {
|
|
[ -d "$1" ] || return 0
|
|
case ":${PKG_CONFIG_PATH}:" in
|
|
*":$1:"*) ;;
|
|
*)
|
|
if [ -n "$PKG_CONFIG_PATH" ]; then
|
|
PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$1"
|
|
else
|
|
PKG_CONFIG_PATH="$1"
|
|
fi
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# macOS: Apple Silicon Homebrew
|
|
if [ -d "/opt/homebrew" ]; then
|
|
_add_pkg_config_path "/opt/homebrew/lib/pkgconfig"
|
|
_add_pkg_config_path "/opt/homebrew/share/pkgconfig"
|
|
for _dir in /opt/homebrew/opt/*/lib/pkgconfig \
|
|
/opt/homebrew/opt/*/share/pkgconfig; do
|
|
_add_pkg_config_path "$_dir"
|
|
done
|
|
fi
|
|
|
|
# Linux (apt / rpm / LSB / manual build & install paths) and user paths
|
|
for _dir in \
|
|
"$HOME/.local/lib/pkgconfig" \
|
|
"$HOME/.local/share/pkgconfig" \
|
|
/usr/local/lib/pkgconfig \
|
|
/usr/local/lib64/pkgconfig \
|
|
/usr/local/share/pkgconfig \
|
|
/usr/lib/pkgconfig \
|
|
/usr/lib64/pkgconfig \
|
|
/usr/share/pkgconfig \
|
|
/usr/lib/*-linux-gnu*/pkgconfig \
|
|
/usr/local/lib/*-linux-gnu*/pkgconfig
|
|
do
|
|
_add_pkg_config_path "$_dir"
|
|
done
|
|
|
|
export PKG_CONFIG_PATH
|
|
}
|
|
_setup_pkgconfig
|
|
unset -f _setup_pkgconfig _add_pkg_config_path
|