Mercurial > hg > aboriginal
comparison host-tools.sh @ 352:1782b77fae15
Add command logging. Set RECORD_COMMANDS=1 to log every command line run
by the build into log files named "build/cmdlines.$STAGE.$PACKAGE".
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 02 Jul 2008 22:37:41 -0500 |
parents | 595332f94fea |
children | f6e1d29086c1 |
comparison
equal
deleted
inserted
replaced
351:7f529baf0b57 | 352:1782b77fae15 |
---|---|
12 NO_ARCH=1 | 12 NO_ARCH=1 |
13 source include.sh | 13 source include.sh |
14 | 14 |
15 mkdir -p "${HOSTTOOLS}" || dienow | 15 mkdir -p "${HOSTTOOLS}" || dienow |
16 | 16 |
17 # Here are the utilities the build needs that this script doesn't | 17 # If we want to record the host command lines, so we know exactly what commands |
18 # build, but which me must instead use from the host system. | 18 # the build uses. |
19 | 19 |
20 # The first seven are from packages already in mini-native. | 20 if [ ! -z "$RECORD_COMMANDS" ] |
21 # The last six need to be added to toybox. (The build breaks if we use | 21 then |
22 # the busybox-1.2.2 versions.) | 22 echo setup wrapdir |
23 | 23 |
24 for i in ar as nm cc gcc make ld bzip2 find install od sort diff wget | 24 # Build the wrapper and install it into build/wrapdir/wrappy |
25 do | 25 rm -rf "$BUILD/wrapdir" |
26 [ ! -f "${HOSTTOOLS}/$i" ] && (ln -s `which $i` "${HOSTTOOLS}/$i" || dienow) | 26 mkdir "$BUILD/wrapdir" && |
27 done | 27 $CC -Os "$SOURCES/toys/wrappy.c" -o "$BUILD/wrapdir/wrappy" || dienow |
28 | 28 |
29 # Build toybox | 29 # Loop through each $PATH element and create a symlink to the wrapper with |
30 if [ ! -f "${HOSTTOOLS}/toybox" ] | 30 # that name. |
31 then | |
32 setupfor toybox && | |
33 make defconfig && | |
34 make install_flat PREFIX="${HOSTTOOLS}" && | |
35 cd .. | |
36 | 31 |
37 cleanup toybox | 32 for i in $(echo $PATH | sed 's/:/ /g') |
33 do | |
34 for j in $(ls $i) | |
35 do | |
36 ln -s wrappy "$BUILD/wrapdir/$j" | |
37 done | |
38 done | |
39 | |
40 # Adjust things to use wrapper directory | |
41 | |
42 export WRAPPY_REALPATH="$PATH" | |
43 PATH="$BUILD/wrapdir" | |
44 | |
45 # If we're not recording the host command lines, then populate a directory | |
46 # with host versions of all the command line utilities we're going to install | |
47 # into mini-native. When we're done, PATH can be set to include just this | |
48 # directory and nothing else. | |
49 | |
50 # This serves three purposes: | |
51 # | |
52 # 1) Enumerate exactly what we need to build the system, so we can make sure | |
53 # mini-native has everything it needs to rebuild us. If anything is missing | |
54 # from this list, the resulting mini-native probably won't have it either, | |
55 # so it's nice to know as early as possible that we actually needed it. | |
56 # | |
57 # 2) Quick smoke test that the versions of the tools we're using can compile | |
58 # everything from source correctly, and thus mini-native should be able to | |
59 # rebuild from source using those same tools. | |
60 # | |
61 # 3) Reduce variation from distro to distro. The build always uses the | |
62 # same command line utilities no matter where we're running, because we | |
63 # provide our own. | |
64 | |
65 else | |
66 | |
67 # Start by creating symlinks to the host toolchain, since we need to use | |
68 # that to build anything else. We build a cross compiler, and a native | |
69 # compiler for the target, but we don't build a host toolchain. We use the | |
70 # one that's already there. | |
71 | |
72 for i in ar as nm cc gcc make ld | |
73 do | |
74 [ ! -f "${HOSTTOOLS}/$i" ] && (ln -s `which $i` "${HOSTTOOLS}/$i" || dienow) | |
75 done | |
76 | |
77 # These commands need to be added to toybox. The build breaks if we use | |
78 # the busybox-1.2.2 versions, where available. I'm working to remove this | |
79 # hunk... | |
80 | |
81 for i in bzip2 find install od diff wget | |
82 do | |
83 [ ! -f "${HOSTTOOLS}/$i" ] && (ln -s `which $i` "${HOSTTOOLS}/$i" || dienow) | |
84 done | |
85 | |
86 # Build toybox | |
87 | |
88 if [ ! -f "${HOSTTOOLS}/toybox" ] | |
89 then | |
90 setupfor toybox && | |
91 make defconfig && | |
92 make install_flat PREFIX="${HOSTTOOLS}" && | |
93 cd .. | |
94 | |
95 cleanup toybox | |
96 fi | |
97 | |
98 # Build busybox | |
99 | |
100 # Yes this is an old version of busybox. (It's the last version I released | |
101 # as busybox maintainer.) We're gradually replacing busybox with toybox, one | |
102 # command at a time. | |
103 | |
104 if [ ! -f "${HOSTTOOLS}/busybox" ] | |
105 then | |
106 setupfor busybox && | |
107 cp "${SOURCES}/config-busybox" .config && | |
108 yes "" | make oldconfig && | |
109 make && | |
110 cp busybox "${HOSTTOOLS}" | |
111 | |
112 [ $? -ne 0 ] && dienow | |
113 | |
114 for i in $(sed 's@.*/@@' busybox.links) | |
115 do | |
116 ln -s busybox "${HOSTTOOLS}"/$i || dienow | |
117 done | |
118 cd .. | |
119 | |
120 cleanup busybox | |
121 fi | |
38 fi | 122 fi |
39 | 123 |
40 # Yes this is an old version of busybox. (It's the last version I released | |
41 # as busybox maintainer.) We're gradually replacing busybox with toybox, one | |
42 # command at a time. | |
43 | |
44 # Build busybox | |
45 if [ ! -f "${HOSTTOOLS}/busybox" ] | |
46 then | |
47 setupfor busybox && | |
48 cp "${SOURCES}/config-busybox" .config && | |
49 yes "" | make oldconfig && | |
50 make && | |
51 cp busybox "${HOSTTOOLS}" | |
52 | |
53 [ $? -ne 0 ] && dienow | |
54 | |
55 for i in $(sed 's@.*/@@' busybox.links) | |
56 do | |
57 ln -s busybox "${HOSTTOOLS}"/$i || dienow | |
58 done | |
59 cd .. | |
60 | |
61 cleanup busybox | |
62 fi | |
63 | 124 |
64 # This is optionally used by mini-native to accelerate native builds when | 125 # This is optionally used by mini-native to accelerate native builds when |
65 # running under qemu. It's not used to build mini-native, or to build | 126 # running under qemu. It's not used to build mini-native, or to build |
66 # the cross compiler, but it needs to be on the host system in order to | 127 # the cross compiler, but it needs to be on the host system in order to |
67 # use the distcc acceleration trick. | 128 # use the distcc acceleration trick. |
111 #cp mksquashfs unsquashfs "${HOSTTOOLS}" && | 172 #cp mksquashfs unsquashfs "${HOSTTOOLS}" && |
112 #cd .. | 173 #cd .. |
113 # | 174 # |
114 #cleanup squashfs | 175 #cleanup squashfs |
115 | 176 |
177 if [ ! -z "$RECORD_COMMANDS" ] | |
178 then | |
179 # Add the host tools we just built to wrapdir | |
180 for j in $(ls "$HOSTTOOLS") | |
181 do | |
182 ln -s wrappy "$BUILD/wrapdir/$j" | |
183 done | |
184 fi | |
185 | |
116 echo -e "\e[32mHost tools build complete.\e[0m" | 186 echo -e "\e[32mHost tools build complete.\e[0m" |