STAGES.md (5073B)
1 # CLFS Stages 2 3 ## Stage 0 : Initial Setup 4 Will be rebuilt every run 5 6 Process: 7 1. Select build target + configuration 8 2. Write out shell "includes" for exported variables (e.g. source archives, 9 versions, package names) 10 3. Create clfs build user + setup user bashrc with build configuration 11 4. Create clfs build directory + subdirectories 12 5. Download required sources and check source signatures 13 6. Copy required source package build scripts to build directory 14 6. Create linux standard filesystem layout for rootfs 15 16 ### Build Directory Structure 17 ```text 18 /clfs 19 /sources # contains all package sources 20 /init # contains the init scripts for the linux system 21 ... 22 /sysconf # contains linux system configuration files (e.g. fstab, mdev) 23 ... 24 ... # archives of all packages 25 /configs # contains all configuration files 26 f target # the build target (arm, arm64, x86_64, etc) 27 /pkg1 # contains configuration for package 1 28 ... 29 /pkg2 # contains configuration for package 2 30 ... 31 /pkg3 # contains configuration for package 3 32 ... 33 ... 34 /stage1 # cross-toolchain 35 f timestamp # when this stage was last built 36 f pkgindex # the packages (+versions) last used to build this stage 37 /pkgs # contains symlinks to package sources 38 l linux -> ../../sources/linux-x.y.z 39 l libc -> ../../sources/musl-libc-x.y.z 40 l libc++ -> ../../sources/gcc-x.y.z (/libstdc++?) 41 l binutils -> ../../sources/binutils-x.y.z 42 l gmp -> ../../sources/gmp-x.y.z 43 l mpc -> ../../sources/mpc-x.y.z 44 l mpfr -> ../../sources/mpfr-x.y.z 45 l gcc -> ../../sources/gcc-x.y.z 46 /conf # contains symlinks to configuration files 47 -- 48 /steps # contains the steps for the build 49 f 000-started.sh 50 f 010-linux-headers.sh 51 f 020-binutils-pass1.sh 52 f 030-gcc-pass1.sh 53 f 040-xtools-libc.sh 54 f 050-xtools-libc++.sh 55 f 060-binutils-pass2.sh 56 f 070-gcc-pass2.sh 57 f 999-finished.sh 58 /build # contains the output of the build 59 -- 60 /stage2 # minimal build environment (cross-compiled using stage1) 61 f timestamp 62 f pkgindex 63 /pkgs 64 l linux -> ../../sources/linux-x.y.z 65 l libc -> ../../sources/musl-libc-x.y.z 66 l libc++ -> ../../sources/gcc-x.y.z (/libstdc++?) 67 l zlib -> ../../sources/zlib-x.y.z 68 l busybox (toybox?) -> ../../sources/busybox-x.y.z 69 l iana -> ../../sources/iana-x.y.z 70 l init -> ../../sources/init 71 l sysconf -> ../../sources/sysconf 72 l binutils -> ../../sources/binutils-x.y.z 73 l gmp -> ../../sources/gmp-x.y.z 74 l mpc -> ../../sources/mpc-x.y.z 75 l mpfr -> ../../sources/mpfr-x.y.z 76 l gcc -> ../../sources/gcc-x.y.z 77 l make -> ../../sources/make-x.y.z 78 l uboot -> ../../sources/uboot-x.y.z 79 /conf 80 l linux-config -> ../../configs/$TGT-linux-config 81 l uboot-config -> ../../configs/$TGT-uboot-config 82 l busybox-config -> ../../configs/$TGT-busybox-config 83 /steps 84 f 000-started.sh 85 f 010-linux-headers.sh 86 f 020-libc.sh 87 f 030-libc++.sh 88 f 040-zlib.sh 89 f 050-busybox.sh 90 f 060-sysconf.sh 91 f 070-iana.sh 92 f 080-init.sh 93 f 090-binutils.sh 94 f 100-gcc.sh 95 f 110-make.sh 96 f 120-linux.sh 97 f 130-uboot.sh 98 f 999-finished.sh 99 /build 100 -- 101 /stage3 # base system (natively compiled under stage2) 102 f timestamp 103 f pkgindex 104 /pkgs 105 /conf 106 /steps 107 /build 108 /stage4 # custom system (natively compiled under stage3) 109 f timestamp 110 f pkgindex 111 /pkgs 112 /conf 113 /steps 114 /build 115 ``` 116 117 ## Stage 1 : The Cross-Toolchain 118 Once built, can be reused until its scripts change or user requests rebuild 119 120 Required Packages: 121 1. Linux 122 2. Libc (musl) 123 3. Libc++ (libstdc++) 124 4. Binutils 125 5. GMP 126 6. MPC 127 7. MPFR 128 8. GCC 129 130 Process: 131 1. Extract linux headers for target arch 132 2. Build static no-libc x-binutils to build libc 133 3. Build static no-libc x-gcc to build libc 134 4. Build libc 135 5. Build libc++ 136 6. Build final x-binutils 137 7. Build final x-gcc 138 8. Update build users .bashrc to register new tools 139 140 ## Stage 2 : The Minimal Build Environment 141 Should be rebuilt every run 142 143 Required Packages: 144 1. Linux 145 2. Libc (musl) 146 3. Libc++ (libstdc++) 147 4. Zlib 148 5. Busybox (toybox?) 149 6. Sysconfig 150 7. IANA 151 8. Bootscripts 152 9. Binutils 153 10. GMP 154 11. MPC 155 12. MPFR 156 13. GCC 157 14. Make 158 15. Uboot 159 160 Process: 161 1. Extract linux header for target arch 162 2. Cross compile libc 163 3. Cross compile libc++ 164 4. Cross compile zlib 165 5. Cross compile busybox (toybox?) 166 6. Install system configuration files 167 7. Install IANA data 168 8. Install bootscripts 169 9. Cross compile binutils 170 10. Cross compile GCC 171 11. Cross compile make 172 12. Cross compile linux kernel for target arch 173 13. Cross compile uboot for target arch 174 175 010-linux-headers.sh 176 020-libc.sh 177 030-libc++.sh 178 040-zlib.sh 179 050-busybox.sh 180 060-sysconf.sh 181 070-iana.sh 182 080-init.sh 183 090-binutils.sh 184 100-gcc.sh 185 110-make.sh 186 120-linux.sh 187 130-uboot.sh 188 189 ## Stage 3 : The Base System 190 Should be rebuilt every run 191 192 ## Stage 4 : The Custom System 193 Should be rebuilt every run 194