annotate simple-cross-compiler.sh @ 1358:9252453c40d0

Combine set_titlebar and "echo ===" stuff into announce() function. Consistently output target/stage info, and yank redundant instances.
author Rob Landley <rob@landley.net>
date Sun, 22 May 2011 04:18:30 -0500
parents 74541aac72f9
children b74d36876c0a
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
1007
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
3 # Build a simple cross compiler for the specified target.
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
4
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
5 # This simple compiler has no thread support, no libgcc_s.so, doesn't include
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
6 # uClibc++, and is dynamically linked against the host's shared libraries.
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
7
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
8 # Its stripped down nature makes it easy to build on an arbitrary host, and
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
9 # provides just enough capability to build a root filesystem, and to be used
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
10 # as a distcc accelerator from within that system.
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
11
888
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 855
diff changeset
12
34
ad1cfcb043c7 Cleaup pass: Break out shell functions and variable definitions into include.sh.
Rob Landley <rob@landley.net>
parents: 33
diff changeset
13 # 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
14
669
1cf41855bb85 More error checking.
Rob Landley <rob@landley.net>
parents: 654
diff changeset
15 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
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 # 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
18
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
19 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
20
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 # 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
22
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
23 check_for_base_arch || exit 0
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
24
1208
74541aac72f9 Missed one (PROGRAM_PREFIX->TOOLCHAIN_PREFIX).
Rob Landley <rob@landley.net>
parents: 1157
diff changeset
25 export TOOLCHAIN_PREFIX="${ARCH}-"
1090
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1011
diff changeset
26
820
d1a88d878e18 Factor out and unify binutils, gcc, and ccwrap builds.
Rob Landley <rob@landley.net>
parents: 819
diff changeset
27 # 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
28
1090
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1011
diff changeset
29 build_section binutils
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1011
diff changeset
30 build_section gcc
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1011
diff changeset
31 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
32
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
33 # 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
34
906
5e0cbc73da55 Split out linux-headers, uClibc, and uClibc++ as their own sections.
Rob Landley <rob@landley.net>
parents: 905
diff changeset
35 build_section linux-headers
1090
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1011
diff changeset
36 build_section uClibc
3
1b721a51e9c6 Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
landley@driftwood
parents: 1
diff changeset
37
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
38 cat > "${STAGE_DIR}"/README << EOF &&
1090
affef1edbdba Cleanup "FROM_ARCH" mess. Rename FROM_ARCH->HOST_ARCH, make stage script responsible for setting HOST_ARCH (not includes.sh). Also, remove HOST_UTILS variable, only build uClibc utils for non-simple compilers and bypass uClibc's (weird) makefile for the utils directory.
Rob Landley <rob@landley.net>
parents: 1011
diff changeset
39 Cross compiler for $ARCH from http://aboriginal.impactlinux.com
33
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
40
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
41 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
42 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
43
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
44 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
45
41
3baa8ab7ee6d Largeish update.
Rob Landley <rob@landley.net>
parents: 39
diff changeset
46 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
47
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
48 EOF
bf2e771f4ba5 Update build script. Now uses a config file (usage: ./build.sh arch), and
Rob Landley <rob@landley.net>
parents: 27
diff changeset
49
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
50 # Strip the binaries
48
0f77e2472d27 Strip binaries.
Rob Landley <rob@landley.net>
parents: 47
diff changeset
51
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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 fi
507
58e9523a775d Tweak the readme, add comments, remove some dead code.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
60
783
db06a8c1bfed Lots of changes to move buildall.sh functionality into build.sh.
Rob Landley <rob@landley.net>
parents: 744
diff changeset
61 # 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
62 # 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
63
175
6fd189c18c1c Three things: 1) dash->bash, 2) install cross-ldd and cross-readelf,
Rob Landley <rob@landley.net>
parents: 147
diff changeset
64 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
65
93
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 "${SOURCES}/toys/hello.c" -o "$WORK"/hello &&
1007
48784ae8533e Move CROSS_SMOKE_TEST implementation out of simple-cross-compiler.sh and into sources/more/cross-smoke-test.sh, called from build.sh. Clean up comments a bit while we're there.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
67 "${ARCH}-gcc" -Os -static "${SOURCES}/toys/hello.c" -o "$WORK"/hello || dienow
93
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
68
1116
2b68517f5b62 Break out simple-root-filesystem.sh and root-filesystem.sh (adding native-compiler.sh output), and use NO_NATIVE_COMPILER to determine which to use. Rename STATIC_CC_HOST to CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
69 # Does the hello world we just built actually run?
2b68517f5b62 Break out simple-root-filesystem.sh and root-filesystem.sh (adding native-compiler.sh output), and use NO_NATIVE_COMPILER to determine which to use. Rename STATIC_CC_HOST to CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
70
2b68517f5b62 Break out simple-root-filesystem.sh and root-filesystem.sh (adding native-compiler.sh output), and use NO_NATIVE_COMPILER to determine which to use. Rename STATIC_CC_HOST to CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
71 if [ ! -z "$CROSS_SMOKE_TEST" ]
2b68517f5b62 Break out simple-root-filesystem.sh and root-filesystem.sh (adding native-compiler.sh output), and use NO_NATIVE_COMPILER to determine which to use. Rename STATIC_CC_HOST to CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
72 then
1157
300e6d919d86 Move "sources/more/" to just "more/", add a README explaining why those scripts are there, and adjust calls to them.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
73 more/cross-smoke-test.sh "$ARCH" || exit 1
1116
2b68517f5b62 Break out simple-root-filesystem.sh and root-filesystem.sh (adding native-compiler.sh output), and use NO_NATIVE_COMPILER to determine which to use. Rename STATIC_CC_HOST to CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
74 fi
2b68517f5b62 Break out simple-root-filesystem.sh and root-filesystem.sh (adding native-compiler.sh output), and use NO_NATIVE_COMPILER to determine which to use. Rename STATIC_CC_HOST to CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1090
diff changeset
75
1011
1b364391e821 Bug spotted by Milton Miller: create stage tarball _after_ the compile smoketest.
Rob Landley <rob@landley.net>
parents: 1007
diff changeset
76 # Tar it up
1b364391e821 Bug spotted by Milton Miller: create stage tarball _after_ the compile smoketest.
Rob Landley <rob@landley.net>
parents: 1007
diff changeset
77
1b364391e821 Bug spotted by Milton Miller: create stage tarball _after_ the compile smoketest.
Rob Landley <rob@landley.net>
parents: 1007
diff changeset
78 create_stage_tarball
93
153ba1a0b427 Break out the qemu build (and squashfs) into something easy to comment out,
Rob Landley <rob@landley.net>
parents: 88
diff changeset
79
47
edaa86240321 Turnerize the build script and teach cross-compile.sh to build qemu when
Rob Landley <rob@landley.net>
parents: 41
diff changeset
80 echo -e "\e[32mCross compiler toolchain build complete.\e[0m"