1############################# Makefile1
CC = arm-linux-gcc
KVER =$(shell uname -r)
KDIR = /lib/modules/$(KVER)/build
myDIR = /friendly-arm/kernel
OBJS = mddri.o
CFLAGS = -D__KERNEL__ -I$(myDIR)/include -DMODULE -D__KERNEL_SYSCALLS__ -DEXPORT_SYMTAB -O2 -fomit-frame-pointer -Wall -DMODVERSIONS -I$(myDIR)/include/linux/modversions.h -I$(myDIR)/include -I/root/md/driver
all : $(OBJS)
mddri.o : mddriverport.o modbusl1.o modbusl2.o
arm-linux-ld -r -o $@ $^
clean :
rm -fr *.o
///////////////////////////////////////////////////////////////////////////
#############################范例2############################# Makefile2
TARGET := mddri.o
WARN := -Wall -Wstrict-prototypes -Wmissing-prototypes -O2
INCLUDE:= -I/friendly-arm/kernel/include -I/root/md/driver
CFLAGS := -D__KERNEL__ $(WARN) $(INCLUDE) -DMODULE
CC := arm-linux-gcc
OBJS := mddriverport.o modbusl2.o modbusl1.o
SORC := mddriverport.c modbusl2.c modbusl1.c
HEADERS:= mdtypedef.h modbusl1.h modbusl2.h
$(TARGET): $(OBJS)
arm-linux-ld -r -o $(TARGET) $^
modbusl1.o : modbusl1.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
modbusl2.o : modbusl2.c ${HEADERS}
$(CC) $(CFLAGS) -c $< -o $@
mddriverport.o : mddriverport.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
.PHONY : clean
clean:
rm -fr *.o
阅读(2229) | 评论(0) | 转发(0) |