annotate build.sh @ 1816:fb05f99ffcce draft

Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR, MY_ROOT_OVERLAY, MY_CROSS_PATH and MY_CROSS_PREFIX.
author Rob Landley <rob@landley.net>
date Sat, 21 Nov 2015 16:44:39 -0600
parents acaa88463c0c
children 92d542aa6ceb
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
888
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 873
diff changeset
3 # Run all the steps needed to build a system image from scratch.
626288dd5cf3 Lots of comments.
Rob Landley <rob@landley.net>
parents: 873
diff changeset
4
1212
19f3be2b4d04 Teach build.sh to build host compiler if necessary for CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1129
diff changeset
5 # The default set of stages run by this script is (in order):
1730
7f1b9fb1099e Move simple-root-filesystem.sh to root-filesystem.sh
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
6 # download, host-tools, simple-cross-compiler, root-filesystem,
1728
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1706
diff changeset
7 # native-compiler, system-image.
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
8
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
9 # That sanitizes the host build environment and builds a cross compiler,
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
10 # cross compiles a root filesystem and a native toolchain for the target,
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
11 # and finally packages the root filesystem up into a system image bootable
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
12 # by qemu.
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
13
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
14 # The optional cross-compiler stage (after simple-cross-compiler but before
1730
7f1b9fb1099e Move simple-root-filesystem.sh to root-filesystem.sh
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
15 # root-filesystem) creates a more powerful and portable cross compiler
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
16 # that can be used to cross compile more stuff (if you're into that sort of
1212
19f3be2b4d04 Teach build.sh to build host compiler if necessary for CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1129
diff changeset
17 # thing). To enable that:
19f3be2b4d04 Teach build.sh to build host compiler if necessary for CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1129
diff changeset
18
1350
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
19 # CROSS_COMPILER_HOST=i686 ./build.sh $TARGET
1212
19f3be2b4d04 Teach build.sh to build host compiler if necessary for CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1129
diff changeset
20
19f3be2b4d04 Teach build.sh to build host compiler if necessary for CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1129
diff changeset
21 # Where "i686" is whichever target you want the new cross compiler to run on.
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
22
1728
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1706
diff changeset
23 # The simplest set of stages (if you run them yourself) is:
1730
7f1b9fb1099e Move simple-root-filesystem.sh to root-filesystem.sh
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
24 # download, simple-cross-compiler, root-filesystem, system-image.
1728
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1706
diff changeset
25
1395
ee222555de52 Print better error message for bad architecture name, idea from Alessio Igor Bogani.
Rob Landley <rob@landley.net>
parents: 1378
diff changeset
26 # If this script was run with no arguments, list available 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
27
1739
4ca4ddd185db Check up front that "./build.sh $ARCH $STAGE" actually names an existing stage to rebuild from.
Rob Landley <rob@landley.net>
parents: 1737
diff changeset
28 [ ! -z "$2" ] && REBUILD="$2" &&
4ca4ddd185db Check up front that "./build.sh $ARCH $STAGE" actually names an existing stage to rebuild from.
Rob Landley <rob@landley.net>
parents: 1737
diff changeset
29 [ ! -e "$2".sh ] && echo "no stage $2" && exit 1
1471
9c2b7ec6b0c7 Optional second argument to build.sh indicates which stage to start rebuilding from after a successful first build.
Rob Landley <rob@landley.net>
parents: 1458
diff changeset
30
9c2b7ec6b0c7 Optional second argument to build.sh indicates which stage to start rebuilding from after a successful first build.
Rob Landley <rob@landley.net>
parents: 1458
diff changeset
31 if [ $# -lt 1 ] || [ $# -gt 2 ] || [ ! -e sources/targets/"$1" ]
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
32 then
1602
045160e8ad71 Better help test for build.sh
Rob Landley <rob@landley.net>
parents: 1471
diff changeset
33 echo
1471
9c2b7ec6b0c7 Optional second argument to build.sh indicates which stage to start rebuilding from after a successful first build.
Rob Landley <rob@landley.net>
parents: 1458
diff changeset
34 echo "Usage: $0 TARGET [REBUILD_FROM_STAGE]"
1602
045160e8ad71 Better help test for build.sh
Rob Landley <rob@landley.net>
parents: 1471
diff changeset
35 echo
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
36 echo "Supported architectures:"
1395
ee222555de52 Print better error message for bad architecture name, idea from Alessio Igor Bogani.
Rob Landley <rob@landley.net>
parents: 1378
diff changeset
37 ls sources/targets
1602
045160e8ad71 Better help test for build.sh
Rob Landley <rob@landley.net>
parents: 1471
diff changeset
38 echo
045160e8ad71 Better help test for build.sh
Rob Landley <rob@landley.net>
parents: 1471
diff changeset
39 echo "Build stages:"
045160e8ad71 Better help test for build.sh
Rob Landley <rob@landley.net>
parents: 1471
diff changeset
40 sed -n 's/#.*//;s@.*[.]/\([^.]*\)[.]sh.*@\1@p' "$0" | uniq | xargs echo
045160e8ad71 Better help test for build.sh
Rob Landley <rob@landley.net>
parents: 1471
diff changeset
41 echo
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
42
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
43 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
44 fi
941
7dd3fb4dd333 Minor cleanups and comments, introduce check_prerequisite function.
Rob Landley <rob@landley.net>
parents: 915
diff changeset
45 ARCH="$1"
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
46
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
47 # Use environment variables persistently set in the config file.
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
48
1028
5897a868313e Jean-Christophe Dubois pointed out that if build.sh doesn't source config, it doesn't get things like NO_NATIVE_COMPILER.
Rob Landley <rob@landley.net>
parents: 1007
diff changeset
49 [ -e config ] && source config
5897a868313e Jean-Christophe Dubois pointed out that if build.sh doesn't source config, it doesn't get things like NO_NATIVE_COMPILER.
Rob Landley <rob@landley.net>
parents: 1007
diff changeset
50
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
51 # Allow the output directory to be overridden. This hasn't been tested in
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
52 # forever and probably doesn't work.
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
53
984
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
54 [ -z "$BUILD" ] && BUILD="build"
9840847885e8 Add export_if_blank and make lots of build paths overrideable.
Rob Landley <rob@landley.net>
parents: 944
diff changeset
55
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
56 # Very simple dependency tracking: skip stages that have already been done
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
57 # (because the tarball they create is already there).
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
58
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
59 # If you need to rebuild a stage (and everything after it), delete its
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
60 # tarball out of "build" and re-run build.sh.
941
7dd3fb4dd333 Minor cleanups and comments, introduce check_prerequisite function.
Rob Landley <rob@landley.net>
parents: 915
diff changeset
61
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
62 not_already()
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
63 {
1743
10b64f52ad20 Make tweak.sh actually work, and do less unnecessary rebuilding.
Rob Landley <rob@landley.net>
parents: 1740
diff changeset
64 [ "$AGAIN" == "$1" ] && return 0
1458
60f1087591ac Add ability to specify a package to rebuild to build.sh with REBUILD= (and then dependencies take it from there to the system image).
Rob Landley <rob@landley.net>
parents: 1395
diff changeset
65 [ "$REBUILD" == "$1" ] && zap "$1"
60f1087591ac Add ability to specify a package to rebuild to build.sh with REBUILD= (and then dependencies take it from there to the system image).
Rob Landley <rob@landley.net>
parents: 1395
diff changeset
66
1737
1acbe7e78d9d Switch from bz2 to gz tarball output.
Rob Landley <rob@landley.net>
parents: 1730
diff changeset
67 if [ -f "$BUILD/$1-$ARCH.tar.gz" ]
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
68 then
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
69 echo "=== Skipping $1-$ARCH (already there)"
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
70 return 1
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
71 fi
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
72
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
73 return 0
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
74 }
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
75
1350
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
76 zap()
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
77 {
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
78 for i in "$@"
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
79 do
1740
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
80 rm -f "$BUILD/$i-$ARCH.tar.gz"
1350
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
81 done
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
82 }
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
83
1740
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
84 do_stage()
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
85 {
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
86 STAGE="$1"
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
87 shift
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
88
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
89 if [ "$AFTER" == "$STAGE" ]
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
90 then
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
91 unset AFTER
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
92 else
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
93 time ./"$STAGE".sh "$@" || exit 1
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
94 fi
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
95 }
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
96
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
97 # The first two stages (download.sh and host-tools.sh) are architecture
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
98 # independent. In order to allow multiple builds in parallel, re-running
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
99 # them after they've already completed must be a safe NOP.
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
100
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
101 # Download source code.
944
fc134a13357e Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents: 941
diff changeset
102
1740
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
103 do_stage download
944
fc134a13357e Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents: 941
diff changeset
104
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
105 # Build host tools. This populates a single directory with every command the
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
106 # build needs, so we can ditch the host's $PATH afterwards.
944
fc134a13357e Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents: 941
diff changeset
107
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
108 if [ -z "$NO_HOST_TOOLS" ]
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
109 then
1740
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
110 do_stage host-tools
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
111 fi
944
fc134a13357e Largeish refactoring and cleanup of compiler build:
Rob Landley <rob@landley.net>
parents: 941
diff changeset
112
941
7dd3fb4dd333 Minor cleanups and comments, introduce check_prerequisite function.
Rob Landley <rob@landley.net>
parents: 915
diff changeset
113 # Do we need to build the simple cross compiler?
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
114
1816
fb05f99ffcce Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR,
Rob Landley <rob@landley.net>
parents: 1812
diff changeset
115 if [ -z "$MY_CROSS_PATH" ] && not_already simple-cross-compiler
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
116 then
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
117 # 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
118
1755
6f81048998fe The linux-kernel stage got merged back into system-image but build.sh dependencies weren't updated. (Oops.)
Rob Landley <rob@landley.net>
parents: 1743
diff changeset
119 zap root-filesystem cross-compiler native-compiler system-image
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: 998
diff changeset
120
1740
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
121 do_stage simple-cross-compiler "$ARCH"
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
122 fi
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
123
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: 998
diff changeset
124 # Optionally, we can build a more capable statically linked compiler via
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: 998
diff changeset
125 # canadian cross. (It's more powerful than we need here, but if you're going
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: 998
diff changeset
126 # to use the cross compiler in other contexts this is probably what you want.)
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
127
1816
fb05f99ffcce Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR,
Rob Landley <rob@landley.net>
parents: 1812
diff changeset
128 if [ -z "$MY_CROSS_PATH" ] && [ ! -z "$CROSS_COMPILER_HOST" ] &&
1812
acaa88463c0c Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents: 1794
diff changeset
129 not_already cross-compiler
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
130 then
1755
6f81048998fe The linux-kernel stage got merged back into system-image but build.sh dependencies weren't updated. (Oops.)
Rob Landley <rob@landley.net>
parents: 1743
diff changeset
131 zap root-filesystem native-compiler system-image
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
132
1212
19f3be2b4d04 Teach build.sh to build host compiler if necessary for CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1129
diff changeset
133 # Build the host compiler if necessary
19f3be2b4d04 Teach build.sh to build host compiler if necessary for CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1129
diff changeset
134
1350
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
135 if ARCH="$CROSS_COMPILER_HOST" not_already simple-cross-compiler
1212
19f3be2b4d04 Teach build.sh to build host compiler if necessary for CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1129
diff changeset
136 then
1740
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
137 do_stage simple-cross-compiler "$CROSS_COMPILER_HOST"
1212
19f3be2b4d04 Teach build.sh to build host compiler if necessary for CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1129
diff changeset
138 fi
19f3be2b4d04 Teach build.sh to build host compiler if necessary for CROSS_HOST_ARCH.
Rob Landley <rob@landley.net>
parents: 1129
diff changeset
139
1740
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
140 do_stage cross-compiler "$ARCH"
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
141 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
142
1765
feac53ef0d1c Building ELF toolchain with ./build.sh should stop early.
Rob Landley <rob@landley.net>
parents: 1755
diff changeset
143 if ! grep -q KARCH= sources/targets/"$ARCH"
feac53ef0d1c Building ELF toolchain with ./build.sh should stop early.
Rob Landley <rob@landley.net>
parents: 1755
diff changeset
144 then
feac53ef0d1c Building ELF toolchain with ./build.sh should stop early.
Rob Landley <rob@landley.net>
parents: 1755
diff changeset
145 echo no KARCH in $1, stopping here
feac53ef0d1c Building ELF toolchain with ./build.sh should stop early.
Rob Landley <rob@landley.net>
parents: 1755
diff changeset
146 fi
feac53ef0d1c Building ELF toolchain with ./build.sh should stop early.
Rob Landley <rob@landley.net>
parents: 1755
diff changeset
147
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
148 # Build the basic 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
149
1730
7f1b9fb1099e Move simple-root-filesystem.sh to root-filesystem.sh
Rob Landley <rob@landley.net>
parents: 1728
diff changeset
150 if not_already root-filesystem
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
151 then
1728
b89324905ca2 Giant redo to put simple-root-filesystem in initmpfs.
Rob Landley <rob@landley.net>
parents: 1706
diff changeset
152 zap system-image
1755
6f81048998fe The linux-kernel stage got merged back into system-image but build.sh dependencies weren't updated. (Oops.)
Rob Landley <rob@landley.net>
parents: 1743
diff changeset
153 [ "$SYSIMAGE_TYPE" == rootfs ] && zap system-image
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
154
1740
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
155 do_stage root-filesystem "$ARCH"
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
156 fi
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
157
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
158 # Build a native compiler. It's statically linked by default so it can
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
159 # run on an arbitrary host system.
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
160
1793
d461b345c3c9 Build sh2eb for the numato mimas v2. Still a lot of rough edges.
Rob Landley <rob@landley.net>
parents: 1766
diff changeset
161 # Not trying to build nommu native compilers for the moment.
d461b345c3c9 Build sh2eb for the numato mimas v2. Still a lot of rough edges.
Rob Landley <rob@landley.net>
parents: 1766
diff changeset
162
1816
fb05f99ffcce Collate site-local variables under "MY_XXX" prefix: MY_PATCH_DIR,
Rob Landley <rob@landley.net>
parents: 1812
diff changeset
163 if [ -z "$MY_CROSS_PATH" ] && ! grep -q ELF2FLT sources/targets/"$ARCH" &&
1812
acaa88463c0c Add CROSS_COMPILER_PATH and CC_PREFIX knobs.
Rob Landley <rob@landley.net>
parents: 1794
diff changeset
164 not_already native-compiler
1350
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
165 then
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
166 zap system-image
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
167
1740
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
168 do_stage native-compiler "$ARCH"
1350
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
169 fi
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
170
7eabfa815c90 Split up system-image.sh into root-image.sh, linux-kernel.sh, and system-image.sh. Rename CROSS_HOST_ARCH to CROSS_COMPILER_HOST.
Rob Landley <rob@landley.net>
parents: 1228
diff changeset
171 # Package it all up into something qemu can boot.
1128
e5f9681a8b3c Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document.
Rob Landley <rob@landley.net>
parents: 1116
diff changeset
172
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
173 if not_already system-image
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
174 then
1740
258427b0c8be Add more/tweak.sh to rebuild a package in a stage.
Rob Landley <rob@landley.net>
parents: 1739
diff changeset
175 do_stage system-image "$ARCH"
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
176 fi