- 论坛徽章:
- 36
|
看到内核版另外一个帖子也在问类似的问题,我也测试了一下。
用的是 LZ 的两个源码文件,分别为 a.c 和 b.c,编译情况如下:
[root@Godbach module_export]# make
make -C /lib/modules/`uname -r`/build M=/mnt/hgfs/wine/src/km/module_export modules
make[1]: Entering directory `/data/work/linux-2.6.24.4'
CC [M] /mnt/hgfs/wine/src/km/module_export/a.o
CC [M] /mnt/hgfs/wine/src/km/module_export/b.o
Building modules, stage 2.
MODPOST 2 modules
CC /mnt/hgfs/wine/src/km/module_export/a.mod.o
LD [M] /mnt/hgfs/wine/src/km/module_export/a.ko
CC /mnt/hgfs/wine/src/km/module_export/b.mod.o
LD [M] /mnt/hgfs/wine/src/km/module_export/b.ko
make[1]: Leaving directory `/data/work/linux-2.6.24.4'
没有 warning。
Makefile 如下:
# To build modules outside of the kernel tree, we run "make"
# in the kernel source tree; the Makefile these then includes this
# Makefile once again.
# This conditional selects whether we are being included from the
# kernel Makefile or not.
ifeq ($(KERNELRELEASE),)
# Assume the source tree is where the running kernel was built
# You should set KERNELDIR in the environment if it's elsewhere
KERNELDIR ?= /lib/modules/`uname -r`/build
# The current directory is passed to sub-makes as argument
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY: modules modules_install clean
else
# called from kernel build system: just declare what our modules are
obj-m += a.o b.o
endif |
|