-
Notifications
You must be signed in to change notification settings - Fork 3
/
spackle-pathify
141 lines (120 loc) · 4.6 KB
/
spackle-pathify
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# This sets up a pathify environment. Put this file at
# ~/.pathify/spackle
# then run
# pathify spackle
# to activate this environment.
#
# This file must be loaded from pathify. (Or you can source it directly)
# You cannot run it.
#
# This sets up environment variables for a spackle build environment
deactivate_spackle () {
# reset old environment variables
if [ -n "${_OLD_SPACKLE_PATH+set}" ] ; then
PATH="$_OLD_SPACKLE_PATH"
[ -z "$PATH" ] && unset PATH || export PATH
unset _OLD_SPACKLE_PATH
fi
if [ -n "${_OLD_SPACKLE_MANPATH+set}" ] ; then
MANPATH="$_OLD_SPACKLE_MANPATH"
[ -z "$MANPATH" ] && unset MANPATH || export MANPATH
unset _OLD_SPACKLE_MANPATH
fi
if [ -n "${_OLD_SPACKLE_INFOPATH+set}" ] ; then
INFOPATH="$_OLD_SPACKLE_INFOPATH"
[ -z "$INFOPATH" ] && unset INFOPATH || export INFOPATH
unset _OLD_SPACKLE_INFOPATH
fi
if [ -n "${_OLD_SPACKLE_CFLAGS+set}" ] ; then
CFLAGS="$_OLD_SPACKLE_CFLAGS"
[ -z "$CFLAGS" ] && unset CFLAGS || export CFLAGS
unset _OLD_SPACKLE_CFLAGS
fi
if [ -n "${_OLD_SPACKLE_CXXFLAGS+set}" ] ; then
CXXFLAGS="$_OLD_SPACKLE_CXXFLAGS"
[ -z "$CXXFLAGS" ] && unset CXXFLAGS || export CXXFLAGS
unset _OLD_SPACKLE_CXXFLAGS
fi
if [ -n "${_OLD_SPACKLE_CPPFLAGS+set}" ] ; then
CPPFLAGS="$_OLD_SPACKLE_CPPFLAGS"
[ -z "$CPPFLAGS" ] && unset CPPFLAGS || export CPPFLAGS
unset _OLD_SPACKLE_CPPFLAGS
fi
if [ -n "${_OLD_SPACKLE_LDFLAGS+set}" ] ; then
LDFLAGS="$_OLD_SPACKLE_LDFLAGS"
[ -z "$LDFLAGS" ] && unset LDFLAGS || export LDFLAGS
unset _OLD_SPACKLE_LDFLAGS
fi
if [ -n "${_OLD_SPACKLE_LD_RUN_PATH+set}" ] ; then
LD_RUN_PATH="$_OLD_SPACKLE_LD_RUN_PATH"
[ -z "$LD_RUN_PATH" ] && unset LD_RUN_PATH || export LD_RUN_PATH
unset _OLD_SPACKLE_LD_RUN_PATH
fi
if [ -n "${_OLD_SPACKLE_MAKEFLAGS+set}" ] ; then
MAKEFLAGS="$_OLD_SPACKLE_MAKEFLAGS"
[ -z "$MAKEFLAGS" ] && unset MAKEFLAGS || export MAKEFLAGS
unset _OLD_SPACKLE_MAKEFLAGS
fi
if [ -n "${_OLD_SPACKLE_PKG_CONFIG_PATH+set}" ] ; then
PKG_CONFIG_PATH="$_OLD_SPACKLE_PKG_CONFIG_PATH"
[ -z "$PKG_CONFIG_PATH" ] && unset PKG_CONFIG_PATH || export PKG_CONFIG_PATH
unset _OLD_SPACKLE_PKG_CONFIG_PATH
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r
fi
if [ -n "$_OLD_SPACKLE_PS1" ] ; then
PS1="$_OLD_SPACKLE_PS1"
export PS1
unset _OLD_SPACKLE_PS1
fi
unset SPACKLE_ENV
unset SPACKLE_PREFIX
if [ ! "$1" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate_spackle
fi
}
# unset irrelavent variables
deactivate_spackle nondestructive
SPACKLE_ENV="spackle"
export SPACKLE_ENV
SPACKLE_PREFIX="$HOME/local"
export SPACKLE_PREFIX
_OLD_SPACKLE_PATH="$PATH"
export PATH="$SPACKLE_PREFIX/bin:$SPACKLE_PREFIX/usr/bin:$SPACKLE_PREFIX/usr/sbin:$PATH"
_OLD_SPACKLE_MANPATH="$MANPATH"
export MANPATH="$SPACKLE_PREFIX/usr/share/man:$MANPATH"
_OLD_SPACKLE_INFOPATH="$INFOPATH"
export INFOPATH="$SPACKLE_PREFIX/usr/share/info:$INFOPATH"
_OLD_SPACKLE_CFLAGS="$CFLAGS"
export CFLAGS="-I$SPACKLE_PREFIX/usr/include $CFLAGS"
_OLD_SPACKLE_CXXFLAGS="$CXXFLAGS"
export CXXFLAGS="-I$SPACKLE_PREFIX/usr/include $CXXFLAGS"
_OLD_SPACKLE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="-I$SPACKLE_PREFIX/usr/include $CPPFLAGS"
_OLD_SPACKLE_LDFLAGS="$LDFLAGS"
export LDFLAGS="-L$SPACKLE_PREFIX/usr/lib -Wl,-rpath,$SPACKLE_PREFIX/usr/lib $LDFLAGS"
_OLD_SPACKLE_LD_RUN_PATH="$LD_RUN_PATH"
export LD_RUN_PATH="$SPACKLE_PREFIX/usr/lib${LD_RUN_PATH:+:$LD_RUN_PATH}"
_OLD_SPACKLE_MAKEFLAGS="$MAKEFLAGS"
export MAKEFLAGS="-j1 $MAKEFLAGS"
_OLD_SPACKLE_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="$SPACKLE_PREFIX/usr/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
if [ -z "$SPACKLE_DISABLE_PROMPT" ] &&
[ -z "$PATHIFY_DISABLE_PROMPT" ] ; then
_OLD_SPACKLE_PS1="$PS1"
# Add env name before first non-whitespace PS1 char
PS1=$(echo "$PS1" | sed -e '0,/\S/ s//[spackle] &/')
export PS1
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r
fi
# vim: set ft=zsh ts=4 sw=4 sts=4 et: