Linux Kernel Compile
1. Compile
1.1. Clean
make clean: Deletes most files generated during build except the.configfile. The.configfile is the config file used in previous kernel compilation.make mrproper: Deletes all files generated during build including the.configfile and config-related backup files.make distclean: Performsmrproperand additionally deletes editor backup files and patch files.
1.2. Configuration
make config: Sets config in a question-and-answer format.make menuconfig: Sets config using an Ncurses (Text)-based GUI. When using a config file from a previous kernel version, if additional settings are needed, they are set to default values.make xconfig: Sets config using a QT (X-Window)-based GUI. When using a config file from a previous kernel version, if additional settings are needed, they are set to default values.make oldconfig: Uses an existing.configfile. When using a config file from a previous kernel version, if additional settings are needed, it asks the user for configuration methods in a question-and-answer format.
1.3. Build
make zImage: Compiles the kernel and creates a compressedzImagefile.make uImage: Creates azImagefile and then creates auImagefile used by u-boot. Themkimagetool must be installed. On Ubuntu, install theuboot-mkimagepackage.make modules: Compiles modules.
1.4. Install
make install: Creates an initrd image, copiesvmlinuzandSystem.mapfiles to/boot, creates symbolic links, and modifiesgrub.confappropriately so that it can boot with the new kernel image.make modules_install: Stores compiled modules in the$INSTALL_MOD_PATH/lib/modules/[kernel version]folder. You can change the copy location by setting the$INSTALL_MOD_PATHvariable in the shell. If$INSTALL_MOD_PATHis not set, they are copied under thelibfolder of /(root).
1.5. E.T.C
make tags: Createsctagsfiles.make cscope: Createscscopefiles.make help: Shows make targets and descriptions.
2. Example
2.1. ARM
$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make menuconfig
$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make zImage
$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make uImage
$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make modules
$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=tmp make modules_install