dependencies.sh 9.4 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 4 -o $COMPILER_MAJOR -eq 4 -a $COMPILER_MINOR -lt 8 ] ; then
  105. echo
  106. echo "You have gcc '$COMPILER_VERSION' installed. gcc >= 4.8 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 4 -o $CXXCOMPILER_MAJOR -eq 4 -a $CXXCOMPILER_MINOR -lt 8 ] ; then
  130. echo
  131. echo "You have g++ '$CXXCOMPILER_VERSION' installed. g++ >= 4.8 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 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. # apply-patches.sh needs patch with --no-backup-if-mismatch support (GNU, busybox w/DESKTOP)
  166. if ! patch --no-backup-if-mismatch </dev/null 2>/dev/null; then
  167. echo "Your patch program does not support the --no-backup-if-mismatch option. Install GNU patch"
  168. exit 1
  169. fi
  170. if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then
  171. if ! which locale > /dev/null ; then
  172. echo
  173. echo "You need locale support on your build machine to build a toolchain supporting locales"
  174. exit 1 ;
  175. fi
  176. if ! locale -a | grep -q -i -E 'utf-?8$' ; then
  177. echo
  178. echo "You need at least one UTF8 locale to build a toolchain supporting locales"
  179. exit 1 ;
  180. fi
  181. fi
  182. if grep -q ^BR2_NEEDS_HOST_JAVA=y $BR2_CONFIG ; then
  183. check_prog_host "java"
  184. JAVA_GCJ=$(java -version 2>&1 | grep gcj)
  185. if [ ! -z "$JAVA_GCJ" ] ; then
  186. echo
  187. echo "$JAVA_GCJ is not sufficient to compile your package selection."
  188. echo "Please install an OpenJDK/IcedTea/Oracle Java."
  189. exit 1 ;
  190. fi
  191. fi
  192. if grep -q ^BR2_HOSTARCH_NEEDS_IA32_LIBS=y $BR2_CONFIG ; then
  193. if test ! -f /lib/ld-linux.so.2 ; then
  194. echo
  195. echo "Your Buildroot configuration uses pre-built tools for the x86 architecture,"
  196. echo "but your build machine uses the x86-64 architecture without the 32 bits compatibility"
  197. echo "library."
  198. echo "If you're running a Debian/Ubuntu distribution, install the libc6-i386,"
  199. echo "lib32stdc++6, and lib32z1 packages (or alternatively libc6:i386,"
  200. echo "libstdc++6:i386, and zlib1g:i386)."
  201. echo "If you're running a RedHat/Fedora distribution, install the glibc.i686 and"
  202. echo "zlib.i686 packages."
  203. echo "If you're running an ArchLinux distribution, install lib32-glibc."
  204. echo "For other distributions, refer to the documentation on how to install the 32 bits"
  205. echo "compatibility libraries."
  206. exit 1
  207. fi
  208. fi
  209. if grep -q ^BR2_HOSTARCH_NEEDS_IA32_COMPILER=y $BR2_CONFIG ; then
  210. if ! echo "int main(void) {}" | gcc -m32 -x c - -o /dev/null 2>/dev/null; then
  211. echo
  212. echo "Your Buildroot configuration needs a compiler capable of building 32 bits binaries."
  213. echo "If you're running a Debian/Ubuntu distribution, install the gcc-multilib package."
  214. echo "For other distributions, refer to their documentation."
  215. exit 1
  216. fi
  217. if ! echo "int main(void) {}" | g++ -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 g++-multilib package."
  221. echo "For other distributions, refer to their documentation."
  222. exit 1
  223. fi
  224. fi
  225. if grep ^BR2_NEEDS_HOST_GCC_PLUGIN_SUPPORT=y $BR2_CONFIG ; then
  226. if ! echo "#include <gcc-plugin.h>" | $HOSTCXX_NOCCACHE -I$($HOSTCXX_NOCCACHE -print-file-name=plugin)/include -x c++ -c - -o /dev/null ; then
  227. echo
  228. echo "Your Buildroot configuration needs a host compiler capable of building gcc plugins."
  229. echo "If you're running a Debian/Ubuntu distribution, install gcc-X-plugin-dev package."
  230. echo "For other distributions, refer to their documentation."
  231. exit 1 ;
  232. fi
  233. fi
  234. # Check that the Perl installation is complete enough for Buildroot.
  235. required_perl_modules="Data::Dumper" # Needed to build host-autoconf
  236. required_perl_modules="$required_perl_modules ExtUtils::MakeMaker" # Used by host-libxml-parser-perl
  237. required_perl_modules="$required_perl_modules Thread::Queue" # Used by host-automake
  238. if grep -q ^BR2_PACKAGE_MPV=y $BR2_CONFIG ; then
  239. required_perl_modules="$required_perl_modules Math::BigInt"
  240. required_perl_modules="$required_perl_modules Math::BigRat"
  241. fi
  242. if grep -q ^BR2_PACKAGE_WHOIS=y $BR2_CONFIG ; then
  243. required_perl_modules="$required_perl_modules autodie"
  244. fi
  245. if grep -q -E '^BR2_PACKAGE_(WEBKITGTK|WPEWEBKIT)=y' $BR2_CONFIG ; then
  246. required_perl_modules="${required_perl_modules} JSON::PP"
  247. fi
  248. # This variable will keep the modules that are missing in your system.
  249. missing_perl_modules=""
  250. for pm in $required_perl_modules ; do
  251. if ! perl -e "require $pm" > /dev/null 2>&1 ; then
  252. missing_perl_modules="$missing_perl_modules $pm"
  253. fi
  254. done
  255. if [ -n "$missing_perl_modules" ] ; then
  256. echo "Your Perl installation is not complete enough; at least the following"
  257. echo "modules are missing:"
  258. echo
  259. for pm in $missing_perl_modules ; do
  260. printf "\t $pm\n"
  261. done
  262. echo
  263. exit 1
  264. fi