1. Make compilation of Linux kernel source code
After configuring the Linux kernel using the command "make xxx_defconfig", you can use the "make" or "make all" command to compile.
2. Make process of Linux kernel source code
After configuring the Linux kernel using the command "
make xxx_defconfig "
, you can use " make " or " make all "
command to compile. The top-level
Makefile
has the following code:
125 PHONY := _all
126 _all:
......
192 PHONY += all
193 ifeq ($(KBUILD_EXTMOD),)
194 _all: all
195 else
196 _all: modules
197 endif
......
608 all: vmlinux
Line
126
,
_all
is the default target,
which will be matched if Linux is compiled using the command "
make
" .
Line
193
, if
KBUILD_EXTMOD
is empty, the code in line
194 holds, and the default target
_all
depends
on all
.
Line 608 , the target all depends on vmlinux , so the next focus is vmlinux !
There is the following code in the top-level
Makefile
:
905 export KBUILD_VMLINUX_INIT := $(head-y) $(init-y)
906 export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y)
$(net-y)
907 export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
908 export LDFLAGS_vmlinux
909 # used by scripts/pacmage/Makefile
910 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinuxalldirs)) arch Documentation include samples scripts tools virt)
911
912 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
913
914 # Final link of vmlinux
915 cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS)
$(LDFLAGS_vmlinux)
916 quiet_cmd_link-vmlinux = LINK $@
917
918 # Include targets which we want to
919 # execute if the rest of the kernel build went well.
920 vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE
921 ifdef CONFIG_HEADERS_CHECK
922 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
923 endif
924 ifdef CONFIG_SAMPLES
925 $(Q)$(MAKE) $(build)=samples
926 endif
927 ifdef CONFIG_BUILD_DOCSRC
928 $(Q)$(MAKE) $(build)=Documentation
929 endif
930 ifdef CONFIG_GDB_SCRIPTS
931 $(Q)ln -fsn `cd $(srctree) && /bin/pwd`/scripts/gdb/vmlinuxgdb.py
932 endif
933 +$(call if_changed,link-vmlinux)
As can be seen from the above code:
Line
920
, it can be seen that the target
vmlinux
depends on
scripts/link-vmlinux.sh, $(vmlinux-deps), FORCE
.
Line 912
defines
vmlinux-deps
with the value:
vmlinux-deps= $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
Line
905
,
KBUILD_VMLINUX_INIT= $(head-y) $(init-y)
.
第
906
行,
KBUILD_VMLINUX_MAIN = $(core-y) $(libs-y) $(drivers-y) $(net-y)
。
Line
907
,
KBUILD_LDS= arch/$(SRCARCH)/kernel/vmlinux.lds
, where
SRCARCH=arm
, therefore,
KBUILD_LDS= arch/arm/kernel/vmlinux.lds
To sum up, the dependencies of vmlinux are: scripts/link-vmlinux.sh, $(head-y), $(init-y), $(core-y), $(libs-y), $(drivers- y), $(net-y), arch/arm/kernel/vmlinux.lds and FORCE.
The command on line 933 is used
to
link and generate
vmlinux
.
The next article will focus on
$(head-y)
,
$(init-y)
,
$(core-y)
,
$(libs-y)
,
$(drivers-y)
and $(
net
-y).
the value of a variable.