GNU ARM汇编--(十七)u-boot的makefile和mkconfig解读
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_0.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_1.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_2.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_3.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_4.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_0.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_1.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_2.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_3.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_4.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_10.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_0.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_1.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_2.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_3.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_4.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_0.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_1.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_2.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_3.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_4.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_10.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_22.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_23.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_24.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_25.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_22.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_27.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_2.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_29.jpg)
![](http://m.amcfsurvey.com/editerupload/fetch/20161101/321714_3_24.jpg)
这里也给出顶层目录下的config.mk文件的注释:
[cpp]view plaincopy
- #
- #(C)Copyright2000-2006
- #WolfgangDenk,DENXSoftwareEngineering,wd@denx.de.
- #
- #SeefileCREDITSforlistofpeoplewhocontributedtothis
- #project.
- #
- #Thisprogramisfreesoftware;youcanredistributeitand/or
- #modifyitunderthetermsoftheGNUGeneralPublicLicenseas
- #publishedbytheFreeSoftwareFoundation;eitherversion2of
- #theLicense,or(atyouroption)anylaterversion.
- #
- #Thisprogramisdistributedinthehopethatitwillbeuseful,
- #butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof
- #MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe
- #GNUGeneralPublicLicenseformoredetails.
- #
- #YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense
- #alongwiththisprogram;ifnot,writetotheFreeSoftware
- #Foundation,Inc.,59TemplePlace,Suite330,Boston,
- #MA02111-1307USA
- #
- #########################################################################
- ifeq($(CURDIR),$(SRCTREE))
- dir:=
- else
- dir:=$(subst$(SRCTREE)/,,$(CURDIR))
- endif
- ###########################################################################
- #在顶层makefile中已经分析了CURDIR和SRCTREE都是当前目录,所以这里dir暂时为空
- ###########################################################################
- ifneq($(OBJTREE),$(SRCTREE))
- #CreateobjectfilesforSPLinaseparatedirectory
- ifeq($(CONFIG_SPL_BUILD),y)
- obj:=$(if$(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
- else
- obj:=$(if$(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
- endif
- src:=$(if$(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
- $(shellmkdir-p$(obj))
- else
- #CreateobjectfilesforSPLinaseparatedirectory
- ifeq($(CONFIG_SPL_BUILD),y)
- obj:=$(if$(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
- $(shellmkdir-p$(obj))
- else
- obj:=
- endif
- src:=
- endif
- ########################################################################################
- #首先OBJTREE和SRCTREE都是当前目录,所以执行else
- #查找CONFIG_SPL_BUILD是否定义为y,在autoconf.mk中,并没有这个定义,所以obj和src暂时也为空
- ########################################################################################
- #cleantheslate...
- PLATFORM_RELFLAGS=
- PLATFORM_CPPFLAGS=
- PLATFORM_LDFLAGS=
- #########################################################################
- HOSTCFLAGS=-Wall-Wstrict-prototypes-O2-fomit-frame-pointer
- $(HOSTCPPFLAGS)
- HOSTSTRIP=strip
- #
- #MacOSX/DarwinsCpreprocessorisApplespecific.It
- #generatesnumerouserrorsandwarnings.Wewanttobypassit
- #anduseGNUCscpp.Todothiswepassthe-traditional-cpp
- #optiontothecompiler.Notethatthe-traditional-cppflag
- #DOESNOThavethesamesemanticsasGNUCsflag,allitdoes
- #isinvoketheGNUpreprocessorinstockANSI/ISOCfashion.
- #
- #Appleslinkerissimilar,thankstothenew2stagelinking
- #multiplesymboldefinitionsaretreatedaserrors,hencethe
- #-multiply_definedsuppressoptiontoturnoffthiserror.
- #
- ifeq($(HOSTOS),darwin)
- #getmajorandminorproductversion(e.g.10and6forSnowLeopard)
- DARWIN_MAJOR_VERSION=$(shellsw_vers-productVersion|cut-f1-d.)
- DARWIN_MINOR_VERSION=$(shellsw_vers-productVersion|cut-f2-d.)
- os_x_before=$(shellif[$(DARWIN_MAJOR_VERSION)-le$(1)-a
- $(DARWIN_MINOR_VERSION)-le$(2)];thenecho"$(3)";elseecho"$(4)";fi;)
- #SnowLeopardsbuildenvironmenthasnolongerrestrictionsasdescribedabove
- HOSTCC=$(callos_x_before,10,5,"cc","gcc")
- HOSTCFLAGS+=$(callos_x_before,10,4,"-traditional-cpp")
- HOSTLDFLAGS+=$(callos_x_before,10,5,"-multiply_definedsuppress")
- else
- HOSTCC=gcc
- endif
- ifeq($(HOSTOS),cygwin)
- HOSTCFLAGS+=-ansi
- endif
- #Webuildsomefileswithextrapedanticflagstotrytominimizethings
- #thatwontbuildonsomeweirdhostcompiler--thoughtherearelotsof
- #exceptionsforfilesthatarentcomplaint.
- HOSTCFLAGS_NOPED=$(filter-out-pedantic,$(HOSTCFLAGS))
- HOSTCFLAGS+=-pedantic
- ############################################################
- #HOSTCFLAGS_NOPED是利用filter-out函数从HOSTCFLAGS中过滤掉-pedantic选项
- #而HOSTCFLAGS追加上-pedantic选项
- ############################################################
- #########################################################################
- #
- #Optionchecker,gccversion(courtesylinuxkernel)toensure
- #onlysupportedcompileroptionsareused
- #
- CC_OPTIONS_CACHE_FILE:=$(OBJTREE)/include/generated/cc_options.mk
- CC_TEST_OFILE:=$(OBJTREE)/include/generated/cc_test_file.o
- -include$(CC_OPTIONS_CACHE_FILE)
- #############################################################################
- #定义编译选项
- #在cc_options.mk中有如下选项:
- #CC_OPTIONS+=-marm
- #CC_OPTIONS+=-mno-thumb-interwork
- #CC_OPTIONS+=-mapcs-32
- #CC_OPTIONS+=-malignment-traps
- #CC_OPTIONS+=-Wno-format-nonliteral
- #CC_OPTIONS+=-Wno-format-security
- #CC_OPTIONS+=-mabi=apcs-gnu
- #CC_OPTIONS+=-mabi=aapcs-linux
- #############################################################################
- cc-option-sys=$(shellmkdir-p$(dir$(CC_TEST_OFILE));
- if$(CC)$(CFLAGS)$(1)-S-xc/dev/null-o$(CC_TEST_OFILE)
- >/dev/null2>&1;then
- echoCC_OPTIONS+=$(strip$1)>>$(CC_OPTIONS_CACHE_FILE);
- echo"$(1)";fi)
- ifeq($(CONFIG_CC_OPT_CACHE_DISABLE),y)
- cc-option=$(strip$(if$(callcc-option-sys,$1),$1,$2))
- else
- cc-option=$(strip$(if$(findstring$1,$(CC_OPTIONS)),$1,
- $(if$(callcc-option-sys,$1),$1,$2)))
- endif
- ###########################################################################################
- #定义两个函数,cc-option-sys被cc-option调用
- #cc-option被后面的函数调用
- ############################################################################################
- #cc-version
- #Usagegcc-ver:=$(callcc-version)
- cc-version=$(shell$(SHELL)$(SRCTREE)/tools/gcc-version.sh$(CC))
- ##########################################################################################
- #使用tools/gcc-version.sh脚本来获取编译器的版本
- #在顶层makefile中,有调用cc-version函数
- ##########################################################################################
- #
- #Includethemakevariables(CC,etc...)
- #
- AS=$(CROSS_COMPILE)as
- LD=$(CROSS_COMPILE)ld
- CC=$(CROSS_COMPILE)gcc
- CPP=$(CC)-E
- AR=$(CROSS_COMPILE)ar
- NM=$(CROSS_COMPILE)nm
- LDR=$(CROSS_COMPILE)ldr
- STRIP=$(CROSS_COMPILE)strip
- OBJCOPY=$(CROSS_COMPILE)objcopy
- OBJDUMP=$(CROSS_COMPILE)objdump
- RANLIB=$(CROSS_COMPILE)RANLIB
- DTC=dtc
- #########################################################################
- #定义汇编器,连接器,编译器,打包工具,反汇编工具,值的注意的RANLIB的作用是在静态库有添加新的.o后,负责更新索引.
- #########################################################################
- #Loadgeneratedboardconfiguration
- sinclude$(OBJTREE)/include/autoconf.mk
- sinclude$(OBJTREE)/include/config.mk
- ################################################################################################
- #包上配置编译时产生的autoconf.mk和config.mk文件
- ################################################################################################
- #Somearchitectureconfig.mkfilesneedtoknowwhatCPUDIRissetto,
- #socalculateCPUDIRbeforeincludingARCH/SOC/CPUconfig.mkfiles.
- #Checkifarch/$ARCH/cpu/$CPUexists,otherwiseassumearch/$ARCH/cpucontains
- #CPU-specificcode.
- CPUDIR=arch/$(ARCH)/cpu/$(CPU)
- ifneq($(SRCTREE)/$(CPUDIR),$(wildcard$(SRCTREE)/$(CPUDIR)))
- CPUDIR=arch/$(ARCH)/cpu
- endif
- #################################################################################################
- #定义CPUDIR为arch/arm/cpu/arm920t
- #################################################################################################
- sinclude$(TOPDIR)/arch/$(ARCH)/config.mk#includearchitecturedependendrules
- sinclude$(TOPDIR)/$(CPUDIR)/config.mk#includeCPUspecificrules
- ##################################################################################################
- #包上arch/arm/config.mk和/arch/arm/cpu/arm920t/config.mk文件
- ##################################################################################################
- ifdefSOC
- sinclude$(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk#includeSoCspecificrules
- endif
- ######################################################################
- #包上arch/arm/cpu/arm920t/s3c24x0/config.mk文件
- #####################################################################
- ifdefVENDOR
- BOARDDIR=$(VENDOR)/$(BOARD)
- else
- BOARDDIR=$(BOARD)
- endif
- ifdefBOARD
- sinclude$(TOPDIR)/board/$(BOARDDIR)/config.mk#includeboardspecificrules
- endif
- ######################################################################################
- #包上board/samsung/smdk2410/config.mk文件
- ######################################################################################
- #########################################################################
- #Wedontactuallyuse$(ARFLAGS)anywhereanymore,socatchpeople
- #whoareportingoldcodetolatestmainlinebutnotupdating$(AR).
- ARFLAGS=$(errorupdateyourMakefiletousecmd_link_o_targetandnotAR)
- RELFLAGS=$(PLATFORM_RELFLAGS)
- DBGFLAGS=-g#-DDEBUG
- OPTFLAGS=-Os#-fomit-frame-pointer
- OBJCFLAGS+=--gap-fill=0xff
- gccincdir:=$(shell$(CC)-print-file-name=include)
- CPPFLAGS:=$(DBGFLAGS)$(OPTFLAGS)$(RELFLAGS)
- -D__KERNEL__
- #Enablegarbagecollectionofun-usedsectionsforSPL
- ifeq($(CONFIG_SPL_BUILD),y)
- CPPFLAGS+=-ffunction-sections-fdata-sections
- LDFLAGS_FINAL+=--gc-sections
- endif
- ifneq($(CONFIG_SYS_TEXT_BASE),)
- CPPFLAGS+=-DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
- endif
- ifneq($(CONFIG_SPL_TEXT_BASE),)
- CPPFLAGS+=-DCONFIG_SPL_TEXT_BASE=$(CONFIG_SPL_TEXT_BASE)
- endif
- ifneq($(CONFIG_SPL_PAD_TO),)
- CPPFLAGS+=-DCONFIG_SPL_PAD_TO=$(CONFIG_SPL_PAD_TO)
- endif
- ifeq($(CONFIG_SPL_BUILD),y)
- CPPFLAGS+=-DCONFIG_SPL_BUILD
- endif
- ifneq($(RESET_VECTOR_ADDRESS),)
- CPPFLAGS+=-DRESET_VECTOR_ADDRESS=$(RESET_VECTOR_ADDRESS)
- endif
- ifneq($(OBJTREE),$(SRCTREE))
- CPPFLAGS+=-I$(OBJTREE)/include2-I$(OBJTREE)/include
- endif
- CPPFLAGS+=-I$(TOPDIR)/include
- CPPFLAGS+=-fno-builtin-ffreestanding-nostdinc
- -isystem$(gccincdir)-pipe$(PLATFORM_CPPFLAGS)
- ifdefBUILD_TAG
- CFLAGS:=$(CPPFLAGS)-Wall-Wstrict-prototypes
- -DBUILD_TAG="$(BUILD_TAG)"
- else
- CFLAGS:=$(CPPFLAGS)-Wall-Wstrict-prototypes
- endif
- CFLAGS_SSP:=$(callcc-option,-fno-stack-protector)
- CFLAGS+=$(CFLAGS_SSP)
- #Sometoolchainsenablesecurityrelatedwarningflagsbydefault,
- #buttheydontmakemuchsenseintheu-bootworld,sodisablethem.
- CFLAGS_WARN:=$(callcc-option,-Wno-format-nonliteral)
- $(callcc-option,-Wno-format-security)
- CFLAGS+=$(CFLAGS_WARN)
- #Reportstackusageifsupported
- CFLAGS_STACK:=$(callcc-option,-fstack-usage)
- CFLAGS+=$(CFLAGS_STACK)
- #$(CPPFLAGS)sets-g,whichcausesgcctopassasuitable-g
- #optiontotheassembler.
- AFLAGS_DEBUG:=
- #turnjbsrintojsrform68k
- ifeq($(ARCH),m68k)
- ifeq($(findstring3.4,$(shell$(CC)--version)),3.4)
- AFLAGS_DEBUG:=-Wa,-gstabs,-S
- endif
- endif
-
评论