]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - support/dependencies/dependencies.sh
655b4c6346aaf34894514fdf28353645b1722c9c
[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 'TRiGGER_start\.:' >/dev/null 2>&1 ||
19         echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep ':\.TRiGGER_end' >/dev/null 2>&1 ||
20         echo TRiGGER_start"$LD_LIBRARY_PATH"TRiGGER_end | grep 'TRiGGER_start\.TRiGGER_end' >/dev/null 2>&1
21         if test $? = 0; then
22                 echo
23                 echo "You seem to have the current working directory in your"
24                 echo "LD_LIBRARY_PATH environment variable. This doesn't work."
25                 exit 1;
26         fi
27 fi;
28
29 # sanity check for CWD in PATH. Having the current working directory
30 # in the PATH makes the toolchain build process break.
31 # try not to rely on egrep..
32 if test -n "$PATH" ; then
33         echo TRiGGER_start"$PATH"TRiGGER_end | grep ':\.:' >/dev/null 2>&1 ||
34         echo TRiGGER_start"$PATH"TRiGGER_end | grep 'TRiGGER_start\.:' >/dev/null 2>&1 ||
35         echo TRiGGER_start"$PATH"TRiGGER_end | grep ':\.TRiGGER_end' >/dev/null 2>&1 ||
36         echo TRiGGER_start"$PATH"TRiGGER_end | grep 'TRiGGER_start\.TRiGGER_end' >/dev/null 2>&1
37         if test $? = 0; then
38                 echo
39                 echo "You seem to have the current working directory in your"
40                 echo "PATH environment variable. This doesn't work."
41                 exit 1;
42         fi
43 fi;
44
45 if test -n "$PERL_MM_OPT" ; then
46         echo
47         echo "You have PERL_MM_OPT defined because Perl local::lib"
48         echo "is installed on your system. Please unset this variable"
49         echo "before starting Buildroot, otherwise the compilation of"
50         echo "Perl related packages will fail"
51         exit 1
52 fi
53
54 check_prog_host()
55 {
56         prog="$1"
57         if ! which $prog > /dev/null ; then
58                 echo >&2
59                 echo "You must install '$prog' on your build machine" >&2
60                 exit 1
61         fi
62 }
63
64 # Verify that which is installed
65 check_prog_host "which"
66 # Verify that sed is installed
67 check_prog_host "sed"
68
69 # Check make
70 MAKE=$(which make 2> /dev/null)
71 if [ -z "$MAKE" ] ; then
72         echo
73         echo "You must install 'make' on your build machine";
74         exit 1;
75 fi;
76 MAKE_VERSION=$($MAKE --version 2>&1 | sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
77 if [ -z "$MAKE_VERSION" ] ; then
78         echo
79         echo "You must install 'make' on your build machine";
80         exit 1;
81 fi;
82 MAKE_MAJOR=$(echo $MAKE_VERSION | sed -e "s/\..*//g")
83 MAKE_MINOR=$(echo $MAKE_VERSION | sed -e "s/^$MAKE_MAJOR\.//g" -e "s/\..*//g" -e "s/[a-zA-Z].*//g")
84 if [ $MAKE_MAJOR -lt 3 ] || [ $MAKE_MAJOR -eq 3 -a $MAKE_MINOR -lt 81 ] ; then
85         echo
86         echo "You have make '$MAKE_VERSION' installed.  GNU make >=3.81 is required"
87         exit 1;
88 fi;
89
90 # Check host gcc
91 COMPILER=$(which $HOSTCC_NOCCACHE 2> /dev/null)
92 if [ -z "$COMPILER" ] ; then
93         COMPILER=$(which cc 2> /dev/null)
94 fi;
95 if [ -z "$COMPILER" ] ; then
96         echo
97         echo "You must install 'gcc' on your build machine";
98         exit 1;
99 fi;
100
101 COMPILER_VERSION=$($COMPILER -v 2>&1 | sed -n '/^gcc version/p' |
102         sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
103 if [ -z "$COMPILER_VERSION" ] ; then
104         echo
105         echo "You must install 'gcc' on your build machine";
106         exit 1;
107 fi;
108 COMPILER_MAJOR=$(echo $COMPILER_VERSION | sed -e "s/\..*//g")
109 COMPILER_MINOR=$(echo $COMPILER_VERSION | sed -e "s/^$COMPILER_MAJOR\.//g" -e "s/\..*//g")
110 if [ $COMPILER_MAJOR -lt 3 -o $COMPILER_MAJOR -eq 2 -a $COMPILER_MINOR -lt 95 ] ; then
111         echo
112         echo "You have gcc '$COMPILER_VERSION' installed.  gcc >= 2.95 is required"
113         exit 1;
114 fi;
115
116 # check for host CXX
117 CXXCOMPILER=$(which $HOSTCXX_NOCCACHE 2> /dev/null)
118 if [ -z "$CXXCOMPILER" ] ; then
119         CXXCOMPILER=$(which c++ 2> /dev/null)
120 fi
121
122 if [ -z "$CXXCOMPILER" ] ; then
123         echo
124         echo "You may have to install 'g++' on your build machine"
125 fi
126 if [ ! -z "$CXXCOMPILER" ] ; then
127         CXXCOMPILER_VERSION=$($CXXCOMPILER -v 2>&1 | sed -n '/^gcc version/p' |
128                 sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')
129         if [ -z "$CXXCOMPILER_VERSION" ] ; then
130                 echo
131                 echo "You may have to install 'g++' on your build machine"
132         fi
133
134         CXXCOMPILER_MAJOR=$(echo $CXXCOMPILER_VERSION | sed -e "s/\..*//g")
135         CXXCOMPILER_MINOR=$(echo $CXXCOMPILER_VERSION | sed -e "s/^$CXXCOMPILER_MAJOR\.//g" -e "s/\..*//g")
136         if [ $CXXCOMPILER_MAJOR -lt 3 -o $CXXCOMPILER_MAJOR -eq 2 -a $CXXCOMPILER_MINOR -lt 95 ] ; then
137                 echo
138                 echo "You have g++ '$CXXCOMPILER_VERSION' installed.  g++ >= 2.95 is required"
139                 exit 1
140         fi
141 fi
142
143 # Check bash
144 # We only check bash is available, setting SHELL appropriately is done
145 # in the top-level Makefile, and we mimick the same sequence here
146 if   [ -n "${BASH}" ]; then :
147 elif [ -x /bin/bash ]; then :
148 elif [ -z "$( sh -c 'echo $BASH' )" ]; then
149         echo
150         echo "You must install 'bash' on your build machine"
151         exit 1
152 fi
153
154 # Check that a few mandatory programs are installed
155 missing_progs="no"
156 for prog in patch perl tar wget cpio python unzip rsync bc ${DL_TOOLS} ; do
157         if ! which $prog > /dev/null ; then
158                 echo "You must install '$prog' on your build machine";
159                 missing_progs="yes"
160                 if test $prog = "svn" ; then
161                         echo "  svn is usually part of the subversion package in your distribution"
162                 elif test $prog = "hg" ; then
163                         echo "  hg is usually part of the mercurial package in your distribution"
164                 elif test $prog = "zcat" ; then
165                         echo "  zcat is usually part of the gzip package in your distribution"
166                 elif test $prog = "bzcat" ; then
167                         echo "  bzcat is usually part of the bzip2 package in your distribution"
168                 fi
169         fi
170 done
171
172 if test "${missing_progs}" = "yes" ; then
173         exit 1
174 fi
175
176 if grep ^BR2_TOOLCHAIN_BUILDROOT=y $BR2_CONFIG > /dev/null && \
177         grep ^BR2_ENABLE_LOCALE=y       $BR2_CONFIG > /dev/null ; then
178         if ! which locale > /dev/null ; then
179                 echo
180                 echo "You need locale support on your build machine to build a toolchain supporting locales"
181                 exit 1 ;
182         fi
183         if ! locale -a | grep -q -i utf8$ ; then
184                 echo
185                 echo "You need at least one UTF8 locale to build a toolchain supporting locales"
186                 exit 1 ;
187         fi
188 fi
189
190 if grep -q ^BR2_PACKAGE_CLASSPATH=y $BR2_CONFIG ; then
191         for prog in javac jar; do
192                 if ! which $prog > /dev/null ; then
193                         echo >&2
194                         echo "You must install '$prog' on your build machine" >&2
195                         exit 1
196                 fi
197         done
198 fi
199
200 if grep -q ^BR2_NEEDS_HOST_JAVA=y $BR2_CONFIG ; then
201         check_prog_host "java"
202 fi
203
204 if grep -q ^BR2_HOSTARCH_NEEDS_IA32_LIBS=y $BR2_CONFIG ; then
205         if test ! -f /lib/ld-linux.so.2 ; then
206                 echo
207                 echo "Your Buildroot configuration uses pre-built tools for the x86 architecture,"
208                 echo "but your build machine uses the x86-64 architecture without the 32 bits compatibility"
209                 echo "library."
210                 echo "If you're running a Debian/Ubuntu distribution, install the libc6:i386,"
211                 echo "libstdc++6:i386, and zlib1g:i386 packages."
212                 echo "For other distributions, refer to the documentation on how to install the 32 bits"
213                 echo "compatibility libraries."
214                 exit 1
215         fi
216 fi
217
218 if grep -q ^BR2_HOSTARCH_NEEDS_IA32_COMPILER=y $BR2_CONFIG ; then
219         if ! echo "int main(void) {}" | gcc -m32 -x c - -o /dev/null ; then
220                 echo
221                 echo "Your Buildroot configuration needs a compiler capable of building 32 bits binaries."
222                 echo "If you're running a Debian/Ubuntu distribution, install the gcc-multilib package."
223                 echo "For other distributions, refer to their documentation."
224                 exit 1
225         fi
226 fi
227
228 # Check that the Perl installation is complete enough to build
229 # host-autoconf.
230 if ! perl  -e "require Data::Dumper" > /dev/null 2>&1 ; then
231         echo "Your Perl installation is not complete enough, at least Data::Dumper is missing."
232         echo "On Debian/Ubuntu distributions, install the 'perl' package."
233         exit 1
234 fi