cpio: add missing else
[openadk.git] / scripts / prereq.sh
blob0245d6e9df04d4f65271d46e2e09093d4600a033
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 #set -x
7 # resolve prerequisites for OpenADK build
9 topdir=$(pwd)
10 target="$@"
11 flags="$MAKEFLAGS"
12 out=0
14 mirror=https://distfiles.openadk.org
15 makever=4.2.1
16 bashver=4.4.18
18 # detect operating system
19 os=$(env uname)
20 osver=$(env uname -r)
21 printf " ---> $os $osver for build detected.\n"
23 # check if the filesystem is case sensitive
24 rm -f foo
25 echo >FOO
26 if [ -e foo ]; then
27 printf "ERROR: OpenADK cannot be built in a case-insensitive file system.\n"
28 case $os in
29 CYG*)
30 printf "Building OpenADK on $os needs a small registry change.\n"
31 printf "http://cygwin.com/cygwin-ug-net/using-specialnames.html\n"
33 Darwin*)
34 printf "Building OpenADK on $os needs a case-sensitive disk partition.\n"
35 printf "For Snow Leopard and above you can use diskutil to resize your existing disk.\n"
36 printf "Example: sudo diskutil resizeVolume disk0s2 90G 1 jhfsx adk 30G\n"
37 printf "For older versions you might consider to use a disk image:\n"
38 printf "hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 30g ~/openadk.dmg\n"
40 esac
41 rm -f FOO
42 exit 1
44 rm -f FOO
46 # do we have a download tool?
47 tools="curl wget"
48 for tool in $tools; do
49 printf " ---> checking if $tool is installed.. "
50 if which $tool >/dev/null; then
51 printf "found\n"
52 case $tool in
53 curl)
54 FETCHCMD="$(which $tool) --progress-bar -L -k -f -o "
56 wget)
57 FETCHCMD="$(which $tool) --no-check-certificate -O "
59 esac
60 break
61 else
62 printf "not found\n"
63 continue
65 done
66 if [ -z "$FETCHCMD" ]; then
67 printf "ERROR: no download tool found. Fatal error.\n"
68 exit 1
71 # do we have a checksum tool?
72 tools="sha256sum sha256 cksum shasum"
73 for tool in $tools; do
74 printf " ---> checking if $tool is installed.. "
75 if which $tool >/dev/null 2>/dev/null; then
76 printf "found\n"
77 # check if cksum is usable
78 case $tool in
79 sha256sum)
80 SHA256=$(which $tool)
82 sha256)
83 SHA256="$(which $tool) -q"
85 cksum)
86 if cksum -t >/dev/null 2>/dev/null; then
87 SHA256="$(which $tool) -q -a sha256"
88 else
89 continue
92 shasum)
93 SHA256="$(which $tool) -a 256"
95 esac
96 break
97 else
98 printf "not found\n"
99 continue
101 done
102 if [ -z "$SHA256" ]; then
103 printf "ERROR: no checksum tool found. Fatal error.\n"
104 exit 1
107 # create download dir
108 if [ ! -d $topdir/dl ]; then
109 mkdir -p $topdir/dl
112 # check for c compiler
113 if [ $os = "Darwin" ]; then
114 compilerbins="clang cc gcc"
115 else
116 compilerbins="cc gcc clang"
118 for compilerbin in $compilerbins; do
119 printf " ---> checking if $compilerbin is installed.. "
120 if which $compilerbin >/dev/null; then
121 printf "found\n"
122 CC=$compilerbin
123 CCFOUND=1
124 break
125 else
126 printf "not found\n"
127 continue
129 done
130 if [ -z "$CCFOUND" ]; then
131 printf "ERROR: no C compiler found. Fatal error.\n"
132 exit 1
135 # check for c++ compiler
136 if [ $os = "Darwin" ]; then
137 compilerbins="clang++ c++ g++"
138 else
139 compilerbins="c++ g++ clang++"
141 for compilerbin in $compilerbins; do
142 printf " ---> checking if $compilerbin is installed.. "
143 if which $compilerbin >/dev/null; then
144 printf "found\n"
145 CXX=$compilerbin
146 CXXFOUND=1
147 break
148 else
149 printf "not found\n"
150 continue
152 done
153 if [ -z "$CXXFOUND" ]; then
154 printf "ERROR: no C++ compiler found. Fatal error.\n"
155 exit 1
158 gnu_host_name=$(${CC} -dumpmachine)
160 # relocation of topdir?
161 olddir=$(grep "^ADK_TOPDIR" prereq.mk 2>/dev/null |cut -d '=' -f 2)
162 newdir=$(pwd)
164 if [ ! -z "$olddir" ]; then
165 if [ "$olddir" != "$newdir" ]; then
166 printf " ---> adk directory was relocated, fixing .."
167 sed -i -e "s#$olddir#$newdir#g" $(find target_* -name \*.pc 2>/dev/null|xargs) 2>/dev/null
168 sed -i -e "s#$olddir#$newdir#g" $(find host_${gnu_host_name} -type f 2>/dev/null|xargs) 2>/dev/null
169 sed -i -e "s#$olddir#$newdir#g" $(find target_*/scripts -type f 2>/dev/null|xargs) 2>/dev/null
170 sed -i -e "s#$olddir#$newdir#" target_*/etc/ipkg.conf 2>/dev/null
171 sleep 1
172 printf "done\n"
177 case :$PATH: in
178 (*:$topdir/host_${gnu_host_name}/bin:*) ;;
179 (*) export PATH=$topdir/host_${gnu_host_name}/bin:$PATH ;;
180 esac
182 # check for GNU make
183 makebins="gmake make"
184 for makebin in $makebins; do
185 printf " ---> checking if $makebin is installed.. "
186 if which $makebin >/dev/null 2>/dev/null; then
187 printf "found\n"
188 printf " ---> checking if it is GNU make.. "
189 $makebin --version 2>/dev/null| grep GNU >/dev/null
190 if [ $? -eq 0 ]; then
191 printf "yes\n"
192 MAKE=$(which $makebin)
194 printf " ---> checking if it is make 4.x.. "
195 LC_ALL=C $makebin --version 2>/dev/null| grep -i "Make 4" >/dev/null
196 if [ $? -eq 0 ]; then
197 printf "yes\n"
198 break
199 else
200 # we need to build GNU make
201 printf "no\n"
202 printf " ---> compiling missing GNU make.. "
203 cd dl
204 $FETCHCMD make-${makever}.tar.gz $mirror/make-${makever}.tar.gz
205 if [ $? -ne 0 ]; then
206 printf "ERROR: failed to download make from $mirror\n"
207 exit 1
209 cd ..
210 mkdir tmp
211 cd tmp
212 tar xzf ../dl/make-${makever}.tar.gz
213 cd make-$makever
214 ./configure --prefix=$topdir/host_$gnu_host_name
215 make
216 make install
217 cd ..
218 cd ..
219 rm -rf tmp
220 (cd $topdir/host_$gnu_host_name/bin/; ln -sf make gnumake)
221 MAKE=$topdir/host_$gnu_host_name/bin/make
222 makebin=$topdir/host_$gnu_host_name/bin/make
223 printf " done\n"
225 else
226 printf "not found\n"
227 continue
229 done
231 # check for bash
232 printf " ---> checking if bash is installed.. "
233 if which bash >/dev/null; then
234 printf "found\n"
235 printf " ---> checking if it is bash 4.x or 5.x"
236 LC_ALL=C bash --version 2>/dev/null| grep -i "version \(4\|5\)" >/dev/null
237 if [ $? -eq 0 ]; then
238 printf "yes\n"
239 else
240 # we need to build GNU bash 4.x
241 printf "not found\n"
242 printf " ---> compiling missing GNU bash.. "
243 cd dl
244 $FETCHCMD bash-${bashver}.tar.gz $mirror/bash-${bashver}.tar.gz
245 if [ $? -ne 0 ]; then
246 printf "ERROR: failed to download make from $mirror\n"
247 exit 1
249 cd ..
250 mkdir tmp
251 cd tmp
252 tar xzf ../dl/bash-${bashver}.tar.gz
253 cd bash-${bashver}
254 ./configure --prefix=$topdir/host_$gnu_host_name/
255 make
256 make install
257 cd ..
258 cd ..
259 rm -rf tmp
260 printf " done\n"
264 # skip the script if distclean / cleandir
265 if [ "$target" = "distclean" -o "$target" = "cleandir" ]; then
266 touch prereq.mk
267 $makebin ADK_TOPDIR=$topdir -s -f Makefile.adk $flags $target
268 exit 0
271 printf " ---> checking if strings is installed.. "
272 if ! which strings >/dev/null 2>&1; then
273 echo You must install strings to continue.
274 echo
275 out=1
276 printf "not found\n"
278 printf "found\n"
280 printf " ---> checking if perl is installed.. "
281 if ! which perl >/dev/null 2>&1; then
282 echo You must install perl to continue.
283 echo
284 out=1
285 printf "not found\n"
287 printf "found\n"
289 printf " ---> checking if gzip is installed.. "
290 if ! which gzip >/dev/null 2>&1; then
291 echo You must install gzip to continue.
292 echo
293 out=1
294 printf "not found\n"
296 printf "found\n"
298 printf " ---> checking if git is installed.. "
299 if ! which git >/dev/null 2>&1; then
300 echo You must install git to continue.
301 echo
302 out=1
303 printf "not found\n"
305 printf "found\n"
308 # creating prereq.mk
309 echo "ADK_TOPDIR:=$(readlink -nf . 2>/dev/null || pwd -P)" > $topdir/prereq.mk
310 echo "BASH:=$(which bash)" >> $topdir/prereq.mk
311 echo "SHELL:=$(which bash)" >> $topdir/prereq.mk
312 echo "GMAKE:=$MAKE" >> $topdir/prereq.mk
313 echo "MAKE:=$MAKE" >> $topdir/prereq.mk
314 echo "FETCHCMD:=$FETCHCMD" >> $topdir/prereq.mk
315 echo "SHA256:=$SHA256" >> $topdir/prereq.mk
316 echo "GNU_HOST_NAME:=${gnu_host_name}" >> $topdir/prereq.mk
317 echo "OS_FOR_BUILD:=${os}" >> $topdir/prereq.mk
318 echo "ARCH_FOR_BUILD:=$(${CC} -dumpmachine | sed \
319 -e 's/x86_64-linux-gnux32/x32/' \
320 -e s'/-.*//' \
321 -e 's/sparc.*/sparc/' \
322 -e 's/armeb.*/armeb/g' \
323 -e 's/arm.*/arm/g' \
324 -e 's/m68k.*/m68k/' \
325 -e 's/sh[234]/sh/' \
326 -e 's/mips-.*/mips/' \
327 -e 's/mipsel-.*/mipsel/' \
328 -e 's/i[3-9]86/x86/' \
329 )" >>prereq.mk
331 if [ "$CC" = "clang" ]; then
332 echo "HOST_CC:=${CC} -fbracket-depth=1024" >> $topdir/prereq.mk
333 else
334 echo "HOST_CC:=${CC}" >> $topdir/prereq.mk
336 if [ "$CXX" = "clang++" ]; then
337 echo "HOST_CXX:=${CXX} -fbracket-depth=1024" >> $topdir/prereq.mk
338 else
339 echo "HOST_CXX:=${CXX}" >> $topdir/prereq.mk
342 echo "HOST_CFLAGS:=-O0 -g0" >> $topdir/prereq.mk
343 echo "HOST_CXXFLAGS:=-O0 -g0" >> $topdir/prereq.mk
344 echo 'LANGUAGE:=C' >> $topdir/prereq.mk
345 echo 'LC_ALL:=C' >> $topdir/prereq.mk
346 echo "_PATH:=$PATH" >> $topdir/prereq.mk
347 echo "PATH:=${topdir}/scripts:/usr/sbin:$PATH" >> $topdir/prereq.mk
348 echo "GIT:=$(which git 2>/dev/null)" >> $topdir/prereq.mk
349 echo "export ADK_TOPDIR GIT SHA256 BASH SHELL" >> $topdir/prereq.mk
351 # create temporary Makefile
352 cat >Makefile.tmp <<'EOF'
353 include ${ADK_TOPDIR}/prereq.mk
354 all: test
356 test: test.c
357 @${HOST_CC} ${HOST_CFLAGS} -o $@ $^ ${LDADD}
360 # check if compiler works
361 cat >test.c <<-'EOF'
362 #include <stdio.h>
364 main()
366 printf("YES");
367 return (0);
371 printf " ---> checking if compiler is working.. "
372 $MAKE --no-print-directory ADK_TOPDIR=$topdir -f Makefile.tmp >/dev/null 2>&1
373 X=$(./test 2>/dev/null)
374 if [ X$X != XYES ]; then
375 echo Cannot compile a simple test programme.
376 echo You must install a host make and C compiler.
377 echo
378 out=1
379 else
380 printf "okay\n"
382 rm test.c test 2>/dev/null
384 printf " ---> checking if zlib is installed.. "
385 # check for zlib
386 cat >test.c <<-'EOF'
387 #include <stdio.h>
388 #include <zlib.h>
390 #ifndef STDIN_FILENO
391 #define STDIN_FILENO 0
392 #endif
395 main()
397 gzFile zstdin;
398 char buf[1024];
399 int i;
401 zstdin = gzdopen(STDIN_FILENO, "rb");
402 i = gzread(zstdin, buf, sizeof (buf));
403 if ((i > 0) && (i < sizeof (buf)))
404 buf[i] = '\0';
405 buf[sizeof (buf) - 1] = '\0';
406 printf("%s\n", buf);
407 return (0);
411 $MAKE --no-print-directory LDADD=-lz ADK_TOPDIR=$topdir -f Makefile.tmp >/dev/null 2>&1
412 X=$(echo YES | gzip | ./test 2>/dev/null)
413 if [ X$X != XYES ]; then
414 echo Cannot compile a libz test programm.
415 echo You must install the zlib development package,
416 echo usually called libz-dev, and the run-time library.
417 echo
418 out=1
419 else
420 printf "found\n"
423 rm test.c test 2>/dev/null
424 rm Makefile.tmp 2>/dev/null
426 # for make kernelconfig pkg-config is required to find ncurses
427 if [ $os = "Darwin" ]; then
428 printf " ---> checking if pkg-config is installed.. "
429 if ! which pkg-config >/dev/null 2>&1; then
430 printf "not found\n"
431 out=1
432 else
433 printf "found\n"
437 # error out on any required prerequisite
438 if [ $out -ne 0 ]; then
439 exit
442 printf " ---> checking if bc is installed.. "
443 host_build_bc=0
444 if which bc >/dev/null 2>&1; then
445 if ! echo quit|bc -q 2>/dev/null >/dev/null; then
446 printf "not usable\n"
447 host_build_bc=1
448 else
449 if bc -v 2>&1| grep -q BSD >/dev/null 2>&1; then
450 host_build_bc=1
451 printf "not usable\n"
453 printf "found\n"
455 else
456 printf "not found\n"
457 host_build_bc=1
460 printf " ---> checking if bison is installed.. "
461 host_build_bison=0
462 if ! which bison >/dev/null 2>&1; then
463 printf "not found\n"
464 host_build_bison=1
465 else
466 printf "found\n"
469 printf " ---> checking if bzip2 is installed.. "
470 host_build_bzip2=0
471 if ! which bzip2 >/dev/null 2>&1; then
472 printf "not found\n"
473 host_build_bzip2=1
474 else
475 printf "found\n"
478 printf " ---> checking if file is installed.. "
479 host_build_file=0
480 if ! which file >/dev/null 2>&1; then
481 printf "not found\n"
482 host_build_file=1
483 else
484 printf "found\n"
487 printf " ---> checking if flex is installed.. "
488 host_build_flex=0
489 if ! which flex >/dev/null 2>&1; then
490 printf "not found\n"
491 host_build_flex=1
492 else
493 printf "found\n"
496 host_build_m4=0
497 if ! which m4 >/dev/null 2>&1; then
498 host_build_m4=1
501 host_build_mkimage=0
502 if ! which mkimage >/dev/null 2>&1; then
503 host_build_mkimage=1
506 printf " ---> checking if mksh is installed.. "
507 host_build_mksh=0
508 if ! which mksh >/dev/null 2>&1; then
509 printf "not found\n"
510 host_build_mksh=1
511 else
512 printf "found\n"
515 printf " ---> checking if patch is installed.. "
516 host_build_patch=0
517 if ! which patch >/dev/null 2>&1; then
518 printf "not found\n"
519 host_build_patch=1
520 else
521 printf "found\n"
524 host_build_tar=0
525 if which tar >/dev/null 2>&1; then
526 if ! tar --version 2>/dev/null|grep GNU >/dev/null;then
527 host_build_tar=1
529 else
530 host_build_tar=1
533 printf " ---> checking if xargs is installed.. "
534 host_build_findutils=0
535 if which xargs >/dev/null 2>&1; then
536 if ! xargs --version 2>/dev/null|grep GNU >/dev/null;then
537 printf "found but not usable\n"
538 host_build_findutils=1
539 else
540 printf "found\n"
542 else
543 printf "not found\n"
544 host_build_findutils=1
547 printf " ---> checking if find is installed.. "
548 if which find >/dev/null 2>&1; then
549 if ! find --version 2>/dev/null|grep GNU >/dev/null;then
550 printf "found but not usable\n"
551 host_build_findutils=1
552 else
553 printf "found\n"
555 else
556 printf "not found\n"
557 host_build_findutils=1
560 printf " ---> checking if grep is installed.. "
561 host_build_grep=0
562 if which grep >/dev/null 2>&1; then
563 if ! grep --version 2>/dev/null|grep GNU >/dev/null;then
564 printf "found but not usable\n"
565 host_build_grep=1
566 else
567 printf "found\n"
569 else
570 printf "not found\n"
571 host_build_grep=1
574 printf " ---> checking if gawk is installed.. "
575 host_build_gawk=0
576 if ! which gawk >/dev/null 2>&1; then
577 printf "not found\n"
578 host_build_gawk=1
579 else
580 printf "found\n"
583 printf " ---> checking if sed is installed.. "
584 host_build_sed=0
585 if which sed >/dev/null 2>&1; then
586 if ! sed --version 2>/dev/null|grep GNU >/dev/null;then
587 printf "found but not usable\n"
588 host_build_sed=1
589 else
590 printf "found\n"
592 else
593 printf "not found\n"
594 host_build_sed=1
597 printf " ---> checking if cpio is installed.. "
598 host_build_cpio=0
599 if which cpio >/dev/null 2>&1; then
600 if ! cpio --version 2>/dev/null|grep GNU >/dev/null;then
601 printf "found but not usable\n"
602 host_build_cpio=1
603 else
604 printf "found\n"
606 else
607 printf "not found\n"
608 host_build_cpio=1
611 printf " ---> checking if xz is installed.. "
612 host_build_xz=0
613 if ! which xz >/dev/null 2>&1; then
614 printf "not found\n"
615 host_build_xz=1
616 else
617 printf "found\n"
620 # optional
621 host_build_cdrtools=0
622 if ! which mkisofs >/dev/null 2>&1; then
623 host_build_cdrtools=1
626 host_build_genext2fs=0
627 if ! which genext2fs >/dev/null 2>&1; then
628 host_build_genext2fs=1
631 host_build_lzma=0
632 if ! which lzma >/dev/null 2>&1; then
633 host_build_lzma=1
636 host_build_lz4=0
637 if ! which lz4c >/dev/null 2>&1; then
638 host_build_lz4=1
641 host_build_lzop=0
642 if ! which lzop >/dev/null 2>&1; then
643 host_build_lzop=1
646 host_build_qemu=0
647 if ! which qemu-img >/dev/null 2>&1; then
648 host_build_qemu=1
651 host_build_coreutils=0
652 if which tr >/dev/null 2>&1; then
653 if ! tr --version 2>/dev/null|grep GNU >/dev/null;then
654 host_build_coreutils=1
658 echo "config ADK_HOST_BUILD_TOOLS" > $topdir/target/config/Config.in.prereq
659 printf "\t%s\n" "bool" >> $topdir/target/config/Config.in.prereq
660 printf "\t%s\n" "default y" >> $topdir/target/config/Config.in.prereq
661 # always required
662 if [ $host_build_bc -eq 1 ]; then
663 printf "\t%s\n" "select ADK_HOST_BUILD_BC" >> $topdir/target/config/Config.in.prereq
665 if [ $host_build_bison -eq 1 ]; then
666 printf "\t%s\n" "select ADK_HOST_BUILD_BISON" >> $topdir/target/config/Config.in.prereq
668 if [ $host_build_bzip2 -eq 1 ]; then
669 printf "\t%s\n" "select ADK_HOST_BUILD_BZIP2" >> $topdir/target/config/Config.in.prereq
671 if [ $host_build_file -eq 1 ]; then
672 printf "\t%s\n" "select ADK_HOST_BUILD_FILE" >> $topdir/target/config/Config.in.prereq
674 if [ $host_build_flex -eq 1 ]; then
675 printf "\t%s\n" "select ADK_HOST_BUILD_FLEX" >> $topdir/target/config/Config.in.prereq
677 if [ $host_build_gawk -eq 1 ]; then
678 printf "\t%s\n" "select ADK_HOST_BUILD_GAWK" >> $topdir/target/config/Config.in.prereq
680 if [ $host_build_grep -eq 1 ]; then
681 printf "\t%s\n" "select ADK_HOST_BUILD_GREP" >> $topdir/target/config/Config.in.prereq
683 if [ $host_build_m4 -eq 1 ]; then
684 printf "\t%s\n" "select ADK_HOST_BUILD_M4" >> $topdir/target/config/Config.in.prereq
686 if [ $host_build_mkimage -eq 1 ]; then
687 printf "\t%s\n" "select ADK_HOST_NEED_U_BOOT" >> $topdir/target/config/Config.in.prereq
689 if [ $host_build_mksh -eq 1 ]; then
690 printf "\t%s\n" "select ADK_HOST_BUILD_MKSH" >> $topdir/target/config/Config.in.prereq
692 if [ $host_build_patch -eq 1 ]; then
693 printf "\t%s\n" "select ADK_HOST_BUILD_PATCH" >> $topdir/target/config/Config.in.prereq
695 if [ $host_build_findutils -eq 1 ]; then
696 printf "\t%s\n" "select ADK_HOST_BUILD_FINDUTILS" >> $topdir/target/config/Config.in.prereq
698 if [ $host_build_sed -eq 1 ]; then
699 printf "\t%s\n" "select ADK_HOST_BUILD_SED" >> $topdir/target/config/Config.in.prereq
701 if [ $host_build_tar -eq 1 ]; then
702 printf "\t%s\n" "select ADK_HOST_BUILD_TAR" >> $topdir/target/config/Config.in.prereq
704 if [ $host_build_coreutils -eq 1 ]; then
705 printf "\t%s\n" "select ADK_HOST_BUILD_COREUTILS" >> $topdir/target/config/Config.in.prereq
707 if [ $host_build_cpio -eq 1 ]; then
708 printf "\t%s\n" "select ADK_HOST_BUILD_CPIO" >> $topdir/target/config/Config.in.prereq
710 if [ $host_build_xz -eq 1 ]; then
711 printf "\t%s\n" "select ADK_HOST_BUILD_XZ" >> $topdir/target/config/Config.in.prereq
713 # optional
714 if [ $host_build_cdrtools -eq 1 ]; then
715 printf "\t%s\n" "select ADK_HOST_BUILD_CDRTOOLS if ADK_HOST_NEED_CDRTOOLS" >> $topdir/target/config/Config.in.prereq
717 if [ $host_build_genext2fs -eq 1 ]; then
718 printf "\t%s\n" "select ADK_HOST_BUILD_GENEXT2FS if ADK_HOST_NEED_GENEXT2FS" >> $topdir/target/config/Config.in.prereq
720 if [ $host_build_lzma -eq 1 ]; then
721 printf "\t%s\n" "select ADK_HOST_BUILD_LZMA if ADK_HOST_NEED_LZMA" >> $topdir/target/config/Config.in.prereq
723 if [ $host_build_lz4 -eq 1 ]; then
724 printf "\t%s\n" "select ADK_HOST_BUILD_LZ4 if ADK_HOST_NEED_LZ4" >> $topdir/target/config/Config.in.prereq
726 if [ $host_build_lzop -eq 1 ]; then
727 printf "\t%s\n" "select ADK_HOST_BUILD_LZOP if ADK_HOST_NEED_LZOP" >> $topdir/target/config/Config.in.prereq
729 if [ $host_build_qemu -eq 1 ]; then
730 printf "\t%s\n" "select ADK_HOST_BUILD_QEMU if ADK_HOST_NEED_QEMU" >> $topdir/target/config/Config.in.prereq
733 # create Host OS symbols
734 case $os in
735 Linux)
736 printf "\nconfig ADK_HOST_LINUX\n" >> $topdir/target/config/Config.in.prereq
737 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
738 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
740 Darwin)
741 printf "\nconfig ADK_HOST_DARWIN\n" >> $topdir/target/config/Config.in.prereq
742 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
743 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
745 OpenBSD)
746 printf "\nconfig ADK_HOST_OPENBSD\n" >> $topdir/target/config/Config.in.prereq
747 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
748 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
750 FreeBSD)
751 printf "\nconfig ADK_HOST_FREEBSD\n" >> $topdir/target/config/Config.in.prereq
752 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
753 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
755 NetBSD)
756 printf "\nconfig ADK_HOST_NETBSD\n" >> $topdir/target/config/Config.in.prereq
757 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
758 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
760 MirBSD)
761 printf "\nconfig ADK_HOST_MIRBSD\n" >> $topdir/target/config/Config.in.prereq
762 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
763 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
765 Cygwin*)
766 printf "\nconfig ADK_HOST_CYGWIN\n" >> $topdir/target/config/Config.in.prereq
767 printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
768 printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
770 esac
772 if [ "$target" = "defconfig" ]; then
773 $makebin ADK_TOPDIR=$topdir --no-print-directory -f Makefile.adk $flags $target
774 exit 0
777 if [ ! -f $topdir/.config ]; then
778 # create a config if no exist
779 touch .firstrun
780 $makebin ADK_TOPDIR=$topdir --no-print-directory -f Makefile.adk menuconfig
781 else
782 # scan host-tool prerequisites of certain packages before building.
783 . $topdir/.config
784 if [ -n "$ADK_PACKAGE_KODI" ]; then
785 NEED_JAVA="$NEED_JAVA kodi"
788 if [ -n "$ADK_PACKAGE_ICU4C" ]; then
789 NEED_STATIC_LIBSTDCXX="$NEED_STATIC_LIBSTDCXX icu4c"
792 if [ -n "$ADK_PACKAGE_XKEYBOARD_CONFIG" ]; then
793 NEED_XKBCOMP="$NEED_XKBCOMP xkeyboard-config"
796 if [ -n "$ADK_PACKAGE_FONT_BH_100DPI" ]; then
797 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-100dpi"
800 if [ -n "$ADK_PACKAGE_FONT_BH_75DPI" ]; then
801 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-75dpi"
804 if [ -n "$ADK_PACKAGE_FONT_BH_TYPE1" ]; then
805 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-type1"
808 if [ -n "$ADK_PACKAGE_FONT_BH_TTF" ]; then
809 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-ttf"
812 if [ -n "$ADK_PACKAGE_FONT_BH_LUCIDATYPEWRITER_100DPI" ]; then
813 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-lucidatypewriter-100dpi"
816 if [ -n "$ADK_PACKAGE_FONT_BH_LUCIDATYPEWRITER_75DPI" ]; then
817 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bh-lucidatypewriter-75dpi"
820 if [ -n "$ADK_PACKAGE_FONT_BITSTREAM_100DPI" ]; then
821 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bitstream-100dpi"
824 if [ -n "$ADK_PACKAGE_FONT_BITSTREAM_75DPI" ]; then
825 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bitstream-75dpi"
828 if [ -n "$ADK_PACKAGE_FONT_BITSTREAM_TYPE1" ]; then
829 NEED_MKFONTDIR="$NEED_MKFONTDIR font-bitstream-type1"
832 if [ -n "$ADK_PACKAGE_FONT_ADOBE_100DPI" ]; then
833 NEED_MKFONTDIR="$NEED_MKFONTDIR font-adobe-100dpi"
836 if [ -n "$ADK_PACKAGE_FONT_ADOBE_75DPI" ]; then
837 NEED_MKFONTDIR="$NEED_MKFONTDIR font-adobe-75dpi"
840 if [ -n "$ADK_PACKAGE_FONT_XFREE86_TYPE1" ]; then
841 NEED_MKFONTDIR="$NEED_MKFONTDIR font-xfree86-type1"
844 if [ -n "$ADK_PACKAGE_FONT_MISC_MISC" ]; then
845 NEED_MKFONTDIR="$NEED_MKFONTDIR font-misc-misc"
848 if [ -n "$ADK_PACKAGE_LIBERATION_FONTS_TTF" ]; then
849 NEED_MKFONTSCALE="$NEED_MKFONTSCALE liberation-fonts-ttf"
852 if [ -n "$NEED_MKFONTDIR" ]; then
853 if ! which mkfontdir >/dev/null 2>&1; then
854 printf "You need mkfontdir to build $NEED_MKFONTDIR \n"
855 out=1
859 if [ -n "$NEED_MKFONTSCALE" ]; then
860 if ! which mkfontscale >/dev/null 2>&1; then
861 printf "You need mkfontscale to build $NEED_MKFONTSCALE \n"
862 out=1
866 if [ -n "$NEED_XKBCOMP" ]; then
867 if ! which xkbcomp >/dev/null 2>&1; then
868 printf "You need xkbcomp to build $NEED_XKBCOMP \n"
869 out=1
873 if [ -n "$NEED_JAVA" ]; then
874 if ! which java >/dev/null 2>&1; then
875 printf "You need java to build $NEED_JAVA \n"
876 out=1
880 if [ -n "$NEED_STATIC_LIBSTDCXX" ]; then
881 cat >test.c <<-'EOF'
882 #include <stdio.h>
884 main()
886 return (0);
889 if ! $CXX -static-libstdc++ -o test test.c 2>/dev/null ; then
890 printf "You need static version of libstdc++ installed to build $NEED_STATIC_LIBSTDCXX \n"
891 out=1
892 rm test test.c 2>/dev/null
896 # error out
897 if [ $out -ne 0 ]; then
898 exit $out
901 # start build
902 $makebin ADK_TOPDIR=$topdir --no-print-directory -f Makefile.adk $flags $target