uboot2013-10移植(三)--config.mk注释

来源:互联网 发布:1password mac 破解 编辑:程序博客网 时间:2024/05/17 17:42

这个文件主要是设置一些编译选项~ 有空了再挖一下gcc相关的东西···

## (C) Copyright 2000-2013# Wolfgang Denk, DENX Software Engineering, wd@denx.de.## SPDX-License-Identifier:GPL-2.0+########################################################################### Set shell to bash if possible, otherwise fall back to sh# -x 表示判断文件是否有执行权限SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \else if [ -x /bin/bash ]; then echo /bin/bash; \else echo sh; fi; fi)exportSHELLifeq ($(CONFIG_TPL_BUILD),y)SPL_BIN := u-boot-tplelseSPL_BIN := u-boot-splendififeq ($(CURDIR),$(SRCTREE))dir :=# 设置为空elsedir := $(subst $(SRCTREE)/,,$(CURDIR))endififneq ($(OBJTREE),$(SRCTREE)) # 不成立# Create object files for SPL in a separate directoryifeq ($(CONFIG_SPL_BUILD),y)ifeq ($(CONFIG_TPL_BUILD),y)obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)elseobj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)endifelseobj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)endifsrc := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)$(shell mkdir -p $(obj))else# 执行这里# Create object files for SPL in a separate directoryifeq ($(CONFIG_SPL_BUILD),y)# 定义:SPLTREE   = /home/tomato/u-boot-2013.10/splifeq ($(CONFIG_TPL_BUILD),y)obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)elseobj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)endif$(shell mkdir -p $(obj))elseobj :=endifsrc :=endif# clean the slate ...PLATFORM_RELFLAGS =PLATFORM_CPPFLAGS =PLATFORM_LDFLAGS =########################################################################## -Wall 允许发出Gcc提供的所有有用的报警信息# -Wstrict-prototypes 如果函数的声明或定义没有指出参数类型,编译器就发出警告。# -fomit-frame-pointer 使用ebpHOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \  $(HOSTCPPFLAGS)HOSTSTRIP= strip## Mac OS X / Darwin's C preprocessor is Apple specific.  It# generates numerous errors and warnings.  We want to bypass it# and use GNU C's cpp.To do this we pass the -traditional-cpp# option to the compiler.  Note that the -traditional-cpp flag# DOES NOT have the same semantics as GNU C's flag, all it does# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.## Apple's linker is similar, thanks to the new 2 stage linking# multiple symbol definitions are treated as errors, hence the# -multiply_defined suppress option to turn off this error.## 判断条件不成立ifeq ($(HOSTOS),darwin)# get major and minor product version (e.g. '10' and '6' for Snow Leopard)DARWIN_MAJOR_VERSION= $(shell sw_vers -productVersion | cut -f 1 -d '.')DARWIN_MINOR_VERSION= $(shell sw_vers -productVersion | cut -f 2 -d '.')os_x_before= $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \$(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)# Snow Leopards build environment has no longer restrictions as described aboveHOSTCC = $(call os_x_before, 10, 5, "cc", "gcc")HOSTCFLAGS+= $(call os_x_before, 10, 4, "-traditional-cpp")HOSTLDFLAGS+= $(call os_x_before, 10, 5, "-multiply_defined suppress")else# 执行下面这条赋值语句HOSTCC= gccendififeq ($(HOSTOS),cygwin)# 不成立HOSTCFLAGS+= -ansi  # -ansi : 关闭GNU扩展中与ANSI C相抵触的部分。endif# We build some files with extra pedantic flags to try to minimize things# that won't build on some weird host compiler -- though there are lots of# exceptions for files that aren't complaint.# 变量:HOSTCFLAGS_NOPED   = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointerHOSTCFLAGS_NOPED = $(filter-out -pedantic,$(HOSTCFLAGS))# HOSTCFLAGS = HOSTCFLAGS_NOPED   = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pedanticHOSTCFLAGS+= -pedantic # 允许发出ANSI C标准所列的全部警告信息########################################################################### Option checker, gcc version (courtesy linux kernel) to ensure# only supported compiler options are used#CC_OPTIONS_CACHE_FILE := $(OBJTREE)/include/generated/cc_options.mkCC_TEST_OFILE := $(OBJTREE)/include/generated/cc_test_file.o-include $(CC_OPTIONS_CACHE_FILE)# cc-option-sys值为空cc-option-sys = $(shell mkdir -p $(dir $(CC_TEST_OFILE)); \if $(CC) $(CFLAGS) $(1) -S -xc /dev/null -o $(CC_TEST_OFILE) \> /dev/null 2>&1; then \echo 'CC_OPTIONS += $(strip $1)' >> $(CC_OPTIONS_CACHE_FILE); \echo "$(1)"; fi)# cc-option值为空ifeq ($(CONFIG_CC_OPT_CACHE_DISABLE),y)cc-option = $(strip $(if $(call cc-option-sys,$1),$1,$2))elsecc-option = $(strip $(if $(findstring $1,$(CC_OPTIONS)),$1,\$(if $(call cc-option-sys,$1),$1,$2)))endif# cc-version# Usage gcc-ver := $(call cc-version)# cc-version = 0407cc-version = $(shell $(SHELL) $(SRCTREE)/tools/gcc-version.sh $(CC))# binutils-version = 0222binutils-version = $(shell $(SHELL) $(SRCTREE)/tools/binutils-version.sh $(AS))# dtc-version = 0000dtc-version = $(shell $(SHELL) $(SRCTREE)/tools/dtc-version.sh $(DTC))## Include the make variables (CC, etc...)#AS= $(CROSS_COMPILE)as# Always use GNU ld# LD=/opt/toolchains/bin/arm-none-eabi-ld.bfdLD= $(shell if $(CROSS_COMPILE)ld.bfd -v > /dev/null 2>&1; \then echo "$(CROSS_COMPILE)ld.bfd"; else echo "$(CROSS_COMPILE)ld"; fi;)CC= $(CROSS_COMPILE)gccCPP= $(CC) -EAR= $(CROSS_COMPILE)arNM= $(CROSS_COMPILE)nmLDR= $(CROSS_COMPILE)ldrSTRIP= $(CROSS_COMPILE)stripOBJCOPY = $(CROSS_COMPILE)objcopyOBJDUMP = $(CROSS_COMPILE)objdumpRANLIB= $(CROSS_COMPILE)RANLIBDTC= dtcCHECK= sparse########################################################################## Load generated board configurationifeq ($(CONFIG_TPL_BUILD),y)# Include TPL autoconfsinclude $(OBJTREE)/include/tpl-autoconf.mkelse # 执行这里的分支ifeq ($(CONFIG_SPL_BUILD),y)# Include SPL autoconfsinclude $(OBJTREE)/include/spl-autoconf.mkelse# Include normal autoconfsinclude $(OBJTREE)/include/autoconf.mkendifendifsinclude $(OBJTREE)/include/config.mk# Some architecture config.mk files need to know what CPUDIR is set to,# so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.# Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains# CPU-specific code.CPUDIR=arch/$(ARCH)/cpu/$(CPU) # CPUDIR   = arch/arm/cpu/armv7ifneq ($(SRCTREE)/$(CPUDIR),$(wildcard $(SRCTREE)/$(CPUDIR))) # 不成立CPUDIR=arch/$(ARCH)/cpuendifsinclude $(TOPDIR)/arch/$(ARCH)/config.mk# include architecture dependend rulessinclude $(TOPDIR)/$(CPUDIR)/config.mk# include  CPUspecific rulesifdefSOCsinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk# include  SoCspecific rulesendififdefVENDORBOARDDIR = $(VENDOR)/$(BOARD)elseBOARDDIR = $(BOARD)endififdefBOARDsinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk# include board specific rulesendif########################################################################## We don't actually use $(ARFLAGS) anywhere anymore, so catch people# who are porting old code to latest mainline but not updating $(AR).ARFLAGS = $(error update your Makefile to use cmd_link_o_target and not AR)RELFLAGS= $(PLATFORM_RELFLAGS)DBGFLAGS= -g # -DDEBUGOPTFLAGS= -Os #-fomit-frame-pointerOBJCFLAGS += --gap-fill=0xffgccincdir := $(shell $(CC) -print-file-name=include)CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)\-D__KERNEL__# Enable garbage collection of un-used sections for SPL# 使用-ffunction-sections 和 -fdata-sections将每个符号创建为一个sections. sections名# 与function,data名保持一致。# 在link阶段,-Wl,--gc-sections 申明去掉不用的section。就可以去掉没用的function(符号)了。ifeq ($(CONFIG_SPL_BUILD),y)CPPFLAGS += -ffunction-sections -fdata-sectionsLDFLAGS_FINAL += --gc-sectionsendif# TODO(sjg@chromium.org): Is this correct on Mac OS?# MXSImage needs LibSSL# 条件不成立ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)HOSTLIBS+= -lssl -lcrypto# Add CONFIG_MXS into host CFLAGS, so we can check whether or not register# the mxsimage support within tools/mxsimage.c .HOSTCFLAGS+= -DCONFIG_MXSendif# 条件不成立ifdef CONFIG_FIT_SIGNATUREHOSTLIBS+= -lssl -lcrypto# This affects include/image.h, but including the board config file# is tricky, so manually define this options here.HOSTCFLAGS+= -DCONFIG_FIT_SIGNATUREendififneq ($(CONFIG_SYS_TEXT_BASE),)CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)endififeq ($(CONFIG_SPL_BUILD),y)CPPFLAGS += -DCONFIG_SPL_BUILDifeq ($(CONFIG_TPL_BUILD),y)CPPFLAGS += -DCONFIG_TPL_BUILDendifendif# Does this architecture support generic board init?ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)ifneq ($(CONFIG_SYS_GENERIC_BOARD),)CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)endifendififneq ($(OBJTREE),$(SRCTREE))CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/includeendifCPPFLAGS += -I$(TOPDIR)/includeCPPFLAGS += -fno-builtin -ffreestanding -nostdinc\-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypesifdef BUILD_TAGCFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'endifCFLAGS_SSP := $(call cc-option,-fno-stack-protector)CFLAGS += $(CFLAGS_SSP)# Some toolchains enable security related warning flags by default,# but they don't make much sense in the u-boot world, so disable them.CFLAGS_WARN := $(call cc-option,-Wno-format-nonliteral) \       $(call cc-option,-Wno-format-security)CFLAGS += $(CFLAGS_WARN)# Report stack usage if supportedCFLAGS_STACK := $(call cc-option,-fstack-usage)CFLAGS += $(CFLAGS_STACK)BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))ifeq ($(findstring examples/,$(BCURDIR)),)ifeq ($(CONFIG_SPL_BUILD),)ifdef FTRACECFLAGS += -finstrument-functions -DFTRACEendifendifendif# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format># option to the assembler.AFLAGS_DEBUG :=# turn jbsr into jsr for m68kifeq ($(ARCH),m68k)ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)AFLAGS_DEBUG := -Wa,-gstabs,-SendifendifAFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)LDFLAGS += $(PLATFORM_LDFLAGS)LDFLAGS_FINAL += -BstaticLDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)ifneq ($(CONFIG_SYS_TEXT_BASE),)LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)endifLDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)ifneq ($(CONFIG_SPL_TEXT_BASE),)LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)endif# Linus' kernel sanity checking toolCHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \  -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)# Location of a usable BFD library, where we define "usable" as# "built for ${HOST}, supports ${TARGET}".  Sensible values are# - When cross-compiling: the root of the cross-environment# - Linux/ppc (native): /usr# - NetBSD/ppc (native): you lose ... (must extract these from the#   binutils build directory, plus the native and U-Boot include#   files don't like each other)## So far, this is used only by tools/gdb/Makefile.ifeq ($(HOSTOS),darwin)BFD_ROOT_DIR =/usr/local/toolselseifeq ($(HOSTARCH),$(ARCH))# nativeBFD_ROOT_DIR =/usrelse#BFD_ROOT_DIR =/LinuxPPC/CDK# Linux/i386#BFD_ROOT_DIR =/usr/pkg/cross# NetBSD/i386BFD_ROOT_DIR =/opt/powerpcendifendif#########################################################################exportHOSTCC HOSTCFLAGS HOSTLDFLAGS PEDCFLAGS HOSTSTRIP CROSS_COMPILE \AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKEexportCONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS########################################################################## Allow boards to use custom optimize flags on a per dir/file basisALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR))ALL_CFLAGS += $(EXTRA_CPPFLAGS)# The _DEP version uses the $< file target (for dependency generation)# See rules.mkEXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \$(CPPFLAGS_$(BCURDIR))$(obj)%.s:%.S$(CPP) $(ALL_AFLAGS) -o $@ $<$(obj)%.o:%.S$(CC)  $(ALL_AFLAGS) -o $@ $< -c$(obj)%.o:%.cifneq ($(CHECKSRC),0)$(CHECK) $(CHECKFLAGS) $(ALL_CFLAGS) $<endif$(CC)  $(ALL_CFLAGS) -o $@ $< -c$(obj)%.i:%.c$(CPP) $(ALL_CFLAGS) -o $@ $< -c$(obj)%.s:%.c$(CC)  $(ALL_CFLAGS) -o $@ $< -c -S########################################################################## If the list of objects to link is empty, just create an empty built-in.ocmd_link_o_target = $(if $(strip $1),\      $(LD) $(LDFLAGS) -r -o $@ $1,\      rm -f $@; $(AR) rcs $@ )#########################################################################


0 0
原创粉丝点击