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
12 mirror
=http
://distfiles.openadk.org
17 # detect operating system
20 printf " ---> $os $osver for build detected.\n"
22 # check if the filesystem is case sensitive
26 printf "ERROR: OpenADK cannot be built in a case-insensitive file system."
29 printf "Building OpenADK on $os needs a small registry change."
30 printf "http://cygwin.com/cygwin-ug-net/using-specialnames.html"
33 printf "Building OpenADK on $os needs a case-sensitive disk partition."
34 printf "For Snow Leopard and above you can use diskutil to resize your existing disk."
35 printf "Example: sudo diskutil resizeVolume disk0s2 90G 1 jhfsx adk 30G"
36 printf "For older versions you might consider to use a disk image:"
37 printf "hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 30g ~/openadk.dmg"
45 # do we have a download tool?
47 for tool
in $tools; do
48 printf " ---> checking if $tool is installed.. "
49 if which $tool >/dev
/null
; then
53 FETCHCMD
="$(which $tool) -L -k -f -\# -o "
56 FETCHCMD
="$(which $tool) --no-check-certificate -O "
65 if [ -z "$FETCHCMD" ]; then
66 printf "ERROR: no download tool found. Fatal error.\n"
70 # do we have a checksum tool?
71 tools
="sha256sum sha256 cksum shasum"
72 for tool
in $tools; do
73 printf " ---> checking if $tool is installed.. "
74 if which $tool >/dev
/null
2>/dev
/null
; then
76 # check if cksum is usable
82 SHA256
="$(which $tool) -q"
85 if cksum -q >/dev
/null
2>/dev
/null
; then
86 SHA256
="$(which $tool) -q -a sha256"
92 SHA256
="$(which $tool) -a 256"
101 if [ -z "$SHA256" ]; then
102 printf "ERROR: no checksum tool found. Fatal error.\n"
106 # create download dir
107 if [ ! -d $topdir/dl
]; then
111 # check for c compiler
112 compilerbins
="clang cc gcc"
113 for compilerbin
in $compilerbins; do
114 printf " ---> checking if $compilerbin is installed.. "
115 if which $compilerbin >/dev
/null
; then
125 if [ -z "$CCFOUND" ]; then
126 printf "ERROR: no C compiler found. Fatal error.\n"
130 # check for c++ compiler
131 compilerbins
="clang++ c++ g++"
132 for compilerbin
in $compilerbins; do
133 printf " ---> checking if $compilerbin is installed.. "
134 if which $compilerbin >/dev
/null
; then
144 if [ -z "$CXXFOUND" ]; then
145 printf "ERROR: no C++ compiler found. Fatal error.\n"
149 gnu_host_name
=$
(${CC} -dumpmachine)
151 # relocation of topdir?
152 olddir
=$
(grep "^ADK_TOPDIR" prereq.mk
2>/dev
/null |cut
-d '=' -f 2)
155 if [ ! -z "$olddir" ]; then
156 if [ "$olddir" != "$newdir" ]; then
157 printf " ---> adk directory was relocated, fixing .."
158 sed -i -e "s#$olddir#$newdir#g" $
(find target_
* -name \
*.pc|
xargs) 2>/dev
/null
159 sed -i -e "s#$olddir#$newdir#g" $
(find host_
${gnu_host_name} -type f|
xargs) 2>/dev
/null
160 sed -i -e "s#$olddir#$newdir#g" $
(find target_
*/scripts
-type f|
xargs) 2>/dev
/null
161 sed -i -e "s#$olddir#$newdir#" target_
*/etc
/ipkg.conf
2>/dev
/null
169 (*:$topdir/host_
${gnu_host_name}/bin
:*) ;;
170 (*) export PATH
=$topdir/host_
${gnu_host_name}/bin
:$PATH ;;
174 makebins
="gmake make"
175 for makebin
in $makebins; do
176 printf " ---> checking if $makebin is installed.. "
177 if which $makebin >/dev
/null
2>/dev
/null
; then
179 printf " ---> checking if it is GNU make.. "
180 $makebin --version 2>/dev
/null|
grep GNU
>/dev
/null
181 if [ $?
-eq 0 ]; then
183 MAKE
=$
(which $makebin)
186 # we need to build GNU make
188 printf " ---> compiling missing GNU make.. "
190 $FETCHCMD make-
${makever}.
tar.gz
$mirror/make-
${makever}.
tar.gz
191 if [ $?
-ne 0 ]; then
192 printf "ERROR: failed to download make from $mirror\n"
198 tar xzf ..
/dl
/make-
${makever}.
tar.gz
200 .
/configure
--prefix=$topdir/host_
$gnu_host_name/
206 MAKE
=$topdir/host_
$gnu_host_name/bin
/make
207 makebin
=$topdir/host_
$gnu_host_name/bin
/make
217 printf " ---> checking if bash is installed.. "
218 if which bash
>/dev
/null
; then
220 printf " ---> checking if it is bash 4.x.. "
221 bash
--version 2>/dev
/null|
grep -i "Version 4" >/dev
/null
222 if [ $?
-eq 0 ]; then
225 # we need to build GNU bash 4.x
227 printf " ---> compiling missing GNU bash.. "
229 $FETCHCMD bash-
${bashver}.
tar.gz
$mirror/bash-
${bashver}.
tar.gz
230 if [ $?
-ne 0 ]; then
231 printf "ERROR: failed to download make from $mirror\n"
237 tar xzf ..
/dl
/bash-
${bashver}.
tar.gz
239 .
/configure
--prefix=$topdir/host_
$gnu_host_name/
249 # skip the script if distclean / cleandir
250 if [ "$target" = "distclean" -o "$target" = "cleandir" ]; then
252 $makebin ADK_TOPDIR
=$topdir -s -f Makefile.adk
$flags $target
256 printf " ---> checking if strings is installed.. "
257 if ! which strings >/dev
/null
2>&1; then
258 echo You must
install strings to
continue.
265 printf " ---> checking if perl is installed.. "
266 if ! which perl
>/dev
/null
2>&1; then
267 echo You must
install perl to
continue.
274 printf " ---> checking if gzip is installed.. "
275 if ! which gzip >/dev
/null
2>&1; then
276 echo You must
install gzip to
continue.
283 printf " ---> checking if git is installed.. "
284 if ! which git
>/dev
/null
2>&1; then
285 echo You must
install git to
continue.
294 echo "ADK_TOPDIR:=$(readlink -nf . 2>/dev/null || pwd -P)" > $topdir/prereq.mk
295 echo "BASH:=$(which bash)" >> $topdir/prereq.mk
296 echo "SHELL:=$(which bash)" >> $topdir/prereq.mk
297 echo "GMAKE:=$MAKE" >> $topdir/prereq.mk
298 echo "MAKE:=$MAKE" >> $topdir/prereq.mk
299 echo "FETCHCMD:=$FETCHCMD" >> $topdir/prereq.mk
300 echo "SHA256:=$SHA256" >> $topdir/prereq.mk
301 echo "GNU_HOST_NAME:=${gnu_host_name}" >> $topdir/prereq.mk
302 echo "OS_FOR_BUILD:=${os}" >> $topdir/prereq.mk
303 echo "ARCH_FOR_BUILD:=$(${CC} -dumpmachine | sed \
304 -e 's/x86_64-linux-gnux32/x32/' \
306 -e 's/sparc.*/sparc/' \
307 -e 's/armeb.*/armeb/g' \
309 -e 's/m68k.*/m68k/' \
311 -e 's/mips-.*/mips/' \
312 -e 's/mipsel-.*/mipsel/' \
313 -e 's/i[3-9]86/x86/' \
316 if [ "$CC" = "clang" ]; then
317 echo "HOST_CC:=${CC} -fbracket-depth=1024" >> $topdir/prereq.mk
319 echo "HOST_CC:=${CC}" >> $topdir/prereq.mk
321 if [ "$CXX" = "clang++" ]; then
322 echo "HOST_CXX:=${CXX} -fbracket-depth=1024" >> $topdir/prereq.mk
324 echo "HOST_CXX:=${CXX}" >> $topdir/prereq.mk
327 echo "HOST_CFLAGS:=-O0 -g0" >> $topdir/prereq.mk
328 echo "HOST_CXXFLAGS:=-O0 -g0" >> $topdir/prereq.mk
329 echo 'LANGUAGE:=C' >> $topdir/prereq.mk
330 echo 'LC_ALL:=C' >> $topdir/prereq.mk
331 echo "_PATH:=$PATH" >> $topdir/prereq.mk
332 echo "PATH:=${topdir}/scripts:/usr/sbin:$PATH" >> $topdir/prereq.mk
333 echo "GIT:=$(which git 2>/dev/null)" >> $topdir/prereq.mk
334 if [ $dlverbose -eq 0 ]; then
335 echo "GITOPTS:=--quiet" >> $topdir/prereq.mk
337 echo "export ADK_TOPDIR GIT GITOPTS SHA256 BASH SHELL" >> $topdir/prereq.mk
339 # create temporary Makefile
340 cat >Makefile.tmp
<<'EOF'
341 include ${ADK_TOPDIR}/prereq.mk
345 @${HOST_CC} ${HOST_CFLAGS} -o $@ $^ ${LDADD}
348 # check if compiler works
359 $MAKE --no-print-directory ADK_TOPDIR
=$topdir -f Makefile.tmp
2>&1
361 if [ $X != YES
]; then
362 echo "$X" |
sed 's/^/| /'
363 echo Cannot compile a simple
test programme.
364 echo You must
install a
host make and C compiler.
368 rm test.c
test 2>/dev
/null
376 #define STDIN_FILENO 0
386 zstdin = gzdopen(STDIN_FILENO, "rb");
387 i = gzread(zstdin, buf, sizeof (buf));
388 if ((i > 0) && (i < sizeof (buf)))
390 buf[sizeof (buf) - 1] = '\0';
396 $MAKE --no-print-directory LDADD
=-lz ADK_TOPDIR
=$topdir -f Makefile.tmp
2>&1
397 X
=$
(echo YES |
gzip | .
/test)
398 if [ $X != YES
]; then
399 echo "$X" |
sed 's/^/| /'
400 echo Cannot compile a libz
test programm.
401 echo You must
install the zlib development package
,
402 echo usually called libz-dev
, and the run-time library.
407 rm test.c
test 2>/dev
/null
408 rm Makefile.tmp
2>/dev
/null
410 # error out on any required prerequisite
411 if [ $out -ne 0 ]; then
416 if which bc >/dev
/null
2>&1; then
417 if ! echo quit|
bc -q 2>/dev
/null
>/dev
/null
; then
420 if bc -v 2>&1|
grep -q BSD
>/dev
/null
2>&1; then
429 if ! which bison
>/dev
/null
2>&1; then
434 if ! which bzip2 >/dev
/null
2>&1; then
439 if ! which file >/dev
/null
2>&1; then
444 if ! which flex
>/dev
/null
2>&1; then
449 if ! which m4 >/dev
/null
2>&1; then
454 if ! which mkimage
>/dev
/null
2>&1; then
459 if ! which mksh
>/dev
/null
2>&1; then
464 if ! which patch >/dev
/null
2>&1; then
469 if ! which pkgconf
>/dev
/null
2>&1; then
474 if which tar >/dev
/null
2>&1; then
475 if ! tar --version 2>/dev
/null|
grep GNU
>/dev
/null
;then
482 host_build_findutils
=0
483 if which xargs >/dev
/null
2>&1; then
484 if ! xargs --version 2>/dev
/null|
grep GNU
>/dev
/null
;then
485 host_build_findutils
=1
489 if which find >/dev
/null
2>&1; then
490 if ! find --version 2>/dev
/null|
grep GNU
>/dev
/null
;then
491 host_build_findutils
=1
496 if which grep >/dev
/null
2>&1; then
497 if ! grep --version 2>/dev
/null|
grep GNU
>/dev
/null
;then
503 if ! which gawk
>/dev
/null
2>&1; then
508 if which sed >/dev
/null
2>&1; then
509 if ! sed --version 2>/dev
/null|
grep GNU
>/dev
/null
;then
515 if ! which xz
>/dev
/null
2>&1; then
520 host_build_cdrtools
=0
521 if ! which mkisofs
>/dev
/null
2>&1; then
522 host_build_cdrtools
=1
526 if ! which ccache
>/dev
/null
2>&1; then
530 host_build_genext2fs
=0
531 if ! which genext2fs
>/dev
/null
2>&1; then
532 host_build_genext2fs
=1
536 if ! which lzma
>/dev
/null
2>&1; then
541 if ! which lz4c
>/dev
/null
2>&1; then
546 if ! which lzop
>/dev
/null
2>&1; then
551 if ! which qemu-img
>/dev
/null
2>&1; then
555 host_build_coreutils
=0
556 if which tr >/dev
/null
2>&1; then
557 if ! tr --version 2>/dev
/null|
grep GNU
>/dev
/null
;then
558 host_build_coreutils
=1
562 echo "config ADK_HOST_BUILD_TOOLS" > $topdir/target
/config
/Config.
in.prereq
563 printf "\t%s\n" "bool" >> $topdir/target
/config
/Config.
in.prereq
564 printf "\t%s\n" "default y" >> $topdir/target
/config
/Config.
in.prereq
566 if [ $host_build_bc -eq 1 ]; then
567 printf "\t%s\n" "select ADK_HOST_BUILD_BC" >> $topdir/target
/config
/Config.
in.prereq
569 if [ $host_build_bison -eq 1 ]; then
570 printf "\t%s\n" "select ADK_HOST_BUILD_BISON" >> $topdir/target
/config
/Config.
in.prereq
572 if [ $host_build_bzip2 -eq 1 ]; then
573 printf "\t%s\n" "select ADK_HOST_BUILD_BZIP2" >> $topdir/target
/config
/Config.
in.prereq
575 if [ $host_build_file -eq 1 ]; then
576 printf "\t%s\n" "select ADK_HOST_BUILD_FILE" >> $topdir/target
/config
/Config.
in.prereq
578 if [ $host_build_flex -eq 1 ]; then
579 printf "\t%s\n" "select ADK_HOST_BUILD_FLEX" >> $topdir/target
/config
/Config.
in.prereq
581 if [ $host_build_gawk -eq 1 ]; then
582 printf "\t%s\n" "select ADK_HOST_BUILD_GAWK" >> $topdir/target
/config
/Config.
in.prereq
584 if [ $host_build_grep -eq 1 ]; then
585 printf "\t%s\n" "select ADK_HOST_BUILD_GREP" >> $topdir/target
/config
/Config.
in.prereq
587 if [ $host_build_m4 -eq 1 ]; then
588 printf "\t%s\n" "select ADK_HOST_BUILD_M4" >> $topdir/target
/config
/Config.
in.prereq
590 if [ $host_build_mkimage -eq 1 ]; then
591 printf "\t%s\n" "select ADK_HOST_BUILD_U_BOOT" >> $topdir/target
/config
/Config.
in.prereq
593 if [ $host_build_mksh -eq 1 ]; then
594 printf "\t%s\n" "select ADK_HOST_BUILD_MKSH" >> $topdir/target
/config
/Config.
in.prereq
596 if [ $host_build_patch -eq 1 ]; then
597 printf "\t%s\n" "select ADK_HOST_BUILD_PATCH" >> $topdir/target
/config
/Config.
in.prereq
599 if [ $host_build_pkgconf -eq 1 ]; then
600 printf "\t%s\n" "select ADK_HOST_BUILD_PKGCONF" >> $topdir/target
/config
/Config.
in.prereq
602 if [ $host_build_findutils -eq 1 ]; then
603 printf "\t%s\n" "select ADK_HOST_BUILD_FINDUTILS" >> $topdir/target
/config
/Config.
in.prereq
605 if [ $host_build_sed -eq 1 ]; then
606 printf "\t%s\n" "select ADK_HOST_BUILD_SED" >> $topdir/target
/config
/Config.
in.prereq
608 if [ $host_build_tar -eq 1 ]; then
609 printf "\t%s\n" "select ADK_HOST_BUILD_TAR" >> $topdir/target
/config
/Config.
in.prereq
611 if [ $host_build_xz -eq 1 ]; then
612 printf "\t%s\n" "select ADK_HOST_BUILD_XZ" >> $topdir/target
/config
/Config.
in.prereq
615 if [ $host_build_ccache -eq 1 ]; then
616 printf "\t%s\n" "select ADK_HOST_BUILD_CCACHE if ADK_HOST_NEED_CCACHE" >> $topdir/target
/config
/Config.
in.prereq
618 if [ $host_build_cdrtools -eq 1 ]; then
619 printf "\t%s\n" "select ADK_HOST_BUILD_CDRTOOLS if ADK_HOST_NEED_CDRTOOLS" >> $topdir/target
/config
/Config.
in.prereq
621 if [ $host_build_genext2fs -eq 1 ]; then
622 printf "\t%s\n" "select ADK_HOST_BUILD_GENEXT2FS if ADK_HOST_NEED_GENEXT2FS" >> $topdir/target
/config
/Config.
in.prereq
624 if [ $host_build_lzma -eq 1 ]; then
625 printf "\t%s\n" "select ADK_HOST_BUILD_LZMA if ADK_HOST_NEED_LZMA" >> $topdir/target
/config
/Config.
in.prereq
627 if [ $host_build_lz4 -eq 1 ]; then
628 printf "\t%s\n" "select ADK_HOST_BUILD_LZ4 if ADK_HOST_NEED_LZ4" >> $topdir/target
/config
/Config.
in.prereq
630 if [ $host_build_lzop -eq 1 ]; then
631 printf "\t%s\n" "select ADK_HOST_BUILD_LZOP if ADK_HOST_NEED_LZOP" >> $topdir/target
/config
/Config.
in.prereq
633 if [ $host_build_qemu -eq 1 ]; then
634 printf "\t%s\n" "select ADK_HOST_BUILD_QEMU if ADK_HOST_NEED_QEMU" >> $topdir/target
/config
/Config.
in.prereq
636 if [ $host_build_coreutils -eq 1 ]; then
637 printf "\t%s\n" "select ADK_HOST_BUILD_COREUTILS if ADK_HOST_NEED_COREUTILS" >> $topdir/target
/config
/Config.
in.prereq
640 # create Host OS symbols
643 printf "\nconfig ADK_HOST_LINUX\n" >> $topdir/target
/config
/Config.
in.prereq
644 printf "\tbool\n" >> $topdir/target
/config
/Config.
in.prereq
645 printf "\tdefault y\n" >> $topdir/target
/config
/Config.
in.prereq
648 printf "\nconfig ADK_HOST_DARWIN\n" >> $topdir/target
/config
/Config.
in.prereq
649 printf "\tbool\n" >> $topdir/target
/config
/Config.
in.prereq
650 printf "\tdefault y\n" >> $topdir/target
/config
/Config.
in.prereq
653 printf "\nconfig ADK_HOST_OPENBSD\n" >> $topdir/target
/config
/Config.
in.prereq
654 printf "\tbool\n" >> $topdir/target
/config
/Config.
in.prereq
655 printf "\tdefault y\n" >> $topdir/target
/config
/Config.
in.prereq
658 printf "\nconfig ADK_HOST_FREEBSD\n" >> $topdir/target
/config
/Config.
in.prereq
659 printf "\tbool\n" >> $topdir/target
/config
/Config.
in.prereq
660 printf "\tdefault y\n" >> $topdir/target
/config
/Config.
in.prereq
663 printf "\nconfig ADK_HOST_NETBSD\n" >> $topdir/target
/config
/Config.
in.prereq
664 printf "\tbool\n" >> $topdir/target
/config
/Config.
in.prereq
665 printf "\tdefault y\n" >> $topdir/target
/config
/Config.
in.prereq
668 printf "\nconfig ADK_HOST_MIRBSD\n" >> $topdir/target
/config
/Config.
in.prereq
669 printf "\tbool\n" >> $topdir/target
/config
/Config.
in.prereq
670 printf "\tdefault y\n" >> $topdir/target
/config
/Config.
in.prereq
673 printf "\nconfig ADK_HOST_CYGWIN\n" >> $topdir/target
/config
/Config.
in.prereq
674 printf "\tbool\n" >> $topdir/target
/config
/Config.
in.prereq
675 printf "\tdefault y\n" >> $topdir/target
/config
/Config.
in.prereq
679 if [ "$target" = "defconfig" ]; then
680 $makebin ADK_TOPDIR
=$topdir --no-print-directory -f Makefile.adk
$flags $target
684 if [ ! -f $topdir/.config
]; then
685 # create a config if no exist
687 $makebin ADK_TOPDIR
=$topdir --no-print-directory -f Makefile.adk menuconfig
689 # scan host-tool prerequisites of certain packages before building.
691 if [ -n "$ADK_PACKAGE_KODI" ]; then
692 NEED_JAVA
="$NEED_JAVA kodi"
695 if [ -n "$ADK_PACKAGE_ICU4C" ]; then
696 NEED_STATIC_LIBSTDCXX
="$NEED_STATIC_LIBSTDCXX icu4c"
699 if [ -n "$ADK_PACKAGE_XKEYBOARD_CONFIG" ]; then
700 NEED_XKBCOMP
="$NEED_XKBCOMP xkeyboard-config"
703 if [ -n "$ADK_PACKAGE_FONT_BITSTREAM_100DPI" ]; then
704 NEED_MKFONTDIR
="$NEED_MKFONTDIR font-bitstream-100dpi"
707 if [ -n "$ADK_PACKAGE_FONT_BITSTREAM_75DPI" ]; then
708 NEED_MKFONTDIR
="$NEED_MKFONTDIR font-bitstream-75dpi"
711 if [ -n "$ADK_PACKAGE_FONT_ADOBE_100DPI" ]; then
712 NEED_MKFONTDIR
="$NEED_MKFONTDIR font-adobe-100dpi"
715 if [ -n "$ADK_PACKAGE_FONT_ADOBE_75DPI" ]; then
716 NEED_MKFONTDIR
="$NEED_MKFONTDIR font-adobe-75dpi"
719 if [ -n "$NEED_MKFONTDIR" ]; then
720 if ! which mkfontdir
>/dev
/null
2>&1; then
721 printf "You need mkfontdir to build $NEED_MKFONTDIR \n"
726 if [ -n "$NEED_XKBCOMP" ]; then
727 if ! which xkbcomp
>/dev
/null
2>&1; then
728 printf "You need xkbcomp to build $NEED_XKBCOMP \n"
733 if [ -n "$NEED_JAVA" ]; then
734 if ! which java
>/dev
/null
2>&1; then
735 printf "You need java to build $NEED_JAVA \n"
740 if [ -n "$NEED_STATIC_LIBSTDCXX" ]; then
749 if ! $CXX -static-libstdc++ -o test test.c
2>/dev
/null
; then
750 printf "You need static version of libstdc++ installed to build $NEED_STATIC_LIBSTDCXX \n"
752 rm test test.c
2>/dev
/null
757 if [ $out -ne 0 ]; then
762 $makebin ADK_TOPDIR
=$topdir --no-print-directory -f Makefile.adk
$flags $target