1. Realizar una compilación del código fuente del kernel de Linux.
Después de configurar el kernel de Linux usando el comando "make xxx_defconfig", puede usar el comando "make" o "make all" para compilar.
2. Crear proceso del código fuente del kernel de Linux
Después de configurar el kernel de Linux usando el comando "
make xxx_defconfig "
, puede usar " make " o " make all "
comando para compilar.
El Makefile
de nivel superior
tiene el siguiente código:
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
Línea
126
,
_all
es el destino predeterminado,
que coincidirá si Linux se compila usando el comando "
make
" .
Línea
193
, si
KBUILD_EXTMOD
está vacío, el código de la línea
194 se mantiene y el destino predeterminado
_all
depende
de all
.
Línea 608 , todo el objetivo depende de vmlinux , por lo que el siguiente enfoque es vmlinux .
Existe el siguiente código en el Makefile
de nivel superior
:
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)
Como se puede ver en el código anterior:
Línea
920
, se puede ver que el
vmlinux de destino
depende de
scripts/link-vmlinux.sh, $(vmlinux-deps), FORCE
.
La línea 912
define
vmlinux-deps
con el valor:
vmlinux-deps= $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
Línea
905
,
KBUILD_VMLINUX_INIT= $(head-y) $(init-y)
.
Ejemplo
906
,
KBUILD_VMLINUX_MAIN = $(core-y) $(libs-y) $(drivers-y) $(net-y)
。
Línea
907
,
KBUILD_LDS= arch/$(SRCARCH)/kernel/vmlinux.lds
, donde
SRCARCH=arm
, por lo tanto,
KBUILD_LDS= arch/arm/kernel/vmlinux.lds
En resumen, las dependencias de vmlinux son: scripts/link-vmlinux.sh, $(head-y), $(init-y), $(core-y), $(libs-y), $(drivers- y), $(net-y), arch/arm/kernel/vmlinux.lds y FORCE.
El comando en la línea 933 se usa
para
vincular y generar
vmlinux
.
El próximo artículo se centrará en
$(head-y)
,
$(init-y)
,
$(core-y)
,
$(libs-y)
,
$(drivers-y)
y $(
net
-y).