AVR-GCC Makefile文件
2010-05-25 12:56:19| 分类: 嵌入式|字号 订阅
# 这是一个Makefile
#---------------------------------------------------------------------------- # 作者:刘光 # 学校:南开大学 #日期:2010. 5.25
#---------------------------------------------------------------------------- # 可执行的make命令 # make all = Make software. # 编译文件
# make clean = Clean out built project files. #清除目标文件
# make coff = Convert ELF to AVR COFF. #转换ELF文件为AVR COFF
# make extcoff = Convert ELF to AVR Extended COFF. #转换ELF文件为AVR 扩展COFF
# make program = Download the hex file to the device, using avrdude. # 下载intel hex文件到AVR单片机
# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. #开始debug调试
# make filename.s = Just compile filename.c into the assembler code only. #编译*.c文件到汇编文件
# make filename.i = Create a preprocessed source file for use in submitting # bug reports to the GCC project. #编译产生一个预编译文件
# To rebuild project do \
# rebuild工程,需要首先执行“make clean”,然后执行“make all” #----------------------------------------------------------------------------
# MCU name
# 选择嵌入式AVR单片机型号 MCU = atmega128
# Processor frequency.
#设置嵌入式AVR单片机工作频率
# This will define a symbol, F_CPU, in all source code files equal to the # processor frequency. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # Typical values are: # F_CPU = 1000000 # F_CPU = 1843200 # F_CPU = 2000000 # F_CPU = 3686400 # F_CPU = 4000000 # F_CPU = 7372800 # F_CPU = 8000000 # F_CPU = 11059200 # F_CPU = 14745600 # F_CPU = 16000000 # F_CPU = 18432000 # F_CPU = 20000000 F_CPU = 7372800
# Output format. (can be srec, ihex, binary) #设置目标文件输出格式可以为srec,ihex,binary FORMAT = ihex
# Target file name (without extension). #目标文件名 TARGET = main
# Object files directory #目标文件目录
# To put object files in current directory, use a dot (.), do NOT make # this an empty or blank macro! OBJDIR = .
# List C source files here. (C dependencies are automatically generated.) #列出所有*.c文件 SRC = $(TARGET).c SRC += radiocontrol.c SRC += led.c SRC += fun.c SRC += physical.c SRC += cc1000.c
# List C++ source files here. (C dependencies are automatically generated.) #列出所有*.cpp文件 CPPSRC =
# List Assembler source files here. #列出所有*.c文件
# Make them always end in a capital .S. Files ending in a lowercase .s # will not be considered source files but generated files (assembler # output from the compiler), and will be deleted upon \# Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. ASRC =
# Optimization level, can be [0, 1, 2, 3, s].
# 设置编译优化级别,优化级别可以为0,1,2,3,s # 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s
# Debugging format. # 设置debug模式
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. # AVR Studio 4.10 requires dwarf-2.
# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. DEBUG = dwarf-2
# List any extra directories to look for include files here. # 列出所有可供查找的头文件目录
# Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. EXTRAINCDIRS =
# Compiler flag to set the C Standard level. # 设置c语言标准 # c89 = \
# gnu89 = c89 plus GCC extensions
# c99 = ISO C99 standard (not yet fully implemented) # gnu99 = c99 plus GCC extensions CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources #为*.c语言添加-D或者-U选项 CDEFS = -DF_CPU=$(F_CPU)UL
# Place -D or -U options here for ASM sources #为*.s语言添加-D或者-U选项 ADEFS = -DF_CPU=$(F_CPU)
# Place -D or -U options here for C++ sources
#为*.cpp语言添加-D或者-U选项 CPPDEFS = -DF_CPU=$(F_CPU)UL #CPPDEFS += -D__STDC_LIMIT_MACROS #CPPDEFS += -D__STDC_CONSTANT_MACROS
#---------------- Compiler Options C ---------------- # C语言编译选项
# -g*: generate debugging information # 产生debug信息
# -O*: optimization level # 设置优化级别
# -f...: tuning, see GCC manual and avr-libc documentation # -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler. # -adhlns...: create assembler listing CFLAGS = -g$(DEBUG) CFLAGS += $(CDEFS) CFLAGS += -O$(OPT) CFLAGS += -funsigned-char CFLAGS += -funsigned-bitfields CFLAGS += -fpack-struct CFLAGS += -fshort-enums CFLAGS += -Wall
CFLAGS += -Wstrict-prototypes #CFLAGS += -mshort-calls #CFLAGS += -fno-unit-at-a-time #CFLAGS += -Wundef
#CFLAGS += -Wunreachable-code #CFLAGS += -Wsign-compare
CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) CFLAGS += $(CSTANDARD)
#---------------- Compiler Options C++ ----------------