1 | #! /bin/bash
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Copyright (c) 2009 Martin Decky
|
---|
5 | # All rights reserved.
|
---|
6 | #
|
---|
7 | # Redistribution and use in source and binary forms, with or without
|
---|
8 | # modification, are permitted provided that the following conditions
|
---|
9 | # are met:
|
---|
10 | #
|
---|
11 | # - Redistributions of source code must retain the above copyright
|
---|
12 | # notice, this list of conditions and the following disclaimer.
|
---|
13 | # - Redistributions in binary form must reproduce the above copyright
|
---|
14 | # notice, this list of conditions and the following disclaimer in the
|
---|
15 | # documentation and/or other materials provided with the distribution.
|
---|
16 | # - The name of the author may not be used to endorse or promote products
|
---|
17 | # derived from this software without specific prior written permission.
|
---|
18 | #
|
---|
19 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
20 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
21 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
22 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
23 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
24 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
28 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
29 | #
|
---|
30 |
|
---|
31 | GMP_MAIN=<<EOF
|
---|
32 | #define GCC_GMP_VERSION_NUM(a, b, c) \
|
---|
33 | (((a) << 16L) | ((b) << 8) | (c))
|
---|
34 |
|
---|
35 | #define GCC_GMP_VERSION \
|
---|
36 | GCC_GMP_VERSION_NUM(__GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL)
|
---|
37 |
|
---|
38 | #if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,3,2)
|
---|
39 | choke me
|
---|
40 | #endif
|
---|
41 | EOF
|
---|
42 |
|
---|
43 | MPFR_MAIN=<<EOF
|
---|
44 | #if MPFR_VERSION < MPFR_VERSION_NUM(2, 4, 2)
|
---|
45 | choke me
|
---|
46 | #endif
|
---|
47 | EOF
|
---|
48 |
|
---|
49 | MPC_MAIN=<<EOF
|
---|
50 | #if MPC_VERSION < MPC_VERSION_NUM(0, 8, 1)
|
---|
51 | choke me
|
---|
52 | #endif
|
---|
53 | EOF
|
---|
54 |
|
---|
55 | BINUTILS_VERSION="2.23.1"
|
---|
56 | BINUTILS_RELEASE=""
|
---|
57 | BINUTILS_PATCHES="toolchain-binutils-2.23.1.patch"
|
---|
58 | GCC_VERSION="4.8.1"
|
---|
59 | GCC_PATCHES="toolchain-gcc-4.8.1-targets.patch toolchain-gcc-4.8.1-headers.patch"
|
---|
60 | GDB_VERSION="7.6"
|
---|
61 | GDB_PATCHES="toolchain-gdb-7.6.patch"
|
---|
62 |
|
---|
63 | BASEDIR="`pwd`"
|
---|
64 | BINUTILS="binutils-${BINUTILS_VERSION}${BINUTILS_RELEASE}.tar.bz2"
|
---|
65 | GCC="gcc-${GCC_VERSION}.tar.bz2"
|
---|
66 | GDB="gdb-${GDB_VERSION}.tar.bz2"
|
---|
67 |
|
---|
68 | REAL_INSTALL=true
|
---|
69 | USE_HELENOS_TARGET=false
|
---|
70 | INSTALL_DIR="${BASEDIR}/PKG"
|
---|
71 |
|
---|
72 | #
|
---|
73 | # Check if the library described in the argument
|
---|
74 | # exists and has acceptable version.
|
---|
75 | #
|
---|
76 | check_dependency() {
|
---|
77 | DEPENDENCY="$1"
|
---|
78 | HEADER="$2"
|
---|
79 | BODY="$3"
|
---|
80 |
|
---|
81 | FNAME="/tmp/conftest-$$"
|
---|
82 |
|
---|
83 | echo "#include ${HEADER}" > "${FNAME}.c"
|
---|
84 | echo >> "${FNAME}.c"
|
---|
85 | echo "int main()" >> "${FNAME}.c"
|
---|
86 | echo "{" >> "${FNAME}.c"
|
---|
87 | echo "${BODY}" >> "${FNAME}.c"
|
---|
88 | echo " return 0;" >> "${FNAME}.c"
|
---|
89 | echo "}" >> "${FNAME}.c"
|
---|
90 |
|
---|
91 | cc -c -o "${FNAME}.o" "${FNAME}.c" 2> "${FNAME}.log"
|
---|
92 | RC="$?"
|
---|
93 |
|
---|
94 | if [ "$RC" -ne "0" ] ; then
|
---|
95 | echo " ${DEPENDENCY} not found, too old or compiler error."
|
---|
96 | echo " Please recheck manually the source file \"${FNAME}.c\"."
|
---|
97 | echo " The compilation of the toolchain is probably going to fail,"
|
---|
98 | echo " you have been warned."
|
---|
99 | echo
|
---|
100 | echo " ===== Compiler output ====="
|
---|
101 | cat "${FNAME}.log"
|
---|
102 | echo " ==========================="
|
---|
103 | echo
|
---|
104 | else
|
---|
105 | echo " ${DEPENDENCY} found"
|
---|
106 | rm -f "${FNAME}.log" "${FNAME}.o" "${FNAME}.c"
|
---|
107 | fi
|
---|
108 | }
|
---|
109 |
|
---|
110 | check_dependecies() {
|
---|
111 | echo ">>> Basic dependency check"
|
---|
112 | check_dependency "GMP" "<gmp.h>" "${GMP_MAIN}"
|
---|
113 | check_dependency "MPFR" "<mpfr.h>" "${MPFR_MAIN}"
|
---|
114 | check_dependency "MPC" "<mpc.h>" "${MPC_MAIN}"
|
---|
115 | echo
|
---|
116 | }
|
---|
117 |
|
---|
118 | check_error() {
|
---|
119 | if [ "$1" -ne "0" ]; then
|
---|
120 | echo
|
---|
121 | echo "Script failed: $2"
|
---|
122 |
|
---|
123 | exit 1
|
---|
124 | fi
|
---|
125 | }
|
---|
126 |
|
---|
127 | check_md5() {
|
---|
128 | FILE="$1"
|
---|
129 | SUM="$2"
|
---|
130 |
|
---|
131 | COMPUTED="`md5sum "${FILE}" | cut -d' ' -f1`"
|
---|
132 | if [ "${SUM}" != "${COMPUTED}" ] ; then
|
---|
133 | echo
|
---|
134 | echo "Checksum of ${FILE} does not match."
|
---|
135 |
|
---|
136 | exit 2
|
---|
137 | fi
|
---|
138 | }
|
---|
139 |
|
---|
140 | show_usage() {
|
---|
141 | echo "Cross-compiler toolchain build script"
|
---|
142 | echo
|
---|
143 | echo "Syntax:"
|
---|
144 | echo " $0 [--no-install] [--helenos-target] <platform>"
|
---|
145 | echo
|
---|
146 | echo "Possible target platforms are:"
|
---|
147 | echo " amd64 AMD64 (x86-64, x64)"
|
---|
148 | echo " arm32 ARM"
|
---|
149 | echo " ia32 IA-32 (x86, i386)"
|
---|
150 | echo " ia64 IA-64 (Itanium)"
|
---|
151 | echo " mips32 MIPS little-endian 32b"
|
---|
152 | echo " mips32eb MIPS big-endian 32b"
|
---|
153 | echo " mips64 MIPS little-endian 64b"
|
---|
154 | echo " ppc32 32-bit PowerPC"
|
---|
155 | echo " ppc64 64-bit PowerPC"
|
---|
156 | echo " sparc64 SPARC V9"
|
---|
157 | echo " all build all targets"
|
---|
158 | echo " parallel same as 'all', but all in parallel"
|
---|
159 | echo " 2-way same as 'all', but 2-way parallel"
|
---|
160 | echo
|
---|
161 | echo "The toolchain is installed into directory specified by the"
|
---|
162 | echo "CROSS_PREFIX environment variable. If the variable is not"
|
---|
163 | echo "defined, /usr/local/cross/ is used as default."
|
---|
164 | echo
|
---|
165 | echo "If --no-install is present, the toolchain still uses the"
|
---|
166 | echo "CROSS_PREFIX as the target directory but the installation"
|
---|
167 | echo "copies the files into PKG/ subdirectory without affecting"
|
---|
168 | echo "the actual root file system. That is only useful if you do"
|
---|
169 | echo "not want to run the script under the super user."
|
---|
170 | echo
|
---|
171 | echo "The --helenos-target will build HelenOS-specific toolchain"
|
---|
172 | echo "(i.e. it will use *-helenos-* triplet instead of *-linux-*)."
|
---|
173 | echo "This toolchain is installed into /usr/local/cross-helenos by"
|
---|
174 | echo "default. The settings can be changed by setting environment"
|
---|
175 | echo "variable CROSS_HELENOS_PREFIX."
|
---|
176 | echo
|
---|
177 |
|
---|
178 | exit 3
|
---|
179 | }
|
---|
180 |
|
---|
181 | change_title() {
|
---|
182 | echo -en "\e]0;$1\a"
|
---|
183 | }
|
---|
184 |
|
---|
185 | show_countdown() {
|
---|
186 | TM="$1"
|
---|
187 |
|
---|
188 | if [ "${TM}" -eq 0 ] ; then
|
---|
189 | echo
|
---|
190 | return 0
|
---|
191 | fi
|
---|
192 |
|
---|
193 | echo -n "${TM} "
|
---|
194 | change_title "${TM}"
|
---|
195 | sleep 1
|
---|
196 |
|
---|
197 | TM="`expr "${TM}" - 1`"
|
---|
198 | show_countdown "${TM}"
|
---|
199 | }
|
---|
200 |
|
---|
201 | show_dependencies() {
|
---|
202 | echo "IMPORTANT NOTICE:"
|
---|
203 | echo
|
---|
204 | echo "For a successful compilation and use of the cross-compiler"
|
---|
205 | echo "toolchain you need at least the following dependencies."
|
---|
206 | echo
|
---|
207 | echo "Please make sure that the dependencies are present in your"
|
---|
208 | echo "system. Otherwise the compilation process might fail after"
|
---|
209 | echo "a few seconds or minutes."
|
---|
210 | echo
|
---|
211 | echo " - SED, AWK, Flex, Bison, gzip, bzip2, Bourne Shell"
|
---|
212 | echo " - gettext, zlib, Texinfo, libelf, libgomp"
|
---|
213 | echo " - terminfo"
|
---|
214 | echo " - GNU Multiple Precision Library (GMP)"
|
---|
215 | echo " - GNU Make"
|
---|
216 | echo " - GNU tar"
|
---|
217 | echo " - GNU Coreutils"
|
---|
218 | echo " - GNU Sharutils"
|
---|
219 | echo " - MPFR"
|
---|
220 | echo " - MPC"
|
---|
221 | echo " - Parma Polyhedra Library (PPL)"
|
---|
222 | echo " - ClooG-PPL"
|
---|
223 | echo " - native C compiler, assembler and linker"
|
---|
224 | echo " - native C library with headers"
|
---|
225 | echo
|
---|
226 | }
|
---|
227 |
|
---|
228 | download_fetch() {
|
---|
229 | SOURCE="$1"
|
---|
230 | FILE="$2"
|
---|
231 | CHECKSUM="$3"
|
---|
232 |
|
---|
233 | if [ ! -f "${FILE}" ]; then
|
---|
234 | change_title "Downloading ${FILE}"
|
---|
235 | wget -c "${SOURCE}${FILE}"
|
---|
236 | check_error $? "Error downloading ${FILE}."
|
---|
237 | fi
|
---|
238 |
|
---|
239 | check_md5 "${FILE}" "${CHECKSUM}"
|
---|
240 | }
|
---|
241 |
|
---|
242 | source_check() {
|
---|
243 | FILE="$1"
|
---|
244 |
|
---|
245 | if [ ! -f "${FILE}" ]; then
|
---|
246 | echo
|
---|
247 | echo "File ${FILE} not found."
|
---|
248 |
|
---|
249 | exit 4
|
---|
250 | fi
|
---|
251 | }
|
---|
252 |
|
---|
253 | cleanup_dir() {
|
---|
254 | DIR="$1"
|
---|
255 |
|
---|
256 | if [ -d "${DIR}" ]; then
|
---|
257 | change_title "Removing ${DIR}"
|
---|
258 | echo " >>> Removing ${DIR}"
|
---|
259 | rm -fr "${DIR}"
|
---|
260 | fi
|
---|
261 | }
|
---|
262 |
|
---|
263 | create_dir() {
|
---|
264 | DIR="$1"
|
---|
265 | DESC="$2"
|
---|
266 |
|
---|
267 | change_title "Creating ${DESC}"
|
---|
268 | echo ">>> Creating ${DESC}"
|
---|
269 |
|
---|
270 | mkdir -p "${DIR}"
|
---|
271 | test -d "${DIR}"
|
---|
272 | check_error $? "Unable to create ${DIR}."
|
---|
273 | }
|
---|
274 |
|
---|
275 | unpack_tarball() {
|
---|
276 | FILE="$1"
|
---|
277 | DESC="$2"
|
---|
278 |
|
---|
279 | change_title "Unpacking ${DESC}"
|
---|
280 | echo " >>> Unpacking ${DESC}"
|
---|
281 |
|
---|
282 | tar -xjf "${FILE}"
|
---|
283 | check_error $? "Error unpacking ${DESC}."
|
---|
284 | }
|
---|
285 |
|
---|
286 | patch_sources() {
|
---|
287 | PATCH_FILE="$1"
|
---|
288 | PATCH_STRIP="$2"
|
---|
289 | DESC="$3"
|
---|
290 |
|
---|
291 | change_title "Patching ${DESC}"
|
---|
292 | echo " >>> Patching ${DESC} with ${PATCH_FILE}"
|
---|
293 |
|
---|
294 | patch -t "-p${PATCH_STRIP}" <"$PATCH_FILE"
|
---|
295 | check_error $? "Error patching ${DESC}."
|
---|
296 | }
|
---|
297 |
|
---|
298 | prepare() {
|
---|
299 | show_dependencies
|
---|
300 | check_dependecies
|
---|
301 | show_countdown 10
|
---|
302 |
|
---|
303 | BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
|
---|
304 | GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
|
---|
305 | GDB_SOURCE="ftp://ftp.gnu.org/gnu/gdb/"
|
---|
306 |
|
---|
307 | download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "33adb18c3048d057ac58d07a3f1adb38"
|
---|
308 | download_fetch "${GCC_SOURCE}" "${GCC}" "3b2386c114cd74185aa3754b58a79304"
|
---|
309 | download_fetch "${GDB_SOURCE}" "${GDB}" "fda57170e4d11cdde74259ca575412a8"
|
---|
310 | }
|
---|
311 |
|
---|
312 | set_target_from_platform() {
|
---|
313 | case "$1" in
|
---|
314 | "amd64")
|
---|
315 | LINUX_TARGET="amd64-linux-gnu"
|
---|
316 | HELENOS_TARGET="amd64-helenos"
|
---|
317 | ;;
|
---|
318 | "arm32")
|
---|
319 | LINUX_TARGET="arm-linux-gnueabi"
|
---|
320 | HELENOS_TARGET="arm-helenos-gnueabi"
|
---|
321 | ;;
|
---|
322 | "ia32")
|
---|
323 | LINUX_TARGET="i686-pc-linux-gnu"
|
---|
324 | HELENOS_TARGET="i686-pc-helenos"
|
---|
325 | ;;
|
---|
326 | "ia64")
|
---|
327 | LINUX_TARGET="ia64-pc-linux-gnu"
|
---|
328 | HELENOS_TARGET="ia64-pc-helenos"
|
---|
329 | ;;
|
---|
330 | "mips32")
|
---|
331 | LINUX_TARGET="mipsel-linux-gnu"
|
---|
332 | HELENOS_TARGET="mipsel-helenos"
|
---|
333 | ;;
|
---|
334 | "mips32eb")
|
---|
335 | LINUX_TARGET="mips-linux-gnu"
|
---|
336 | HELENOS_TARGET="mips-helenos"
|
---|
337 | ;;
|
---|
338 | "mips64")
|
---|
339 | LINUX_TARGET="mips64el-linux-gnu"
|
---|
340 | HELENOS_TARGET="mips64el-helenos"
|
---|
341 | ;;
|
---|
342 | "ppc32")
|
---|
343 | LINUX_TARGET="ppc-linux-gnu"
|
---|
344 | HELENOS_TARGET="ppc-helenos"
|
---|
345 | ;;
|
---|
346 | "ppc64")
|
---|
347 | LINUX_TARGET="ppc64-linux-gnu"
|
---|
348 | HELENOS_TARGET="ppc64-helenos"
|
---|
349 | ;;
|
---|
350 | "sparc64")
|
---|
351 | LINUX_TARGET="sparc64-linux-gnu"
|
---|
352 | HELENOS_TARGET="sparc64-helenos"
|
---|
353 | ;;
|
---|
354 | *)
|
---|
355 | check_error 1 "No target known for $1."
|
---|
356 | ;;
|
---|
357 | esac
|
---|
358 | }
|
---|
359 |
|
---|
360 | build_target() {
|
---|
361 | PLATFORM="$1"
|
---|
362 | # This sets the *_TARGET variables
|
---|
363 | set_target_from_platform "$PLATFORM"
|
---|
364 | if $USE_HELENOS_TARGET; then
|
---|
365 | TARGET="$HELENOS_TARGET"
|
---|
366 | else
|
---|
367 | TARGET="$LINUX_TARGET"
|
---|
368 | fi
|
---|
369 |
|
---|
370 | WORKDIR="${BASEDIR}/${PLATFORM}"
|
---|
371 | BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
|
---|
372 | GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
|
---|
373 | OBJDIR="${WORKDIR}/gcc-obj"
|
---|
374 | GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"
|
---|
375 |
|
---|
376 | if [ -z "${CROSS_PREFIX}" ] ; then
|
---|
377 | CROSS_PREFIX="/usr/local/cross"
|
---|
378 | fi
|
---|
379 | if [ -z "${CROSS_HELENOS_PREFIX}" ] ; then
|
---|
380 | CROSS_HELENOS_PREFIX="/usr/local/cross-helenos"
|
---|
381 | fi
|
---|
382 |
|
---|
383 | if $USE_HELENOS_TARGET; then
|
---|
384 | PREFIX="${CROSS_HELENOS_PREFIX}/${PLATFORM}"
|
---|
385 | else
|
---|
386 | PREFIX="${CROSS_PREFIX}/${PLATFORM}"
|
---|
387 | fi
|
---|
388 |
|
---|
389 | echo ">>> Downloading tarballs"
|
---|
390 | source_check "${BASEDIR}/${BINUTILS}"
|
---|
391 | source_check "${BASEDIR}/${GCC}"
|
---|
392 | source_check "${BASEDIR}/${GDB}"
|
---|
393 |
|
---|
394 | echo ">>> Removing previous content"
|
---|
395 | $REAL_INSTALL && cleanup_dir "${PREFIX}"
|
---|
396 | cleanup_dir "${WORKDIR}"
|
---|
397 |
|
---|
398 | $REAL_INSTALL && create_dir "${PREFIX}" "destination directory"
|
---|
399 | create_dir "${OBJDIR}" "GCC object directory"
|
---|
400 |
|
---|
401 | echo ">>> Unpacking tarballs"
|
---|
402 | cd "${WORKDIR}"
|
---|
403 | check_error $? "Change directory failed."
|
---|
404 |
|
---|
405 | unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils"
|
---|
406 | unpack_tarball "${BASEDIR}/${GCC}" "GCC"
|
---|
407 | unpack_tarball "${BASEDIR}/${GDB}" "GDB"
|
---|
408 |
|
---|
409 | echo ">>> Applying patches"
|
---|
410 | for p in $BINUTILS_PATCHES; do
|
---|
411 | patch_sources "${BASEDIR}/${p}" 0 "binutils"
|
---|
412 | done
|
---|
413 | for p in $GCC_PATCHES; do
|
---|
414 | patch_sources "${BASEDIR}/${p}" 0 "GCC"
|
---|
415 | done
|
---|
416 | for p in $GDB_PATCHES; do
|
---|
417 | patch_sources "${BASEDIR}/${p}" 0 "GDB"
|
---|
418 | done
|
---|
419 |
|
---|
420 | echo ">>> Processing binutils (${PLATFORM})"
|
---|
421 | cd "${BINUTILSDIR}"
|
---|
422 | check_error $? "Change directory failed."
|
---|
423 |
|
---|
424 | change_title "binutils: configure (${PLATFORM})"
|
---|
425 | CFLAGS=-Wno-error ./configure \
|
---|
426 | "--target=${TARGET}" \
|
---|
427 | "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
|
---|
428 | --disable-nls --disable-werror
|
---|
429 | check_error $? "Error configuring binutils."
|
---|
430 |
|
---|
431 | change_title "binutils: make (${PLATFORM})"
|
---|
432 | make all
|
---|
433 | check_error $? "Error compiling binutils."
|
---|
434 |
|
---|
435 | change_title "binutils: install (${PLATFORM})"
|
---|
436 | if $REAL_INSTALL; then
|
---|
437 | make install
|
---|
438 | else
|
---|
439 | make install "DESTDIR=${INSTALL_DIR}"
|
---|
440 | fi
|
---|
441 | check_error $? "Error installing binutils."
|
---|
442 |
|
---|
443 |
|
---|
444 | echo ">>> Processing GCC (${PLATFORM})"
|
---|
445 | cd "${OBJDIR}"
|
---|
446 | check_error $? "Change directory failed."
|
---|
447 |
|
---|
448 | change_title "GCC: configure (${PLATFORM})"
|
---|
449 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${GCCDIR}/configure" \
|
---|
450 | "--target=${TARGET}" \
|
---|
451 | "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
|
---|
452 | --with-gnu-as --with-gnu-ld --disable-nls --disable-threads \
|
---|
453 | --enable-languages=c,objc,c++,obj-c++ \
|
---|
454 | --disable-multilib --disable-libgcj --without-headers \
|
---|
455 | --disable-shared --enable-lto --disable-werror
|
---|
456 | check_error $? "Error configuring GCC."
|
---|
457 |
|
---|
458 | change_title "GCC: make (${PLATFORM})"
|
---|
459 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc
|
---|
460 | check_error $? "Error compiling GCC."
|
---|
461 |
|
---|
462 | change_title "GCC: install (${PLATFORM})"
|
---|
463 | if $REAL_INSTALL; then
|
---|
464 | PATH="${PATH}:${PREFIX}/bin" make install-gcc
|
---|
465 | else
|
---|
466 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
|
---|
467 | fi
|
---|
468 | check_error $? "Error installing GCC."
|
---|
469 |
|
---|
470 |
|
---|
471 | echo ">>> Processing GDB (${PLATFORM})"
|
---|
472 | cd "${GDBDIR}"
|
---|
473 | check_error $? "Change directory failed."
|
---|
474 |
|
---|
475 | change_title "GDB: configure (${PLATFORM})"
|
---|
476 | PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" ./configure \
|
---|
477 | "--target=${TARGET}" \
|
---|
478 | "--prefix=${PREFIX}" "--program-prefix=${TARGET}-"
|
---|
479 | check_error $? "Error configuring GDB."
|
---|
480 |
|
---|
481 | change_title "GDB: make (${PLATFORM})"
|
---|
482 | PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all
|
---|
483 | check_error $? "Error compiling GDB."
|
---|
484 |
|
---|
485 | change_title "GDB: make (${PLATFORM})"
|
---|
486 | if $REAL_INSTALL; then
|
---|
487 | PATH="${PATH}:${PREFIX}/bin" make install
|
---|
488 | else
|
---|
489 | PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install "DESTDIR=${INSTALL_DIR}"
|
---|
490 | fi
|
---|
491 | check_error $? "Error installing GDB."
|
---|
492 |
|
---|
493 |
|
---|
494 | cd "${BASEDIR}"
|
---|
495 | check_error $? "Change directory failed."
|
---|
496 |
|
---|
497 | echo ">>> Cleaning up"
|
---|
498 | cleanup_dir "${WORKDIR}"
|
---|
499 |
|
---|
500 | echo
|
---|
501 | echo ">>> Cross-compiler for ${TARGET} installed."
|
---|
502 | }
|
---|
503 |
|
---|
504 | while [ "$#" -gt 1 ]; do
|
---|
505 | case "$1" in
|
---|
506 | --no-install)
|
---|
507 | REAL_INSTALL=false
|
---|
508 | shift
|
---|
509 | ;;
|
---|
510 | --helenos-target)
|
---|
511 | USE_HELENOS_TARGET=true
|
---|
512 | shift
|
---|
513 | ;;
|
---|
514 | *)
|
---|
515 | show_usage
|
---|
516 | ;;
|
---|
517 | esac
|
---|
518 | done
|
---|
519 |
|
---|
520 | if [ "$#" -lt "1" ]; then
|
---|
521 | show_usage
|
---|
522 | fi
|
---|
523 |
|
---|
524 | case "$1" in
|
---|
525 | amd64|arm32|ia32|ia64|mips32|mips32eb|mips64|ppc32|ppc64|sparc64)
|
---|
526 | prepare
|
---|
527 | build_target "$1"
|
---|
528 | ;;
|
---|
529 | "all")
|
---|
530 | prepare
|
---|
531 | build_target "amd64"
|
---|
532 | build_target "arm32"
|
---|
533 | build_target "ia32"
|
---|
534 | build_target "ia64"
|
---|
535 | build_target "mips32"
|
---|
536 | build_target "mips32eb"
|
---|
537 | build_target "mips64"
|
---|
538 | build_target "ppc32"
|
---|
539 | build_target "ppc64"
|
---|
540 | build_target "sparc64"
|
---|
541 | ;;
|
---|
542 | "parallel")
|
---|
543 | prepare
|
---|
544 | build_target "amd64" &
|
---|
545 | build_target "arm32" &
|
---|
546 | build_target "ia32" &
|
---|
547 | build_target "ia64" &
|
---|
548 | build_target "mips32" &
|
---|
549 | build_target "mips32eb" &
|
---|
550 | build_target "mips64" &
|
---|
551 | build_target "ppc32" &
|
---|
552 | build_target "ppc64" &
|
---|
553 | build_target "sparc64" &
|
---|
554 | wait
|
---|
555 | ;;
|
---|
556 | "2-way")
|
---|
557 | prepare
|
---|
558 | build_target "amd64" &
|
---|
559 | build_target "arm32" &
|
---|
560 | wait
|
---|
561 |
|
---|
562 | build_target "ia32" &
|
---|
563 | build_target "ia64" &
|
---|
564 | wait
|
---|
565 |
|
---|
566 | build_target "mips32" &
|
---|
567 | build_target "mips32eb" &
|
---|
568 | wait
|
---|
569 |
|
---|
570 | build_target "mips64" &
|
---|
571 | build_target "ppc32" &
|
---|
572 | wait
|
---|
573 |
|
---|
574 | build_target "ppc64" &
|
---|
575 | build_target "sparc64" &
|
---|
576 | wait
|
---|
577 | ;;
|
---|
578 | *)
|
---|
579 | show_usage
|
---|
580 | ;;
|
---|
581 | esac
|
---|