1*4882a593Smuzhiyun// -*- mode:doc; -*- 2*4882a593Smuzhiyun// vim: set syntax=asciidoc: 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun== How Buildroot works 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunAs mentioned above, Buildroot is basically a set of Makefiles that 7*4882a593Smuzhiyundownload, configure, and compile software with the correct options. It 8*4882a593Smuzhiyunalso includes patches for various software packages - mainly the ones 9*4882a593Smuzhiyuninvolved in the cross-compilation toolchain (+gcc+, +binutils+ and 10*4882a593Smuzhiyun+uClibc+). 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunThere is basically one Makefile per software package, and they are 13*4882a593Smuzhiyunnamed with the +.mk+ extension. Makefiles are split into many different 14*4882a593Smuzhiyunparts. 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun* The +toolchain/+ directory contains the Makefiles 17*4882a593Smuzhiyun and associated files for all software related to the 18*4882a593Smuzhiyun cross-compilation toolchain: +binutils+, +gcc+, +gdb+, 19*4882a593Smuzhiyun +kernel-headers+ and +uClibc+. 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun* The +arch/+ directory contains the definitions for all the processor 22*4882a593Smuzhiyun architectures that are supported by Buildroot. 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun* The +package/+ directory contains the Makefiles and 25*4882a593Smuzhiyun associated files for all user-space tools and libraries that Buildroot 26*4882a593Smuzhiyun can compile and add to the target root filesystem. There is one 27*4882a593Smuzhiyun sub-directory per package. 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun* The +linux/+ directory contains the Makefiles and associated files for 30*4882a593Smuzhiyun the Linux kernel. 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun* The +boot/+ directory contains the Makefiles and associated files for 33*4882a593Smuzhiyun the bootloaders supported by Buildroot. 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun* The +system/+ directory contains support for system integration, e.g. 36*4882a593Smuzhiyun the target filesystem skeleton and the selection of an init system. 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun* The +fs/+ directory contains the Makefiles and 39*4882a593Smuzhiyun associated files for software related to the generation of the 40*4882a593Smuzhiyun target root filesystem image. 41*4882a593Smuzhiyun 42*4882a593SmuzhiyunEach directory contains at least 2 files: 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun* +something.mk+ is the Makefile that downloads, configures, 45*4882a593Smuzhiyun compiles and installs the package +something+. 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun* +Config.in+ is a part of the configuration tool 48*4882a593Smuzhiyun description file. It describes the options related to the 49*4882a593Smuzhiyun package. 50*4882a593Smuzhiyun 51*4882a593SmuzhiyunThe main Makefile performs the following steps (once the 52*4882a593Smuzhiyunconfiguration is done): 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun* Create all the output directories: +staging+, +target+, +build+, 55*4882a593Smuzhiyun etc. in the output directory (+output/+ by default, 56*4882a593Smuzhiyun another value can be specified using +O=+) 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun* Generate the toolchain target. When an internal toolchain is used, this 59*4882a593Smuzhiyun means generating the cross-compilation toolchain. When an external 60*4882a593Smuzhiyun toolchain is used, this means checking the features of the external 61*4882a593Smuzhiyun toolchain and importing it into the Buildroot environment. 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun* Generate all the targets listed in the +TARGETS+ variable. This 64*4882a593Smuzhiyun variable is filled by all the individual components' 65*4882a593Smuzhiyun Makefiles. Generating these targets will trigger the compilation of 66*4882a593Smuzhiyun the userspace packages (libraries, programs), the kernel, the 67*4882a593Smuzhiyun bootloader and the generation of the root filesystem images, 68*4882a593Smuzhiyun depending on the configuration. 69*4882a593Smuzhiyun 70