dependencies.sh 9.7 KB

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