亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 1213 | 回復(fù): 0
打印 上一主題 下一主題

translating makefile.txt in Linux source code [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2009-05-05 23:54 |只看該作者 |倒序?yàn)g覽

                                                Linux Kernel Makefiles
This document describes the Linux kernel Makefiles.
=== Table of Contents
    === 1 Overview
    === 2 Who does what
    === 3 The kbuild files
       --- 3.1 Goal definitions
       --- 3.2 Built-in object goals - obj-y
       --- 3.3 Loadable module goals - obj-m
       --- 3.4 Objects which export symbols
       --- 3.5 Library file goals - lib-y
       --- 3.6 Descending down in directories
       --- 3.7 Compilation flags
       --- 3.8 Command line dependency
       --- 3.9 Dependency tracking
       --- 3.10 Special Rules
    === 4 Host Program support
       --- 4.1 Simple Host Program
       --- 4.2 Composite Host Programs
       --- 4.3 Defining shared libraries  
       --- 4.4 Using C++ for host programs
       --- 4.5 Controlling compiler options for host programs
       --- 4.6 When host programs are actually built
       --- 4.7 Using hostprogs-$(CONFIG_FOO)
    === 5 Kbuild clean infrastructure
    === 6 Architecture Makefiles
       --- 6.1 Set variables to tweak the build to the architecture
       --- 6.2 Add prerequisites to prepare:
       --- 6.3 List directories to visit when descending
       --- 6.4 Architecture specific boot images
       --- 6.5 Building non-kbuild targets
       --- 6.6 Commands useful for building a boot image
       --- 6.7 Custom kbuild commands
       --- 6.8 Preprocessing linker scripts
       --- 6.9 $(CC) support functions
    === 7 Kbuild Variables
    === 8 Makefile language
    === 9 Credits
    === 10 TODO
=== 1 Overview
The Makefiles have five parts:
    Makefile        the top Makefile.
    .config            the kernel configuration file.
    arch/$(ARCH)/Makefile    the arch Makefile.
    scripts/Makefile.*    common rules etc. for all kbuild Makefiles.
    kbuild Makefiles    there are about 500 of these.
The top Makefile reads the .config file, which comes from the kernel
configuration process.
The top Makefile is responsible for building two major products: vmlinux
(the resident kernel image) and modules (any module files).
It builds these goals by recursively descending into the subdirectories of
the kernel source tree.
The list of subdirectories which are visited depends upon the kernel
configuration. The top Makefile textually includes an arch Makefile
with the name arch/$(ARCH)/Makefile. The arch Makefile supplies
architecture-specific information to the top Makefile.
Each subdirectory has a kbuild Makefile which carries out the commands
passed down from above. The kbuild Makefile uses information from the
.config file to construct various file lists used by kbuild to build
any built-in or modular targets.
scripts/Makefile.* contains all the definitions/rules etc. that
are used to build the kernel based on the kbuild makefiles.
(譯)
=== 1 概述
Makefiles 分為五部分:
    Makefile        頂層的Makefile.
    .config            內(nèi)核配置文件.
    arch/$(ARCH)/Makefile    體系Makefile.
    scripts/Makefile.*    公共規(guī)則等等. 供給所有的kbuild Makefiles.
    kbuild Makefiles    大約有500這樣的Makefiles.
頂層的Makefile讀入.config文件,這文件來(lái)自內(nèi)核配置處理。
頂層Makefile是負(fù)責(zé)建立兩個(gè)主要的產(chǎn)物:vmlinux(常駐內(nèi)核鏡像)和模塊 (任何模塊文件)。
它建立這些目標(biāo)通過(guò)遞歸向下的進(jìn)入內(nèi)核源碼樹的子目錄來(lái)實(shí)現(xiàn)的。
這些子目錄列表根據(jù)內(nèi)核的配置來(lái)被訪問(wèn)。頂層Makefile原文地包含體系的Makefile
"arch/$(ARCH)/Makefile". 這個(gè)體系的Makefile 提供指定的體系信息給頂層的Makefile.
每個(gè)子目錄都有一個(gè)kbuild Makefile 來(lái)執(zhí)行從上層傳遞下來(lái)的命令。這些kbuild Makefile使用
來(lái)自.config文件的信息來(lái)構(gòu)造各種文件列表,用來(lái)給kbuild建立各種build-in或模塊目標(biāo)。
scripts/Makefile.* 包含所有的定義/規(guī)則等等。用以基于kbuild Makefiles來(lái)建立內(nèi)核。
   
=== 2 Who does what
People have four different relationships with the kernel Makefiles.
*Users* are people who build kernels.  These people type commands such as
"make menuconfig" or "make".  They usually do not read or edit
any kernel Makefiles (or any other source files).
*Normal developers* are people who work on features such as device
drivers, file systems, and network protocols.  These people need to
maintain the kbuild Makefiles for the subsystem that they are
working on.  In order to do this effectively, they need some overall
knowledge about the kernel Makefiles, plus detailed knowledge about the
public interface for kbuild.
*Arch developers* are people who work on an entire architecture, such
as sparc or ia64.  Arch developers need to know about the arch Makefile
as well as kbuild Makefiles.
*Kbuild developers* are people who work on the kernel build system itself.
These people need to know about all aspects of the kernel Makefiles.
This document is aimed towards normal developers and arch developers.
(譯)
=== 2 人們與Makefile。
人們與kernel Makefiles的之間分為4種不同的關(guān)系。
*用戶* 是一類建立內(nèi)核的人們。 這些人只是敲命令例如"make menuconfig" 或者 "make".
他們通常不需要閱讀或者編輯任何內(nèi)核Makefiles(或者任何其他的源文件)。
*普通的開發(fā)者* 是一類工作在例如設(shè)備驅(qū)動(dòng),文件系統(tǒng)和網(wǎng)絡(luò)協(xié)議的人們。這些人需要
維護(hù)他們工作的子系統(tǒng)的kbuild Makefiles。為了使到這些更高效,他們需要一些全面
的知識(shí)關(guān)于內(nèi)核Makefiles, 和詳細(xì)的知識(shí)關(guān)于kbuild公共接口。
*體系開發(fā)者* 是一類工作在整個(gè)體系的人們,例如 sparc或者ia64的。體系開發(fā)者既需要
理解體系Makefile,也需要理解kbuild Makefiles.
*kbuild開發(fā)者* 是一類工作在建立內(nèi)核build系統(tǒng)的人們。這些人們需要理解內(nèi)核Makefiles
的各個(gè)方面知識(shí)。
這個(gè)文檔是面向普通的開發(fā)人員和體系開發(fā)者。
=== 3 The kbuild files
Most Makefiles within the kernel are kbuild Makefiles that use the
kbuild infrastructure. This chapter introduce the syntax used in the
kbuild makefiles.
The preferred name for the kbuild files is 'Kbuild' but 'Makefile' will
continue to be supported. All new developmen is expected to use the
Kbuild filename.
Section 3.1 "Goal definitions" is a quick intro, further chapters provide
more details, with real examples.
(譯)
=== 3 kbuild文件
大部分處在內(nèi)核中的Makefiles都是kbuild Makefiles, 用來(lái)kbuild的下部構(gòu)造。這章介紹
kbuild makefiles用到的語(yǔ)法。
給kbuild files個(gè)更好的稱呼是'Kbuild',而不是'Makefile',這會(huì)繼續(xù)被使用。希望所有新
的開發(fā)者都去使用Kbuild這個(gè)名字。
3.1 節(jié) “目標(biāo)定義”是一個(gè)快速介紹,后面的章節(jié)提供更詳細(xì)的信息和真實(shí)的例子。
--- 3.1 Goal definitions
    Goal definitions are the main part (heart) of the kbuild Makefile.
    These lines define the files to be built, any special compilation
    options, and any subdirectories to be entered recursively.
    The most simple kbuild makefile contains one line:
    Example:
        obj-y += foo.o
    This tell kbuild that there is one object in that directory named
    foo.o. foo.o will be built from foo.c or foo.S.
    If foo.o shall be built as a module, the variable obj-m is used.
    Therefore the following pattern is often used:
    Example:
        obj-$(CONFIG_FOO) += foo.o
    $(CONFIG_FOO) evaluates to either y (for built-in) or m (for module).
    If CONFIG_FOO is neither y nor m, then the file will not be compiled
    nor linked.
(譯)
--- 3.1 目標(biāo)定義
目標(biāo)定義是kbuild Makefile主要(核心)部分。這些行定義了建立這些文件,任何特殊的
編譯選項(xiàng),和遞歸地進(jìn)入任何子目錄。
最簡(jiǎn)單的kbuild makefile包含一行:
例子:
obj-y += foo.o
這告訴kbuild在這個(gè)目錄下有一個(gè)目標(biāo)叫做foo.o. 這個(gè)foo.o將被建立通過(guò)foo.c或者foo.S.
如果foo.o應(yīng)該被作為模塊來(lái)建立,變量obj-m被使用。因此下面模式經(jīng)常被使用:
例子:
obj-$(CONFIG_FOO) += foo.o
$(CONFIG_FOO) 評(píng)估為y(built-in)或者m(模塊)。如果CONFIG_FOO既不是y也不是m,那么該文件
將會(huì)不被編譯也不被鏈接。
--- 3.2 Built-in object goals - obj-y
    The kbuild Makefile specifies object files for vmlinux
    in the lists $(obj-y).  These lists depend on the kernel
    configuration.
    Kbuild compiles all the $(obj-y) files.  It then calls
    "$(LD) -r" to merge these files into one built-in.o file.
    built-in.o is later linked into vmlinux by the parent Makefile.
    The order of files in $(obj-y) is significant.  Duplicates in
    the lists are allowed: the first instance will be linked into
    built-in.o and succeeding instances will be ignored.
    Link order is significant, because certain functions
    (module_init() / __initcall) will be called during boot in the
    order they appear. So keep in mind that changing the link
    order may e.g.  change the order in which your SCSI
    controllers are detected, and thus you disks are renumbered.
    Example:
        #drivers/isdn/i4l/Makefile
        # Makefile for the kernel ISDN subsystem and device drivers.
        # Each configuration option enables a list of files.
        obj-$(CONFIG_ISDN)             += isdn.o
        obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o
(譯)
--- 3.2 Built-in object 目標(biāo) - obj-y
這個(gè)kbuild Makefile 在$(obj-y)列表里為vmlinux指定了object文件。這些列表在
內(nèi)核配置的時(shí)候?qū)⒈皇褂玫健?br /> Kbuild 編譯所有的$(obj-y)文件。它然后調(diào)用"$(LD) -r" 去合并這些文件成一個(gè)built-in.o
文件。built-in.o將會(huì)被父目錄的Makefile鏈接到vmlinux去。
在$(obj-y)列表里的文件順序是非常重要的。在列表里重復(fù)出現(xiàn)是允許的:最前面的實(shí)例將被
鏈接到built-in.o, 而后面同名的實(shí)例將會(huì)被忽略掉。
鏈接的順序也是至關(guān)重要的,因?yàn)槟承┖瘮?shù) (module_init()/ __initcall)將會(huì)在依賴他們
出現(xiàn)的順序在boot的時(shí)候被調(diào)用。所以一定要記住改變鏈接順序可能發(fā)生這樣事情,例如:當(dāng)你
改變SCSI控制器順序被偵測(cè)到后,因此你的硬盤被重編號(hào)。
例子:
        #drivers/isdn/i4l/Makefile
        # Makefile for the kernel ISDN subsystem and device drivers.
        # Each configuration option enables a list of files.
        obj-$(CONFIG_ISDN)             += isdn.o
        obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o
--- 3.3 Loadable module goals - obj-m
    $(obj-m) specify object files which are built as loadable
    kernel modules.
    A module may be built from one source file or several source
    files. In the case of one source file, the kbuild makefile
    simply adds the file to $(obj-m).
    Example:
        #drivers/isdn/i4l/Makefile
        obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o
    Note: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to 'm'
    If a kernel module is built from several source files, you specify
    that you want to build a module in the same way as above.
    Kbuild needs to know which the parts that you want to build your
    module from, so you have to tell it by setting an
    $(-objs) variable.
    Example:
        #drivers/isdn/i4l/Makefile
        obj-$(CONFIG_ISDN) += isdn.o
        isdn-objs := isdn_net_lib.o isdn_v110.o isdn_common.o
    In this example, the module name will be isdn.o. Kbuild will
    compile the objects listed in $(isdn-objs) and then run
    "$(LD) -r" on the list of these files to generate isdn.o.
    Kbuild recognises objects used for composite objects by the suffix
    -objs, and the suffix -y. This allows the Makefiles to use
    the value of a CONFIG_ symbol to determine if an object is part
    of a composite object.
    Example:
        #fs/ext2/Makefile
            obj-$(CONFIG_EXT2_FS)        += ext2.o
         ext2-y                       := balloc.o bitmap.o
            ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o
   
    In this example xattr.o is only part of the composite object
    ext2.o, if $(CONFIG_EXT2_FS_XATTR) evaluates to 'y'.
    Note: Of course, when you are building objects into the kernel,
    the syntax above will also work. So, if you have CONFIG_EXT2_FS=y,
    kbuild will build an ext2.o file for you out of the individual
    parts and then link this into built-in.o, as you would expect.
(譯)
--- 3.3 可加載模塊目標(biāo) - obj-m
$(obj-m) 指定的object文件,這些文件可以作為可加載的內(nèi)核模塊。
一個(gè)模塊可能由一個(gè)源文件或幾個(gè)源文件建立。在由一個(gè)源文件建立的情況,kbuild makefile
簡(jiǎn)單的添加文件到目標(biāo)$(obj-m)。
    例子:
        #drivers/isdn/i4l/Makefile
        obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o
注意:這個(gè)例子里的$(CONFIG_ISDN_PPP_BSDCOMP)被評(píng)估為'm'
如果內(nèi)核模塊由幾個(gè)源文件建立的,你只需要使用上面相同方法指定它們到要建立的目標(biāo)里。
Kbuild 需要知道從哪一部分你想建立你的模塊,所以你必須通過(guò)$(-objs)變量來(lái)告訴它。
    例子:
        #drivers/isdn/i4l/Makefile
        obj-$(CONFIG_ISDN) += isdn.o
        isdn-objs := isdn_net_lib.o isdn_v110.o isdn_common.o
在這個(gè)例子里,模塊名將是isdn.o。Kbuild將編譯這些$(isdn-objs)里的objects, 然后運(yùn)行"$(LD) -r"
通過(guò)這些列表文件來(lái)產(chǎn)生isdn.o。
Kbuild 通過(guò)后綴-objs和-y來(lái)識(shí)別objects構(gòu)造objects,它允許Makefiles去使用CONFIG_符號(hào)值去決定這個(gè)
object是否屬于組合object的一部分。
    例子:
        #fs/ext2/Makefile
            obj-$(CONFIG_EXT2_FS)        += ext2.o
         ext2-y                       := balloc.o bitmap.o
            ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o
在這個(gè)例子里xattr.o是組合目標(biāo)ext2.o的一部分,緊且如果$(CONFIG_EXT2_FS_XATTR)被評(píng)估為'y'。
注意:當(dāng)然,當(dāng)你建立這些objects到內(nèi)核,上面所說(shuō)的語(yǔ)法同樣能工作。所以,如果你的
CONFIG_EXT2_FS=y,Kbuild將為你建立ext2.o為獨(dú)立的部分,然后鏈接它到built-in.o,如你所盼望的那樣。
--- 3.4 Objects which export symbols
    No special notation is required in the makefiles for
    modules exporting symbols.
(譯)
--- 3.4 導(dǎo)出Objects符號(hào)
沒(méi)有特殊的標(biāo)記法,在makefiles被請(qǐng)求模塊導(dǎo)出符號(hào)的。
--- 3.5 Library file goals - lib-y
    Objects listed with obj-* are used for modules or
    combined in a built-in.o for that specific directory.
    There is also the possibility to list objects that will
    be included in a library, lib.a.
    All objects listed with lib-y are combined in a single
    library for that directory.
    Objects that are listed in obj-y and additional listed in
    lib-y will not be included in the library, since they will anyway
    be accessible.
    For consistency objects listed in lib-m will be included in lib.a.
    Note that the same kbuild makefile may list files to be built-in
    and to be part of a library. Therefore the same directory
    may contain both a built-in.o and a lib.a file.
    Example:
        #arch/i386/lib/Makefile
        lib-y    := checksum.o delay.o
    This will create a library lib.a based on checksum.o and delay.o.
    For kbuild to actually recognize that there is a lib.a being build
    the directory shall be listed in libs-y.
    See also "6.3 List directories to visit when descending".

    Usage of lib-y is normally restricted to lib/ and arch/*/lib.
(譯)
--- 3.5 庫(kù)文件目標(biāo) - lib-y
Objects以obj-*列表的形式被模塊使用,或者被聯(lián)合到指定目錄的build-in.o里。同樣也有可能
去列表objects,這些object被包含到一個(gè)庫(kù),lib.a。
所有objects以lib-y列表的形式被合并成一個(gè)簡(jiǎn)單的庫(kù)供給這個(gè)目錄。
在obj-y里面的排列的Objects和在lib-y里的附加列表將不會(huì)被包含進(jìn)庫(kù)里,因?yàn)樗鼈儗⒔?jīng)常的
被訪問(wèn)到。
為了使到objects列表一致性,被包含到lib-m里的同時(shí)也會(huì)被包含進(jìn)lib.a中。
注意同樣的kbuild makefile 可能列表文件為built-in形式和庫(kù)的一部分。因此同一個(gè)目錄下可能
同時(shí)包含built-in.o和lib.a文件。
    例子:
        #arch/i386/lib/Makefile
        lib-y    := checksum.o delay.o
這將基于checksum.o和delay.o創(chuàng)建一個(gè)庫(kù)lib.a。為了kbuild去真實(shí)的明白到有這樣一個(gè)lib.a庫(kù)來(lái)建立
這個(gè)目錄,這個(gè)目錄的包含信息應(yīng)該在lib-y里被列出來(lái)。
同樣參見 "6.3 List directories to visit when descending".
lib-y的用法被普遍的限制到lib/和arch/*/lib里。
--- 3.6 Descending down in directories
    A Makefile is only responsible for building objects in its own
    directory. Files in subdirectories should be taken care of by
    Makefiles in these subdirs. The build system will automatically
    invoke make recursively in subdirectories, provided you let it know of
    them.
    To do so obj-y and obj-m are used.
    ext2 lives in a separate directory, and the Makefile present in fs/
    tells kbuild to descend down using the following assignment.
    Example:
        #fs/Makefile
        obj-$(CONFIG_EXT2_FS) += ext2/
    If CONFIG_EXT2_FS is set to either 'y' (built-in) or 'm' (modular)
    the corresponding obj- variable will be set, and kbuild will descend
    down in the ext2 directory.
    Kbuild only uses this information to decide that it needs to visit
    the directory, it is the Makefile in the subdirectory that
    specifies what is modules and what is built-in.
    It is good practice to use a CONFIG_ variable when assigning directory
    names. This allows kbuild to totally skip the directory if the
    corresponding CONFIG_ option is neither 'y' nor 'm'.
(譯)
--- 3.6 下降到子目錄
一個(gè)Makefile只是負(fù)責(zé)建立它自己目錄下的objects。子目錄下的文件因該有這些子目錄下的
makefiles來(lái)處理。build系統(tǒng)將在子目錄里自動(dòng)的遞歸調(diào)用,你應(yīng)該提供足夠信息給它去處理。
To do so obj-y and obj-m are used.
ext2處在一個(gè)獨(dú)立的目錄里,在fs/里的Makefile會(huì)告訴kbuild去下降處理下面的賦值。
    例子:
        #fs/Makefile
        obj-$(CONFIG_EXT2_FS) += ext2/
如果CONFIG_EXT2_FS被賦值為'y' (built-in) 或者 'm' (模塊),那么相應(yīng)的obj-變量將會(huì)被賦值,
kbuild將下降到ext2目錄。
Kbuild僅僅使用這些信息去決定它需要去訪問(wèn)這個(gè)目錄,在這個(gè)子目錄里的Makefile指示那些是模塊
和那些是built-in。
這是一個(gè)很好的實(shí)例去使用CONFIG_變量,這個(gè)變量被賦值目錄名。這樣允許kbuild去全部跳過(guò)那些
CONFIG_選項(xiàng)既不是'y'又不是'm'的目錄。
--- 3.7 Compilation flags
    EXTRA_CFLAGS, EXTRA_AFLAGS, EXTRA_LDFLAGS, EXTRA_ARFLAGS
    All the EXTRA_ variables apply only to the kbuild makefile
    where they are assigned. The EXTRA_ variables apply to all
    commands executed in the kbuild makefile.
    $(EXTRA_CFLAGS) specifies options for compiling C files with
    $(CC).
    Example:
        # drivers/sound/emu10k1/Makefile
        EXTRA_CFLAGS += -I$(obj)
        ifdef DEBUG
            EXTRA_CFLAGS += -DEMU10K1_DEBUG
        endif
    This variable is necessary because the top Makefile owns the
    variable $(CFLAGS) and uses it for compilation flags for the
    entire tree.
    $(EXTRA_AFLAGS) is a similar string for per-directory options
    when compiling assembly language source.
    Example:
        #arch/x86_64/kernel/Makefile
        EXTRA_AFLAGS := -traditional
    $(EXTRA_LDFLAGS) and $(EXTRA_ARFLAGS) are similar strings for
    per-directory options to $(LD) and $(AR).
    Example:
        #arch/m68k/fpsp040/Makefile
        EXTRA_LDFLAGS := -x
    CFLAGS_$@, AFLAGS_$@
    CFLAGS_$@ and AFLAGS_$@ only apply to commands in current
    kbuild makefile.
    $(CFLAGS_$@) specifies per-file options for $(CC).  The $@
    part has a literal value which specifies the file that it is for.
    Example:
        # drivers/scsi/Makefile
        CFLAGS_aha152x.o =   -DAHA152X_STAT -DAUTOCONF
        CFLAGS_gdth.o    = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ \
                     -DGDTH_STATISTICS
        CFLAGS_seagate.o =   -DARBITRATE -DPARITY -DSEAGATE_USE_ASM
    These three lines specify compilation flags for aha152x.o,
    gdth.o, and seagate.o
    $(AFLAGS_$@) is a similar feature for source files in assembly
    languages.
    Example:
        # arch/arm/kernel/Makefile
        AFLAGS_head-armv.o := -DTEXTADDR=$(TEXTADDR) -traditional
        AFLAGS_head-armo.o := -DTEXTADDR=$(TEXTADDR) -traditional
(譯)
--- 3.7 編譯標(biāo)記
EXTRA_CFLAGS, EXTRA_AFLAGS, EXTRA_LDFLAGS, EXTRA_ARFLAGS
所有的EXTRA_變量被使用,僅且僅當(dāng)在這些kbuild makefile中它們被賦值。EXTRA_變量
被應(yīng)用到所有在kbuild makefile里被執(zhí)行到的命令。
$(EXTRA_CFLAGS) 為使用$(CC)來(lái)編譯C文件提供指定選項(xiàng)。
    例子:
        # drivers/sound/emu10k1/Makefile
        EXTRA_CFLAGS += -I$(obj)
        ifdef DEBUG
            EXTRA_CFLAGS += -DEMU10K1_DEBUG
        endif
這些變量是很必要的,因?yàn)轫攲拥腗akefile擁有變量$(CFLAGS)和使用它作為整個(gè)樹的編譯標(biāo)志。
$(EXTRA_AFLAGS) 是一個(gè)類似的字符串作為每個(gè)目錄的選項(xiàng),當(dāng)編譯匯編語(yǔ)言源文件的時(shí)候。
    例子:
        #arch/x86_64/kernel/Makefile
        EXTRA_AFLAGS := -traditional
$(EXTRA_LDFLAGS) 和 $(EXTRA_ARFLAGS) 都是類似的字符串為每個(gè)目錄下的$(LD)和$(AR)提供選項(xiàng)。
    例子:
        #arch/m68k/fpsp040/Makefile
        EXTRA_LDFLAGS := -x
--- 3.9 Dependency tracking
    Kbuild tracks dependencies on the following:
    1) All prerequisite files (both *.c and *.h)
    2) CONFIG_ options used in all prerequisite files
    3) Command-line used to compile target
    Thus, if you change an option to $(CC) all affected files will
    be re-compiled.
(譯)
--- 3.9 依賴跟蹤
Kbuild跟蹤依賴性如下所示:
1)所有的依賴文件(*.c和*.h)
2)CONFIG_選項(xiàng)被應(yīng)用到所有的依賴文件中。
3)命令行常用來(lái)編譯目標(biāo)。
因此,如果你改變了$(CC)選項(xiàng),那么所有受影響的文件將被重編。
--- 3.10 Special Rules
    Special rules are used when the kbuild infrastructure does
    not provide the required support. A typical example is
    header files generated during the build process.
    Another example is the architecture specific Makefiles which
    needs special rules to prepare boot images etc.
    Special rules are written as normal Make rules.
    Kbuild is not executing in the directory where the Makefile is
    located, so all special rules shall provide a relative
    path to prerequisite files and target files.
    Two variables are used when defining special rules:
    $(src)
    $(src) is a relative path which points to the directory
    where the Makefile is located. Always use $(src) when
    referring to files located in the src tree.
    $(obj)
    $(obj) is a relative path which points to the directory
    where the target is saved. Always use $(obj) when
    referring to generated files.
    Example:
        #drivers/scsi/Makefile
        $(obj)/53c8xx_d.h: $(src)/53c7,8xx.scr $(src)/script_asm.pl
            $(CPP) -DCHIP=810 - -objs) list all objects used to link the final
    executable.
    Example:
        #scripts/lxdialog/Makefile
        hostprogs-y   := lxdialog  
        lxdialog-objs := checklist.o lxdialog.o
    Objects with extension .o are compiled from the corresponding .c
    files. In the above example checklist.c is compiled to checklist.o
    and lxdialog.c is compiled to lxdialog.o.
    Finally the two .o files are linked to the executable, lxdialog.
    Note: The syntax -y is not permitted for host-programs.
(譯)
--- 4.2 構(gòu)造主機(jī)程序
主機(jī)程序能夠由基于混合objects組成。這些語(yǔ)法常用來(lái)為主機(jī)程序定義混合objects,類似于語(yǔ)法
被用來(lái)定義內(nèi)核objects的用法。
$(-objs) 列出的所有objects是常用來(lái)鏈接成最終的可執(zhí)行程序。
    例子:
        #scripts/lxdialog/Makefile
        hostprogs-y   := lxdialog  
        lxdialog-objs := checklist.o lxdialog.o
帶有擴(kuò)展名.o的Objects由相應(yīng)的.c文件來(lái)編譯。在上面的例子checklist.c被編譯成checklist.o和
lxdialog.c被編譯成lxdialog.o。
最后這兩個(gè).o文件都被鏈接成可執(zhí)行文件lxdialog。
注意:語(yǔ)法 -y 是在主機(jī)程序里不允許的。
   
--- 4.3 Defining shared libraries  
  
    Objects with extension .so are considered shared libraries, and
    will be compiled as position independent objects.
    Kbuild provides support for shared libraries, but the usage
    shall be restricted.
    In the following example the libkconfig.so shared library is used
    to link the executable conf.
    Example:
        #scripts/kconfig/Makefile
        hostprogs-y     := conf
        conf-objs       := conf.o libkconfig.so
        libkconfig-objs := expr.o type.o
  
    Shared libraries always require a corresponding -objs line, and
    in the example above the shared library libkconfig is composed by
    the two objects expr.o and type.o.
    expr.o and type.o will be built as position independent code and
    linked as a shared library libkconfig.so. C++ is not supported for
    shared libraries.
(譯)
--- 4.3 定義共享庫(kù)
帶有擴(kuò)展名為.so的Objects被認(rèn)為是共享庫(kù),將被編譯為獨(dú)立的objects。Kbuild提供支持共享庫(kù),
不過(guò)用法應(yīng)該被限制。
在下面的例子,libkconfig.so共享庫(kù)被鏈接為可執(zhí)行文件conf。
    例子:
        #scripts/kconfig/Makefile
        hostprogs-y     := conf
        conf-objs       := conf.o libkconfig.so
        libkconfig-objs := expr.o type.o
共享庫(kù)總是需要一個(gè)相應(yīng)的-objs行,在例子里上面的共享庫(kù)libkconfig由兩個(gè)objects expr.o和type.o組成。
expr.o和type.o將被建立為以位置獨(dú)立的代碼和被鏈接成共享庫(kù)libkconfig.so。C++不被共享庫(kù)所支持。
--- 4.4 Using C++ for host programs
    kbuild offers support for host programs written in C++. This was
    introduced solely to support kconfig, and is not recommended
    for general use.
    Example:
        #scripts/kconfig/Makefile
        hostprogs-y   := qconf
        qconf-cxxobjs := qconf.o
    In the example above the executable is composed of the C++ file
    qconf.cc - identified by $(qconf-cxxobjs).
   
    If qconf is composed by a mixture of .c and .cc files, then an
    additional line can be used to identify this.
    Example:
        #scripts/kconfig/Makefile
        hostprogs-y   := qconf
        qconf-cxxobjs := qconf.o
        qconf-objs    := check.o
(譯)
--- 4.4 在主機(jī)程序里使用C++
kbuild提供在主機(jī)上使用C++編程的支持。這將被獨(dú)立的介紹去支持kconfig,但不推薦一般的使用。
    例子:
        #scripts/kconfig/Makefile
        hostprogs-y   := qconf
        qconf-cxxobjs := qconf.o
上面例子里的可執(zhí)行文件由C++文件qconf.cc來(lái)構(gòu)成 - 通過(guò)$(qconf-cxxobjs)被鑒別。
如果qconf由混合的.c和.cc文件構(gòu)成,那么附加一行能被用來(lái)鑒別這個(gè)。
    例子:
        #scripts/kconfig/Makefile
        hostprogs-y   := qconf
        qconf-cxxobjs := qconf.o
        qconf-objs    := check.o
   
--- 4.5 Controlling compiler options for host programs
    When compiling host programs, it is possible to set specific flags.
    The programs will always be compiled utilising $(HOSTCC) passed
    the options specified in $(HOSTCFLAGS).
    To set flags that will take effect for all host programs created
    in that Makefile use the variable HOST_EXTRACFLAGS.
    Example:
        #scripts/lxdialog/Makefile
        HOST_EXTRACFLAGS += -I/usr/include/ncurses
  
    To set specific flags for a single file the following construction
    is used:
    Example:
        #arch/ppc64/boot/Makefile
        HOSTCFLAGS_piggyback.o := -DKERNELBASE=$(KERNELBASE)
  
    It is also possible to specify additional options to the linker.
  
    Example:
        #scripts/kconfig/Makefile
        HOSTLOADLIBES_qconf := -L$(QTDIR)/lib
    When linking qconf it will be passed the extra option "-L$(QTDIR)/lib".
(譯)
--- 4.5 為主機(jī)程序控制編譯器選項(xiàng)
當(dāng)編譯主機(jī)程序時(shí),很可能要設(shè)定指定的標(biāo)志。程序?qū)⒖偸鞘褂?(HOSTCC)來(lái)編譯,$(HOSTCC)被傳遞
的選項(xiàng)在$(HOSTCFLAGS)里被指定。
去設(shè)置標(biāo)志將影響所有的主機(jī)程序,這些程序在Makefile里使用變量HOST_EXTRACFLAGS被創(chuàng)建。
    例子:
        #scripts/lxdialog/Makefile
        HOST_EXTRACFLAGS += -I/usr/include/ncurses
為一個(gè)簡(jiǎn)單的文件設(shè)置指定的標(biāo)志,下面的構(gòu)造被使用:
    例子:
        #arch/ppc64/boot/Makefile
        HOSTCFLAGS_piggyback.o := -DKERNELBASE=$(KERNELBASE)
它同樣可能給連接器指定附加的選項(xiàng)。
    例子:
        #scripts/kconfig/Makefile
        HOSTLOADLIBES_qconf := -L$(QTDIR)/lib
當(dāng)鏈接qconf時(shí),它將被傳遞額外的選項(xiàng) "-L$(QTDIR)/lib"。

--- 4.6 When host programs are actually built
    Kbuild will only build host-programs when they are referenced
    as a prerequisite.
    This is possible in two ways:
    (1) List the prerequisite explicitly in a special rule.
    Example:
        #drivers/pci/Makefile
        hostprogs-y := gen-devlist
        $(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist
            ( cd $(obj); ./gen-devlist )  produced .config
2) Store kernel version in include/linux/version.h
3) Symlink include/asm to include/asm-$(ARCH)
4) Updating all other prerequisites to the target prepare:
   - Additional prerequisites are specified in arch/$(ARCH)/Makefile
5) Recursively descend down in all directories listed in
   init-* core* drivers-* net-* libs-* and build all targets.
   - The value of the above variables are extended in arch/$(ARCH)/Makefile.
6) All object files are then linked and the resulting file vmlinux is
   located at the root of the src tree.
   The very first objects linked are listed in head-y, assigned by
   arch/$(ARCH)/Makefile.
7) Finally the architecture specific part does any required post processing
   and builds the final bootimage.
   - This includes building boot records
   - Preparing initrd images and the like
(譯)
=== 6 體系 Makefiles
頂層的Makefile在開始下降進(jìn)入個(gè)別目錄之前設(shè)置環(huán)境和做好一切的準(zhǔn)備工作。
頂層Makefile包含通用的部分,然而arch/$(ARCH)/Makefile包含所需求的設(shè)置kbuild
為所說(shuō)的體系。
去完成這樣的arch/$(ARCH)/Makefile,設(shè)置大量變量和定義一些目標(biāo)。
kbuild依次地執(zhí)行下面步驟(粗略地):
1)配置內(nèi)核 => 產(chǎn)生.config文件
2)存儲(chǔ)內(nèi)核版本到include/linux/version.h。
3)建立符號(hào)鏈接 include/asm 鏈接到 include/asm-$(ARCH)
4)更新目標(biāo)所有其他依賴準(zhǔn)備:
   -- 附加的依賴在arch/$(ARCH)/Makefile里被指定。
5)遞歸下降到所有的目錄,這些目錄被列表在init-* core* drivers-* net-* libs-*,
   里面, 和建立所有的目標(biāo)。
6) 所有的object文件都然后被鏈接和結(jié)果文件vmlinux被放置在源碼樹的根目錄里。
   在head-y列表里的最先的objects在arch/$(ARCH)/Makefile里被賦值。
7) 最后,這個(gè)體系指定部分完成所有需要的后置處理和建立最終的bootimage。
   - 這包括建立boot記錄
   - 準(zhǔn)備initrd 鏡像和the like
               
               
               
               
               
               

本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u3/94861/showart_1919178.html
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP