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