在Linux内核中单独编译KO文件

https://blog.csdn.net/suntao222/article/details/7457886

在当前模块目录下创建Makefile: obj-m := mxt224.o

然后再该模块目录下打开终端输入:make -C /home/kernel_path/ M=$(pwd) modules

/home/kernel_path/ 是内核所在路径

或者用该makefile:

#set KERNELDIR and CROSS_COMPILE path yourself
#
ifneq   ($(KERNELRELEASE),) 
 obj-m   :=   mxt224.o
else 
 KERNELDIR   :=   /home/stone/stone_share/Project/t11/t11-2.3/kernel
 #KERNELDIR   :=   /home/bee/bee_share/mini6410/linux-2.6.36-android/linux-2.6.36-android
 #KERNELDIR   :=   /opt/mini6440/linux/linux-2.6.36
 PWD   :=   $(shell pwd)
 #CROSS_ARCH := ARCH=arm CROSS_COMPILE=/usr/local/arm/4.5.1/bin/arm-linux- #6410-linux-2.6.36
 CROSS_ARCH := ARCH=arm CROSS_COMPILE=/usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-
default: 
 $(MAKE) $(CROSS_ARCH) -C  $(KERNELDIR)   M=$(PWD)   modules 
 
install: 
 $(MAKE)  $(CROSS_ARCH) -C  $(KERNELDIR)   M=$(PWD)   modules_install 
clean: 
 rm   -rf   *.o   *~   core   .depend   .*.cmd   *.ko   *.mod.c   .tmp_versions *.symvers *.d *.markers *.order
 
.PHONY:   modules   modules_install   clean  main
endif

 

未經允許不得轉載:GoMCU » 在Linux内核中单独编译KO文件

評論 搶沙發

  • 暱稱 (必填)
  • 郵箱 (必填)
  • 網址