分爲本地編譯和交叉編譯,主要是Makefile的寫法:linux
本地編譯:shell
obj-m := bcm2835-i2s.o KDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) all: make -C $(KDIR) M=$(PWD) modules clean: rm *.o *.ko *.mod.c modules.order Module.symvers .PHONY:clean
交叉編譯:bash
KERN_DIR = /home/qiengo/doc/Linux/raspberrypi/linux_all/linux PWD:=$(shell pwd) obj-m += ker_rw.o all: make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C $(KERN_DIR) M=$(PWD) modules clean: rm -rf *.o *.ko *.order *.mod.c