2012-06-08 4 views

उत्तर

34

कर्नेल Makefiles kbuild प्रणाली, वेब पर विभिन्न स्थानों में प्रलेखित उदाहरण http://lwn.net/Articles/21835/ के लिए का हिस्सा हैं। प्रासंगिक अंश यहाँ है:

--- 3.1 Goal definitions 

लक्ष्य परिभाषाओं kbuild Makefile का मुख्य हिस्सा (हृदय) कर रहे हैं। ये पंक्तियां फाइलों को परिभाषित करने के लिए परिभाषित करती हैं, कोई विशेष संकलन विकल्प, और किसी भी उपनिर्देशिका को दोबारा दर्ज किया जाना चाहिए।

उदाहरण::

सबसे सरल kbuild makefile एक पंक्ति है obj-y + = foo.o

यह kbuild बताया कि निर्देशिका foo.o. नामित में एक वस्तु है कि वहाँ foo.o foo.c या fooS से बनाया जाएगा

यदि foo.o को मॉड्यूल के रूप में बनाया जाएगा, तो परिवर्तनीय obj-m का उपयोग किया जाता है। इसलिए निम्नलिखित पैटर्न अक्सर प्रयोग किया जाता है:

उदाहरण: obj - $ (CONFIG_FOO) + = foo.o

$ (CONFIG_FOO) का मूल्यांकन या तो y (के लिए निर्मित) या मीटर (मॉड्यूल के लिए) । यदि CONFIG_FOO न तो y और न ही एम है, तो फ़ाइल को संकलित नहीं किया जाएगा और न ही लिंक किया जाएगा।

तो m मॉड्यूल, y साधन में निर्मित (कर्नेल config प्रक्रिया में हाँ के लिए खड़ा है), और $ (CONFIG_FOO) सामान्य config प्रक्रिया से सही जवाब खींचती है का मतलब है।

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 चर में सभी ओ फ़ाइलें जोड़ने के बाद, जहां यह वास्तव में उन्हें संकलित करता है "कुछ" निर्देशिका के लिए जाना कह और निष्पादित करने के लिए अनुरूप है? मेरा मतलब है कि कर्नेल के पेड़ में कई मेकफ़ाइलों में से एक में? –

4

obj-y + = कुछ/

इसका मतलब है कि kbuild निर्देशिका "कुछ" में जाना चाहिए। एक बार यह इस निर्देशिका में जाने के बाद, यह तय करने के लिए मेकफ़ाइल "कुछ" में दिखता है कि कौन सी वस्तुओं का निर्माण किया जाना चाहिए।

यह "कर"

संबंधित मुद्दे