obj-m += button.o
ARCH=arm
MYCROSS_COMPILE=/opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
KERN_DIR =/home/wys/workspace/imx6/M6708-T_V1.01/kernel-imx/


PWD := $(shell pwd)
modules:
$(MAKE) ARCH=arm  CROSS_COMPILE=$(MYCROSS_COMPILE)  -C  $(KERN_DIR) M=$(PWD) modules
$(MYCROSS_COMPILE)gcc -mfloat-abi=hard button_test.c -o button_test -lpthread
clean:
$(MAKE) ARCH=arm  CROSS_COMPILE=$(MYCROSS_COMPILE)  -C $(KERN_DIR) M=$(PWD) modules clean

注意:
修改Makefile檔案的MYCROSS_COMPILE為交叉工具鏈和KERN_DIR為核心原始碼目錄
Ubuntu下執行sudo make