about summary refs log tree commit diff
path: root/nixpkgs/pkgs/desktops/gnustep/make/builder.sh
blob: 79ead3f7b7295887aa21cef1a924cddbb46cd26c (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

providedPreConfigure="$preConfigure";

preConfigure() {
    eval "$providedPreConfigure"

    . $GNUSTEP_MAKEFILES/GNUstep.sh
}

wrapGSMake() {
    local program="$1"
    local config="$2"
    local wrapped="$(dirname $program)/.$(basename $program)-wrapped"

    mv "$program" "$wrapped"

    cat > "$program"<<EOF
#! $SHELL -e

export GNUSTEP_CONFIG_FILE="$config"

exec "$wrapped" "\$@"
EOF
    chmod +x "$program"
}

postInstall() {
    local conf="$out/share/.GNUstep.conf"

    mkdir -p "$out/share"
    touch $conf

    # add the current package to the paths
    local tmp="$out/lib/GNUstep/Applications"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_APPS" in *"${tmp}"*) false;; *) true;; esac; then
        addToSearchPath NIX_GNUSTEP_SYSTEM_APPS "$tmp"
    fi
    tmp="$out/lib/GNUstep/Applications"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_ADMIN_APPS" in *"${tmp}"*) false;; *) true;; esac; then
        addToSearchPath NIX_GNUSTEP_SYSTEM_ADMIN_APPS "$tmp"
    fi
    tmp="$out/lib/GNUstep/WebApplications"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_WEB_APPS" in *"${tmp}"*) false;; *) true;; esac; then
        addToSearchPath NIX_GNUSTEP_SYSTEM_WEB_APPS "$tmp"
    fi
    tmp="$out/bin"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_TOOLS" in *"${tmp}"*) false;; *) true;; esac; then
        addToSearchPath NIX_GNUSTEP_SYSTEM_TOOLS "$tmp"
    fi
    tmp="$out/sbin"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_ADMIN_TOOLS" in *"${tmp}"*) false;; *) true;; esac; then
        addToSearchPath NIX_GNUSTEP_SYSTEM_ADMIN_TOOLS "$tmp"
    fi
    tmp="$out/lib/GNUstep"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_LIBRARY" in *"${tmp}"*) false;; *) true;; esac; then
            addToSearchPath NIX_GNUSTEP_SYSTEM_LIBRARY "$tmp"
    fi
    tmp="$out/include"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_HEADERS" in *"${tmp}"*) false;; *) true;; esac; then
            if [ -z "$NIX_GNUSTEP_SYSTEM_HEADERS" ]; then
                export NIX_GNUSTEP_SYSTEM_HEADERS="$tmp"
            else
                export NIX_GNUSTEP_SYSTEM_HEADERS+=" $tmp"
            fi
    fi
    tmp="$out/lib"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_LIBRARIES" in *"${tmp}"*) false;; *) true;; esac; then
        addToSearchPath NIX_GNUSTEP_SYSTEM_LIBRARIES "$tmp"
    fi
    tmp="$out/share/GNUstep/Documentation"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_DOC" in *"${tmp}"*) false;; *) true;; esac; then
        addToSearchPath NIX_GNUSTEP_SYSTEM_DOC "$tmp"
    fi
    tmp="$out/share/man"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_DOC_MAN" in *"${tmp}"*) false;; *) true;; esac; then
        addToSearchPath NIX_GNUSTEP_SYSTEM_DOC_MAN "$tmp"
    fi
    tmp="$out/share/info"
    if [ -d "$tmp" ] && case "$NIX_GNUSTEP_SYSTEM_DOC_INFO" in *"${tmp}"*) false;; *) true;; esac; then
        addToSearchPath NIX_GNUSTEP_SYSTEM_DOC_INFO "$tmp"
    fi

    # write the config file
    echo GNUSTEP_MAKEFILES=$GNUSTEP_MAKEFILES >> $conf
    if [ -n "$NIX_GNUSTEP_SYSTEM_APPS" ]; then
        echo NIX_GNUSTEP_SYSTEM_APPS="$NIX_GNUSTEP_SYSTEM_APPS"
    fi
    if [ -n "$NIX_GNUSTEP_SYSTEM_ADMIN_APPS" ]; then
        echo NIX_GNUSTEP_SYSTEM_ADMIN_APPS="$NIX_GNUSTEP_SYSTEM_ADMIN_APPS" >> $conf
    fi
    if [ -n "$NIX_GNUSTEP_SYSTEM_WEB_APPS" ]; then
        echo NIX_GNUSTEP_SYSTEM_WEB_APPS="$NIX_GNUSTEP_SYSTEM_WEB_APPS" >> $conf
    fi
    if [ -n "$NIX_GNUSTEP_SYSTEM_TOOLS" ]; then
        echo NIX_GNUSTEP_SYSTEM_TOOLS="$NIX_GNUSTEP_SYSTEM_TOOLS" >> $conf
    fi
    if [ -n "$NIX_GNUSTEP_SYSTEM_ADMIN_TOOLS" ]; then
        echo NIX_GNUSTEP_SYSTEM_ADMIN_TOOLS="$NIX_GNUSTEP_SYSTEM_ADMIN_TOOLS" >> $conf
    fi
    if [ -n "$NIX_GNUSTEP_SYSTEM_LIBRARY" ]; then
        echo NIX_GNUSTEP_SYSTEM_LIBRARY="$NIX_GNUSTEP_SYSTEM_LIBRARY" >> $conf
    fi
    if [ -n "$NIX_GNUSTEP_SYSTEM_HEADERS" ]; then
        echo NIX_GNUSTEP_SYSTEM_HEADERS="$NIX_GNUSTEP_SYSTEM_HEADERS" >> $conf
    fi
    if [ -n "$NIX_GNUSTEP_SYSTEM_LIBRARIES" ]; then
        echo NIX_GNUSTEP_SYSTEM_LIBRARIES="$NIX_GNUSTEP_SYSTEM_LIBRARIES" >> $conf
    fi
    if [ -n "$NIX_GNUSTEP_SYSTEM_DOC" ]; then
        echo NIX_GNUSTEP_SYSTEM_DOC="$NIX_GNUSTEP_SYSTEM_DOC" >> $conf
    fi
    if [ -n "$NIX_GNUSTEP_SYSTEM_DOC_MAN" ]; then
        echo NIX_GNUSTEP_SYSTEM_DOC_MAN="$NIX_GNUSTEP_SYSTEM_DOC_MAN" >> $conf
    fi
    if [ -n "$NIX_GNUSTEP_SYSTEM_DOC_INFO" ]; then
        echo NIX_GNUSTEP_SYSTEM_DOC_INFO="$NIX_GNUSTEP_SYSTEM_DOC_INFO" >> $conf
    fi

    for i in $out/bin/*; do
        echo "wrapping $(basename $i)"
        wrapGSMake "$i" "$out/share/.GNUstep.conf"
    done
}

genericBuild