QT210 -> u-boot-samsung-dev中的config.mk文件注释

来源:互联网 发布:网络思想政治教育方法 编辑:程序博客网 时间:2024/06/12 22:34

## (C) Copyright 2000-2006# Wolfgang Denk, DENX Software Engineering, wd@denx.de.## See file CREDITS for list of people who contributed to this# project.## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License as# published by the Free Software Foundation; either version 2 of# the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place, Suite 330, Boston,# MA 02111-1307 USA########################################################################### 假如$(OBJTREE)和$(SRCTREE)不相等。这里是相等ifneq ($(OBJTREE),$(SRCTREE))# 假如$(CURDIR)和$(SRCTREE)相等。这里是相等ifeq ($(CURDIR),$(SRCTREE))dir :=else# 将$(CURDIR)中的$(SRCTREE)/替换为空。# subst字符串处理函数。$(subst FROM,TO,TEXT),即将TEXT中的东西从FROM变为TO dir := $(subst $(SRCTREE)/,,$(CURDIR))endif# 假如$(dir)存在且值不为空,则obj:=$(OBJTREE)/$(dir)/;则obj:=$(OBJTREE)/# 这里,$(dir)未定义,因此这里:# obj:=$(OBJTREE)/# src:=$(SRCTREE)/obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)# 创建目录$(obj)。-p的意思是:假如目录已经存在,不产生错误;如果需要,创建父目录。$(shell mkdir -p $(obj))elseobj :=src :=endif# clean the slate ...PLATFORM_RELFLAGS =PLATFORM_CPPFLAGS =PLATFORM_LDFLAGS =########################################################################## 假如存在$BASH则CONFIG_SHELL:=$BASH;否则假如存在/bin/bash则CONFIG_SHELL:=/bin/bash;否则CONFIG_SHELL:=sh# 这里CONFIG_SHELL:=$BASHCONFIG_SHELL:= $(shell if [ -x "$$BASH" ]; then echo $$BASH; \    else if [ -x /bin/bash ]; then echo /bin/bash; \    else echo sh; fi ; fi)HOSTCC= gcc# -Wall 打开所有警告# -Wstrict-prototypes 假如函数声明或定义时没有指定参数类型,发出警告# -O2 优化等级2# -fomit-frame-pointer 函数不再需要就不保存frame pointer在寄存器。(去除函数框架)#  FP(frame pointer,指向栈中一个函数的local 变量的首地址)HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer# strip函数:去掉字串中开头和结尾的空字符,字符串内部的连续多个空格替换为一个空格。HOSTSTRIP= strip########################################################################### Option checker (courtesy linux kernel) to ensure# only supported compiler options are used## 执行$(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1命令# 将$(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null的标准输出输出到/dev/null,2>&1是将标准错误输出重定向到标准输出,也就是输出到2>&1/dev/null。# $(1) 这里是用在call函数里面,见后面使用此变量的位置。详情请查询call函数。# $(call ,,,...)# 当make执行这个函数时,参数中的变量,如$(1),$(2),$(3)等,会被参数,,依次取代。而的返回值就是call函数的返回值。# -S 仅仅编译,不组合或连接# -o <file> 输出文件到<file># -x <language> 指定输入文件的语言cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)## Include the make variables (CC, etc...)#AS= $(CROSS_COMPILE)asLD= $(CROSS_COMPILE)ldCC= $(CROSS_COMPILE)gcc# -E 仅仅预处理,不编译,组合或连接CPP= $(CC) -EAR= $(CROSS_COMPILE)arNM= $(CROSS_COMPILE)nmLDR= $(CROSS_COMPILE)ldrSTRIP= $(CROSS_COMPILE)stripOBJCOPY = $(CROSS_COMPILE)objcopyOBJDUMP = $(CROSS_COMPILE)objdumpRANLIB= $(CROSS_COMPILE)RANLIB########################################################################## Load generated board configuration# -include 对于任何不存在的 makefile 文件都不会产生错误(即使警告信息也不会产生)# 为保持兼容性所以使用sinclude,作用同-includesinclude $(OBJTREE)/include/autoconf.mk# 假如定义了$ARCHifdefARCH# sinclude arm_config.mk。里面预定义了CONFIG_ARM和__ARM__,默认值分别为1sinclude $(TOPDIR)/$(ARCH)_config.mk# include architecture dependend rulesendififdefCPU# sinclude cpu/s5pc11x/config.mk。sinclude $(TOPDIR)/cpu/$(CPU)/config.mk# include  CPUspecific rulesendififdefSOC# sinclude cpu/s5pc11x/$(SOC)/config.mk。没找到这个文件sinclude $(TOPDIR)/cpu/$(CPU)/$(SOC)/config.mk# include  SoCspecific rulesendififdefVENDOR# BOARDDIR = samsung/smdkc110BOARDDIR = $(VENDOR)/$(BOARD)elseBOARDDIR = $(BOARD)endififdefBOARD# sinclude board/samsung/smdkc110/config.mk。sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk# include board specific rules# TEXT_BASE=0xc3e00000endif########################################################################## 假如没有在$(MAKEFLAGS)中找到字符串“s”ifneq (,$(findstring s,$(MAKEFLAGS)))# c 假如库被创建,也不产生警告# r 取代现有的或插入新文件到归档ARFLAGS = crelse# v 输出详细信息ARFLAGS = crvendif# RELFLAGS为空值RELFLAGS= $(PLATFORM_RELFLAGS)# -g 以操作系统的本地格式(stabs, COFF, XCOFF,或DWARF)产生调试信息。GDB能够使用这些调试信息。DBGFLAGS= -g # -DDEBUG# -Os OPTFLAGS= -Os #-fomit-frame-pointer# 这里,LDSCRIPT未定义ifndef LDSCRIPT# LDSCRIPT去掉前面的顶层目录的路径后的值为:board/samsung/smdkc110/u-boot.lds#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debugLDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.ldsendif# --gap-fill 用0xff填补空白部分OBJCFLAGS += --gap-fill=0xff# -print-file-name=<lib> 显示<lib>库的全路径gccincdir := $(shell $(CC) -print-file-name=include)# -D__KERNEL__预定义宏__KERNEL__,默认值1CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)\-D__KERNEL__# 扩展开来后,即,预定义宏TEXT_BASE,值为0xc3e00000CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)ifneq ($(OBJTREE),$(SRCTREE))CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/includeendif# -I dir 添加dir目录到被搜索的头文件目录列表中CPPFLAGS += -I$(TOPDIR)/include# -fno-builtin 不识别内置功能,不要一开始就用“__builtin_”作为前缀# -ffreestanding 断言编译发生在一个独立的环境。# -nostdinc 不要搜索标准系统目录中的头文件。# -isystem dir 在dir中搜索头文件。# -pipe 编译的各个阶段之间使用管道沟通,而不是使用临时文件。CPPFLAGS += -fno-builtin -ffreestanding -nostdinc\-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)# 没有定义BUILD_TAGifdef BUILD_TAGCFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \-DBUILD_TAG='"$(BUILD_TAG)"'else# -Wall 打开所有警告# -Wstrict-prototypes 假如一个函数申明或定义时没有指定参数类型则发出警告CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypesendif# -fno-stack-protector 不做栈保护CFLAGS += $(call cc-option,-fno-stack-protector)# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format># option to the assembler.AFLAGS_DEBUG :=# -D__ASSEMBLY__预订已宏__ASSEMBLY__,默认值1AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)# -Bstatic 这些选项传递给连接器。# -T script 使用script作为连接器脚本LDFLAGS += -Bstatic -T $(LDSCRIPT) $(PLATFORM_LDFLAGS)# 假如$(TEXT_BASE)不为空ifneq ($(TEXT_BASE),)# -Ttext=org 在输出文件中定位一个段,由org给出绝对地址LDFLAGS += -Ttext $(TEXT_BASE)endif# 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.# 假如$(PCI_CLOCK)等于PCI_66M。这里,PCI_CLOCK没有定义ifeq ($(PCI_CLOCK),PCI_66M)CFLAGS := $(CFLAGS) -DPCI_66Mendif#########################################################################exportCONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \MAKEexportTEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS#########################################################################%.s:%.S# -o <file> 将输出写到<file>$(CPP) $(AFLAGS) -o $@ $<%.o:%.S# -c 编译和组合,但不连接$(CC) $(AFLAGS) -c -o $@ $<%.o:%.c$(CC) $(CFLAGS) -c -o $@ $<#########################################################################

参考文档:来源于对应编译器的说明文档。

-WallThis enables all the warnings about constructions that some users considerquestionable, and that are easy to avoid (or modify to prevent the warning),even in conjunction with macros. This also enables some language-specificwarnings described in Section 3.5 [C++ Dialect Options], page 35 and Section 3.6[Objective-C and Objective-C++ Dialect Options], page 45.‘-Wall’ turns on the following warning flags:-Waddress-Warray-bounds (only with ‘-O2’)-Wc++11-compat-Wchar-subscripts-Wenum-compare (in C/Objc; this is on by default in C++)-Wimplicit-int (C and Objective-C only)-Wimplicit-function-declaration (C and Objective-C only)-Wcomment-Wformat-Wmain (only for C/ObjC and unless ‘-ffreestanding’)-Wmaybe-uninitialized-Wmissing-braces-Wnonnull-Wparentheses-Wpointer-sign-Wreorder-Wreturn-type-Wsequence-point-Wsign-compare (only in C++)-Wstrict-aliasing-Wstrict-overflow=1-Wswitch-Wtrigraphs-Wuninitialized-Wunknown-pragmas-Wunused-function-Wunused-label-Wunused-value-Wunused-variable-Wvolatile-register-varNote that some warning flags are not implied by ‘-Wall’. Some of them warnabout constructions that users generally do not consider questionable, but whichoccasionally you might wish to check for; others warn about constructions thatare necessary or hard to avoid in some cases, and there is no simple way to mod-ify the code to suppress the warning. Some of them are enabled by ‘-Wextra’but many of them must be enabled individually.
-Wstrict-prototypes (C and Objective-C only)Warn if a function is declared or defined without specifying the argument types.(An old-style function definition is permitted without a warning if preceded bya declaration that specifies the argument types.)
-O2Optimize even more. GCC performs nearly all supported optimizations that donot involve a space-speed tradeoff. As compared to ‘-O’, this option increasesboth compilation time and the performance of the generated code.‘-O2’ turns on all optimization flags specified by ‘-O’. It also turns on thefollowing optimization flags:-fthread-jumps-falign-functions -falign-jumps-falign-loops -falign-labels-fcaller-saves-fcrossjumping-fcse-follow-jumps -fcse-skip-blocks-fdelete-null-pointer-checks-fdevirtualize-fexpensive-optimizations-fgcse -fgcse-lm-finline-small-functions-findirect-inlining-fipa-sra-foptimize-sibling-calls-fpartial-inlining-fpeephole2-fregmove-freorder-blocks -freorder-functions-frerun-cse-after-loop-fsched-interblock -fsched-spec-fschedule-insns -fschedule-insns2-fstrict-aliasing -fstrict-overflow-ftree-switch-conversion -ftree-tail-merge-ftree-pre-ftree-vrpPlease note the warning under ‘-fgcse’ about invoking ‘-O2’ on programs thatuse computed gotos.
-fomit-frame-pointerDon’t keep the frame pointer in a register for functions that don’t need one.This avoids the instructions to save, set up and restore frame pointers; it alsomakes an extra register available in many functions. It also makes debuggingimpossible on some machines.On some machines, such as the VAX, this flag has no effect, because the stan-dard calling sequence automatically handles the frame pointer and nothing issaved by pretending it doesn’t exist. The machine-description macro FRAME_POINTER_REQUIRED controls whether a target machine supports this flag. SeeSection “Register Usage” in GNU Compiler Collection (GCC) Internals.Starting with GCC version 4.6, the default setting (when not opti-mizing for size) for 32-bit Linux x86 and 32-bit Darwin x86 targetshas been changed to ‘-fomit-frame-pointer’.The default can bereverted to ‘-fno-omit-frame-pointer’ by configuring GCC with the‘--enable-frame-pointer’ configure option.Enabled at levels ‘-O’, ‘-O2’, ‘-O3’, ‘-Os’.
-SCompile only; do not assemble or link
-o <file>Place the output into <file>
-x <language>Specify the language of the following input filesPermissible languages include: c c++ assembler none'none' means revert to the default behavior ofguessing the language based on the file's extension

-EPreprocess only; do not compile, assemble or link
[c]- do not warn if the library had to be created
r[ab][f][u]- replace existing or insert new file(s) into the archive
[v]- be verbose
-gProduce debugging information in the operating system’s native format (stabs,COFF, XCOFF, or DWARF 2). GDB can work with this debugging informa-tion.On most systems that use stabs format, ‘-g’ enables use of extra debugginginformation that only GDB can use; this extra information makes debuggingwork better in GDB but will probably make other debuggers crash or refuse toread the program. If you want to control for certain whether to generate theextra information, use ‘-gstabs+’, ‘-gstabs’, ‘-gxcoff+’, ‘-gxcoff’, or ‘-gvms’(see below).GCC allows you to use ‘-g’ with ‘-O’. The shortcuts taken by optimized codemay occasionally produce surprising results: some variables you declared maynot exist at all; flow of control may briefly move where you did not expect it;some statements may not be executed because they compute constant resultsor their values were already at hand; some statements may execute in differentplaces because they were moved out of loops.Nevertheless it proves possible to debug optimized output. This makes it rea-sonable to use the optimizer for programs that might have bugs.The following options are useful when GCC is generated with the capability formore than one debugging format.
-Os Optimize for size. ‘-Os’ enables all ‘-O2’ optimizations that do not typically           increase code size. It also performs further optimizations designed to reduce          code size.         ‘-Os’ disables the following optimization flags:-falign-functions -falign-jumps -falign-loops-falign-labels -freorder-blocks -freorder-blocks-and-partition-fprefetch-loop-arrays -ftree-vect-loop-version
--gap-fill <val>Fill gaps between sections with <val>
-print-file-name=libraryPrint the full absolute name of the library file library that would be used whenlinking—and don’t do anything else. With this option, GCC does not compileor link anything; it just prints the file name.
-D namePredefine name as a macro, with definition 1.
-I dir Add the directory dir to the list of directories to be searched for header files.      Directories named by ‘-I’ are searched before the standard system include di-         rectories. If the directory dir is a standard system include directory, the option        is ignored to ensure that the default search order for system directories and the       special treatment of system headers are not defeated . If dir begins with =, then      the = will be replaced by the sysroot prefix; see ‘--sysroot’ and ‘-isysroot’.
-fno-builtin-fno-builtin-functionDon’t recognize built-in functions that do not begin with ‘__builtin_’ as prefix.See Section 6.53 [Other built-in functions provided by GCC], page 405, fordetails of the functions affected, including those which are not built-in functionswhen ‘-ansi’ or ‘-std’ options for strict ISO C conformance are used becausethey do not have an ISO standard meaning.GCC normally generates special code to handle certain built-in functions moreefficiently; for instance, calls to alloca may become single instructions thatadjust the stack directly, and calls to memcpy may become inline copy loops.The resulting code is often both smaller and faster, but since the functioncalls no longer appear as such, you cannot set a breakpoint on those calls,nor can you change the behavior of the functions by linking with a differentlibrary. In addition, when a function is recognized as a built-in function, GCCmay use information about that function to warn about problems with calls tothat function, or to generate more efficient code, even if the resulting code stillcontains calls to that function. For example, warnings are given with ‘-Wformat’for bad calls to printf, when printf is built in, and strlen is known not tomodify global memory.With the ‘-fno-builtin-function ’ option only the built-in function functionis disabled. function must not begin with ‘__builtin_’. If a function is namedthat is not built-in in this version of GCC, this option is ignored. There isno corresponding ‘-fbuiltin-function ’ option; if you wish to enable built-infunctions selectively when using ‘-fno-builtin’ or ‘-ffreestanding’, you maydefine macros such as:#define abs(n)#define strcpy(d, s)__builtin_abs ((n))__builtin_strcpy ((d), (s))
-ffreestandingAssert that compilation takes place in a freestanding environment. This implies‘-fno-builtin’. A freestanding environment is one in which the standardlibrary may not exist, and program startup may not necessarily be at main. Themost obvious example is an OS kernel. This is equivalent to ‘-fno-hosted’.See Chapter 2 [Language Standards Supported by GCC], page 5, for details offreestanding and hosted environments.
-nostdincDo not search the standard system directories for header files. Only the direc-tories you have specified with ‘-I’ options (and the directory of the current file,if appropriate) are searched.
-isystem dirSearch dir for header files, after all directories specified by ‘-I’ but before thestandard system directories. Mark it as a system directory, so that it gets thesame special treatment as is applied to the standard system directories. If dirbegins with =, then the = will be replaced by the sysroot prefix; see ‘--sysroot’and ‘-isysroot’.
-pipe Use pipes rather than temporary files for communication between the various     stages of compilation. This fails to work on some systems where the assembler    is unable to read from a pipe; but the GNU assembler has no trouble.
-fstack-protectorEmit extra code to check for buffer overflows, such as stack smashing attacks.This is done by adding a guard variable to functions with vulnerable objects.This includes functions that call alloca, and functions with buffers larger than8 bytes. The guards are initialized when a function is entered and then checkedwhen the function exits. If a guard check fails, an error message is printed andthe program exits.
-Bstatic-BdynamicThese options are passed down to the linker. They are defined for compatibilitywith Diab.
-T scriptUse script as the linker script. This option is supported by most systems usingthe GNU linker. On some targets, such as bare-board targets without an oper-ating system, the ‘-T’ option may be required when linking to avoid referencesto undefined symbols.
-Ttext=orgSame as ‘--section-start’, with .bss, .data or .text as the sectionname.
--section-start=sectionname =orgLocate a section in the output file at the absolute address given by org. Youmay use this option as many times as necessary to locate multiple sections in thecommand line. org must be a single hexadecimal integer; for compatibility withother linkers, you may omit the leading ‘0x’ usually associated with hexadecimalvalues. Note: there should be no white space between sectionname, the equalssign (“=”), and org.
-o file Write output to file. This is the same as specifying file as the second non-option       argument to cpp. gcc has a different interpretation of a second non-option      argument, so you must use ‘-o’ to specify the output file.
-cCompile or assemble the source files, but do not link. The linking stage simplyis not done. The ultimate output is in the form of an object file for each sourcefile.By default, the object file name for a source file is made by replacing the suffix‘.c’, ‘.i’, ‘.s’, etc., with ‘.o’.Unrecognized input files, not requiring compilation or assembly, are ignored.


原创粉丝点击