annotate cross-compiler.sh @ 808:cce6b8e81581

Added tag 0.9.7 for changeset d0b74a631587
author Rob Landley <rob@landley.net>
date Thu, 20 Aug 2009 20:18:46 -0500
parents db06a8c1bfed
children e2fc10ede93f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
175
6fd189c18c1c Three things: 1) dash->bash, 2) install cross-ldd and cross-readelf,
Rob Landley <rob@landley.net>
parents: 147
diff changeset
1 #!/bin/bash
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
2
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents: 33
diff changeset
3 # Get lots of predefined environment variables and shell functions.
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
4
669
1cf41855bb85 More error checking.
Rob Landley <rob@landley.net>
parents: 654
diff changeset
5 source sources/include.sh || exit 1
1
9add2b1ccdfa First version of new build script. Does nothing, but does it correctly.
landley@driftwood
parents:
diff changeset
6
744
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 726
diff changeset
7 # Parse the sources/targets/$1 directory
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 726
diff changeset
8
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 726
diff changeset
9 read_arch_dir "$1"
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 726
diff changeset
10
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 726
diff changeset
11 # If this target has a base architecture that's already been built, use that.
583
1bb180e6a4ba Actually define CROSS (missed in 581).
Rob Landley <rob@landley.net>
parents: 576
diff changeset
12
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
13 check_for_base_arch || exit 0
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
14
744
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 726
diff changeset
15 # Ok, we have work to do. Announce start of stage.
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 726
diff changeset
16
485
b0438691e9e1 Move color selection into ./config. (The default colors don't look great on a white background.)
Rob Landley <rob@landley.net>
parents: 482
diff changeset
17 echo -e "$CROSS_COLOR"
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
18 echo "=== Building $STAGE_NAME"
47
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
19
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
20 CROSS="${BUILD}/${STAGE_NAME}-${ARCH}"
744
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 726
diff changeset
21 blank_tempdir "$CROSS"
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 726
diff changeset
22 blank_tempdir "$WORK"
685
90ab1a1f4db5 Teach build not to rebuild base architecture toolchains. Factor out some common code while there.
Rob Landley <rob@landley.net>
parents: 675
diff changeset
23
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
24 # Build and install binutils
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
25
250
cef5bbd777fa Make sure error return from setupfor is noticed.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
26 setupfor binutils build-binutils &&
407
e64eb9ff27b9 Use unstable infrastructure to back off non-unstable kernel to 2.6.25 (where powerpc works) and bring back binutils 2.18 build as unstable version.
Rob Landley <rob@landley.net>
parents: 400
diff changeset
27 AR=ar AS=as LD=ld NM=nm OBJDUMP=objdump OBJCOPY=objcopy \
e64eb9ff27b9 Use unstable infrastructure to back off non-unstable kernel to 2.6.25 (where powerpc works) and bring back binutils 2.18 build as unstable version.
Rob Landley <rob@landley.net>
parents: 400
diff changeset
28 "${CURSRC}/configure" --prefix="${CROSS}" --host=${CROSS_HOST} \
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
29 --target=${CROSS_TARGET} --with-lib-path=lib --disable-nls \
59
18c065749b79 Add i686 and x86_64 config files. (Might or might not work, dunno.)
Rob Landley <rob@landley.net>
parents: 48
diff changeset
30 --disable-shared --disable-multilib --program-prefix="${ARCH}-" \
417
6dd7e870b1d4 No shipping package should ever use -Werror, no idea what new gcc versions will decide to warn on. (Fixes build on ubuntu 8.10.)
Rob Landley <rob@landley.net>
parents: 414
diff changeset
31 --disable-werror $BINUTILS_FLAGS &&
293
cdd26f8acc35 Update to gcc 4.1.2->4.2.2. Still doesn't fix the internal compiler error
Rob Landley <rob@landley.net>
parents: 287
diff changeset
32 make -j $CPUS configure-host &&
363
80f520811ed6 Teach cross-compiler.sh how to produce static binaries when BUILD_STATIC=1
Rob Landley <rob@landley.net>
parents: 360
diff changeset
33 make -j $CPUS CFLAGS="-O2 $STATIC_FLAGS" &&
293
cdd26f8acc35 Update to gcc 4.1.2->4.2.2. Still doesn't fix the internal compiler error
Rob Landley <rob@landley.net>
parents: 287
diff changeset
34 make -j $CPUS install &&
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
35 cd .. &&
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
36 mkdir -p "${CROSS}/include" &&
301
309b574a5059 Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents: 294
diff changeset
37 cp binutils/include/libiberty.h "${CROSS}/include"
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
38
301
309b574a5059 Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents: 294
diff changeset
39 cleanup binutils build-binutils
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
40
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
41 # Build and install gcc
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
42
250
cef5bbd777fa Make sure error return from setupfor is noticed.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
43 setupfor gcc-core build-gcc &&
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
44 setupfor gcc-g++ build-gcc gcc-core &&
564
425a7d32446a Move $GCC_FLAGS to the end so the details filie can override everything. (Thanks Milton Miller.)
Rob Landley <rob@landley.net>
parents: 546
diff changeset
45 AR_FOR_TARGET="${ARCH}-ar" "${CURSRC}/configure" \
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
46 --prefix="${CROSS}" --host=${CROSS_HOST} --target=${CROSS_TARGET} \
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
47 --enable-languages=c,c++ --enable-long-long --enable-c99 \
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
48 --disable-shared --disable-threads --disable-nls --disable-multilib \
701
b4a9c0084f2f Converted ARMV5L from OABI to EABI with VFP support. Added patches for uClibc and uClibc++ to deal with Unwind Exception handling, made uClibc++ pull in libgcc_eh for this as well, and disabled SJLJ exceptions for ARMV5L EABI, which is apparently required, so --enable-sjlj-exceptions was added to the details file for all the other arches. Also correct the GENTOO_CHOST variable for armeb.
Mark Miller <mark@mirell.org>
parents: 685
diff changeset
49 --enable-__cxa_atexit --disable-libstdcxx-pch \
564
425a7d32446a Move $GCC_FLAGS to the end so the details filie can override everything. (Thanks Milton Miller.)
Rob Landley <rob@landley.net>
parents: 546
diff changeset
50 --program-prefix="${ARCH}-" $GCC_FLAGS &&
487
1828f3fe831e Continuing attempt to make gcc build like a normal program.
Rob Landley <rob@landley.net>
parents: 485
diff changeset
51
1828f3fe831e Continuing attempt to make gcc build like a normal program.
Rob Landley <rob@landley.net>
parents: 485
diff changeset
52 # Try to convince gcc build process not to rebuild itself with itself.
1828f3fe831e Continuing attempt to make gcc build like a normal program.
Rob Landley <rob@landley.net>
parents: 485
diff changeset
53 mkdir -p gcc &&
1828f3fe831e Continuing attempt to make gcc build like a normal program.
Rob Landley <rob@landley.net>
parents: 485
diff changeset
54 ln -s `which gcc` gcc/xgcc &&
1828f3fe831e Continuing attempt to make gcc build like a normal program.
Rob Landley <rob@landley.net>
parents: 485
diff changeset
55
363
80f520811ed6 Teach cross-compiler.sh how to produce static binaries when BUILD_STATIC=1
Rob Landley <rob@landley.net>
parents: 360
diff changeset
56 make -j $CPUS all-gcc LDFLAGS="$STATIC_FLAGS" &&
293
cdd26f8acc35 Update to gcc 4.1.2->4.2.2. Still doesn't fix the internal compiler error
Rob Landley <rob@landley.net>
parents: 287
diff changeset
57 make -j $CPUS install-gcc &&
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
58 cd ..
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
59
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
60 cleanup gcc-core build-gcc
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
61
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
62 echo Fixup toolchain... &&
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
63
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
64 # Move the gcc internal libraries and headers somewhere sane.
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
65
21
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
66 mkdir -p "${CROSS}"/gcc &&
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
67 mv "${CROSS}"/lib/gcc/*/*/include "${CROSS}"/gcc/include &&
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
68 mv "${CROSS}"/lib/gcc/*/* "${CROSS}"/gcc/lib &&
257
d37e39370d39 Fix cross compiler toolchain to be properly relocatable on x86-64 host.
Rob Landley <rob@landley.net>
parents: 250
diff changeset
69 ln -s ${CROSS_TARGET} ${CROSS}/tools &&
d37e39370d39 Fix cross compiler toolchain to be properly relocatable on x86-64 host.
Rob Landley <rob@landley.net>
parents: 250
diff changeset
70 ln -sf ../../../../tools/bin/ld ${CROSS}/libexec/gcc/*/*/collect2 &&
21
c4e1bd04035d Build uClibc under the wrapper script. (There's got to be a better way to
Rob Landley <rob@landley.net>
parents: 18
diff changeset
71
61
eb42ad9e8f81 Shuffle comments around.
Rob Landley <rob@landley.net>
parents: 59
diff changeset
72 # Build and install gcc wrapper script.
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
73
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
74 cd "${CROSS}"/bin &&
390
a9a9eee9e620 Teach the wrapper script to do the libgcc_s --as-needed stuff when
Rob Landley <rob@landley.net>
parents: 387
diff changeset
75 mv "${ARCH}-gcc" "$ARCH-rawgcc" &&
546
a7f128fc53b5 Rename gcc-uClibc.c to ccwrap.c
Rob Landley <rob@landley.net>
parents: 545
diff changeset
76 $CC $STATIC_FLAGS -Os -s "${SOURCES}"/toys/ccwrap.c -o "${ARCH}-gcc" \
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
77 -DGCC_UNWRAPPED_NAME='"'"$ARCH"-rawgcc'"' &&
545
f1337876df98 Actually _create_ the $ARCH-cc symlink.
Rob Landley <rob@landley.net>
parents: 540
diff changeset
78 ln -s "${ARCH}-gcc" "${ARCH}-cc" &&
136
8c3d95f52237 Some tweaks to make toolchain debugging easier.
Rob Landley <rob@landley.net>
parents: 131
diff changeset
79
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
80 # Wrap C++
136
8c3d95f52237 Some tweaks to make toolchain debugging easier.
Rob Landley <rob@landley.net>
parents: 131
diff changeset
81
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
82 mv "${ARCH}-g++" "${ARCH}-rawg++" &&
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
83 rm "${ARCH}-c++" &&
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
84 ln -s "${ARCH}-g++" "${ARCH}-rawc++" &&
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
85 ln -s "${ARCH}-gcc" "${ARCH}-g++" &&
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
86 ln -s "${ARCH}-gcc" "${ARCH}-c++"
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
87
442
4b96ad732432 Add basic c++ support to the cross compiler. (No headers or libraries, but enough to cross compile uClibc++ in mini-native and use distcc with the cross compiler for C++.)
Rob Landley <rob@landley.net>
parents: 424
diff changeset
88 cleanup "${CROSS}"/{lib/gcc,{libexec/gcc,gcc/lib}/install-tools}
8
0068264ad65a Some work I did back in october but hadn't checked in yet: let setupfor()
Rob Landley <rob@landley.net>
parents: 3
diff changeset
89
85
7c874da5505c Switch config-linux to miniconfig-linux. Adjust the build and config scripts,
Rob Landley <rob@landley.net>
parents: 83
diff changeset
90 # Install kernel headers.
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
91
250
cef5bbd777fa Make sure error return from setupfor is noticed.
Rob Landley <rob@landley.net>
parents: 222
diff changeset
92 setupfor linux &&
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
93 # Install Linux kernel headers (for use by uClibc).
182
fc827ab6166f Autodetect number of processors and feed appropriate -j to make.
Rob Landley <rob@landley.net>
parents: 175
diff changeset
94 make -j $CPUS headers_install ARCH="${KARCH}" INSTALL_HDR_PATH="${CROSS}" &&
540
d0b059fd91a8 Link include/asm/page.h to include/sys/user.h, in case people try to build old packages.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
95 # This makes some very old package builds happy.
d0b059fd91a8 Link include/asm/page.h to include/sys/user.h, in case people try to build old packages.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
96 ln -s ../sys/user.h "${CROSS}/include/asm/page.h" &&
301
309b574a5059 Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents: 294
diff changeset
97 cd ..
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
98
301
309b574a5059 Redo the $CLEANUP logic to a cleanup function in include.sh (meaning if a
Rob Landley <rob@landley.net>
parents: 294
diff changeset
99 cleanup linux
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
100
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
101 # Build and install uClibc
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
102
360
c9a9b8a25455 Only try to build $ARCH-ldd if /usr/include exists.
Rob Landley <rob@landley.net>
parents: 351
diff changeset
103 setupfor uClibc
530
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 507
diff changeset
104 make CROSS= KCONFIG_ALLCONFIG="$(getconfig uClibc)" allnoconfig &&
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 507
diff changeset
105 make CROSS="${ARCH}-" KERNEL_HEADERS="${CROSS}/include" PREFIX="${CROSS}/" \
709
64cc63ad26ce Add BUILD_VERBOSE config option.
Rob Landley <rob@landley.net>
parents: 701
diff changeset
106 RUNTIME_PREFIX=/ DEVEL_PREFIX=/ -j $CPUS $VERBOSITY \
64cc63ad26ce Add BUILD_VERBOSE config option.
Rob Landley <rob@landley.net>
parents: 701
diff changeset
107 install hostutils || dienow
530
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 507
diff changeset
108 for i in $(cd utils; ls *.host | sed 's/\.host//')
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 507
diff changeset
109 do
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 507
diff changeset
110 cp utils/"$i".host "$CROSS/bin/$ARCH-$i" || dienow
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 507
diff changeset
111 done
ea7a010e5c47 Add ldd/readelf/ldconfig to cross and native toolchains, and teach build to fallback to stable miniconfig when miniconfig-alt is absent.
Rob Landley <rob@landley.net>
parents: 507
diff changeset
112 cd ..
360
c9a9b8a25455 Only try to build $ARCH-ldd if /usr/include exists.
Rob Landley <rob@landley.net>
parents: 351
diff changeset
113
400
f60b1189c0ea Teach build to use recent uClibc snapshot when USE_UNSTABLE=uClibc
Rob Landley <rob@landley.net>
parents: 394
diff changeset
114 cleanup uClibc
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
115
38
297bb57cf74c Apparently "" around EOF also disables variable substitution, not just ''.
Rob Landley <rob@landley.net>
parents: 36
diff changeset
116 cat > "${CROSS}"/README << EOF &&
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
117 Cross compiler for $ARCH
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
118 From http://impactlinux.com/fwl
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
119
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
120 To use: Add the "bin" subdirectory to your \$PATH, and use "$ARCH-gcc" as
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
121 your compiler.
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
122
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
123 The syntax used to build the Linux kernel is:
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
124
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
125 make ARCH=${KARCH} CROSS_COMPILE=${ARCH}-
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
126
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
127 EOF
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
128
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
129 # Strip the binaries
48
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
130
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
131 cd "$CROSS"
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
132 for i in `find bin -type f` `find "$CROSS_TARGET" -type f`
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
133 do
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
134 strip "$i" 2> /dev/null
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
135 done
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
136
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
137 # Tar it up
48
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
138
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
139 create_stage_tarball
576
036dbe218036 Add BASE_ARCH support, so a hardware architecture can specify a base architecture and just provide a different kernel.
Rob Landley <rob@landley.net>
parents: 564
diff changeset
140
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
141 # A quick hello world program to test the cross compiler out.
93
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
142 # Build hello.c dynamic, then static, to verify header/library paths.
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
143
175
6fd189c18c1c Three things: 1) dash->bash, 2) install cross-ldd and cross-readelf,
Rob Landley <rob@landley.net>
parents: 147
diff changeset
144 echo "Sanity test: building Hello World."
6fd189c18c1c Three things: 1) dash->bash, 2) install cross-ldd and cross-readelf,
Rob Landley <rob@landley.net>
parents: 147
diff changeset
145
93
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
146 "${ARCH}-gcc" -Os "${SOURCES}/toys/hello.c" -o "$WORK"/hello &&
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
147 "${ARCH}-gcc" -Os -static "${SOURCES}/toys/hello.c" -o "$WORK"/hello &&
654
fa2498e3b3c9 Make a config option for the cross compiler smoke test. The problem is that recent kernel upgrades broke qemu-arm (application emulation, not system emulation), so it can't run anything unless you "echo 0 > /proc/sys/vm/mmap_min_addr" as root. Fun.
Rob Landley <rob@landley.net>
parents: 583
diff changeset
148 if [ ! -z "$CROSS_SMOKE_TEST" ] && which qemu-"${QEMU_TEST}" > /dev/null
143
17d06149802e Only run the sanity check on the toolchain if the appropriate qemu is installed.
Rob Landley <rob@landley.net>
parents: 136
diff changeset
149 then
17d06149802e Only run the sanity check on the toolchain if the appropriate qemu is installed.
Rob Landley <rob@landley.net>
parents: 136
diff changeset
150 [ x"$(qemu-"${QEMU_TEST}" "${WORK}"/hello)" == x"Hello world!" ] &&
17d06149802e Only run the sanity check on the toolchain if the appropriate qemu is installed.
Rob Landley <rob@landley.net>
parents: 136
diff changeset
151 echo Cross-toolchain seems to work.
17d06149802e Only run the sanity check on the toolchain if the appropriate qemu is installed.
Rob Landley <rob@landley.net>
parents: 136
diff changeset
152 fi
93
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
153
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
154 [ $? -ne 0 ] && dienow
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
155
47
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
156 echo -e "\e[32mCross compiler toolchain build complete.\e[0m"