blob: 0e4dff4bebaa63c542acaaa5aee455a0a4f3a050 (
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
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
# This file is part of the OpenADK project. OpenADK is copyrighted
# material, please see the LICENCE file in the top-level directory.
shopt -s extglob
topdir=$(pwd)
opath=$PATH
out=0
if [[ $NO_ERROR != @(0|1) ]]; then
echo Please do not invoke this script directly!
exit 1
fi
set -e
rm -rf $topdir/tmp
mkdir -p $topdir/tmp
cd $topdir/tmp
os=$(uname)
rm -f foo
echo >FOO
if [[ -e foo ]]; then
cat >&2 <<-EOF
ERROR: OpenADK cannot be built in a case-insensitive file system.
EOF
case $os in
CYG*)
echo "Building OpenADK on $os needs a small registry change."
echo 'http://cygwin.com/cygwin-ug-net/using-specialnames.html'
;;
Darwin*)
echo "Building OpenADK on $os needs a case-sensitive disk partition."
echo "For Snow Leopard and above you can use diskutil to resize your existing disk."
echo "Example: sudo diskutil resizeVolume disk0s2 90G 1 jhfsx adk 30G"
echo "For older versions you might consider to use a disk image:"
echo "hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 30g ~/openadk.dmg"
;;
esac
exit 1
fi
rm -f FOO
case $os in
Linux)
;;
FreeBSD)
;;
MirBSD)
;;
CYG*)
;;
NetBSD)
;;
OpenBSD)
if ! which gmake >/dev/null 2>&1; then
echo You must install GNU make to continue.
echo
out=1
fi
;;
Darwin*)
;;
*)
# unsupported
echo "Building OpenADK on $os is currently unsupported."
echo "Sorry."
exit 1
;;
esac
set +e
if [ -z $(which gmake 2>/dev/null ) ];then
makecmd=$(which make 2>/dev/null )
else
makecmd=$(which gmake 2>/dev/null )
fi
cat >Makefile <<'EOF'
include ${TOPDIR}/prereq.mk
all: run-test
test: test.c
${HOST_CC} -o $@ $^ ${LDADD}
run-test: test
./test
EOF
cat >test.c <<-'EOF'
#include <stdio.h>
int
main()
{
printf("Yay! Native compiler works.\n");
return (0);
}
EOF
X=$($makecmd TOPDIR=$topdir 2>&1)
if [[ $X != *@(Native compiler works)* ]]; then
echo "$X" | sed 's/^/| /'
echo Cannot compile a simple test programme.
echo You must install a host make and C compiler,
echo usually GCC, to proceed.
echo
out=1
fi
rm test 2>/dev/null
if ! which tar >/dev/null 2>&1; then
echo You must install tar to continue.
echo
out=1
fi
if ! which gzip >/dev/null 2>&1; then
echo You must install gzip to continue.
echo
out=1
fi
cat >test.c <<-'EOF'
#include <stdio.h>
#include <zlib.h>
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
int
main()
{
gzFile zstdin;
char buf[1024];
int i;
zstdin = gzdopen(STDIN_FILENO, "rb");
i = gzread(zstdin, buf, sizeof (buf));
if ((i > 0) && (i < sizeof (buf)))
buf[i] = '\0';
buf[sizeof (buf) - 1] = '\0';
printf("%s\n", buf);
return (0);
}
EOF
X=$(echo 'Yay! Native compiler works.' | gzip | \
$makecmd TOPDIR=$topdir LDADD=-lz 2>&1)
if [[ $X != *@(Native compiler works)* ]]; then
echo "$X" | sed 's/^/| /'
echo Cannot compile a libz test programm.
echo You must install the zlib development package,
echo usually called libz-dev, and the run-time library.
echo
out=1
fi
if [[ ! -s /usr/include/ncurses.h ]]; then
if [[ ! -s /usr/include/curses.h ]]; then
if [[ ! -s /usr/include/ncurses/ncurses.h ]]; then
echo Install ncurses header files, please.
echo
out=1
fi
fi
fi
if ! which wget >/dev/null 2>&1; then
echo You must install wget to continue.
echo
out=1
fi
if ! which perl >/dev/null 2>&1; then
echo You must install perl to continue.
echo
out=1
fi
if ! which g++ >/dev/null 2>&1; then
echo "You need a C++ compiler to continue."
echo
out=1
fi
# always required, but can be provided by host
host_build_bc=0
if ! which bc >/dev/null 2>&1; then
host_build_bc=1
fi
host_build_bison=0
if ! which bison >/dev/null 2>&1; then
host_build_bison=1
fi
host_build_bzip2=0
if ! which bzip2 >/dev/null 2>&1; then
host_build_bzip2=1
fi
host_build_file=0
if ! which file >/dev/null 2>&1; then
host_build_file=1
fi
host_build_flex=0
if ! which flex >/dev/null 2>&1; then
host_build_flex=1
fi
host_build_m4=0
if ! which m4 >/dev/null 2>&1; then
host_build_m4=1
fi
host_build_mksh=0
if ! which mksh >/dev/null 2>&1; then
host_build_mksh=1
fi
host_build_patch=0
if ! which patch >/dev/null 2>&1; then
host_build_patch=1
fi
host_build_pkgconf=0
if ! which pkgconf >/dev/null 2>&1; then
host_build_pkgconf=1
fi
host_build_findutils=0
if ! which gxargs >/dev/null 2>&1; then
if which xargs >/dev/null 2>&1; then
if ! xargs --version 2>/dev/null|grep GNU >/dev/null;then
host_build_findutils=1
fi
fi
fi
if ! which gfind >/dev/null 2>&1; then
if which find >/dev/null 2>&1; then
if ! find --version 2>/dev/null|grep GNU >/dev/null;then
host_build_findutils=1
fi
fi
fi
host_build_gawk=0
if ! which gawk >/dev/null 2>&1; then
host_build_gawk=1
fi
host_build_sed=0
if ! which gsed >/dev/null 2>&1; then
if which sed >/dev/null 2>&1; then
if ! sed --version 2>/dev/null|grep GNU >/dev/null;then
host_build_sed=1
fi
fi
fi
host_build_xz=0
if ! which xz >/dev/null 2>&1; then
host_build_xz=1
fi
# optional
host_build_cdrtools=0
if ! which mkisofs >/dev/null 2>&1; then
host_build_cdrtools=1
fi
host_build_ccache=0
if ! which ccache >/dev/null 2>&1; then
host_build_ccache=1
fi
host_build_genext2fs=0
if ! which genext2fs >/dev/null 2>&1; then
host_build_genext2fs=1
fi
host_build_lzma=0
if ! which lzma >/dev/null 2>&1; then
host_build_lzma=1
fi
host_build_lzop=0
if ! which lzop >/dev/null 2>&1; then
host_build_lzop=1
fi
host_build_qemu=0
if ! which qemu-img >/dev/null 2>&1; then
host_build_qemu=1
fi
echo "config ADK_HOST_BUILD_TOOLS" > $topdir/target/config/Config.in.prereq
printf "\t%s\n" "boolean" >> $topdir/target/config/Config.in.prereq
printf "\t%s\n" "default y" >> $topdir/target/config/Config.in.prereq
# always required
if [ $host_build_bc -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BC" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_bison -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BISON" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_bzip2 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BZIP2" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_file -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FILE" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_flex -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FLEX" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_gawk -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GAWK" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_m4 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_M4" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_mksh -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_MKSH" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_patch -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_PATCH" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_pkgconf -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_PKGCONF" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_findutils -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FINDUTILS" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_sed -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_SED" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_xz -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_XZ" >> $topdir/target/config/Config.in.prereq ;fi
# optional
if [ $host_build_ccache -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_CCACHE if ADK_HOST_NEED_CCACHE" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_cdrtools -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_CDRTOOLS if ADK_HOST_NEED_CDRTOOLS" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_genext2fs -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GENEXT2FS if ADK_HOST_NEED_GENEXT2FS" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_lzma -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_LZMA if ADK_HOST_NEED_LZMA" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_lzop -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_LZOP if ADK_HOST_NEED_LZOP" >> $topdir/target/config/Config.in.prereq ;fi
if [ $host_build_qemu -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_QEMU if ADK_HOST_NEED_QEMU" >> $topdir/target/config/Config.in.prereq ;fi
cd $topdir
rm -rf tmp
exit $out
|