// 1_交叉编译工具链
CROSS_COMPILE = arm-none-linux-gnueabi-
CC = $(CROSS_COMPILE)gcc
CROSS_COMPILE = arm-none-linux-gnueabi-
CC = $(CROSS_COMPILE)gcc
//2_指定内核当前路径
KERNEL_DIR = /home/kernel/driover/linux-3.0.8
CUR_DIR = $(shell pwd)
//3_指定生成的文件
MYAPP = app
MODULE = drv
//4_编译
all:
make -C $(KERNEL_DIR) M=$(CUR_DIR) modules
ifneq ($(MYAPP),)
$(CC) $(myapp) -o $(MYAPP)
endif
KERNEL_DIR = /home/kernel/driover/linux-3.0.8
CUR_DIR = $(shell pwd)
//3_指定生成的文件
MYAPP = app
MODULE = drv
//4_编译
all:
make -C $(KERNEL_DIR) M=$(CUR_DIR) modules
ifneq ($(MYAPP),)
$(CC) $(myapp) -o $(MYAPP)
endif
//5_清除
clean:
make -C $(KERNEL_DIR) M=$(CUR_DIR) clean
rm -rf $(MYAPP)
//6_拷贝
install:
cp *.ko $(MYAPP) /opt/rootfs/drv
//7_指定当前目录文件作为内核模块编译
obj-m += $(MODULE).o
clean:
make -C $(KERNEL_DIR) M=$(CUR_DIR) clean
rm -rf $(MYAPP)
//6_拷贝
install:
cp *.ko $(MYAPP) /opt/rootfs/drv
//7_指定当前目录文件作为内核模块编译
obj-m += $(MODULE).o
<笔记>
obj — y : 编译进内核
obj — : 不编译进去
obj — m : 编驱动模块