/support/dependencies/dependencies.sh

https://github.com/mend0za/Buildroot---pkgsrc · Shell · 160 lines · 150 code · 3 blank · 7 comment · 4 complexity · 61f51bf8c04656fef39308eff73dfa04 MD5 · raw file

  1. #!/bin/sh
  2. # vi: set sw=4 ts=4:
  3. #set -x
  4. export LC_ALL=C
  5. # Verify that grep works
  6. echo "WORKS" | grep "WORKS" >/dev/null 2>&1
  7. if test $? != 0 ; then
  8. /bin/echo -e "\ngrep doesn't work\n"
  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. /bin/echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | /bin/grep ':\.:' >/dev/null 2>&1 ||
  15. /bin/echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | /bin/grep 'TRiGGER_start\.:' >/dev/null 2>&1 ||
  16. /bin/echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | /bin/grep ':\.TRiGGER_end' >/dev/null 2>&1 ||
  17. /bin/echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | /bin/grep 'TRiGGER_start\.TRiGGER_end' >/dev/null 2>&1
  18. if test $? = 0; then
  19. /bin/echo -e "\nYou seem to have the current working directory in your"
  20. /bin/echo -e "LD_LIBRARY_PATH environment variable. This doesn't work.\n"
  21. exit 1;
  22. fi
  23. fi;
  24. # sanity check for CWD in PATH. Having the current working directory
  25. # in the PATH makes the toolchain build process break.
  26. # try not to rely on egrep..
  27. if test -n "$PATH" ; then
  28. /bin/echo TRiGGER_start"$PATH"TRiGGER_end | /bin/grep ':\.:' >/dev/null 2>&1 ||
  29. /bin/echo TRiGGER_start"$PATH"TRiGGER_end | /bin/grep 'TRiGGER_start\.:' >/dev/null 2>&1 ||
  30. /bin/echo TRiGGER_start"$PATH"TRiGGER_end | /bin/grep ':\.TRiGGER_end' >/dev/null 2>&1 ||
  31. /bin/echo TRiGGER_start"$PATH"TRiGGER_end | /bin/grep 'TRiGGER_start\.TRiGGER_end' >/dev/null 2>&1
  32. if test $? = 0; then
  33. /bin/echo -e "\nYou seem to have the current working directory in your"
  34. /bin/echo -e "PATH environment variable. This doesn't work.\n"
  35. exit 1;
  36. fi
  37. fi;
  38. if test -n "$PERL_MM_OPT" ; then
  39. /bin/echo -e "\nYou have PERL_MM_OPT defined because Perl local::lib"
  40. /bin/echo -e "is installed on your system. Please unset this variable"
  41. /bin/echo -e "before starting Buildroot, otherwise the compilation of"
  42. /bin/echo -e "Perl related packages will fail"
  43. exit 1
  44. fi
  45. # Verify that which is installed
  46. if ! which which > /dev/null ; then
  47. /bin/echo -e "\nYou must install 'which' on your build machine\n";
  48. exit 1;
  49. fi;
  50. if ! which sed > /dev/null ; then
  51. /bin/echo -e "\nYou must install 'sed' on your build machine\n"
  52. exit 1
  53. fi
  54. # Check make
  55. MAKE=$(which make 2> /dev/null)
  56. if [ -z "$MAKE" ] ; then
  57. /bin/echo -e "\nYou must install 'make' on your build machine\n";
  58. exit 1;
  59. fi;
  60. MAKE_VERSION=$($MAKE --version 2>&1 | sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
  61. if [ -z "$MAKE_VERSION" ] ; then
  62. /bin/echo -e "\nYou must install 'make' on your build machine\n";
  63. exit 1;
  64. fi;
  65. MAKE_MAJOR=$(echo $MAKE_VERSION | sed -e "s/\..*//g")
  66. MAKE_MINOR=$(echo $MAKE_VERSION | sed -e "s/^$MAKE_MAJOR\.//g" -e "s/\..*//g" -e "s/[a-zA-Z].*//g")
  67. if [ $MAKE_MAJOR -lt 3 ] || [ $MAKE_MAJOR -eq 3 -a $MAKE_MINOR -lt 81 ] ; then
  68. /bin/echo -e "\nYou have make '$MAKE_VERSION' installed. GNU make >=3.81 is required\n"
  69. exit 1;
  70. fi;
  71. # Check host gcc
  72. COMPILER=$(which $HOSTCC_NOCCACHE 2> /dev/null)
  73. if [ -z "$COMPILER" ] ; then
  74. COMPILER=$(which cc 2> /dev/null)
  75. fi;
  76. if [ -z "$COMPILER" ] ; then
  77. /bin/echo -e "\nYou must install 'gcc' on your build machine\n";
  78. exit 1;
  79. fi;
  80. COMPILER_VERSION=$($COMPILER -v 2>&1 | sed -n '/^gcc version/p' |
  81. sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
  82. if [ -z "$COMPILER_VERSION" ] ; then
  83. /bin/echo -e "\nYou must install 'gcc' on your build machine\n";
  84. exit 1;
  85. fi;
  86. COMPILER_MAJOR=$(echo $COMPILER_VERSION | sed -e "s/\..*//g")
  87. COMPILER_MINOR=$(echo $COMPILER_VERSION | sed -e "s/^$COMPILER_MAJOR\.//g" -e "s/\..*//g")
  88. if [ $COMPILER_MAJOR -lt 3 -o $COMPILER_MAJOR -eq 2 -a $COMPILER_MINOR -lt 95 ] ; then
  89. echo "\nYou have gcc '$COMPILER_VERSION' installed. gcc >= 2.95 is required\n"
  90. exit 1;
  91. fi;
  92. # check for host CXX
  93. CXXCOMPILER=$(which $HOSTCXX_NOCCACHE 2> /dev/null)
  94. if [ -z "$CXXCOMPILER" ] ; then
  95. CXXCOMPILER=$(which c++ 2> /dev/null)
  96. fi
  97. if [ -z "$CXXCOMPILER" ] ; then
  98. /bin/echo -e "\nYou may have to install 'g++' on your build machine\n"
  99. #exit 1
  100. fi
  101. if [ ! -z "$CXXCOMPILER" ] ; then
  102. CXXCOMPILER_VERSION=$($CXXCOMPILER -v 2>&1 | sed -n '/^gcc version/p' |
  103. sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
  104. if [ -z "$CXXCOMPILER_VERSION" ] ; then
  105. /bin/echo -e "\nYou may have to install 'g++' on your build machine\n"
  106. fi
  107. CXXCOMPILER_MAJOR=$(echo $CXXCOMPILER_VERSION | sed -e "s/\..*//g")
  108. CXXCOMPILER_MINOR=$(echo $CXXCOMPILER_VERSION | sed -e "s/^$CXXCOMPILER_MAJOR\.//g" -e "s/\..*//g")
  109. if [ $CXXCOMPILER_MAJOR -lt 3 -o $CXXCOMPILER_MAJOR -eq 2 -a $CXXCOMPILER_MINOR -lt 95 ] ; then
  110. /bin/echo -e "\nYou have g++ '$CXXCOMPILER_VERSION' installed. g++ >= 2.95 is required\n"
  111. exit 1
  112. fi
  113. fi
  114. # Check bash
  115. if ! $SHELL --version 2>&1 | grep -q '^GNU bash'; then
  116. /bin/echo -e "\nYou must install 'bash' on your build machine\n";
  117. exit 1;
  118. fi;
  119. # Check that a few mandatory programs are installed
  120. for prog in awk bison flex msgfmt makeinfo patch gzip bzip2 perl tar wget cpio python unzip rsync ${DL_TOOLS} ; do
  121. if ! which $prog > /dev/null ; then
  122. /bin/echo -e "\nYou must install '$prog' on your build machine";
  123. if test $prog = "makeinfo" ; then
  124. /bin/echo -e "makeinfo is usually part of the texinfo package in your distribution\n"
  125. elif test $prog = "msgfmt" ; then
  126. /bin/echo -e "msgfmt is usually part of the gettext package in your distribution\n"
  127. elif test $prog = "svn" ; then
  128. /bin/echo -e "svn is usually part of the subversion package in your distribution\n"
  129. else
  130. /bin/echo -e "\n"
  131. fi
  132. exit 1;
  133. fi
  134. done
  135. if grep ^BR2_TOOLCHAIN_BUILDROOT=y $CONFIG_FILE > /dev/null && \
  136. grep ^BR2_ENABLE_LOCALE=y $CONFIG_FILE > /dev/null ; then
  137. if ! which locale > /dev/null ; then
  138. /bin/echo -e "\nYou need locale support on your build machine to build a toolchain supporting locales\n"
  139. exit 1 ;
  140. fi
  141. if ! locale -a | grep -q -i utf8$ ; then
  142. /bin/echo -e "\nYou need at least one UTF8 locale to build a toolchain supporting locales\n"
  143. exit 1 ;
  144. fi
  145. fi