mips: cleanup and fix mips{32,64}r6 support
[openadk.git] / scripts / prereq.sh
blob57652ed5fe5d13098826e6ebf0c5e336679ba5be
1 #!/bin/sh
2 # This file is part of the OpenADK project. OpenADK is copyrighted
3 # material, please see the LICENCE file in the top-level directory.
5 # resolve prerequisites for OpenADK build
7 topdir=$(pwd)
8 target="$@"
9 flags="$MAKEFLAGS"
10 out=0
12 mirror=http://distfiles.openadk.org
13 makever=4.1
14 bashver=4.3.30
16 # detect operating system
17 os=$(env uname)
18 osver=$(env uname -r)
19 printf " ---> $os $osver for build detected.\n"
21 # check if the filesystem is case sensitive
22 rm -f foo
23 echo >FOO
24 if [ -e foo ]; then
25 printf "ERROR: OpenADK cannot be built in a case-insensitive file system."
26 case $os in
27 CYG*)
28 printf "Building OpenADK on $os needs a small registry change."
29 printf "http://cygwin.com/cygwin-ug-net/using-specialnames.html"
31 Darwin*)
32 printf "Building OpenADK on $os needs a case-sensitive disk partition."
33 printf "For Snow Leopard and above you can use diskutil to resize your existing disk."
34 printf "Example: sudo diskutil resizeVolume disk0s2 90G 1 jhfsx adk 30G"
35 printf "For older versions you might consider to use a disk image:"
36 printf "hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 30g ~/openadk.dmg"
38 esac
39 rm -f FOO
40 exit 1
42 rm -f FOO
44 # do we have a download tool?
45 tools="curl wget"
46 for tool in $tools; do
47 printf " ---> checking if $tool is installed.. "
48 if which $tool >/dev/null; then
49 printf "found\n"
50 case $tool in
51 curl)
52 FETCHCMD="$(which $tool) -L -k -f -\# -o "
54 wget)
55 FETCHCMD="$(which $tool) --no-check-certificate -O "
57 esac
58 break
59 else
60 printf "not found\n"
61 continue
63 done
64 if [ -z "$FETCHCMD" ]; then
65 printf "ERROR: no download tool found. Fatal error.\n"
66 exit 1
69 # do we have a checksum tool?
70 tools="sha256sum sha256 cksum shasum"
71 for tool in $tools; do
72 printf " ---> checking if $tool is installed.. "
73 if which $tool >/dev/null 2>/dev/null; then
74 printf "found\n"
75 # check if cksum is usable
76 case $tool in
77 sha256sum)
78 SHA256=$(which $tool)
80 sha256)
81 SHA256="$(which $tool) -q"
83 cksum)
84 if cksum -q >/dev/null 2>/dev/null; then
85 SHA256="$(which $tool) -q -a sha256"
86 else
87 continue
90 shasum)
91 SHA256="$(which $tool) -a 256"
93 esac
94 break
95 else
96 printf "not found\n"
97 continue
99 done
100 if [ -z "$SHA256" ]; then
101 printf "ERROR: no checksum tool found. Fatal error.\n"
102 exit 1
105 # create download dir
106 if [ ! -d $topdir/dl ]; then
107 mkdir -p $topdir/dl
110 # check for c compiler
111 if [ $os = "Darwin" ]; then
112 compilerbins="clang cc gcc"
113 else
114 compilerbins="cc gcc clang"
116 for compilerbin in $compilerbins; do
117 printf " ---> checking if $compilerbin is installed.. "
118 if which $compilerbin >/dev/null; then
119 printf "found\n"
120 CC=$compilerbin
121 CCFOUND=1
122 break
123 else
124 printf "not found\n"
125 continue
127 done
128 if [ -z "$CCFOUND" ]; then
129 printf "ERROR: no C compiler found. Fatal error.\n"
130 exit 1
133 # check for c++ compiler
134 if [ $os = "Darwin" ]; then
135 compilerbins="clang++ c++ g++"
136 else
137 compilerbins="c++ g++ clang++"
139 for compilerbin in $compilerbins; do
140 printf " ---> checking if $compilerbin is installed.. "
141 if which $compilerbin >/dev/null; then
142 printf "found\n"
143 CXX=$compilerbin
144 CXXFOUND=1
145 break
146 else
147 printf "not found\n"
148 continue
150 done
151 if [ -z "$CXXFOUND" ]; then
152 printf "ERROR: no C++ compiler found. Fatal error.\n"
153 exit 1
156 gnu_host_name=$(${CC} -dumpmachine)
158 # relocation of topdir?
159 olddir=$(grep "^ADK_TOPDIR" prereq.mk 2>/dev/null |cut -d '=' -f 2)
160 newdir=$(pwd)
162 if [ ! -z "$olddir" ]; then
163 if [ "$olddir" != "$newdir" ]; then
164 printf " ---> adk directory was relocated, fixing .."
165 sed -i -e "s#$olddir#$newdir#g" $(find target_* -name \*.pc|xargs) 2>/dev/null
166 sed -i -e "s#$olddir#$newdir#g" $(find host_${gnu_host_name} -type f|xargs) 2>/dev/null
167 sed -i -e "s#$olddir#$newdir#g" $(find target_*/scripts -type f|xargs) 2>/dev/null
168 sed -i -e "s#$olddir#$newdir#" target_*/etc/ipkg.conf 2>/dev/null
169 sleep 2
170 printf "done\n"
175 case :$PATH: in
176 (*:$topdir/host_${gnu_host_name}/bin:*) ;;
177 (*) export PATH=$topdir/host_${gnu_host_name}/bin:$PATH ;;
178 esac
180 # check for GNU make
181 makebins="gmake make"
182 for makebin in $makebins; do
183 printf " ---> checking if $makebin is installed.. "
184 if which $makebin >/dev/null 2>/dev/null; then
185 printf "found\n"
186 printf " ---> checking if it is GNU make.. "
187 $makebin --version 2>/dev/null| grep GNU >/dev/null
188 if [ $? -eq 0 ]; then
189 printf "yes\n"
190 MAKE=$(which $makebin)
191 break
192 else
193 # we need to build GNU make
194 printf "no\n"
195 printf " ---> compiling missing GNU make.. "
196 cd dl
197 $FETCHCMD make-${makever}.tar.gz $mirror/make-${makever}.tar.gz
198 if [ $? -ne 0 ]; then
199 printf "ERROR: failed to download make from $mirror\n"
200 exit 1
202 cd ..
203 mkdir tmp
204 cd tmp
205 tar xzf ../dl/make-${makever}.tar.gz
206 cd make-$makever
207 ./configure --prefix=$topdir/host_$gnu_host_name/
208 make
209 make install
210 cd ..
211 cd ..
212 rm -rf tmp
213 MAKE=$topdir/host_$gnu_host_name/bin/make
214 makebin=$topdir/host_$gnu_host_name/bin/make
215 printf " done\n"
217 else
218 printf "not found\n"
219 continue
221 done
223 # check for bash
224 printf " ---> checking if bash is installed.. "
225 if which bash >/dev/null; then
226 printf "found\n"
227 printf " ---> checking if it is bash 4.x.. "
228 bash --version 2>/dev/null| grep -i "Version 4" >/dev/null
229 if [ $? -eq 0 ]; then
230 printf "yes\n"
231 else
232 # we need to build GNU bash 4.x
233 printf "not found\n"
234 printf " ---> compiling missing GNU bash.. "
235 cd dl
236 $FETCHCMD bash-${bashver}.tar.gz $mirror/bash-${bashver}.tar.gz
237 if [ $? -ne 0 ]; then
238 printf "ERROR: failed to download make from $mirror\n"
239 exit 1
241 cd ..
242 mkdir tmp
243 cd tmp
244 tar xzf ../dl/bash-${bashver}.tar.gz
245 cd bash-${bashver}
246 ./configure --prefix=$topdir/host_$gnu_host_name/
247 make
248 make install
249 cd ..
250 cd ..
251 rm -rf tmp
252 printf " done\n"
256 # skip the script if distclean / cleandir
257 if [ "$target" = "distclean" -o "$target" = "cleandir" ]; then
258 touch prereq.mk
259 $makebin ADK_TOPDIR=$topdir -s -f Makefile.adk $flags $target
260 exit 0
263 printf " ---> checking if strings is installed.. "
264 if ! which strings >/dev/null 2>&1; then
265 echo You must install strings to continue.
266 echo
267 out=1
268 printf "not found\n"
270 printf "found\n"
272 printf " ---> checking if perl is installed.. "
273 if ! which perl >/dev/null 2>&1; then
274 echo You must install perl to continue.
275 echo
276 out=1
277 printf "not found\n"
279 printf "found\n"
281 printf " ---> checking if gzip is installed.. "
282 if ! which gzip >/dev/null 2>&1; then
283 echo You must install gzip to continue.
284 echo
285 out=1
286 printf "not found\n"
288 printf "found\n"
290 printf " ---> checking if git is installed.. "
291 if ! which git >/dev/null 2>&1; then
292 echo You must install git to continue.
293 echo
294 out=1
295 printf "not found\n"
297 printf "found\n"
300 # creating prereq.mk
301 echo "ADK_TOPDIR:=$(readlink -nf . 2>/dev/null || pwd -P)" > $topdir/prereq.mk
302 echo "BASH:=$(which bash)" >> $topdir/prereq.mk
303 echo "SHELL:=$(which bash)" >> $topdir/prereq.mk
304 echo "GMAKE:=$MAKE" >> $topdir/prereq.mk
305 echo "MAKE:=$MAKE" >> $topdir/prereq.mk
306 echo "FETCHCMD:=$FETCHCMD" >> $topdir/prereq.mk
307 echo "SHA256:=$SHA256" >> $topdir/prereq.mk
308 echo "GNU_HOST_NAME:=${gnu_host_name}" >> $topdir/prereq.mk
309 echo "OS_FOR_BUILD:=${os}" >> $topdir/prereq.mk
310 echo "ARCH_FOR_BUILD:=$(${CC} -dumpmachine | sed \
311 -e 's/x86_64-linux-gnux32/x32/' \
312 -e s'/-.*//' \
313 -e 's/sparc.*/sparc/' \
314 -e 's/armeb.*/armeb/g' \
315 -e 's/arm.*/arm/g' \
316 -e 's/m68k.*/m68k/' \
317 -e 's/sh[234]/sh/' \
318 -e 's/mips-.*/mips/' \
319 -e 's/mipsel-.*/mipsel/' \
320 -e 's/i[3-9]86/x86/' \
321 )" >>prereq.mk
323 if [ "$CC" = "clang" ]; then
324 echo "HOST_CC:=${CC} -fbracket-depth=1024" >> $topdir/prereq.mk
325 else
326 echo "HOST_CC:=${CC}" >> $topdir/prereq.mk
328 if [ "$CXX" = "clang++" ]; then
329 echo "HOST_CXX:=${CXX} -fbracket-depth=1024" >> $topdir/prereq.mk
330 else
331 echo "HOST_CXX:=${CXX}" >> $topdir/prereq.mk
334 echo "HOST_CFLAGS:=-O0 -g0" >> $topdir/prereq.mk
335 echo "HOST_CXXFLAGS:=-O0 -g0" >> $topdir/prereq.mk
336 echo 'LANGUAGE:=C' >> $topdir/prereq.mk
337 echo 'LC_ALL:=C' >> $topdir/prereq.mk
338 echo "_PATH:=$PATH" >> $topdir/prereq.mk
339 echo "PATH:=${topdir}/scripts:/usr/sbin:$PATH" >> $topdir/prereq.mk
340 echo "GIT:=$(which git 2>/dev/null)" >> $topdir/prereq.mk
341 echo "export ADK_TOPDIR GIT SHA256 BASH SHELL" >> $topdir/prereq.mk
343 # create temporary Makefile
344 cat >Makefile.tmp <<'EOF'
345 include ${ADK_TOPDIR}/prereq.mk
346 all: test
348 test: test.c
349 @${HOST_CC} ${HOST_CFLAGS} -o $@ $^ ${LDADD}
352 # check if compiler works
353 cat >test.c <<-'EOF'
354 #include <stdio.h>
356 main()
358 printf("YES");
359 return (0);
363 printf " ---> checking if compiler is working.. "
364 $MAKE --no-print-directory ADK_TOPDIR=$topdir -f Makefile.tmp >/dev/null 2>&1
365 X=$(./test 2>/dev/null)
366 if [ X$X != XYES ]; then
367 echo Cannot compile a simple test programme.
368 echo You must install a host make and C compiler.
369 echo
370 out=1
371 else
372 printf "okay\n"
374 rm test.c test 2>/dev/null
376 printf " ---> checking if zlib is installed.. "
377 # check for zlib
378 cat >test.c <<-'EOF'
379 #include <stdio.h>
380 #include <zlib.h>
382 #ifndef STDIN_FILENO
383 #define STDIN_FILENO 0
384 #endif
387 main()
389 gzFile zstdin;
390 char buf[1024];
391 int i;
393 zstdin = gzdopen(STDIN_FILENO, "rb");
394 i = gzread(zstdin, buf, sizeof (buf));
395 if ((i > 0) && (i < sizeof (buf)))
396 buf[i] = '\0';
397 buf[sizeof (buf) - 1] = '\0';
398 printf("%s\n", buf);
399 return (0);
403 $MAKE --no-print-directory LDADD=-lz ADK_TOPDIR=$topdir -f Makefile.tmp >/dev/null 2>&1
404 X=$(echo YES | gzip | ./test 2>/dev/null)
405 if [ X$X != XYES ]; then
406 echo Cannot compile a libz test programm.
407 echo You must install the zlib development package,
408 echo usually called libz-dev, and the run-time library.
409 echo
410 out=1
411 else
412 printf "found\n"
415 rm test.c test 2>/dev/null
416 rm Makefile.tmp 2>/dev/null
418 # error out on any required prerequisite
419 if [ $out -ne 0 ]; then
420 exit
423 printf " ---> checking if bc is installed.. "
424 host_build_bc=0
425 if which bc >/dev/null 2>&1; then
426 if ! echo quit|bc -q 2>/dev/null >/dev/null; then
427 printf "not usable\n"
428 host_build_bc=1
429 else
430 if bc -v 2>&1| grep -q BSD >/dev/null 2>&1; then
431 host_build_bc=1
432 printf "not usable\n"
434 printf "found\n"
436 else
437 printf "not found\n"
438 host_build_bc=1
441 printf " ---> checking if bison is installed.. "
442 host_build_bison=0
443 if ! which bison >/dev/null 2>&1; then
444 printf "not found\n"
445 host_build_bison=1
446 else
447 printf "found\n"
450 printf " ---> checking if bzip2 is installed.. "
451 host_build_bzip2=0
452 if ! which bzip2 >/dev/null 2>&1; then
453 printf "not found\n"
454 host_build_bzip2=1
455 else
456 printf "found\n"
459 printf " ---> checking if file is installed.. "
460 host_build_file=0
461 if ! which file >/dev/null 2>&1; then
462 printf "not found\n"
463 host_build_file=1
464 else
465 printf "found\n"
468 printf " ---> checking if flex is installed.. "
469 host_build_flex=0
470 if ! which flex >/dev/null 2>&1; then
471 printf "not found\n"
472 host_build_flex=1
473 else
474 printf "found\n"
477 host_build_m4=0
478 if ! which m4 >/dev/null 2>&1; then
479 host_build_m4=1
482 host_build_mkimage=0
483 if ! which mkimage >/dev/null 2>&1; then
484 host_build_mkimage=1
487 printf " ---> checking if mksh is installed.. "
488 host_build_mksh=0
489 if ! which mksh >/dev/null 2>&1; then
490 printf "not found\n"
491 host_build_mksh=1
492 else
493 printf "found\n"
496 printf " ---> checking if patch is installed.. "
497 host_build_patch=0
498 if ! which patch >/dev/null 2>&1; then
499 printf "not found\n"
500 host_build_patch=1
501 else
502 printf "found\n"
505 host_build_tar=0
506 if which tar >/dev/null 2>&1; then
507 if ! tar --version 2>/dev/null|grep GNU >/dev/null;then
508 host_build_tar=1
510 else
511 host_build_tar=1
514 printf " ---> checking if xargs is installed.. "
515 host_build_findutils=0
516 if which xargs >/dev/null 2>&1; then
517 if ! xargs --version 2>/dev/null|grep GNU >/dev/null;then
518 printf "found but not usable\n"
519 host_build_findutils=1
520 else
521 printf "found\n"
523 else
524 printf "not found\n"
525 host_build_findutils=1
528 printf " ---> checking if find is installed.. "
529 if which find >/dev/null 2>&1; then
530 if ! find --version 2>/dev/null|grep GNU >/dev/null;then
531 printf "found but not usable\n"
532 host_build_findutils=1
533 else
534 printf "found\n"
536 else
537 printf "not found\n"
538 host_build_findutils=1
541 printf " ---> checking if grep is installed.. "
542 host_build_grep=0
543 if which grep >/dev/null 2>&1; then
544 if ! grep --version 2>/dev/null|grep GNU >/dev/null;then
545 printf "found but not usable\n"
546 host_build_grep=1
547 else
548 printf "found\n"
550 else
551 printf "not found\n"
552 host_build_grep=1
555 printf " ---> checking if gawk is installed.. "
556 host_build_gawk=0
557 if ! which gawk >/dev/null 2>&1; then
558 printf "not found\n"
559 host_build_gawk=1
560 else
561 printf "found\n"
564 printf " ---> checking if sed is installed.. "
565 host_build_sed=0
566 if which sed >/dev/null 2>&1; then
567 if ! sed --version 2>/dev/null|grep GNU >/dev/null;then
568 printf "found but not usable\n"
569 host_build_sed=1
570 else
571 printf "found\n"
573 else
574 printf "not found\n"
575 host_build_sed=1
578 printf " ---> checking if cpio is installed.. "
579 host_build_cpio=0
580 if ! which cpio >/dev/null 2>&1; then
581 printf "not found\n"
582 host_build_cpio=1
583 else
584 printf "found\n"
587 printf " ---> checking if xz is installed.. "
588 host_build_xz=0
589 if ! which xz >/dev/null 2>&1; then
590 printf "not found\n"
591 host_build_xz=1
592 else
593 printf "found\n"
596 # optional
597 host_build_cdrtools=0
598 if ! which mkisofs >/dev/null 2>&1; then
599 host_build_cdrtools=1
602 host_build_genext2fs=0
603 if ! which genext2fs >/dev/null 2>&1; then
604 host_build_genext2fs=1
607 host_build_lzma=0
608 if ! which lzma >/dev/null 2>&1; then
609 host_build_lzma=1
612 host_build_lz4=0
613 if ! which lz4c >/dev/null 2>&1; then
614 host_build_lz4=1
617 host_build_lzop=0
618 if ! which lzop >/dev/null 2>&1; then
619 host_build_lzop=1
622 host_build_qemu=0
623 if ! which qemu-img >/dev/null 2>&1; then
624 host_build_qemu=1
627 host_build_coreutils=0
628 if which tr >/dev/null 2>&1; then
629 if ! tr --version 2>/dev/null|grep GNU >/dev/null;then
630 host_build_coreutils=1
634 echo "config ADK_HOST_BUILD_TOOLS" > $topdir/target/config/Config.in.prereq
635 printf "\t%s\n" "bool" >> $topdir/target/config/Config.in.prereq
636 printf "\t%s\n" "default y" >> $topdir/target/config/Config.in.prereq
637 # always required
638 if [ $host_build_bc -eq 1 ]; then
639 printf "\t%s\n" "select ADK_HOST_BUILD_BC" >> $topdir/target/config/Config.in.prereq
641 if [ $host_build_bison -eq 1 ]; then
642 printf "\t%s\n" "select ADK_HOST_BUILD_BISON" >> $topdir/target/config/Config.in.prereq
644 if [ $host_build_bzip2 -eq 1 ]; then
645 printf "\t%s\n" "select ADK_HOST_BUILD_BZIP2" >> $topdir/target/config/Config.in.prereq
647 if [ $host_build_file -eq 1 ]; then
648 printf "\t%s\n" "select ADK_HOST_BUILD_FILE" >> $topdir/target/config/Config.in.prereq
650 if [ $host_build_flex -eq 1 ]; then
651 printf "\t%s\n" "select ADK_HOST_BUILD_FLEX" >> $topdir/target/config/Config.in.prereq
653 if [ $host_build_gawk -eq 1 ]; then
654 printf "\t%s\n" "select ADK_HOST_BUILD_GAWK" >> $topdir/target/config/Config.in.prereq
656 if [ $host_build_grep -eq 1 ]; then
657 printf "\t%s\n" "select ADK_HOST_BUILD_GREP" >> $topdir/target/config/Config.in.prereq
659 if [ $host_build_m4 -eq 1 ]; then
660 printf "\t%s\n" "select ADK_HOST_BUILD_M4" >> $topdir/target/config/Config.in.prereq
662 if [ $host_build_mkimage -eq 1 ]; then
663 printf "\t%s\n" "select ADK_HOST_BUILD_U_BOOT" >> $topdir/target/config/Config.in.prereq
665 if [ $host_build_mksh -eq 1 ]; then
666 printf "\t%s\n" "select ADK_HOST_BUILD_MKSH" >> $topdir/target/config/Config.in.prereq
668 if [ $host_build_patch -eq 1 ]; then
669 printf "\t%s\n" "select ADK_HOST_BUILD_PATCH" >> $topdir/target/config/Config.in.prereq
671 if [ $host_build_findutils -eq 1 ]; then
672 printf "\t%s\n" "select ADK_HOST_BUILD_FINDUTILS" >> $topdir/target/config/Config.in.prereq
674 if [ $host_build_sed -eq 1 ]; then
675 printf "\t%s\n" "select ADK_HOST_BUILD_SED" >> $topdir/target/config/Config.in.prereq
677 if [ $host_build_tar -eq 1 ]; then
678 printf "\t%s\n" "select ADK_HOST_BUILD_TAR" >> $topdir/target/config/Config.in.prereq
680 if [ $host_build_cpio -eq 1 ]; then
681 printf "\t%s\n" "select ADK_HOST_BUILD_CPIO" >> $topdir/target/config/Config.in.prereq
683 if [ $host_build_xz -eq 1 ]; then
684 printf "\t%s\n" "select ADK_HOST_BUILD_XZ" >> $topdir/target/config/Config.in.prereq
686 # optional
687 if [ $host_build_cdrtools -eq 1 ]; then
688 printf "\t%s\n" "select ADK_HOST_BUILD_CDRTOOLS if ADK_HOST_NEED_CDRTOOLS" >> $topdir/target/config/Config.in.prereq
690 if [ $host_build_genext2fs -eq 1 ]; then
691 printf "\t%s\n" "select ADK_HOST_BUILD_GENEXT2FS if ADK_HOST_NEED_GENEXT2FS" >> $topdir/target/config/Config.in.prereq
693 if [ $host_build_lzma -eq 1 ]; then
694 printf "\t%s\n" "select ADK_HOST_BUILD_LZMA if ADK_HOST_NEED_LZMA" >> $topdir/target/config/Config.in.prereq
696 if [ $host_build_lz4 -eq 1 ]; then
697 printf "\t%s\n" "select ADK_HOST_BUILD_LZ4 if ADK_HOST_NEED_LZ4" >> $topdir/target/config/Config.in.prereq
699 if [ $host_build_lzop -eq 1 ]; then
700 printf "\t%s\n" "select ADK_HOST_BUILD_LZOP if ADK_HOST_NEED_LZOP" >> $topdir/target/config/Config.in.prereq
702 if [ $host_build_qemu -eq 1 ]; then
703 printf "\t%s\n" "select ADK_HOST_BUILD_QEMU if ADK_HOST_NEED_QEMU" >> $topdir/target/config/Config.in.prereq
705 if [ $host_build_coreutils -eq 1 ]; then
706 printf "\t%s\n" "select ADK_HOST_BUILD_COREUTILS if ADK_HOST_NEED_COREUTILS" >> $topdir/target/config/Config.in.prereq
709 # create Host OS symbols
710 case $os in
711 Linux)
712 printf "\nconfig ADK_HOST_LINUX\n" >> $topdir/target/config/Config.in.prereq
713 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
714 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
716 Darwin)
717 printf "\nconfig ADK_HOST_DARWIN\n" >> $topdir/target/config/Config.in.prereq
718 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
719 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
721 OpenBSD)
722 printf "\nconfig ADK_HOST_OPENBSD\n" >> $topdir/target/config/Config.in.prereq
723 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
724 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
726 FreeBSD)
727 printf "\nconfig ADK_HOST_FREEBSD\n" >> $topdir/target/config/Config.in.prereq
728 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
729 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
731 NetBSD)
732 printf "\nconfig ADK_HOST_NETBSD\n" >> $topdir/target/config/Config.in.prereq
733 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
734 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
736 MirBSD)
737 printf "\nconfig ADK_HOST_MIRBSD\n" >> $topdir/target/config/Config.in.prereq
738 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
739 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
741 Cygwin*)
742 printf "\nconfig ADK_HOST_CYGWIN\n" >> $topdir/target/config/Config.in.prereq
743 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
744 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
746 esac
748 if [ "$target" = "defconfig" ]; then
749 $makebin ADK_TOPDIR=$topdir --no-print-directory -f Makefile.adk $flags $target
750 exit 0
753 if [ ! -f $topdir/.config ]; then
754 # create a config if no exist
755 touch .firstrun
756 $makebin ADK_TOPDIR=$topdir --no-print-directory -f Makefile.adk menuconfig
757 else
758 # scan host-tool prerequisites of certain packages before building.
759 . $topdir/.config
760 if [ -n "$ADK_PACKAGE_KODI" ]; then
761 NEED_JAVA="$NEED_JAVA kodi"
764 if [ -n "$ADK_PACKAGE_ICU4C" ]; then
765 NEED_STATIC_LIBSTDCXX="$NEED_STATIC_LIBSTDCXX icu4c"
768 if [ -n "$ADK_PACKAGE_XKEYBOARD_CONFIG" ]; then
769 NEED_XKBCOMP="$NEED_XKBCOMP xkeyboard-config"
772 if [ -n "$ADK_PACKAGE_FONT_BH_100DPI" ]; then
773 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-100dpi"
776 if [ -n "$ADK_PACKAGE_FONT_BH_75DPI" ]; then
777 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-75dpi"
780 if [ -n "$ADK_PACKAGE_FONT_BH_TYPE1" ]; then
781 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-type1"
784 if [ -n "$ADK_PACKAGE_FONT_BH_TTF" ]; then
785 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-ttf"
788 if [ -n "$ADK_PACKAGE_FONT_BH_LUCIDATYPEWRITER_100DPI" ]; then
789 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-lucidatypewriter-100dpi"
792 if [ -n "$ADK_PACKAGE_FONT_BH_LUCIDATYPEWRITER_75DPI" ]; then
793 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-lucidatypewriter-75dpi"
796 if [ -n "$ADK_PACKAGE_FONT_BITSTREAM_100DPI" ]; then
797 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bitstream-100dpi"
800 if [ -n "$ADK_PACKAGE_FONT_BITSTREAM_75DPI" ]; then
801 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bitstream-75dpi"
804 if [ -n "$ADK_PACKAGE_FONT_BITSTREAM_TYPE1" ]; then
805 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bitstream-type1"
808 if [ -n "$ADK_PACKAGE_FONT_ADOBE_100DPI" ]; then
809 NEED_MKFONTDIR="$NEED_MKFONTDIR font-adobe-100dpi"
812 if [ -n "$ADK_PACKAGE_FONT_ADOBE_75DPI" ]; then
813 NEED_MKFONTDIR="$NEED_MKFONTDIR font-adobe-75dpi"
816 if [ -n "$ADK_PACKAGE_FONT_XFREE86_TYPE1" ]; then
817 NEED_MKFONTDIR="$NEED_MKFONTDIR font-xfree86-type1"
820 if [ -n "$ADK_PACKAGE_FONT_MISC_MISC" ]; then
821 NEED_MKFONTDIR="$NEED_MKFONTDIR font-misc-misc"
824 if [ -n "$ADK_PACKAGE_LIBERATION_FONTS_TTF" ]; then
825 NEED_MKFONTSCALE="$NEED_MKFONTSCALE liberation-fonts-ttf"
828 if [ -n "$NEED_MKFONTDIR" ]; then
829 if ! which mkfontdir >/dev/null 2>&1; then
830 printf "You need mkfontdir to build $NEED_MKFONTDIR \n"
831 out=1
835 if [ -n "$NEED_MKFONTSCALE" ]; then
836 if ! which mkfontscale >/dev/null 2>&1; then
837 printf "You need mkfontscale to build $NEED_MKFONTSCALE \n"
838 out=1
842 if [ -n "$NEED_XKBCOMP" ]; then
843 if ! which xkbcomp >/dev/null 2>&1; then
844 printf "You need xkbcomp to build $NEED_XKBCOMP \n"
845 out=1
849 if [ -n "$NEED_JAVA" ]; then
850 if ! which java >/dev/null 2>&1; then
851 printf "You need java to build $NEED_JAVA \n"
852 out=1
856 if [ -n "$NEED_STATIC_LIBSTDCXX" ]; then
857 cat >test.c <<-'EOF'
858 #include <stdio.h>
860 main()
862 return (0);
865 if ! $CXX -static-libstdc++ -o test test.c 2>/dev/null ; then
866 printf "You need static version of libstdc++ installed to build $NEED_STATIC_LIBSTDCXX \n"
867 out=1
868 rm test test.c 2>/dev/null
872 # error out
873 if [ $out -ne 0 ]; then
874 exit $out
877 # start build
878 $makebin ADK_TOPDIR=$topdir --no-print-directory -f Makefile.adk $flags $target