Makfile 模板

# Makefile2.6
obj-m += hellomod.o # 产生hellomod 模块的目标文件
CURRENT_PATH := $(shell pwd)         #模块所在的当前路径
LINUX_KERNEL := $(shell uname -r) #Linux内核源代码的当前版本
LINUX_KERNEL_PATH := /lib/modules/$(LINUX_KERNEL)/build#Linux内核源代码的绝对路径
modules:
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules #编译模块了
clean:
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean #清理

 

======================================================

#linux derive develop

#makefile

 

  CC= /opt/crosstool/gcc-3.4.4-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-linux-gcc

 

ifneq ($(KERNELRELEASE),)

         obj-m :=led1.o

  led1-objs = led.o supply.o

else

         KDIR :=/opt/linux-2.6.18.2

         PWD :=$(shell pwd)

 

default:

  $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
 #@rm -rf led_test *.o
 rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

endif

你可能感兴趣的:(Makfile 模板)