y 是编译到内核
m 是生成模块.ko
n 是不编译
这个生成过程是怎么样的呢?
我们以DM9000网卡为例,搜索DM9000
s3c@s3c-desktop:~/workspace/system/linux-2.6.22.6$ grep "CONFIG_DM9000" * -nwR arch/mips/defconfig:745:# CONFIG_DM9000 is not set arch/arm/plat-s3c24xx/common-smdk.c:46:#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) arch/arm/plat-s3c24xx/common-smdk.c:162:#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) arch/arm/plat-s3c24xx/common-smdk.c:200:#endif /* CONFIG_DM9000 */ arch/arm/plat-s3c24xx/common-smdk.c:250:#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) arch/arm/configs/lpd7a404_defconfig:503:# CONFIG_DM9000 is not set arch/arm/configs/shark_defconfig:445:# CONFIG_DM9000 is not set arch/arm/configs/at91rm9200ek_defconfig:454:# CONFIG_DM9000 is not set arch/arm/configs/ks8695_defconfig:491:# CONFIG_DM9000 is not set arch/arm/configs/realview_defconfig:378:# CONFIG_DM9000 is not set arch/arm/configs/at91rm9200dk_defconfig:468:# CONFIG_DM9000 is not set arch/arm/configs/trizeps4_defconfig:738:CONFIG_DM9000=y arch/arm/configs/ixp23xx_defconfig:657:# CONFIG_DM9000 is not set arch/arm/configs/s3c2410_defconfig:588:CONFIG_DM9000=y arch/arm/configs/netx_defconfig:491:# CONFIG_DM9000 is not set arch/arm/configs/lpd270_defconfig:529:# CONFIG_DM9000 is not set arch/arm/configs/kafa_defconfig:456:# CONFIG_DM9000 is not set arch/arm/configs/at91sam9261ek_defconfig:519:CONFIG_DM9000=y arch/arm/configs/iop32x_defconfig:666:# CONFIG_DM9000 is not set arch/arm/mach-at91/board-sam9261ek.c:79:#if defined(CONFIG_DM9000) arch/arm/mach-at91/board-sam9261ek.c:134:#endif /* CONFIG_DM9000 */ config_ok:599:CONFIG_DM9000=y drivers/net/Makefile:197:obj-$(CONFIG_DM9000) += dm9dev9000c.o drivers/net/Makefile:198:#obj-$(CONFIG_DM9000) += dm9000.o drivers/net/Makefile:199:#obj-$(CONFIG_DM9000) += dm9ks.o include/config/auto.conf:128:CONFIG_DM9000=y include/linux/autoconf.h:129:#define CONFIG_DM9000 1
从搜索的结果可以看到DM9000出现在以下几个地方:
1. 默认配置项里:arch/arm/configs/
2. 源代码里:arch/arm/plat-s3c24xx/common-smdk.c
3. 子目录makefile里:drivers/net/Makefile
4. include/config/auto.conf
5. include/linux/autoconf.h
一. 首先生成必要的文件
我们知道配置内核之后会生成.config
在执行make uImage命令时会根据.config生成include/config/auto.conf 文件 include/linux/autoconf.h 文件第一个文件是被子目录的Makefile使用的,比如drive/net/Makefile
二. 根据子目录makefile生成相应的内核或.ko
在子目录drive/net/Makefile里可以看到:
obj-$(CONFIG_NET_NETX) += netx-eth.o obj-$(CONFIG_DL2K) += dl2k.o obj-$(CONFIG_R8169) += r8169.o obj-$(CONFIG_AMD8111_ETH) += amd8111e.o obj-$(CONFIG_IBMVETH) += ibmveth.o obj-$(CONFIG_S2IO) += s2io.o obj-$(CONFIG_MYRI10GE) += myri10ge/ obj-$(CONFIG_SMC91X) += smc91x.o obj-$(CONFIG_SMC911X) += smc911x.o obj-$(CONFIG_DM9000) += dm9dev9000c.o这句的意思是如果CONFIG_DM9000被定义成y,就把dm9000.c编译到内核;如果CONFIG_DM9000被定义成m,就把dm9000.c编译成.ko。
三. CONFIG_DM9000是在哪里定义的呢?
在 include/config/auto.conf 里有定义,这个文件是根据.config自动生成的.
CONFIG_SPLIT_PTLOCK_CPUS=4096 CONFIG_JFFS2_FS=y CONFIG_SENSORS_EEPROM=m CONFIG_MTD_NAND_S3C2410=y CONFIG_BLK_DEV_RAM=y CONFIG_PARPORT_1284=y CONFIG_VM_EVENT_COUNTERS=y CONFIG_INPUT_MOUSEDEV=y CONFIG_CPU_32v5=y CONFIG_BINFMT_AOUT=y CONFIG_DM9000=y这样就完成了整个配置的生成。