Linux內核動態模塊的Makefile編寫

export ARCH=arm
export CROSS_COMPILE=/home/toolchain/usr/bin/arm-buildroot-linux-gnueabihf-  #工具鏈路徑

ifeq ($(KERNELRELEASE),)

KERNELDIR ?= /home/work/linux_source	#內核源碼路徑

PWD := $(shell pwd)

modules:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
	$(CROSS_COMPILE)gcc -o test.out test.c  #C文件編譯

modules_install:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
	
clean:
	rm -rf *.out *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions modules.* Module*

.PHONY: modules modules_install clean

else
	obj-m := hello.o
endif
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章