ºìÁªLinuxÃÅ»§
Linux°ïÖú

linuxÄÚºËÖÐKconfigÎĵµµÄ×÷ÓÃ

·¢²¼Ê±¼ä:2008-09-16 01:13:52À´Ô´:ºìÁª×÷Õß:troonv
ÄÚºËÔ´ÂëÊ÷µÄĿ¼Ï¶¼ÓÐÁ½¸öÎĵµKconfig£¨2.4°æ±¾ÊÇConfig.in£©ºÍMakefile¡£·Ö²¼µ½¸÷Ŀ¼µÄKconfig¹¹³ÉÁËÒ»¸ö·Ö²¼Ê½µÄÄÚºËÅäÖÃÊý¾Ý¿â£¬Ã¿¸öKconfig·Ö±ðÃèÊöÁËËùÊôĿ¼ԴÎĵµÏà¹ØµÄÄÚºËÅäÖò˵¥¡£ÔÚÄÚºËÅäÖÃmake menuconfig(»òxconfigµÈ)ʱ£¬´ÓKconfigÖжÁ³ö²Ëµ¥£¬Óû§Ñ¡Ôñºó±£´æµ½.configµÄÄÚºËÅäÖÃÎĵµÖС£ ÔÚÄں˱àÒëʱ£¬Ö÷Makefileµ÷ÓÃÕâ¸ö.config£¬¾ÍÖªµÀÁËÓû§µÄÑ¡Ôñ¡£

ÉÏÃæµÄÄÚÈÝ˵Ã÷ÁË£¬Kconfig¾ÍÊǶÔÓ¦×ÅÄں˵ÄÅäÖò˵¥¡£¼ÙÈçÒªÏëÌí¼ÓеÄÇý¶¯µ½Äں˵ÄÔ´ÂëÖУ¬Äܹ»ÐÞ¸ÄKconfig,ÕâÑù¾ÍÄܹ»Ñ¡ÔñÕâ¸öÇý¶¯£¬¼ÙÈçÏëʹÕâ¸öÇý¶¯±»±àÒ룬ҪÐÞ¸ÄMakefile¡£

Òò´ËÌí¼ÓеÄÇý¶¯Ê±ÐèÒªÐ޸ĵÄÎĵµÓÐÁ½ÖÖ£¨×¢Òâ²»Ö»ÊÇÁ½¸ö£©

*Kconfig
*Makefile

ÒªÏëÖªµÀÔõôÐÞ¸ÄÕâÁ½ÖÖÎĵµ£¬¾ÍÒªÖªµÀÁ½ÖÖÎĵµµÄÓï·¨½á¹¹¡£

First:Kconfig

ÿ¸ö²Ëµ¥¶¼ÓÐÒ»¸ö¹Ø¼ü×Ö±êʶ£¬×î³£¼ûµÄ¾ÍÊÇconfig¡£

Óï·¨£º
config

symbolÊǸöеıê¼ÇµÄ²Ëµ¥ÏoptionsÊÇÔÚÕâ¸öеIJ˵¥ÏîϵÄÊôÐÔºÍÑ¡Ïî

ÆäÖÐoptions²¿·ÖÓУº

1¡¢ÀàÐͶ¨Ò壺
ÿ¸öconfig²Ëµ¥ÏҪÓÐÀàÐͶ¨Ò壬bool²¼¶ûÀàÐÍ¡¢ tristateÈý̬£ºÄÚ½¨¡¢Ä£¿é¡¢ÒƳý string×Ö·û´®¡¢ hexÊ®Áù½øÖÆ¡¢ integerÕûÐÍ

ÀýÈçconfig HELLO_MODULE
bool "hello test module"

boolÀàÐ͵ÄÖ»ÄÜÑ¡Öлò²»Ñ¡ÖУ¬tristateÀàÐ͵IJ˵¥Ïî¶àÁ˱àÒë³ÉÄÚºËÄ£¿éµÄÑ¡Ï¼ÙÈçÑ¡Ôñ±àÒë³ÉÄÚºËÄ£¿é£¬Ôò»áÔÚ.configÖÐÉú³ÉÒ»¸öCONFIG_HELLO_MODULE=mµÄÅäÖ㬼ÙÈçÑ¡ÔñÄÚ½¨£¬¾ÍÊÇÖ±½Ó±àÒë³ÉÄÚºËÓ°Ï죬¾Í»áÔÚ.configÖÐÉú³ÉÒ»¸öCONFIG_HELLO_MODULE=yµÄÅäÖÃ.

2¡¢ÒÀÀµÐͶ¨Òådepends on»òrequires
Ö¸´Ë²Ëµ¥µÄ³öÏֺͷñÒÀÀµÓÚÁíÒ»¸ö¶¨Òå

config HELLO_MODULE
bool "hello test module"
depends on ARCH_PXA

Õâ¸öÀý×Ó±íÃ÷HELLO_MODULEÕâ¸ö²Ëµ¥ÏîÖ»¶ÔXScale´¦ÀíÆ÷ÓÐЧ¡£

3¡¢°ïÖúÐÔ¶¨Òå
Ö»ÊÇÔö¼Ó°ïÖúÓùؼü×Öhelp»ò---help---

Second:Äں˵ÄMakefile
ÔÚlinux2.6.x/Documentation/kbuildĿ¼ÏÂÓÐÖÜÏêµÄ½éÉÜÓйØkernel makefileµÄ֪ʶ¡£

Äں˵ÄMakefile·ÖΪ5¸ö×é³É²¿·Ö£º
Makefile ×²ãµÄMakefile
.config Äں˵ĵ±Ç°ÅäÖÃÎĵµ£¬±àÒëʱ³ÉΪ¶¥²ãMakefileµÄÒ»²¿·Ö
arch/$(ARCH)/Makefile ºÍÌåϵ½á¹¹Ïà¹ØµÄMakefile
s/ Makefile.* һЩMakefileµÄͨÓùæÔò
kbuild Makefile ¸÷¼¶Ä¿Â¼ÏµĴó¸ÅÔ¼500¸öÎĵµ£¬±àÒëʱ¸ù¾ÝÉϲãMakefile´«ÏÂÀ´µÄºê¶¨ÒåºÍÆäËû±àÒë¹æÔò£¬½«Ô´´úÂë±àÒë³ÉÄ£¿é»ò±àÈëÄںˡ£

¶¥²ãµÄMakefileÎĵµ¶ÁÈ¡ .configÎĵµµÄÄÚÈÝ£¬²¢×ÜÌåÉϸºÔðbuildÄں˺ÍÄ£¿é¡£Arch MakefileÔòÌṩ²¹³äÌåϵ½á¹¹Ïà¹ØµÄÐÅÏ¢¡£ sĿ¼ÏµÄMakefileÎĵµ°üº¬ÁËÈκÎÓÃÀ´¸ù¾Ýkbuild Makefile ¹¹½¨ÄÚºËËùÐèµÄ¶¨ÒåºÍ¹æÔò¡£

£¨ÆäÖÐ.configµÄÄÚÈÝÊÇÔÚmake menuconfigµÄʱºò£¬Í¨¹ýKconfigÎĵµÅäÖõĽá¹û£©

¾Ù¸öÀý×Ó£º
¼ÙÉèÏë°Ñ×Ô¼ºÐ´µÄÒ»¸öflashµÄÇý¶¯³Ìʽ¼ÓÔص½¹¤³ÌÖУ¬¶øÇÒÄܹ»Í¨¹ýmenuconfigÅäÖÃÄÚºËʱѡÔñ¸ÃÇý¶¯¸ÃÔõô°ìÄØ£¿Äܹ»·ÖÈý²½£º

µÚÒ»£º½«ÄúдµÄflashtest.c ÎĵµÌí¼Óµ½/driver/mtd/maps/ Ŀ¼Ï¡£

µÚ¶þ£ºÐÞ¸Ä/driver/mtd/mapsĿ¼ÏµÄkconfigÎĵµ£º
config MTD_flashtest
tristate ¡°ap71 flash"

ÕâÑùµ±make menuconfigʱ £¬½«»á³öÏÖ ap71 flashÑ¡Ïî¡£

µÚÈý£ºÐ޸ĸÃĿ¼ÏÂmakefileÎĵµ¡£
Ìí¼ÓÈçÏÂÄÚÈÝ£ºobj-$(CONFIG_MTD_flashtest) += flashtest.o

ÕâÑù£¬µ±ÄúÔËÐÐmake menucofnigʱ£¬Äú½«·¢ÏÖap71 flashÑ¡Ï¼ÙÈçÄúÑ¡ÔñÁË´ËÏî¡£¸ÃÑ¡Ôñ¾Í»á±£´æÔÚ.configÎĵµÖС£µ±Äú±àÒëÄÚºËʱ£¬½«»á¶ÁÈ¡.configÎĵµ£¬µ±·¢ÏÖap71 flash Ñ¡ÏîΪyes ʱ£¬ÏµÍ³ÔÚµ÷ÓÃ/driver/mtd/maps/ϵÄmakefile ʱ£¬½«»á°Ñ flashtest.o ¼ÓÈëµ½ÄÚºËÖС£¼´¿É´ïµ½ÄúµÄÄ¿µÄ¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 4 ÌõÆÀÂÛ

  1. Å£×Ó250 ÓÚ 2012-02-03 23:02:53·¢±í:

    ºÃ¶«Î÷°¡

  2. long_007 ÓÚ 2011-12-12 12:47:45·¢±í:

    ¿´ÁË£¬Ð´µÃºÜºÃ~

  3. wangxuefang224 ÓÚ 2011-12-12 09:05:12·¢±í:

    дµÄ²»´í£¬¸Ð¾õͦºÃµÄ

  4. sunrisehl ÓÚ 2011-11-07 21:01:44·¢±í:

    ¶¥£¡