| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514 | #!/bin/sh# This file is part of the OpenADK project. OpenADK is copyrighted# material, please see the LICENCE file in the top-level directory.# resolve prerequisites for OpenADK buildtopdir=$(pwd)target="$@"flags="$MAKEFLAGS"out=0# detect operating systemos=$(env uname)osver=$(env uname -r)printf " --->  $os $osver for build detected.\n"# check if the filesystem is case sensitiverm -f fooecho >FOOif [[ -e foo ]]; then  printf "ERROR: OpenADK cannot be built in a case-insensitive file system."   case $os in    CYG*)      printf "Building OpenADK on $os needs a small registry change."      printf "http://cygwin.com/cygwin-ug-net/using-specialnames.html"      ;;    Darwin*)      printf "Building OpenADK on $os needs a case-sensitive disk partition."      printf "For Snow Leopard and above you can use diskutil to resize your existing disk."      printf "Example: sudo diskutil resizeVolume disk0s2 90G 1 jhfsx adk 30G"      printf "For older versions you might consider to use a disk image:"      printf "hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 30g ~/openadk.dmg"      ;;  esac  rm -f FOO  exit 1firm -f FOO# relocation of topdir?olddir=$(grep "^ADK_TOPDIR" prereq.mk 2>/dev/null |cut -d '=' -f 2)newdir=$(pwd)if [ ! -z "$olddir" ]; then  if [ "$olddir" != "$newdir" ]; then    printf " --->  adk directory was relocated, fixing .."    printf "old directory: $olddir"    printf "new directory: $newdir"    sed -i -e "s#$olddir#$newdir#g" $(find target_* -name \*.pc|xargs)    sed -i -e "s#$olddir#$newdir#g" $(find target_*/scripts -type f|xargs)    sed -i -e "s#$olddir#$newdir#" target_*/etc/ipkg.conf  fifi# do we have a download tool?tools="curl wget ftp lftp"for tool in $tools; do  printf " --->  checking if $tool is installed.. "  if which $tool >/dev/null; then    printf "found\n"    DLTOOL=$(which $tool)    break  else    printf "not found\n"    continue  fidoneif [ -z $DLTOOL ]; then  printf "ERROR: no download tool found. Fatal error.\n"  exit 1fi# do we have a checksum tool?tools="sha256sum sha256"for tool in $tools; do  printf " --->  checking if $tool is installed.. "  if which $tool >/dev/null 2>/dev/null; then    printf "found\n"    if [ $tool = "sha256" ]; then      SHA256="$(which $tool) -q"    else      SHA256=$(which $tool)    fi    break  else    printf "not found\n"    continue  fidoneif [ -z "$SHA256" ]; then  printf "ERROR: no checksum tool found. Fatal error.\n"  exit 1fi# create download dirif [ ! -d $topdir/dl ]; then  mkdir -p $topdir/dlfi# check for GNU makemakebins="gmake make"for makebin in $makebins; do  printf " --->  checking if $makebin is installed.. "  if which $makebin >/dev/null; then    printf "found\n"    printf " --->  checking if it is GNU make.. "    $makebin --version 2>/dev/null| grep GNU >/dev/null    if [ $? -eq 0 ]; then      printf "yes\n"      MAKE=$(which $makebin)      break    fi  else    printf "not found\n"    continue  fidone# skip the script if distclean / cleandirif [ "$target" = "distclean" -o "$target" = "cleandir" ]; then  touch prereq.mk  $makebin -s -f Makefile.adk $flags $target  exit 0fi# check for c compilercompilerbins="cc gcc clang"for compilerbin in $compilerbins; do  printf " --->  checking if $compilerbin is installed.. "  if which $compilerbin >/dev/null; then    printf "found\n"    CC=$compilerbin    break  fidone# check for c++ compilercompilerbins="c++ g++ clang++"for compilerbin in $compilerbins; do  printf " --->  checking if $compilerbin is installed.. "  if which $compilerbin >/dev/null; then    printf "found\n"    CXX=$compilerbin    break  fidoneif ! which perl >/dev/null 2>&1; then  echo You must install perl to continue.  echo  out=1fi# creating prereq.mkecho "ADK_TOPDIR:=$(readlink -nf . 2>/dev/null || pwd -P)" > $topdir/prereq.mkecho "BASH:=$(which bash)" >> $topdir/prereq.mkecho "SHELL:=$BASH" >> $topdir/prereq.mkecho "GMAKE:=$MAKE" >> $topdir/prereq.mkecho "MAKE:=$MAKE" >> $topdir/prereq.mkecho "SHA256:=$SHA256" >> $topdir/prereq.mkecho "GNU_HOST_NAME:=$(${CC} -dumpmachine)" >> $topdir/prereq.mkecho "OS_FOR_BUILD:=${os}" >> $topdir/prereq.mkecho "ARCH_FOR_BUILD:=$(${CC} -dumpmachine | sed \    -e 's/x86_64-linux-gnux32/x32/' \    -e s'/-.*//' \    -e 's/sparc.*/sparc/' \    -e 's/armeb.*/armeb/g' \    -e 's/arm.*/arm/g' \    -e 's/m68k.*/m68k/' \    -e 's/sh[234]/sh/' \    -e 's/mips-.*/mips/' \    -e 's/mipsel-.*/mipsel/' \    -e 's/i[3-9]86/x86/' \    )" >>prereq.mkif [ "$CC" = "clang" ]; then  echo "HOST_CC:=${CC} -fbracket-depth=1024" >> $topdir/prereq.mkelse  echo "HOST_CC:=${CC}" >> $topdir/prereq.mkfiif [ "$CXX" = "clang++" ]; then  echo "HOST_CXX:=${CXX} -fbracket-depth=1024" >> $topdir/prereq.mkelse  echo "HOST_CXX:=${CXX}" >> $topdir/prereq.mkfiecho 'LANGUAGE:=C' >> $topdir/prereq.mkecho 'LC_ALL:=C' >> $topdir/prereq.mkecho "_PATH:=$PATH" >> $topdir/prereq.mkecho "PATH:=${topdir}/scripts:/usr/sbin:$PATH" >> $topdir/prereq.mkecho "GIT:=$(which git 2>/dev/null)" >> $topdir/prereq.mkecho "export GIT SHA256" >> $topdir/prereq.mk# check if compiler workscat >Makefile.tmp <<'EOF'include ${ADK_TOPDIR}/prereq.mkall: run-testtest: test.c	${HOST_CC} ${HOST_CFLAGS} -o $@ $^ ${LDADD}run-test: test	./testEOFcat >test.c <<-'EOF'	#include <stdio.h>	int	main()	{		printf("Yay! Native compiler works.\n");		return (0);	}EOFX=$($MAKE --no-print-directory ADK_TOPDIR=$topdir -f Makefile.tmp HOST_CFLAGS=${HOST_CFLAGS} 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  out=1firm test.c test Makefile.tmp 2>/dev/null# error out on any required prerequisiteif [ $out -ne 0 ]; then  exit $outfi# always required, but can be provided by hosthost_build_bc=0if which bc >/dev/null 2>&1; then  if ! echo quit|bc -q 2>/dev/null >/dev/null; then    host_build_bc=1  else     if bc -v 2>&1| grep -q BSD >/dev/null 2>&1; then      host_build_bc=1    fi   fielse  host_build_bc=1fihost_build_bison=0if ! which bison >/dev/null 2>&1; then  host_build_bison=1fihost_build_bzip2=0if ! which bzip2 >/dev/null 2>&1; then  host_build_bzip2=1fihost_build_file=0if ! which file >/dev/null 2>&1; then  host_build_file=1fihost_build_flex=0if ! which flex >/dev/null 2>&1; then  host_build_flex=1fihost_build_m4=0if ! which m4 >/dev/null 2>&1; then  host_build_m4=1fihost_build_mksh=0if ! which mksh >/dev/null 2>&1; then  host_build_mksh=1fihost_build_patch=0if ! which patch >/dev/null 2>&1; then  host_build_patch=1fihost_build_pkgconf=0if ! which pkgconf >/dev/null 2>&1; then  host_build_pkgconf=1fihost_build_tar=0if which tar >/dev/null 2>&1; then  if ! tar --version 2>/dev/null|grep GNU >/dev/null;then    host_build_tar=1  fielse  host_build_tar=1fihost_build_findutils=0if ! 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  fifiif which find >/dev/null 2>&1; then  if ! find --version 2>/dev/null|grep GNU >/dev/null;then    host_build_findutils=1  fifihost_build_grep=0if which grep >/dev/null 2>&1; then  if ! grep --version 2>/dev/null|grep GNU >/dev/null;then    host_build_grep=1  fifihost_build_gawk=0if ! which gawk >/dev/null 2>&1; then  host_build_gawk=1fihost_build_sed=0if which sed >/dev/null 2>&1; then  if ! sed --version 2>/dev/null|grep GNU >/dev/null;then    host_build_sed=1  fifihost_build_xz=0if ! which xz >/dev/null 2>&1; then  host_build_xz=1fi# optionalhost_build_cdrtools=0if ! which mkisofs >/dev/null 2>&1; then  host_build_cdrtools=1fihost_build_ccache=0if ! which ccache >/dev/null 2>&1; then  host_build_ccache=1fihost_build_genext2fs=0if ! which genext2fs >/dev/null 2>&1; then  host_build_genext2fs=1fihost_build_lzma=0if ! which lzma >/dev/null 2>&1; then  host_build_lzma=1fihost_build_lz4=0if ! which lz4c >/dev/null 2>&1; then  host_build_lz4=1fihost_build_lzop=0if ! which lzop >/dev/null 2>&1; then  host_build_lzop=1fihost_build_qemu=0if ! which qemu-img >/dev/null 2>&1; then  host_build_qemu=1fiecho "config ADK_HOST_BUILD_TOOLS" > $topdir/target/config/Config.in.prereqprintf "\t%s\n" "bool" >> $topdir/target/config/Config.in.prereqprintf "\t%s\n" "default y" >> $topdir/target/config/Config.in.prereq# always requiredif [ $host_build_bc -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BC" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_bison -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BISON" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_bzip2 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BZIP2" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_file -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FILE" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_flex -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FLEX" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_gawk -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GAWK" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_grep -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GREP" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_m4 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_M4" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_mksh -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_MKSH" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_patch -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_PATCH" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_pkgconf -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_PKGCONF" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_findutils -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FINDUTILS" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_sed -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_SED" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_tar -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_TAR" >> $topdir/target/config/Config.in.prereq ;fiif [ $host_build_xz -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_XZ" >> $topdir/target/config/Config.in.prereq ;fi# optionalif [ $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 ;fiif [ $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 ;fiif [ $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 ;fiif [ $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 ;fiif [ $host_build_lz4 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_LZ4 if ADK_HOST_NEED_LZ4" >> $topdir/target/config/Config.in.prereq ;fiif [ $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 ;fiif [ $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# create Host OS symbolscase $os in  Linux)    printf "\nconfig ADK_HOST_LINUX\n" >> $topdir/target/config/Config.in.prereq    printf "\tbool\n" >> $topdir/target/config/Config.in.prereq    printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq    ;;  Darwin)    printf "\nconfig ADK_HOST_DARWIN\n" >> $topdir/target/config/Config.in.prereq    printf "\tbool\n" >> $topdir/target/config/Config.in.prereq    printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq    ;;  OpenBSD)    printf "\nconfig ADK_HOST_OPENBSD\n" >> $topdir/target/config/Config.in.prereq    printf "\tbool\n" >> $topdir/target/config/Config.in.prereq    printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq    ;;  FreeBSD)    printf "\nconfig ADK_HOST_FREEBSD\n" >> $topdir/target/config/Config.in.prereq    printf "\tbool\n" >> $topdir/target/config/Config.in.prereq    printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq    ;;  NetBSD)    printf "\nconfig ADK_HOST_NETBSD\n" >> $topdir/target/config/Config.in.prereq    printf "\tbool\n" >> $topdir/target/config/Config.in.prereq    printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq    ;;  MirBSD)    printf "\nconfig ADK_HOST_MIRBSD\n" >> $topdir/target/config/Config.in.prereq    printf "\tbool\n" >> $topdir/target/config/Config.in.prereq    printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq    ;;  Cygwin*)    printf "\nconfig ADK_HOST_CYGWIN\n" >> $topdir/target/config/Config.in.prereq    printf "\tbool\n" >> $topdir/target/config/Config.in.prereq    printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq    ;;esacif [ ! -f $topdir/.config ]; then  # create a config if no exist  touch .firstrun  $makebin --no-print-directory -f Makefile.adk menuconfigelse  # scan host-tool prerequisites of certain packages before building.  . $topdir/.config  if [[ -n $ADK_PACKAGE_KODI ]]; then    NEED_JAVA="$NEED_JAVA kodi"  fi  if [[ -n $ADK_PACKAGE_ICU4C ]]; then    NEED_STATIC_LIBSTDCXX="$NEED_STATIC_LIBSTDCXX icu4c"  fi  if [[ -n $ADK_PACKAGE_XKEYBOARD_CONFIG ]]; then    NEED_XKBCOMP="$NEED_XKBCOMP xkeyboard-config"  fi  if [[ -n $ADK_PACKAGE_FONT_BITSTREAM_100DPI ]]; then    NEED_MKFONTDIR="$NEED_MKFONTDIR font-bitstream-100dpi"  fi  if [[ -n $ADK_PACKAGE_FONT_BITSTREAM_75DPI ]]; then    NEED_MKFONTDIR="$NEED_MKFONTDIR font-bitstream-75dpi"  fi  if [[ -n $ADK_PACKAGE_FONT_ADOBE_100DPI ]]; then    NEED_MKFONTDIR="$NEED_MKFONTDIR font-adobe-100dpi"  fi  if [[ -n $ADK_PACKAGE_FONT_ADOBE_75DPI ]]; then    NEED_MKFONTDIR="$NEED_MKFONTDIR font-adobe-75dpi"  fi  if [[ -n $NEED_MKFONTDIR ]]; then    if ! which mkfontdir >/dev/null 2>&1; then      echo >&2 You need mkfontdir to build $NEED_MKFONTDIR      out=1    fi  fi  if [[ -n $NEED_XKBCOMP ]]; then    if ! which xkbcomp >/dev/null 2>&1; then      echo >&2 You need xkbcomp to build $NEED_XKBCOMP      out=1    fi  fi  if [[ -n $NEED_JAVA ]]; then    if ! which java >/dev/null 2>&1; then      echo >&2 You need java to build $NEED_JAVA      out=1    fi  fi  if [[ -n $NEED_STATIC_LIBSTDCXX ]]; thencat >test.c <<-'EOF'	#include <stdio.h>	int	main()	{		return (0);	}EOF    if ! $CXX -static-libstdc++ -o test test.c ; then      echo >&2 You need static version of libstdc++ installed to build $NEED_STATIC_LIBSTDCXX      out=1      rm test 2>/dev/null    fi  fi  # error out  if [ $out -ne 0 ]; then    exit $out  fi  # start build  $makebin --no-print-directory -f Makefile.adk $flags $targetfi
 |