about summary refs log tree commit diff
path: root/pkgs-ng/stdenv/generic/setup.sh
blob: 25b84bb5edcc9228686abd5c167f641340e61cbb (plain) (blame)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Set up the initial path.
for i in @INITIALPATH@; do
    PATH=$PATH:$i/bin
done
echo $PATH

# Execute the pre-hook.
param1=@PARAM1@
param2=@PARAM2@
param3=@PARAM3@
param4=@PARAM4@
param5=@PARAM5@
. @PREHOOK@

# Add the directory containing the GCC wrappers to the PATH.
export PATH=@OUT@/bin:$PATH

# Recursively add all buildinputs to the relevant environment variables.
addtoenv()
{
    pkgs="$buildinputs $1"

    if test -d $1/bin; then
        export PATH=$1/bin:$PATH
    fi

    if test -d $1/lib; then
        export NIX_CFLAGS_LINK="-L$1/lib $NIX_CFLAGS_LINK"
        export NIX_LDFLAGS="-rpath $1/lib $NIX_LDFLAGS"
    fi

    if test -d $1/lib/pkgconfig; then
        export PKG_CONFIG_PATH=$1/lib/pkgconfig:$PKG_CONFIG_PATH
    fi

    if test -d $1/include; then
        export NIX_CFLAGS_COMPILE="-I$1/include $NIX_CFLAGS_COMPILE"
    fi

    if test -f $1/propagated-build-inputs; then
        for i in $(cat $1/propagated-build-inputs); do
            addtoenv $i
        done
    fi
}

oldbuildinputs=$buildinputs
buildinputs=

for i in $oldbuildinputs; do
    addtoenv $i
done

# Add the output as an rpath.
if test "$NIX_NO_SELF_RPATH" != "1"; then
    export NIX_LDFLAGS="-rpath $out/lib $NIX_LDFLAGS"
fi

# Strip debug information by default.
export NIX_STRIP_DEBUG=1

# Execute the post-hook.
. @POSTHOOK@

if test "$NIX_DEBUG" == "1"; then
    echo "Setup: PATH=$PATH"
fi