annotate build.sh @ 784:037488e9889d

New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
author Rob Landley <rob@landley.net>
date Sun, 05 Jul 2009 17:51:54 -0500
parents d8c780ed3686
children 5ed920fc2ea5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
96
137ba51ee993 Delete output directories on re-run, teach build to log and build multiple
Rob Landley <rob@landley.net>
parents: 93
diff changeset
1 #!/bin/bash
137ba51ee993 Delete output directories on re-run, teach build to log and build multiple
Rob Landley <rob@landley.net>
parents: 93
diff changeset
2
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
3 # If run with no arguments, list architectures.
108
b66d638a3844 Build User Mode Linux and have that do the ext2 packaging (for now, anyway).
Rob Landley <rob@landley.net>
parents: 105
diff changeset
4
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
5 if [ $# -ne 1 ]
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
6 then
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
7 echo "Usage: $0 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: 719
diff changeset
8 . sources/include.sh
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: 719
diff changeset
9 read_arch_dir
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: 719
diff changeset
10
118
85582f847bd6 When run with no arguments, exit after showing usage message.
Rob Landley <rob@landley.net>
parents: 114
diff changeset
11 exit 1
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
12 fi
108
b66d638a3844 Build User Mode Linux and have that do the ext2 packaging (for now, anyway).
Rob Landley <rob@landley.net>
parents: 105
diff changeset
13
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
14 # Download source code and build host tools.
108
b66d638a3844 Build User Mode Linux and have that do the ext2 packaging (for now, anyway).
Rob Landley <rob@landley.net>
parents: 105
diff changeset
15
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
16 ./download.sh || exit 1
262
b2e353ae7566 Have host-tools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents: 186
diff changeset
17
b2e353ae7566 Have host-tools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents: 186
diff changeset
18 # host-tools populates one directory with every command the build needs,
b2e353ae7566 Have host-tools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents: 186
diff changeset
19 # so we can ditch the old $PATH afterwards.
b2e353ae7566 Have host-tools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents: 186
diff changeset
20
186
f8dac531cbb5 Use shell builtin time instead of /usr/bin version not everybody has.
Rob Landley <rob@landley.net>
parents: 184
diff changeset
21 time ./host-tools.sh || exit 1
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
22
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
23 echo "=== Building ARCH $1"
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
24
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
25 # Do we need to build the cross compiler?
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
26
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
27 if [ -f "build/cross-compiler-$1.tar.bz2" ]
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
28 then
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
29 echo "=== Skipping cross-compiler-$1 (already there)"
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
30 else
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
31 # If we need to build cross compiler, assume root filesystem is stale.
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
32
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
33 rm -rf "build/root-filesystem-$1.tar.bz2"
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
34 time ./cross-compiler.sh $1 || exit 1
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
35 fi
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
36
784
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
37 # Optionally, we can build a static compiler via canadian cross. This is
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
38 # built to run on the host system, but statically linked against uClibc
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
39 # instead of the host's libraries. This makes it more portable, and smaller
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
40 # than statically linking against glibc would make it.
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
41
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
42 # We don't autodetect the host because i686 is more portable (running on
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
43 # both 64 and 32 bit hosts), but x86_64 is (slightly) faster on a 64 bit host.
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
44
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
45 if [ ! -z "$STATIC_CROSS_COMPILER_HOST" ]
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
46 then
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
47
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
48 # These are statically linked against uClibc on the host (for portability),
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
49 # built --with-shared, and have uClibc++ installed.
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
50
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
51 # To build each of these we need two existing cross compilers: one for
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
52 # the host (to build the executables) and one for the target (to build
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
53 # the libraries).
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
54
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
55 BUILD_STATIC=1 FROM_ARCH="$STATIC_CROSS_HOST" NATIVE_TOOLCHAIN=only \
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
56 STAGE_NAME=cross-static ./root-filesystem.sh $1
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
57
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
58 # Replace the dynamic cross compiler with the static one.
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
59
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
60 rm -rf "build/cross-compiler-$1" &&
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
61 ln -s "cross-static-$1" "build/cross-compiler-$1" || exit 1
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
62 fi
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
63
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
64 # Optionally, we can build a static native compiler. (The one in
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
65 # root-filesystem is dynamically linked against uClibc, this one can
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
66 # presumably be untarred and run on any appropriate host system.)
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
67
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
68 if [ ! -z "$BUILD_STATIC_NATIVE_COMPILER" ]
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
69 then
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
70
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
71 # Build static native compilers for each target, possibly in parallel
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
72
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
73 BUILD_STATIC=1 NATIVE_TOOLCHAIN=only STAGE_NAME=native-compiler \
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
74 ./root-filesystem.sh $1
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
75 fi
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
76
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
77 # Do we need to build the root filesystem?
539
85979aa53fde Teach build.sh not to rerun build stages we already have the result of.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
78
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
79 if [ -f "build/root-filesystem-$1.tar.bz2" ]
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
80 then
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
81 echo "=== Skipping root-filesystem-$1 (already there)"
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
82 else
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
83 # If we need to build root filesystem, assume system image is stale.
539
85979aa53fde Teach build.sh not to rerun build stages we already have the result of.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
84
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
85 rm -rf "build/system-image-$1.tar.bz2"
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
86 time ./root-filesystem.sh $1 || exit 1
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
87 fi
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
88
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
89 if [ -f "build/system-image-$1.tar.bz2" ]
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
90 then
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
91 echo "=== Skipping system-image-$1 (already there)"
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
92 else
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
93 time ./system-image.sh $1 || exit 1
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
94 fi