????????
????????????????????????????????????????????????? Linux ?????????????????????????????а?????????????????????????·????????make ?????????
???????????????????????Makefile ?????????????????????????????????????????????? Makefile ?????????1591 ?д?????????д???????????????4.2.0???????????汾 ???
??????? makefile ?? Linux ???????? makefile ???????????????????????????????????????????????????????????????????????????????????? makefile?????????????????????????????????????????????????????????????Щ??????????????????????????????????????????????????????????tags ????????????? ????????????????????make ?????????????????????????????????????? bzImage ??????
????????????????? make ?????????????????????????????????????
???????????????
?????????????????
?????????????????к??????????????????????????ú??????????make ???????????????????????Щ??????????????????????????????? makefile ??
????????? Makefile ????????????????????vmlinux ??????????????????????????????? Makefile ????????±????????
????VERSION = 4
????PATCHLEVEL = 2
????SUBLEVEL = 0
????EXTRAVERSION = -rc3
????NAME = Hurr durr I'ma sheep
??????Щ????????????????汾????????????????????????????? Makefile ?е? KERNELVERSION ??
????KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL)??.$(PATCHLEVEL)$(if $(SUBLEVEL)??.$(SUBLEVEL)))$(EXTRAVERSION)
????????????????????ifeq ?????ж????????????鴫??? make ??????????? Makefile ?????????????????? make help ??????????????????е?????????Щ????? make ????Ч???????в?????????????make V=1 ?????????????????????????????????? ifeq ???鴫??? make ?? V=n ??
????ifeq ("$(origin V)"?? "command line")
????KBUILD_VERBOSE = $(V)
????endif
????ifndef KBUILD_VERBOSE
????KBUILD_VERBOSE = 0
????endif
????ifeq ($(KBUILD_VERBOSE)??1)
????quiet =
????Q =
????else
????quiet=quiet_
????Q = @
????endif
????export quiet Q KBUILD_VERBOSE
??????? V=n ?????????? make ??????????? KBUILD_VERBOSE ????? V ???????????KBUILD_VERBOSE ??? 0??????????? KBUILD_VERBOSE ?????????????? quiet ??Q ????????? @ ?????????????????????????????????????????????????????? CC scripts/mod/empty.o????????Compiling …. scripts/mod/empty.o??LCTT ?????CC ?? makefile ????????????????????κ????????????е??????
????????? ifeq ???????????? make ????? O=/dir????????????????????? dir ??????е????????
????ifeq ($(KBUILD_SRC)??)
????ifeq ("$(origin O)"?? "command line")
????KBUILD_OUTPUT := $(O)
????endif
????ifneq ($(KBUILD_OUTPUT)??)
????saved-output := $(KBUILD_OUTPUT)
????KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) /
????&& /bin/pwd)
????$(if $(KBUILD_OUTPUT)???? /
????$(error failed to create output directory "$(saved-output)"))
????sub-make: FORCE
????$(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) /
????-f $(CURDIR)/Makefile $(filter-out _all sub-make??$(MAKECMDGOALS))
????skip-makefile := 1
????endif # ifneq ($(KBUILD_OUTPUT)??)
????endif # ifeq ($(KBUILD_SRC)??)
????????????? KBUILD_SRC???????????????????????????????????????? makefile ?????????????????????? KBUILD_OUTPUT ????????? O ????????????????????????????????????? KBUILD_OUTPUT ???????????ú???????????????????????£?
?????????? KBUILD_OUTPUT ??????浽??????? saved-output??
????????????????????????
??????鴴?????????????????????????
??????????????????????????????????????? make ?????μ????-C????
????????? ifeq ?????鴫??? make ????? C ?? M??
????ifeq ("$(origin C)"?? "command line")
????KBUILD_CHECKSRC = $(C)
????endif
????ifndef KBUILD_CHECKSRC
????KBUILD_CHECKSRC = 0
????endif
????ifeq ("$(origin M)"?? "command line")
????KBUILD_EXTMOD := $(M)
????endif
???????????? C ????? makefile ????????????? $CHECK ??????????????? c ????????????????sparse?????????? M ??????????????饗??????????????
??????????????? KBUILD_SRC????? KBUILD_SRC ??б????????????????? srctree ?.??
????ifeq ($(KBUILD_SRC)??)
????srctree := .
????endif
????objtree := .
????src     := $(srctree)
????obj     := $(objtree)
????export srctree objtree VPATH
??????????? Makefile ?????????????? make ????????????????? objtree ?????????????????????????Щ???????????????????? SUBARCH ?????????????????????????????LCTT ?????????CPU ???????
????SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ /
????-e s/sun4u/sparc64/ /
????-e s/arm.*/arm/ -e s/sa110/arm/ /
????-e s/s390x/s390/ -e s/parisc64/parisc/ /
????-e s/ppc.*/powerpc/ -e s/mips.*/mips/ /
????-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ )
??????????????????? uname ??????????????????????????????????????? uname ?????????????????????Щ????????????? SUBARCH ????? SUBARCH ????????SRCARCH ?? hfr-arch??SRCARCH ?????????????????????hfr-arch ?????????????????
????ifeq ($(ARCH)??i386)
????SRCARCH := x86
????endif
????ifeq ($(ARCH)??x86_64)
????SRCARCH := x86
????endif
????hdr-arch  := $(SRCARCH)
???????ARCH ?? SUBARCH ????????????????ù???????????????·??????? KCONFIG_CONFIG????????????????????????????? .config ??
????KCONFIG_CONFIG  ?= .config
????export KCONFIG_CONFIG
????????????????????????? shell
????CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; /
????else if [ -x /bin/bash ]; then echo /bin/bash; /
????else echo sh; fi ; fi)
??????????????????????????????????????????????????????? C ?? C++ ??????????????????
????HOSTCC       = gcc
????HOSTCXX      = g++
????HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
????HOSTCXXFLAGS = -O2
?????????????????????????????? CC?????????? HOST* ??Щ?????????????? CC ???????????????????????????????????? HOSTCC ???????????????? host ?????????????????????
?????????????????? KBUILD_MODULES ?? KBUILD_BUILTIN ????壬??????????????????????????????????????????????????
????KBUILD_MODULES :=
????KBUILD_BUILTIN := 1
????ifeq ($(MAKECMDGOALS)??modules)
????KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS)??1)
????endif
????????????????????Щ????????壬??????????????????? modules ?? make?????? KBUILD_BUILTIN ?????????????????? CONFIG_MODVERSIONS??
?????????????????????????????
????include scripts/Kbuild.include
??????? Kbuild ????????? Kernel Build System ?????????????????????????????????kbuild ????????? makefile ????????scripts/Kbuild.include ? kbuild ???????Щ???????塣??????????????? kbuild ??????????????????????????????Щ????????壬??Щ?????????????????????б????????????????????????????? binutils ??????????? ????????
????AS      = $(CROSS_COMPILE)as
????LD      = $(CROSS_COMPILE)ld
????CC      = $(CROSS_COMPILE)gcc
????CPP     = $(CC) -E
????AR      = $(CROSS_COMPILE)ar
????NM      = $(CROSS_COMPILE)nm
????STRIP       = $(CROSS_COMPILE)strip
????OBJCOPY     = $(CROSS_COMPILE)objcopy
????OBJDUMP     = $(CROSS_COMPILE)objdump
????AWK     = awk
????...
????...
????...
????????Щ????????????棬?????????????????????USERINCLUDE ?? LINUXINCLUDE?????????????????·????????????????????????????????????
????USERINCLUDE    := /
????-I$(srctree)/arch/$(hdr-arch)/include/uapi /
????-Iarch/$(hdr-arch)/include/generated/uapi /
????-I$(srctree)/include/uapi /
????-Iinclude/generated/uapi /
????-include $(srctree)/include/linux/kconfig.h
????LINUXINCLUDE    := /
????-I$(srctree)/arch/$(hdr-arch)/include /
????...
????????? C ???????????????
????KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs /
????-fno-strict-aliasing -fno-common /
????-Werror-implicit-function-declaration /
????-Wno-format-security /
????-std=gnu89
?????????????????????????????????????????? makefile ??????£????? arch/ ????? kbuild???????????????????????????????? makefile ??á?
????????????????? RCS_FIND_IGNORE ?? RCS_TAR_IGNORE ????????汾????????????????
????export RCS_FIND_IGNORE := /( -name SCCS -o -name BitKeeper -o -name .svn -o    /
????-name CVS -o -name .pc -o -name .hg -o -name .git /) /
????-prune -o
????export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn /
????--exclude CVS --exclude .pc --exclude .hg --exclude .git
?????????????????????????????е??????????????????????????vmlinux??
?????????????
???????????????????????е???????????? makefile????????????μ? makefile???????????????????????????????????????????????????? make ??????????κζ???????????????????????????????????????????? makefile ?? 598 ?п?????????????????vmlinux??
????all: vmlinux
????include arch/$(SRCARCH)/Makefile
????????????????????? export RCS_FIND_IGNORE….. ?? all: vmlinux….. ??????? makefile ?????????????????????????????make *.config?????????????????????????????????????????????????????????
??????? all: ??????????????????????????????????????????????????????????? makefile????????????? arch/x86/Makefile??????????????????????? makefile ???????????????????????????? all ??????? makefile ?????????? vmlinux??
????vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE
????vmlinux ?? linux ????????????????????????? scripts/link-vmlinux.sh ?????????????????????????γ??? vmlinux??
?????????????? vmlinux-deps????????????£?
????vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
?????????????????μ???????? built-in.o ???????????????????????е?????kbuild ???????????????е??? $(obj-y) ??????????????? $(LD) -r ????Щ??????????? build-in.o ????????????????vmlinux-deps????????? vmlinux ?????????????????????? vmlinux-deps ??????????????
????arch/x86/kernel/vmlinux.lds arch/x86/kernel/head_64.o
????arch/x86/kernel/head64.o    arch/x86/kernel/head.o
????init/built-in.o             usr/built-in.o
????arch/x86/built-in.o         kernel/built-in.o
????mm/built-in.o               fs/built-in.o
????ipc/built-in.o              security/built-in.o
????crypto/built-in.o           block/built-in.o
????lib/lib.a                   arch/x86/lib/lib.a
????lib/built-in.o              arch/x86/lib/built-in.o
????drivers/built-in.o          sound/built-in.o
????firmware/built-in.o         arch/x86/pci/built-in.o
????arch/x86/power/built-in.o   arch/x86/video/built-in.o
????net/built-in.o