2012-06-08 710 views

回答

34

內核Makefile是kbuild系統,在網絡上的各個地方文件,例如http://lwn.net/Articles/21835/的一部分。相關的摘錄是在這裏:

--- 3.1 Goal definitions 

目標定義是kbuild的Makefile文件的主要部分(心臟)。 這些行定義了要構建的文件,任何特殊編譯選項以及要遞歸輸入的任何子目錄。

最簡單的kbuild生成文件包含一個行:

實施例:OBJ-γ+ = foo.o的

這告訴的kbuild存在名爲 foo.o.該目錄一個對象foo.o將由foo.c或foo.S.構建。

如果foo.o應構建爲模塊,則使用變量obj-m。 因此下面的模式通常用於:

實施例:OBJ - $(CONFIG_FOO)+ = foo.o的

$(CONFIG_FOO)計算結果爲y(表示內置)或米(對於模塊) 。 如果CONFIG_FOO既不是y也不是m,那麼該文件將不被編譯 也不鏈接。

所以m意味着模塊,內置y手段(在內核配置過程表示肯定),和$(CONFIG_FOO)是直接從正常的配置過程中的正確答案。

3

你的問題似乎是爲什麼整個目錄添加爲目標,的Kconfig文檔的相關部分:

--- 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'. 
+0

的方式,將在OBJ-Y變量的所有.o文件後,在那裏它實際上編譯它們?我的意思是在內核樹中的許多Makefile中的一個? –

4

OBJ-Y + =東西/

這意味着的kbuild應該進入目錄「東西」。一旦它移動到這個目錄中,它會查看Makefile中的「東西」來決定應該構建哪些對象。

它類似於saying-進入目錄「東西」,並執行「使」

相關問題