How to write a Makefile for ARM board

First Edition

 

#
# Description:
# Makefile for 2.6 device drivers
#

# Comment/uncomment the following line to disable/enable debugging
#DEBUG = y

# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g -DCAN_DEBUG
# "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif

#CFLAGS += $(DEBFLAGS) //i am not sure how to use this line

ifneq ($(KERNELRELEASE),)
# call from kernel build system

obj-m := hello.o             //编译模块的名称

else

KERNELDIR ?= /home/boboo/Tools/hfrk/linux-2.6.14 //你所使用内核的目录
PWD := $(shell pwd)

CC := arm-linux-gcc
HOSTCC := gcc

export CC HOSTCC

default:
   $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

endif

clean:
   rm -rf *.o *.ko

 

Second Edition

 

EXEC = demomodule
OBJS = demomodule.o
SRC = demomodule.c
 
INCLUDE = /***/***/2.4.18-rmk7/include
 
#ÒÔÉÏÊÇÄãÄںˎúÂëËùÔڵĿâÎÄŒþµÄ·Ÿ£¬ÄãÐŽµÄÄÇžö²ÎÊýÊÇpcµÄ2.4.20ϵģ¬²»ÊÇÄãÄ¿±ê»úÏÂÒªÓõİ江µÄ¿â¡£
 
CC = arm-linux-gcc
LD = arm-linux-ld
MODEFLAGS = -DMODULE -D__KERNEL__ -I$(INCLUDE) -g -Wall -Wstrict-prototypes /
-Wno-trigraphs -Os -mapcs -fno-strict-aliasing -fno-common -fno-common /
-pipe -mapcs-32 -march=armv4 -mtune=arm9tdmi -mshort-load-bytes -msoft-float /
 
LDFLAGS =
 
all:$(OBJS)
 
$(EXEC):$(OBJS)
        $(LD) $(LDFLAGS) -o $ @ $(OBJS)
       
%.o:%.c
        $(CC) $(MODEFLAGS) -c  $(SRC)
 
clean:
        -rm -f $(EXEC) *.elf *.o *.gdb

 

Third Edition

 

CROSSDIR    = /usr/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux
INSTALLDIR    = $(TFTPDIR)

KERNELDIR =/root/linux-kernel-2.6.14
MODDEV     = usb_driver
CROSS=arm-linux-
CC = $(CROSS)gcc
AS = $(CROSS)as
LD = $(CROSS)ld

ifneq ($(KERNELRELEASE),)
    obj-m := $(MODDEV).o
else
    PWD := $(shell pwd)
all:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
    rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
   
install:
    cp $(MODDEV).ko $(INSTALLDIR)
endif

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值