]> gitweb @ CieloNegro.org - autobuild.git/blob - lib/setPath.bash
src/preamble.bash: mention a plan on moving repository to GitHub.
[autobuild.git] / lib / setPath.bash
1 function setPath () {
2     if (( $# == 0 )); then
3         echo "Usage: $0 VAR [PATH, ...]" >&2
4         return 1
5     fi
6
7     local -r var="$1"
8     local paths=("${@:2}")
9
10     case ${#paths[@]} in
11         0)
12             unset $var;;
13         1)
14             export $var="$paths";;
15         *)
16             export $var="${paths[0]}"
17             local path
18             for path in "${paths[@]:1}"; do
19                 local val=$(eval echo \$$var)
20                 export $var="$val:$path"
21             done
22     esac
23
24     case "$var" in
25         "PATH")
26             # THINKME: Special case for PATH: we prepend "$prefix/bin"
27             # to it.
28             PATH="$prefix/bin:$PATH";;
29         "PKG_CONFIG_PATH")
30             # THINKME: Special case for PKG_CONFIG_PATH: we prepend
31             # "$prefix/lib/pkgconfig" to it.
32             PKG_CONFIG_PATH="$prefix/lib/pkgconfig";;
33         *)
34             ;;
35     esac
36 }