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