summaryrefslogtreecommitdiff
path: root/units/meson-add-wants.sh
blob: b7f57a5e2c9a98fed14b9ffb445b6f6d9abe83d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
set -eu

i=1
while [ $i -lt $# ] ; do
    eval unitdir="\${$i}"
    eval target="\${$((i + 1))}"
    eval unit="\${$((i + 2))}"

    if [ "${MESON_INSTALL_QUIET:-0}" = 1 ] ; then
        VERBOSE=""
    else
        VERBOSE="v"
    fi

    case "$target" in
        */?*) # a path, but not just a slash at the end
            dir="${DESTDIR:-}${target}"
            ;;
        *)
            dir="${DESTDIR:-}${unitdir}/${target}"
            ;;
    esac

    unitpath="${DESTDIR:-}${unitdir}/${unit}"

    case "$target" in
        */)
            mkdir -${VERBOSE}p -m 0755 "$dir"
            ;;
        *)
            mkdir -${VERBOSE}p -m 0755 "$(dirname "$dir")"
            ;;
    esac

    ln -${VERBOSE}fs --relative "$unitpath" "$dir"

    i=$((i + 3))
done