annotate simple-cross-compiler.sh @ 1003:6d3db5bf731a

Make the native build timeout configurable.
author Rob Landley <rob@landley.net>
date Thu, 18 Mar 2010 05:44:47 -0500
parents fc134a13357e
children 48784ae8533e
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
888
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 855
diff changeset
3 # Build a cross compiler for the specified target.
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 855
diff changeset
4
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents: 33
diff changeset
5 # 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
6
669
1cf41855bb85 More error checking.
Rob Landley <rob@landley.net>
parents: 654
diff changeset
7 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
8
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
9 # 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
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 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
12
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
13 # 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
14
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
15 check_for_base_arch || exit 0
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
16
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
17 # 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
18
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
19 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
20
820
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 819
diff changeset
21 # Build binutils, gcc, and ccwrap
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
22
905
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents: 898
diff changeset
23 FROM_ARCH= PROGRAM_PREFIX="${ARCH}-" build_section binutils
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents: 898
diff changeset
24 FROM_ARCH= PROGRAM_PREFIX="${ARCH}-" build_section gcc
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents: 898
diff changeset
25 FROM_ARCH= PROGRAM_PREFIX="${ARCH}-" build_section ccwrap
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
26
837
f80c47e8991d Abstract the C library away from uClibc, so when more build sections are added potentially (For glibc, eglibc, et cetera), nothing needs to be changed in the other files
Mark Miller <mark@mirell.org>
parents: 820
diff changeset
27 # Build C Library
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 17
diff changeset
28
906
5e0cbc73da55 Split out linux-headers, uClibc, and uClibc++ as their own sections.
Rob Landley <rob@landley.net>
parents: 905
diff changeset
29 build_section linux-headers
5e0cbc73da55 Split out linux-headers, uClibc, and uClibc++ as their own sections.
Rob Landley <rob@landley.net>
parents: 905
diff changeset
30 HOST_UTILS=1 build_section uClibc
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
31
813
e2fc10ede93f Consistently use STAGE_DIR as the output directory. (root-filesystem.sh already did, host-tools.sh was using $HOSTTOOLS, cross-compiler.sh was using $CROSS, and system-image.sh was using SYSIMAGE.)
Rob Landley <rob@landley.net>
parents: 783
diff changeset
32 cat > "${STAGE_DIR}"/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
33 Cross compiler for $ARCH
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
34 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
35
905
023b577fb865 Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents: 898
diff changeset
36 To use: Add the "bin" subdirectory to your \$PATH, and use "$ARCH-cc" 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
37 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
38
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
39 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
40
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
41 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
42
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
43 EOF
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
44
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
45 # Strip the binaries
48
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
46
854
3794d9a0be4c Add SKIP_STRIP configuration option to do what it says on the tin, and stop blanking CFLAGS and CFLAGSXX so "export CFLAGS=-g" can pass through to package builds.
Rob Landley <rob@landley.net>
parents: 837
diff changeset
47 if [ -z "$SKIP_STRIP" ]
3794d9a0be4c Add SKIP_STRIP configuration option to do what it says on the tin, and stop blanking CFLAGS and CFLAGSXX so "export CFLAGS=-g" can pass through to package builds.
Rob Landley <rob@landley.net>
parents: 837
diff changeset
48 then
3794d9a0be4c Add SKIP_STRIP configuration option to do what it says on the tin, and stop blanking CFLAGS and CFLAGSXX so "export CFLAGS=-g" can pass through to package builds.
Rob Landley <rob@landley.net>
parents: 837
diff changeset
49 cd "$STAGE_DIR"
3794d9a0be4c Add SKIP_STRIP configuration option to do what it says on the tin, and stop blanking CFLAGS and CFLAGSXX so "export CFLAGS=-g" can pass through to package builds.
Rob Landley <rob@landley.net>
parents: 837
diff changeset
50 for i in `find bin -type f` `find "$CROSS_TARGET" -type f`
3794d9a0be4c Add SKIP_STRIP configuration option to do what it says on the tin, and stop blanking CFLAGS and CFLAGSXX so "export CFLAGS=-g" can pass through to package builds.
Rob Landley <rob@landley.net>
parents: 837
diff changeset
51 do
3794d9a0be4c Add SKIP_STRIP configuration option to do what it says on the tin, and stop blanking CFLAGS and CFLAGSXX so "export CFLAGS=-g" can pass through to package builds.
Rob Landley <rob@landley.net>
parents: 837
diff changeset
52 strip "$i" 2> /dev/null
3794d9a0be4c Add SKIP_STRIP configuration option to do what it says on the tin, and stop blanking CFLAGS and CFLAGSXX so "export CFLAGS=-g" can pass through to package builds.
Rob Landley <rob@landley.net>
parents: 837
diff changeset
53 done
3794d9a0be4c Add SKIP_STRIP configuration option to do what it says on the tin, and stop blanking CFLAGS and CFLAGSXX so "export CFLAGS=-g" can pass through to package builds.
Rob Landley <rob@landley.net>
parents: 837
diff changeset
54 fi
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
55
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
56 # Tar it up
48
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
57
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
58 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
59
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
60 # 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
61 # 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
62
175
6fd189c18c1c Three things: 1) dash->bash, 2) install cross-ldd and cross-readelf,
Rob Landley <rob@landley.net>
parents: 147
diff changeset
63 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
64
93
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
65 "${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
66 "${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
67 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
68 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
69 [ 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
70 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
71 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
72
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
73 [ $? -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
74
47
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
75 echo -e "\e[32mCross compiler toolchain build complete.\e[0m"