GNU ARM匯編--(十七)u-boot的makefile和mkconfig解讀
這里也給出頂層目錄下的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中已經(jīng)分析了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都是當前目錄,所以執(zhí)行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函數(shù)從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
- ###########################################################################################
- #定義兩個函數(shù),cc-option-sys被cc-option調(diào)用
- #cc-option被后面的函數(shù)調(diào)用
- ############################################################################################
- #cc-version
- #Usagegcc-ver:=$(callcc-version)
- cc-version=$(shell$(SHELL)$(SRCTREE)/tools/gcc-version.sh$(CC))
- ##########################################################################################
- #使用tools/gcc-version.sh腳本來獲取編譯器的版本
- #在頂層makefile中,有調(diào)用cc-version函數(shù)
- ##########################################################################################
- #
- #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的作用是在靜態(tài)庫有添加新的.o后,負責更新索引.
- #########################################################################
- #Loadgeneratedboardconfiguration
- sinclude$(OBJTREE)/include/autoconf.mk
- sinclude$(OBJTREE)/include/config.mk
- ################################################################################################
- #包上配置編譯時產(chǎn)生的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
-
評論