Mercurial > hg > aboriginal
comparison host-tools.sh @ 796:5f793a1ca658
Teach host-tools.sh to create multiple symlinks in fallback directories for ccache and distcc.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 07 Aug 2009 23:52:55 -0500 |
parents | b364ed2adf49 |
children | e2fc10ede93f |
comparison
equal
deleted
inserted
replaced
795:c1bf33329d1f | 796:5f793a1ca658 |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Get lots of predefined environment variables and shell functions. | 3 # This script sets up a known host environment. It serves a similar purpose |
4 # to the temporary chroot system in Linux From Scratch chapter 5, isolating | |
5 # the new build from the host system so information from the host doesn't | |
6 # accidentally leak into the target. | |
7 | |
8 # This script populates a build/host directory with busybox and symlinks to | |
9 # the host's toolchain, then adds the other packages (genext2fs, e2fsprogs, | |
10 # squashfs-tools, distcc, and qemu) that might be needed to package and run | |
11 # a system image. This lets the rest of the build run with the $PATH pointing | |
12 # at the new build/host directory and nothing else. | |
13 | |
14 # The tools provided by this stage are as similar as possible to the ones | |
15 # provided in the final system image. The fact the system can build under | |
16 # these tools is a good indication that it should be able to rebuild itself | |
17 # under itself. | |
18 | |
19 # This script is optional. The build runs fine without it, assuming the | |
20 # host has all the necessary packages installed and doesn't have any extra | |
21 # packages (such as libtool, pkg-config, python...) that might provide | |
22 # false information to autoconf or attach themselves as dependencies to | |
23 # the newly generated programs. (In practice, this can be quite fiddly.) | |
4 | 24 |
5 source sources/include.sh || exit 1 | 25 source sources/include.sh || exit 1 |
6 | 26 |
7 echo -e "$HOST_COLOR" | 27 echo -e "$HOST_COLOR" |
8 echo "=== Building $STAGE_NAME" | 28 echo "=== Building $STAGE_NAME" |
117 # Create symlinks to the host toolchain. We need a usable existing host | 137 # Create symlinks to the host toolchain. We need a usable existing host |
118 # toolchain in order to build anything else (even a new host toolchain), | 138 # toolchain in order to build anything else (even a new host toolchain), |
119 # and we don't really want to have to care what the host type is, so | 139 # and we don't really want to have to care what the host type is, so |
120 # just use the toolchain that's already there. | 140 # just use the toolchain that's already there. |
121 | 141 |
142 # This is a little more complicated than it needs to be, because the host | |
143 # toolchain may be using ccache and/or distcc, which means we need every | |
144 # instance of these tools that occurs in the $PATH, in order, each in its | |
145 # own fallback directory. | |
146 | |
122 for i in ar as nm cc make ld gcc | 147 for i in ar as nm cc make ld gcc |
123 do | 148 do |
124 [ ! -f "${HOSTTOOLS}/$i" ] && | 149 if [ ! -f "${HOSTTOOLS}/$i" ] |
125 (ln -sf `PATH="$OLDPATH" $HOSTTOOLS/which $i` "${HOSTTOOLS}/$i" || dienow) | 150 then |
151 # Loop through each instance, populating fallback directories. | |
152 | |
153 X=0 | |
154 FALLBACK="$HOSTTOOLS" | |
155 PATH="$OLDPATH" "$HOSTTOOLS/which" -a "$i" | while read j | |
156 do | |
157 mkdir -p "$FALLBACK" && | |
158 ln -sf "$j" "$FALLBACK/$i" || dienow | |
159 | |
160 X=$[$X+1] | |
161 FALLBACK="$HOSTTOOLS/fallback-$X" | |
162 done | |
163 fi | |
126 done | 164 done |
127 | 165 |
128 # We now have all the tools we need in $HOSTTOOLS, so trim the $PATH to | 166 # We now have all the tools we need in $HOSTTOOLS, so trim the $PATH to |
129 # remove the old ones. | 167 # remove the old ones. |
130 | 168 |
131 PATH="${HOSTTOOLS}" | 169 PATH="$(hosttools_path)" |
132 fi | 170 fi |
133 | 171 |
134 # This is optionally used by root-filesystem to accelerate native builds when | 172 # This is optionally used by root-filesystem to accelerate native builds when |
135 # running under qemu. It's not used to build root-filesystem, or to build | 173 # running under qemu. It's not used to build root-filesystem, or to build |
136 # the cross compiler, but it needs to be on the host system in order to | 174 # the cross compiler, but it needs to be on the host system in order to |