写了一个驱动,gpio.c,放在内核源代码中,修改了makefile,成功地重新交叉编译了内核,但是只出现了gpio.o,没有出现gpio.ko文件。现在想单独编译这个驱动,成为可随时安装卸载的模块。makefile怎么写啊?
我在根目录下新建一个文件夹/home/fineshang/gpio,里面存放了gpio.c和makefile文件,我的内核源代码目录是/home/fineshang/apro-kernel,已经编译过(make menuconfig, make dep, make clean, make zImage),交叉编译链地址为/usr/local/arm/2.95.3/bin/arm-linux,请大侠指点这个makefile怎么写?
arm-linux-gcc -D__KERNEL__ -DMODULE -DLINUX -I /home/fineshang/apro-kernel/include -c -o gpio.o gpio.c
KERNELDIR ?= /home/fineshang/apro-kernel
# The current directory is passed to sub-makes as argument
PWD := $(shell pwd)
CROSS_COMPILE = /usr/local/arm/2.95.3/bin/arm-linux
CC = $(CROSS_COMPILE)gcc
obj-m := gpio.o
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY: modules modules_install clean
应该就可以了把,! 这个这样做的,”gpio.c,放在内核源代码中,修改了makefile,成功地重新交叉编译了内核,