forked from pspdev/psptoolchain
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprepare.sh
executable file
·234 lines (213 loc) · 4.6 KB
/
prepare.sh
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/bin/sh
case "$(uname -s)" in
Linux)
if command -v apt >/dev/null 2>&1
then
if [ "$(id -u)" -ne "0" ]
then
cat >&2 <<_EOF_
Warning: running without superuser privileges
THIS IS MOST LIKELY GOING TO FAIL.
Run this script using sudo, su or pkexec.
_EOF_
fi
set -e
echo 'Installing dependency packages using APT...'
apt install \
autoconf \
automake \
bison \
build-essential \
bzip2 \
ca-certificates \
cmake \
doxygen \
flex \
gcc \
git \
gzip \
g++ \
libelf-dev \
libfreetype6-dev \
libncurses-dev \
libreadline-dev \
libusb-dev \
libtool \
libtool-bin \
subversion \
tcl \
texinfo \
wget \
xz-utils \
zlib1g-dev
elif command -v apt-get >/dev/null
then
if [ "$(id -u)" -ne "0" ]
then
cat >&2 <<_EOF_
Warning: running without superuser privileges
THIS IS MOST LIKELY GOING TO FAIL.
Run this script using sudo, su or pkexec.
_EOF_
fi
set -e
echo 'Installing dependency packages using legacy APT...'
apt-get install \
autoconf \
automake \
automake1.9 \
bison \
build-essential \
bzip2 \
cmake \
doxygen \
flex \
gcc \
git \
gzip \
g++ \
libelf-dev \
libfreetype6-dev \
libncurses5-dev \
libreadline-dev \
libusb-dev \
libtool \
libtool-bin \
subversion \
tcl \
texinfo \
xz-utils \
zlib1g-dev
elif command -v dnf >/dev/null 2>&1
then
cat >&2 <<_EOF_
Error: DNF is not supported yet
_EOF_
exit 77
elif command -v yum >/dev/null 2>&1
then
cat >&2 <<_EOF_
Error: YUM is not supported yet
_EOF_
exit 77
elif command -v pacman >/dev/null 2>&1
then
cat >&2 <<_EOF_
Error: pacman is not supported yet
_EOF_
exit 77
else
cat >&2 <<_EOF_
Error: your Linux distribution uses an unknown package manager or doesn't have one.
_EOF_
exit 77
fi
;;
Darwin)
LIBUSB_URL='https://downloads.sourceforge.net/project/libusb/libusb-0.1%20%28LEGACY%29/0.1.12/libusb-0.1.12.tar.gz'
cleanup_libusb ()
{
echo 'Cleaning up libUSB...'
rm -rf libusb-legacy libusb-legacy.tar.gz
}
download_libusb ()
{
echo 'Downloading libUSB (legacy version)...'
if command -v wget >/dev/null 2>&1
then
wget --continue -O libusb-legacy.tar.gz "$LIBUSB_URL"
elif command -v curl >/dev/null 2>&1
then
curl --continue-at - -o libusb-legacy.tar.gz "$LIBUSB_URL"
else
cat >&2 <<_EOF_
Error: no suitable downloader found.
Install one of these:
* wget (preferred) <https://www.gnu.org/software/wget/>
* curl <https://curl.haxx.se/>
_EOF_
exit 77
fi
}
build_libusb ()
{
echo 'Configuring libUSB (legacy version)...'
mkdir build
cd build
../configure CFLAGS='-Wno-error' CPPFLAGS='-Wno-error'
echo 'Building libUSB (legacy version)...'
make
echo 'Installing libUSB (legacy version)...'
make install
cd ..
}
install_libusb ()
{
cleanup_libusb
download_libusb
echo 'Unpacking libUSB (legacy version)...'
mkdir libusb-legacy
tar --directory=libusb-legacy --strip-components=1 -zxf libusb-legacy.tar.gz
build_libusb
cd libusb-legacy
cd ..
cleanup_libusb
}
if command -v port >/dev/null 2>&1
then
if [ "$(id -u)" -ne 0 ]
then
cat >&2 <<_EOF_
Warning: running without superuser privileges
THIS IS MOST LIKELY GOING TO FAIL.
Run this script using sudo or su.
_EOF_
fi
set -e
echo 'Installing libELF...'
port install libelf
echo 'Installing libUSB...'
port install libusb
echo 'Installing wget...'
port install wget
echo 'Installing xz...'
port install xz
install_libusb
elif command -v brew >/dev/null 2>&1
then
# We are using /usr/bin/stat because otherwise a GNU stat from
# Homebrew may get pulled in which is incompatible.
if [ "$(id -u)" -ne "$(/usr/bin/stat -f'%u' "$(brew --cellar)")" ]
then
cat >&2 <<_EOF_
Warning: you are not the owner of Homebrew.
THIS IS MOST LIKELY GOING TO FAIL.
Run this script using sudo or su, or contact the owner of Homebrew.
_EOF_
fi
echo 'Installing libELF...'
brew install libelf
echo 'Installing libUSB...'
brew install libusb
echo 'Installing libUSB (legacy version)...'
brew install libusb-compat
echo 'Installing wget...'
brew install wget
echo 'Installing xz...'
brew install xz
else
cat >&2 <<_EOF_
No suitable package manager detected!
The following package managers are supported on macOS:
* Homebrew <https://brew.sh/>
* MacPorts <https://macports.org/>
_EOF_
exit 77
fi
;;
*)
cat >&2 <<_EOF_
Error: your operating system is not supported.
_EOF_
exit 77
esac