dependencies.sh 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. #!/bin/sh
  2. # vi: set sw=4 ts=4:
  3. export LC_ALL=C
  4. # Verify that grep works
  5. echo "WORKS" | grep "WORKS" >/dev/null 2>&1
  6. if test $? != 0 ; then
  7. echo
  8. echo "grep doesn't work"
  9. exit 1
  10. fi
  11. # sanity check for CWD in LD_LIBRARY_PATH
  12. # try not to rely on egrep..
  13. if test -n "$LD_LIBRARY_PATH" ; then
  14. echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep '::' >/dev/null 2>&1 ||
  15. echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep ':\.:' >/dev/null 2>&1 ||
  16. echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep 'TRiGGER_start:' >/dev/null 2>&1 ||
  17. echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep 'TRiGGER_start\.:' >/dev/null 2>&1 ||
  18. echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep ':TRiGGER_end' >/dev/null 2>&1 ||
  19. echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep ':\.TRiGGER_end' >/dev/null 2>&1 ||
  20. echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep 'TRiGGER_start\.TRiGGER_end' >/dev/null 2>&1
  21. if test $? = 0; then
  22. echo
  23. echo "You seem to have the current working directory in your"
  24. echo "LD_LIBRARY_PATH environment variable. This doesn't work."
  25. exit 1;
  26. fi
  27. fi;
  28. # PATH should not contain a newline, otherwise it fails in spectacular ways
  29. # as soon as PATH is referenced in a package rule
  30. case "${PATH}" in
  31. (*"
  32. "*) printf "\n"
  33. # Break the '\n' sequence, or a \n is printed (which is not what we want).
  34. printf "Your PATH contains a newline (%sn) character.\n" "\\"
  35. printf "This doesn't work. Fix you PATH.\n"
  36. exit 1
  37. ;;
  38. esac
  39. # sanity check for CWD in PATH. Having the current working directory
  40. # in the PATH makes the toolchain build process break.
  41. # try not to rely on egrep..
  42. if test -n "$PATH" ; then
  43. echo TRiGGER_start"$PATH"TRiGGER_end | grep ':\.:' >/dev/null 2>&1 ||
  44. echo TRiGGER_start"$PATH"TRiGGER_end | grep 'TRiGGER_start\.:' >/dev/null 2>&1 ||
  45. echo TRiGGER_start"$PATH"TRiGGER_end | grep ':\.TRiGGER_end' >/dev/null 2>&1 ||
  46. echo TRiGGER_start"$PATH"TRiGGER_end | grep 'TRiGGER_start\.TRiGGER_end' >/dev/null 2>&1
  47. if test $? = 0; then
  48. echo
  49. echo "You seem to have the current working directory in your"
  50. echo "PATH environment variable. This doesn't work."
  51. exit 1;
  52. fi
  53. fi;
  54. if test -n "$PERL_MM_OPT" ; then
  55. echo
  56. echo "You have PERL_MM_OPT defined because Perl local::lib"
  57. echo "is installed on your system. Please unset this variable"
  58. echo "before starting Buildroot, otherwise the compilation of"
  59. echo "Perl related packages will fail"
  60. exit 1
  61. fi
  62. check_prog_host()
  63. {
  64. prog="$1"
  65. if ! which $prog > /dev/null ; then
  66. echo >&2
  67. echo "You must install '$prog' on your build machine" >&2
  68. exit 1
  69. fi
  70. }
  71. # Verify that which is installed
  72. check_prog_host "which"
  73. # Verify that sed is installed
  74. check_prog_host "sed"
  75. # 'file' must be present and must be exactly /usr/bin/file,
  76. # otherwise libtool fails in incomprehensible ways.
  77. check_prog_host "/usr/bin/file"
  78. # Check make
  79. MAKE=$(which make 2> /dev/null)
  80. if [ -z "$MAKE" ] ; then
  81. echo
  82. echo "You must install 'make' on your build machine";
  83. exit 1;
  84. fi;
  85. MAKE_VERSION=$($MAKE --version 2>&1 | sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
  86. if [ -z "$MAKE_VERSION" ] ; then
  87. echo
  88. echo "You must install 'make' on your build machine";
  89. exit 1;
  90. fi;
  91. MAKE_MAJOR=$(echo $MAKE_VERSION | sed -e "s/\..*//g")
  92. MAKE_MINOR=$(echo $MAKE_VERSION | sed -e "s/^$MAKE_MAJOR\.//g" -e "s/\..*//g" -e "s/[a-zA-Z].*//g")
  93. if [ $MAKE_MAJOR -lt 3 ] || [ $MAKE_MAJOR -eq 3 -a $MAKE_MINOR -lt 81 ] ; then
  94. echo
  95. echo "You have make '$MAKE_VERSION' installed. GNU make >=3.81 is required"
  96. exit 1;
  97. fi;
  98. # Check host gcc
  99. COMPILER=$(which $HOSTCC_NOCCACHE 2> /dev/null)
  100. if [ -z "$COMPILER" ] ; then
  101. COMPILER=$(which cc 2> /dev/null)
  102. fi;
  103. if [ -z "$COMPILER" ] ; then
  104. echo
  105. echo "You must install 'gcc' on your build machine";
  106. exit 1;
  107. fi;
  108. COMPILER_VERSION=$($COMPILER -v 2>&1 | sed -n '/^gcc version/p' |
  109. sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
  110. if [ -z "$COMPILER_VERSION" ] ; then
  111. echo
  112. echo "You must install 'gcc' on your build machine";
  113. exit 1;
  114. fi;
  115. COMPILER_MAJOR=$(echo $COMPILER_VERSION | sed -e "s/\..*//g")
  116. COMPILER_MINOR=$(echo $COMPILER_VERSION | sed -e "s/^$COMPILER_MAJOR\.//g" -e "s/\..*//g")
  117. if [ $COMPILER_MAJOR -lt 3 -o $COMPILER_MAJOR -eq 2 -a $COMPILER_MINOR -lt 95 ] ; then
  118. echo
  119. echo "You have gcc '$COMPILER_VERSION' installed. gcc >= 2.95 is required"
  120. exit 1;
  121. fi;
  122. # check for host CXX
  123. CXXCOMPILER=$(which $HOSTCXX_NOCCACHE 2> /dev/null)
  124. if [ -z "$CXXCOMPILER" ] ; then
  125. CXXCOMPILER=$(which c++ 2> /dev/null)
  126. fi
  127. if [ -z "$CXXCOMPILER" ] ; then
  128. echo
  129. echo "You may have to install 'g++' on your build machine"
  130. fi
  131. if [ ! -z "$CXXCOMPILER" ] ; then
  132. CXXCOMPILER_VERSION=$($CXXCOMPILER -v 2>&1 | sed -n '/^gcc version/p' |
  133. sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
  134. if [ -z "$CXXCOMPILER_VERSION" ] ; then
  135. echo
  136. echo "You may have to install 'g++' on your build machine"
  137. fi
  138. fi
  139. if [ -n "$CXXCOMPILER_VERSION" ] ; then
  140. CXXCOMPILER_MAJOR=$(echo $CXXCOMPILER_VERSION | sed -e "s/\..*//g")
  141. CXXCOMPILER_MINOR=$(echo $CXXCOMPILER_VERSION | sed -e "s/^$CXXCOMPILER_MAJOR\.//g" -e "s/\..*//g")
  142. if [ $CXXCOMPILER_MAJOR -lt 3 -o $CXXCOMPILER_MAJOR -eq 2 -a $CXXCOMPILER_MINOR -lt 95 ] ; then
  143. echo
  144. echo "You have g++ '$CXXCOMPILER_VERSION' installed. g++ >= 2.95 is required"
  145. exit 1
  146. fi
  147. fi
  148. # Check bash
  149. # We only check bash is available, setting SHELL appropriately is done
  150. # in the top-level Makefile, and we mimick the same sequence here
  151. if [ -n "${BASH}" ]; then :
  152. elif [ -x /bin/bash ]; then :
  153. elif [ -z "$( sh -c 'echo $BASH' )" ]; then
  154. echo
  155. echo "You must install 'bash' on your build machine"
  156. exit 1
  157. fi
  158. # Check that a few mandatory programs are installed
  159. missing_progs="no"
  160. for prog in patch perl tar wget cpio python unzip rsync bc ${DL_TOOLS} ; do
  161. if ! which $prog > /dev/null ; then
  162. echo "You must install '$prog' on your build machine";
  163. missing_progs="yes"
  164. if test $prog = "svn" ; then
  165. echo " svn is usually part of the subversion package in your distribution"
  166. elif test $prog = "hg" ; then
  167. echo " hg is usually part of the mercurial package in your distribution"
  168. elif test $prog = "zcat" ; then
  169. echo " zcat is usually part of the gzip package in your distribution"
  170. elif test $prog = "bzcat" ; then
  171. echo " bzcat is usually part of the bzip2 package in your distribution"
  172. fi
  173. fi
  174. done
  175. if test "${missing_progs}" = "yes" ; then
  176. exit 1
  177. fi
  178. if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then
  179. if ! which locale > /dev/null ; then
  180. echo
  181. echo "You need locale support on your build machine to build a toolchain supporting locales"
  182. exit 1 ;
  183. fi
  184. if ! locale -a | grep -q -i -E 'utf-?8$' ; then
  185. echo
  186. echo "You need at least one UTF8 locale to build a toolchain supporting locales"
  187. exit 1 ;
  188. fi
  189. fi
  190. if grep -q ^BR2_NEEDS_HOST_JAVA=y $BR2_CONFIG ; then
  191. check_prog_host "java"
  192. JAVA_GCJ=$(java -version 2>&1 | grep gcj)
  193. if [ ! -z "$JAVA_GCJ" ] ; then
  194. echo
  195. echo "$JAVA_GCJ is not sufficient to compile your package selection."
  196. echo "Please install an OpenJDK/IcedTea/Oracle Java."
  197. exit 1 ;
  198. fi
  199. fi
  200. if grep -q ^BR2_NEEDS_HOST_JAVAC=y $BR2_CONFIG ; then
  201. check_prog_host "javac"
  202. fi
  203. if grep -q ^BR2_NEEDS_HOST_JAR=y $BR2_CONFIG ; then
  204. check_prog_host "jar"
  205. fi
  206. if grep -q ^BR2_HOSTARCH_NEEDS_IA32_LIBS=y $BR2_CONFIG ; then
  207. if test ! -f /lib/ld-linux.so.2 ; then
  208. echo
  209. echo "Your Buildroot configuration uses pre-built tools for the x86 architecture,"
  210. echo "but your build machine uses the x86-64 architecture without the 32 bits compatibility"
  211. echo "library."
  212. echo "If you're running a Debian/Ubuntu distribution, install the libc6-i386,"
  213. echo "lib32stdc++6, and lib32z1 packages (or alternatively libc6:i386,"
  214. echo "libstdc++6:i386, and zlib1g:i386)."
  215. echo "For other distributions, refer to the documentation on how to install the 32 bits"
  216. echo "compatibility libraries."
  217. exit 1
  218. fi
  219. fi
  220. if grep -q ^BR2_HOSTARCH_NEEDS_IA32_COMPILER=y $BR2_CONFIG ; then
  221. if ! echo "int main(void) {}" | gcc -m32 -x c - -o /dev/null 2>/dev/null; then
  222. echo
  223. echo "Your Buildroot configuration needs a compiler capable of building 32 bits binaries."
  224. echo "If you're running a Debian/Ubuntu distribution, install the gcc-multilib package."
  225. echo "For other distributions, refer to their documentation."
  226. exit 1
  227. fi
  228. if ! echo "int main(void) {}" | g++ -m32 -x c++ - -o /dev/null 2>/dev/null; then
  229. echo
  230. echo "Your Buildroot configuration needs a compiler capable of building 32 bits binaries."
  231. echo "If you're running a Debian/Ubuntu distribution, install the g++-multilib package."
  232. echo "For other distributions, refer to their documentation."
  233. exit 1
  234. fi
  235. fi
  236. # Check that the Perl installation is complete enough for Buildroot.
  237. required_perl_modules="Data::Dumper" # Needed to build host-autoconf
  238. required_perl_modules="$required_perl_modules ExtUtils::MakeMaker" # Used by host-libxml-parser-perl
  239. required_perl_modules="$required_perl_modules Thread::Queue" # Used by host-automake
  240. if grep -q ^BR2_PACKAGE_MPV=y $BR2_CONFIG ; then
  241. required_perl_modules="$required_perl_modules Math::BigInt"
  242. required_perl_modules="$required_perl_modules Math::BigRat"
  243. fi
  244. # This variable will keep the modules that are missing in your system.
  245. missing_perl_modules=""
  246. for pm in $required_perl_modules ; do
  247. if ! perl -e "require $pm" > /dev/null 2>&1 ; then
  248. missing_perl_modules="$missing_perl_modules $pm"
  249. fi
  250. done
  251. if [ -n "$missing_perl_modules" ] ; then
  252. echo "Your Perl installation is not complete enough; at least the following"
  253. echo "modules are missing:"
  254. echo
  255. for pm in $missing_perl_modules ; do
  256. printf "\t $pm\n"
  257. done
  258. echo
  259. exit 1
  260. fi
  261. if ! python -c "import argparse" > /dev/null 2>&1 ; then
  262. echo "Your Python installation is not complete enough: argparse module is missing"
  263. exit 1
  264. fi