dependencies.sh 9.1 KB

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