comparison www/build-stages.html @ 1826:1ba206595781 draft

Update build-stages.html documentation.
author Rob Landley <rob@landley.net>
date Wed, 09 Dec 2015 15:28:51 -0600
parents 3a66b5554d1e
children
comparison
equal deleted inserted replaced
1825:2dd2e648c2ae 1826:1ba206595781
16 boot the resulting system image under QEMU, configured for use as a 16 boot the resulting system image under QEMU, configured for use as a
17 development environment. Type <b>exit</b> to shut down the emulator.</p> 17 development environment. Type <b>exit</b> to shut down the emulator.</p>
18 18
19 <h2>Overview</h2> 19 <h2>Overview</h2>
20 20
21 <p>The build runs the following stages, in order:</p> 21 <p><b>build.sh</b> runs the following stages, in order:</p>
22 22
23 <ul> 23 <ul>
24 <li><b>download.sh</b> - Download source packages used by the rest of the build.</li> 24 <li><p><b>download.sh</b> - Download source packages used by the rest of the build.</p></li>
25 <li><b>host-tools.sh</b> - Build prerequisites host needs to run remaining stages.</li> 25 <li><p><b>host-tools.sh</b> - Build prerequisites host needs to run remaining stages.</p></li>
26 <li><b>simple-cross-compiler.sh</b> - Build cross compiler for selected target architecture.</li> 26 <li><p><b>simple-cross-compiler.sh</b> - Build cross compiler for selected target architecture.</p></li>
27 <li><b>[</b>cross-compiler.sh<b>]</b> - optionally produce a more portable 27 <li><p><b>[</b>cross-compiler.sh<b>]</b> - optionally produce a more portable
28 cross compiler (not needed by rest of build, but <a href=bin/>released as 28 cross compiler which can be <a href=bin/>packaged as a tarball</a> for use
29 a tarball</a>).</li> 29 elsewhere. This stage is skipped unless CROSS_COMPILER_HOST is set (usually
30 <li><b>native-compiler.sh</b> - Build native compiler to install/run on target.</li> 30 to i686 or x86_64).</p></li>
31 <li><b>root-filesystem.sh</b> - Build simple initramfs filesystem, just enough to boot to a shell prompt.</li> 31 <li><p><b>root-filesystem.sh</b> - Build simple initramfs filesystem, just enough to boot to a shell prompt.</p></li>
32 <li><b>system-image.sh</b> - Build bootable linux kernel and package together filesystem image and kernel with scripts to launch them under an emulator.</li> 32 <li><p><b>native-compiler.sh</b> - Build native compiler to install/run on target.</p></li>
33 <li><p><b>system-image.sh</b> - Build bootable linux kernel and package together filesystem image and kernel with scripts to launch them under an emulator.</p></li>
33 </ul> 34 </ul>
34 35
35 <p>The top level wrapper script <b>build.sh</b> runs the above stages in order, 36 <p>The top level wrapper script <b>build.sh</b> runs the above stages in order,
36 but each stage script can also be run individually. Each of the above 37 but each stage script can also be run individually. Each of the above
37 build scripts (except download.sh and host-tools.sh) take a single argument: 38 build scripts (except download.sh and host-tools.sh) take a single argument:
53 <b>rm -rf build packages</b> from the top level directory.</p> 54 <b>rm -rf build packages</b> from the top level directory.</p>
54 55
55 <p>None of these scripts need to be run as root -- an explicit design goal of 56 <p>None of these scripts need to be run as root -- an explicit design goal of
56 Aboriginal Linux is that root access on the host is never required.</p> 57 Aboriginal Linux is that root access on the host is never required.</p>
57 58
58 <h2>Build stages</h2> 59 <h2>Files</h2>
59 60
60 <p>The files in the top level directory of the Aboriginal Linux source 61 <p>The files in the top level directory of the Aboriginal Linux source
61 are:</p> 62 are:</p>
62 63
63 <ul> 64 <ul>
122 system images offer a sufficient development environment to rebuild themselves 123 system images offer a sufficient development environment to rebuild themselves
123 from source, because the host tool versions used to build them in the first 124 from source, because the host tool versions used to build them in the first
124 place are the same ones the scripts install into the target root filesystem.</p> 125 place are the same ones the scripts install into the target root filesystem.</p>
125 126
126 <p>This script populates the "build/host" directory, which is automatically 127 <p>This script populates the "build/host" directory, which is automatically
127 <p>used by later stages if it exists. It is not target specific, and only 128 used by later stages if it exists. It is not target specific, and only
128 <p>needs to be run once when building multiple architectures.</p> 129 needs to be run once when building multiple architectures.</p>
129 </blockquote> 130 </blockquote>
130 </li> 131 </li>
131 132
132 <li><b>simple-cross-compiler.sh $TARGET</b> 133 <li><b>simple-cross-compiler.sh $TARGET</b>
133 134
157 CROSS_COMPILER_HOST is set, indicating which host architecture to build for. 158 CROSS_COMPILER_HOST is set, indicating which host architecture to build for.
158 (For PC hardware, i686 is a good choice, since most 64 bit PCs can run static 159 (For PC hardware, i686 is a good choice, since most 64 bit PCs can run static
159 32 bit code. If you run "./cross-comiler.sh $TARGET" manually without setting 160 32 bit code. If you run "./cross-comiler.sh $TARGET" manually without setting
160 CROSS_COMPILER_HOST, it defaults to i686.)</p> 161 CROSS_COMPILER_HOST, it defaults to i686.)</p>
161 162
162 <p>This compiler is statically linked against uClibc, for maximum 163 <p>This compiler is statically linked against musl-libc, for maximum
163 portability. (You can set BUILD_STATIC=none to dynamically link instead, 164 portability. (You can set BUILD_STATIC=none to dynamically link instead,
164 but then have to install uClibc's shared libraries on the host.)</p> 165 but then have to install musl's shared libraries on the host.)</p>
165 </blockquote>
166 </li>
167
168 <li><b>native-compiler.sh $TARGET</b>
169
170 <blockquote>
171 <p>This step creates a compiler for the selected target, using one
172 or more of the existing simple cross compilers. The compiler it produces
173 runs on the target and produces programs that also run on the target.</p>
174
175 <p>By default this compiler is statically linked so you can add it to an
176 existing target root filesystem. Use BUILD_STATIC=none to disable this.</p>
177
178 <p>This compiler includes binutils, gcc, musl, make, bash, and distcc. Because
179 it's a native compiler, the executable names do not have prefixes the
180 way the cross compilers do. (I.E. just "ld" instead of "$TARGET-ld".)</p>
181 </blockquote> 166 </blockquote>
182 </li> 167 </li>
183 168
184 <li><b>root-filesystem.sh $TARGET</b> 169 <li><b>root-filesystem.sh $TARGET</b>
185 170
188 which contains just enough infrastructure to boot up to a shell prompt. 173 which contains just enough infrastructure to boot up to a shell prompt.
189 By default this is packaged as an initramfs, see SYSIMAGE_TYPE in config 174 By default this is packaged as an initramfs, see SYSIMAGE_TYPE in config
190 to see other available filesystem types.</p> 175 to see other available filesystem types.</p>
191 176
192 <p>This creates empty directories, copies the skeleton files from 177 <p>This creates empty directories, copies the skeleton files from
193 sources/root-filesystem, adds the contents of the directory $ROOT_OVERLAY 178 sources/root-filesystem, builds toybox, and finally adds the contents
194 points to (if any), and builds toybox.</p> 179 of the directory $MY_OVERLAY points to (if any). On appropriate hardware
195 <p> 180 (or with an appropriate emulator), you should be able to chroot into this.</p>
196 <p>The config variable ROOT_OVERLAY can add arbitrary files to this stage.</p> 181 </blockquote>
182 </li>
183
184 <li><b>native-compiler.sh $TARGET</b>
185
186 <blockquote>
187 <p>This step creates a compiler for the selected target, using one
188 or more of the existing simple cross compilers. The compiler it produces
189 runs on the target and produces programs that also run on the target.</p>
190
191 <p>By default this compiler is statically linked so you can add it to an
192 existing target root filesystem. Use BUILD_STATIC=none to disable this.</p>
193
194 <p>This compiler includes binutils, gcc, musl, make, bash, and distcc. Because
195 it's a native compiler, the executable names do not have prefixes the
196 way the cross compilers do. (I.E. just "ld" instead of "$TARGET-ld".)</p>
197 </blockquote> 197 </blockquote>
198 </li> 198 </li>
199 199
200 <li><b>system-image.sh $TARGET</b> 200 <li><b>system-image.sh $TARGET</b>
201 <blockquote> 201 <blockquote>
202 <p>Packages up the root-filesystem (usually as a cpio.gz for initramfs), 202 <p>This does three things:</p>
203 builds a linux kernel (generally configured 203 <ul>
204 for use with QEMU), and adds emulator launch scripts.</p> 204 <li><p>Packages up the root-filesystem (the default is cpio.gz for initramfs,
205 205 see SYSIMAGE_TYPE in config for alternatives) and the native-compiler
206 <p>The kernel configuration combines the sources/baseconfig-linux settings 206 (as a squashfs).</p></li>
207 <li><p>Adds emulator launch scripts (usually for QEMU), see the
208 <a href=<about.html#sysimage_use>About page</a> for details.</p></li>
209 <li><p>Builds a linux kernel, generally configured for use with QEMU).</p></li>
210
211 <p>The <b>mini.config</b> file is the kernel configuration in
212 <a href=http://landley.net/aboriginal/FAQ.html#miniconfig>miniconfig</a>
213 format (I.E. start from 'allnoconfig' and list the symbols you'd need to
214 switch on in menuconfig, allowing that to resolve dependencies as it goes).
215 It's created by combining the sources/baseconfig-linux settings
207 (which are the same for each $TARGET) with the target-specific LINUX_CONFIG 216 (which are the same for each $TARGET) with the target-specific LINUX_CONFIG
208 entries from sources/targets/$TARGET. This configuration mechanism 217 entries from sources/targets/$TARGET. This gives you a starting point
209 (<a href=http://landley.net/aboriginal/FAQ.html#miniconfig>miniconfig</a>) 218 to build your own kernel and package up root-filoesystem in your own way
210 essentially starts with "allnoconfig" and then switches on each mentioned 219 if you want to bypass the system-image.sh stage.</p>
211 symbol, resolving dependencies as it goes, just as if you opened up menuconfig
212 and set that list of symbols by hand.</p>
213
214 <p>You can also build your own kernel outside of this build system, using
215 the root-filesystem directory as your initramfs source.</p>
216
217 <p>For more information on system images and launch scripts, see the
218 <a href=prebuilt-binaries.html>the binary docs</a></p>
219 </blockquote> 220 </blockquote>
220 </li> 221 </li>
221 </ul> 222 </ul>
222 223
223 <p>The sources/more directory contains additional scripts the user can run, 224 <p>The <b>sources/</b> directory contains infrastructure, defining variables
224 but which are not called from build.sh. This directory contains the external 225 and shell functions used by the rest of the build. Most prominently, the
225 user interfaces the user can call directly which are not build stages. 226 the shell functions "<b>setupfor</b>" prepares a temporary copy of
226 See more/README in the Aboriginal source code for details.</p> 227 the source (extract and patch the relevant source tarballs and cd into the
227 228 directory), and the shell function "<b>cleanup</b>" deletes that temporary copy
228 <p>The native-build.sh script in each system-image, and the 229 when finished. (The actual implementation has
229 more/native-build-from-build.sh script, use <a href=control-images>build 230 <a href=FAQ.html#debug_source>some optimizations</a> you can usually ignore.)
231 The function "<b>build_section</b>" does both and calls a build script from
232 sources/sections in between (see sources/sections/README for details).</p>
233
234 <p>The <b>sources/targets/</b> directory contains all target-specific
235 information. Each target has a single file defining all target-specific
236 information, and adding a target just means adding a file to this directory.</p>
237
238 <p>The <b>more/</b> directory contains all the additional scripts the user may
239 want to run directly, but which aren't build stages.</p>
240
241 <p>The <b>more/native-build-from-build.sh</b> script (which calls the
242 native-build.sh script in a system-image) uses <a href=control-images>build
230 control images</a>, externally supplied filesystem images (usually squashfs) 243 control images</a>, externally supplied filesystem images (usually squashfs)
231 the system image's init script automatically mounts on /mnt. If the file 244 which the system image's init script automatically mount on /mnt. Then if the
232 /mnt/init exists (I.E. an executable "init" script at the top of the 245 file /mnt/init exists (I.E. an executable "init" script at the top of the
233 build control image), the system image init script will run that file instead 246 build control image), the system image init script will run that file instead
234 of dropping to a shell prompt. This allows arbitrary automated behavior 247 of dropping to a shell prompt. This allows arbitrary automated behavior
235 out of the newly booted image, operating on supplied data.</p> 248 out of the newly booted image, operating on supplied data.</p>
236 249
237 <!--#include file="footer.html" --> 250 <!--#include file="footer.html" -->