The top layer of makefile analysis of U-boot config.mk

Source: Internet
Author: User

Version information: u-boot-2010-06
The config.mk file under the top-level directory mainly accomplishes the following functions:
1. Determine the various tools required to generate the executable file, such as compilers (ARM-LINUX-GCC), Connectors (ARM-LINUX-LD), Disassembler (arm-linux-objdump), etc.
2, determine the CPU, board-related configuration files, exist in each directory Config.mk
3. Determine the operation options for compiling, linking, converting, etc.

4. Generate the required files according to the compilation connection options identified in step 3

CONFIG.MK complete contents and necessary notes are as follows
Note : The config.mk file comment is changed to/* Comment content */

Ifneq ($ (Objtree), $ (srctree)) ifeq ($ (CURDIR), $ (Srctree)) dir: =elsedir: = $ (subst $ (srctree)/,,$ (CURDIR)) Endifobj: = $ ( If $ (dir), $ (objtree)/$ (dir)/,$ (objtree)/) src: = $ (if $ (dir), $ (srctree)/$ (dir)/,$ (Srctree)/) $ (Shell mkdir-p $ (obj)) Elseobj: =src: =endif/* obj = null, src = null * dir = null */* Clean the slate ... */platform_relflags =platform_cppflags =PLATFO Rm_ldflags =/* hostcflags =-wall-wstrict-prototypes-o2-fomit-frame-pointer *-wall: Print out all error or warning messages at compile time *-Wstrict-protot Ypes: When compiling a problem that does not match the data type, a prompt or warning message is printed. This option avoids many errors when porting between different architectures *-O: Five kinds of:-O 0,-o1,-o2,-o3, and-os *-fomit-frame-pointer when compiling code: for functions that do not require frame pointers, do not save frame pointers in registers * Code optimization when opening-fomit-frame-pointer, function calls do not save the frame pointer, you can not use BackTrace () to view the function stack call * BACKTRACE () series functions See [http://blog.csdn.net/ U013686019/ARTICLE/DETAILS/42128771] (application example of BackTrace () series functions in Linux) */hostcflags=-wall-wstrict-prototypes-o2- Fomit-frame-pointer $ (hostcppflags)//Hoststrip = Strip * Strip can eliminate unnecessary identifiers and debugging information in the execution file, can reduce the file size without affecting the normal use,, * and compression is different, the file once the St Cannot be restored after RIP * strip file does not contain debuggingInformation */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 does this we pass the-traditional-cpp * option to the compiler. Note that the-traditional-cpp flag * DOES not has the same semantics as GNU C ' s flag, all it DOES * is invoke the GNU PR Eprocessor in stock ansi/iso C fashion. * * APPLE's linker is similar, thanks to the new 2 stage linking * Multiple symbol definitions be treated as errors, Henc E The *-multiply_defined suppress option to turn off this error. */ifeq ($ (Hostos), Darwin) ... elsehostcc= gccendififeq ($ (Hostos), cygwin) ... endif/* We build some files with extra Pedantic flags to try to minimize things * This won ' t build on some weird host compiler--though there is lots of * exce Ptions for files that aren ' t complaint. */hostcflags_noped = $ (filter-out-pedantic,$ (hostcflags))/*-pedantic: When GCC compiles source code that does not conform to the Ansi/iso C language standard, If the-pedantic option is added to the compilation Directive * then the sourceWhere the extension syntax is used in the program, a corresponding warning message is generated */hostcflags+=-pedantic################################################################ #########/* Option Checker (courtesy Linux kernel) To ensure * Only supported compiler options is used * cc-option variable saves a The command to test the compile option, which is often called by the call function elsewhere, tests the compilation options * if $ (CC) $ (CFLAGS) $ (1)-s-o/dev/null-xc/dev/null >/dev/null 2>&1;the   Necho "$ (1)";   Elseecho "$ (2)"; Fi *-S: End immediately after compilation, do not compile, etc. *-o/dev/null: Generate files to/dev/null, that is, do not generate any compilation results, the file to be compiled is also empty *-XC: Specify to compile in C language * with this statement such as: Call Cc-option,-a,-b  Fruit Support-A option returns-a otherwise returns-B */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) as/* Assembler tool */ld= $ (cross_compile) ld/* link tool */cc= $ (CR Oss_compile) gcc/* Compilation tool */cpp= $ (CC)-e/* preprocessing */ar= $ (cross_compile) ar/* Archive tool */nm= $ (cross_compile) nm/* list the symbols in the object file * /ldr= $ (cross_compile) ldrstrip= $ (cross_compile) Stripobjcopy = $ (cross_compile) OBjcopy/* Convert executable file Format Tool */objdump = $ (cross_compile) OBJDUMP/* Disassembly tool */ranlib= $ (cross_compile) ranlib/* Generate archive file index */####### ##################################################################/* Load Generated Board configuration *//* Sinclude: * In Makefile You can use "sinclude" instead of "include" to ignore errors due to the inclusion of files that do not exist or cannot be created */sinclude $ (objtree)/include/autoconf.mk/* Some architecture config.mk files need to know what cpudir are 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) IFNEQ ($ (srctree)/$ (Cpudir), $ (wildcard $ (srctree)/$ (Cpudir))) cpudir=arch/$ (Arch) /cpuendif/* cpudir=arch/arm/cpu/arm920t *//* include architecture dependend rules:arch/arm/config.mk */sinclude $ ( Topdir)/arch/$ (arch)/config.mk/* include cpuspecific rules:arch/arm/cpu/arm920t/config.mk */sinclude $ (TOPDIR)/$ ( Cpudir)/config.mkifdefsoc/* include socspecific Rules:arch/arm/cpu/arm920t/s3c24x0/config.mk */sinclude $ (topdir)/$ (cpudir)/$ (SOC)/config.mkendififdefvendorboarddir = $ (VENDOR)/$ (BOARD ) Elseboarddir = $ (BOARD) endif/* Boarddir = samsung/smdk2410 */ifdefboard/* include BOARD specific RULES:BOARD/SAMSUNG/SM Dk2410/config.mk */sinclude $ (topdir)/board/$ (boarddir)/config.mkendif########################################## ############################## #ifneq (, $ (findstring s,$ (makeflags))) Arflags = Crelsearflags = crvendifrelflags= $ ( Platform_relflags) dbgflags=-G #-ddebugoptflags=-os #-fomit-frame-pointer/* ldscript = arch/arm/cpu/arm920t/ U-boot.lds, assignment in file arch/arm/config.mk */ifndef ldscript#ldscript: = $ (Topdir)/board/$ (boarddir)/ U-boot.lds.debugifeq ($ (config_nand_u_boot), y) Ldscript: = $ (Topdir)/board/$ (boarddir)/u-boot-nand.ldselseldscript : = $ (Topdir)/board/$ (Boarddir) the gap between/u-boot.ldsendifendif/* segments with 0xFF padding */objcflags + =--gap-fill=0xffgccincdir: = $ ( Shell $ (CC)-print-file-name=include)/* cppflags variable synthesizes the dbgflags,optflags,relflags compilation option and defines __kerbel__ *-D: SetMacro definition __kernel__ */cppflags: = $ (dbgflags) $ (optflags) $ (relflags)-d__kernel__ifneq ($ (text_base),) cppflags + =-DTEXT_ base=$ (Text_base) endififneq ($ (reset_vector_address),) Cppflags + =-dreset_vector_address=$ (RESET_VECTOR_ADDRESS) Endififneq ($ (Objtree), $ (srctree)) Cppflags + =-i$ (objtree)/include2-i$ (objtree)/includeendifcppflags + =-I$ (TOPDIR) /includecppflags + =-fno-builtin-ffreestanding-nostdinc-isystem $ (gccincdir)-pipe $ (platform_cppflags) ifdef BUILD_ Tagcflags: = $ (cppflags)-wall-wstrict-prototypes-dbuild_tag= ' "$ (build_tag)" ' Elsecflags: = $ (cppflags)-Wall- Wstrict-prototypesendifcflags + = $ (call cc-option,-fno-stack-protector)/* $ (Cppflags) sets-g, which causes GCC to pass a suitable-g<format> *//* option to the assembler. */aflags_debug: =aflags: = $ (Aflags_debug)-d__assembly__ $ (cppflags) Ldflags + =-bstatic-t $ (obj) U-boot.lds $ (PLATFORM_  Ldflags) Ifneq ($ (text_base),) Ldflags +-ttext $ (text_base) endif/* ldflags =-bstatic-t u-boot.lds-ttext 0x33F80000 *//* CFLAGS=-g-os-fno-common-ffixed-r8-msoft-float-d__kernel__-dtext_base=0x33f80000-i/u-boot-2010.06/include-fno-builti n-ffreestanding-nostdinc-isystem/usr/local/arm/4.2.2-eabi/usr/bin-ccache/. /lib/gcc/arm-unknown-linux-gnueabi/4.2.2/include-pipe-dconfig_arm-d__arm__-marm-mabi=aapcs-linux- Mno-thumb-interwork-march=armv4-wall-wstrict-prototypes-fno-stack-protector *//* location of a usable BFD library, whe  Re we define "usable" as * "Built for ${host}, supports ${target}". Sensible values is *-when cross-compiling:the root of the cross-environment *-linux/ppc (native):/usr *-netbsd/pp C (native): You lose ... (must extract these from the * binutils build directory, plus the native and u-boot include * files don ' t like each ot She) * So far, this is used only by Tools/gdb/makefile. */ifeq ($ (Hostos), Darwin) Bfd_root_dir =/usr/local/toolselseifeq ($ (Hostarch), $ (ARCH))/* Native */bfd_root_dir =/ usrelse/* bfd_root_dir =/linuxppc/cdk# linux/i386 *//* bfd_root_DIR =/usr/pkg/cross# netbsd/i386 */bfd_root_dir =/opt/powerpcendifendif########################################### ############################# #exportHOSTCC hostcflags hostldflags pedcflags hoststrip cross_compile as LD CC CPP AR NM STR IP objcopy OBJDUMP makeexporttext_base platform_cppflags platform_relflags cppflags CFLAGS aflags##################### ####################################################/* The following lines specify compilation options for compiling various files *//* allow boards to use custom optimize Flags on a per dir/file basis */bcurdir = $ (subst $ (srctree)/,,$ (curdir:$ (obj)%=%)/* Bcurdir = Top level directory */$ (obj)%.s:%. S $ (CPP) $ (aflags) $ (aflags_$ (Bcurdir)/$ (@F)) $ (aflags_$ (bcurdir))-O [email protected] $<$ (obj)%.o:%.  S $ (cc) $ (aflags) $ (aflags_$ (Bcurdir)/$ (@F)) $ (aflags_$ (bcurdir))-O [email protected] $<-c$ (obj)%.o:%.c$ (cc) $ (CFLAGS) $ (cflags_$ (Bcurdir)/$ (@F)) $ (cflags_$ (bcurdir))-O [email protected] $<-c$ (obj)%.i:%.c$ (CPP) $ ( CFLAGS) $ (cflags_$ (Bcurdir)/$ (@F)) $ (cflags_$ (bcurdir))-O [Email&nbsP;protected] $<-c$ (obj)%.s:%.c$ (CC) $ (CFLAGS) $ (cflags_$ (Bcurdir)/$ (@F)) $ (cflags_$ (bcurdir))-O [email  Protected] $<-c-s

The top layer of makefile analysis of U-boot config.mk

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.