xiyanghong 发表于 2017-3-16 20:12
如果只是生成一个.ko文件应该怎样做
#这个makefile,在一个文件夹内放上.c和Makefile,之后make
ifeq ($(KERNELRELEASE),)
#KERNELDIR ?= /your/target/source/directory/
KERNELDIR ?=~/Documents/sourceCodeOriginal/linux-socfpga-socfpga-4.15/ #这个是自己源码的路径
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 Module* module*
.PHONY: modules modules_install clean
else
obj-m := hello.o #注意这个和.c文件的文件名保持一致,如我是hello.c,这里写hello.o
endif