?? makefile
字號:
# Hey Emacs, this is a -*- makefile -*-## WinARM template makefile # based on the WinAVR makefile written by Eric B. Weddington, J鰎g Wunsch, et al.# Released to the Public Domain# Please read the make user manual!### On command line:## make all = Make software.## make clean = Clean out built project files.## make program = Download the hex file to the device, using isp21lpc## make filename.s = Just compile filename.c into the assembler code only## To rebuild project do "make clean" then "make all".## MCU name and submodelMCU = arm7tdmiSUBMDL = LPC2106## Create ROM-Image (final)RUN_MODE=ROM_RUN## Create RAM-Image (debugging)#RUN_MODE=RAM_RUN# Output format. (can be srec, ihex, binary)FORMAT = ihex# Target file name (without extension).TARGET = main# List C source files here. (C dependencies are automatically generated.)SRC = $(TARGET).cSRC += uart.c# List Assembler source files here.# 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 "make clean"!# 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 = crt0.S# Optimization level, can be [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.# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.# AVR (extended) COFF requires stabs, plus an avr-objcopy run.#DEBUG = stabsDEBUG = dwarf-2# List any extra directories to look for include files here.# Each directory must be seperated by a space.#EXTRAINCDIRS = ./includeEXTRAINCDIRS = # Compiler flag to set the C Standard level.# c89 - "ANSI" C# gnu89 - c89 plus GCC extensions# c99 - ISO C99 standard (not yet fully implemented)# gnu99 - c99 plus GCC extensionsCSTANDARD = -std=gnu99# Place -D or -U options for C hereCDEFS = -D$(RUN_MODE)# Place -I options hereCINCS =# Place -D or -U options for ASM hereADEFS = -D$(RUN_MODE)# Compiler flags.# -g*: generate debugging information# -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 listingCFLAGS = -g$(DEBUG)CFLAGS += $(CDEFS) $(CINCS)CFLAGS += -O$(OPT)CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsCFLAGS += -Wall -Wstrict-prototypesCFLAGS += -Wa,-adhlns=$(<:.c=.lst)CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))CFLAGS += $(CSTANDARD)# Assembler flags.# -Wa,...: tell GCC to pass this to the assembler.# -ahlms: create listing# -gstabs: have the assembler create line number information; note that# for use in COFF files, additional information about filenames# and function names needs to be present in the assembler source# files -- see avr-libc docs [FIXME: not yet described there]##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG)#Additional libraries.#Support for newlibc-lpc (file: libnewlibc-lpc.a)#NEWLIBLPC = -lnewlib-lpcNEWLIBCLPC =MATH_LIB = -lm# Linker flags.# -Wl,...: tell GCC to pass this to linker.# -Map: create map file# --cref: add cross reference to map fileLDFLAGS = -nostartfiles -Wl,-Map=$(TARGET).map,--crefLDFLAGS += -lcLDFLAGS += $(NEWLIBLPC) $(MATH_LIB)LDFLAGS += -lc -lgcc# Set Linker-Script Depending On Selected Memoryifeq ($(RUN_MODE),RAM_RUN)LDFLAGS +=-T$(SUBMDL)-RAM.ldelse LDFLAGS +=-T$(SUBMDL)-ROM.ldendif# ---------------------------------------------------------------------------# Flash-Programming support using lpc21isp by Martin Maurer # Settings and variables:LPC21ISP = lpc21ispLPC21ISP_PORT = com1LPC21ISP_BAUD = 115200LPC21ISP_XTAL = 14746LPC21ISP_FLASHFILE = $(TARGET).hex# verbose output:## LPC21ISP_DEBUG = -debug# enter bootloader via RS232 DTR/RTS (only if hardware supports this# feature - see Philips AppNote):## LPC21ISP_CONTROL = -control# ---------------------------------------------------------------------------# Define directories, if needed.## DIRARM = c:/WinARM/## DIRARMBIN = $(DIRAVR)/bin/## DIRAVRUTILS = $(DIRAVR)/utils/bin/# Define programs and commands.SHELL = shCC = arm-elf-gccOBJCOPY = arm-elf-objcopyOBJDUMP = arm-elf-objdumpSIZE = arm-elf-sizeNM = arm-elf-nmREMOVE = rm -fCOPY = cp# Define Messages# EnglishMSG_ERRORS_NONE = Errors: noneMSG_BEGIN = -------- begin --------MSG_END = -------- end --------MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after:MSG_FLASH = Creating load file for Flash:MSG_EXTENDED_LISTING = Creating Extended Listing:MSG_SYMBOL_TABLE = Creating Symbol Table:MSG_LINKING = Linking:MSG_COMPILING = Compiling:MSG_ASSEMBLING = Assembling:MSG_CLEANING = Cleaning project:MSG_LPC21_RESETREMINDER = You may have to bring the target in bootloader-mode now.# Define all object files.OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) # Define all listing files.LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)# Compiler flags to generate dependency files.### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).dGENDEPFLAGS = -MD -MP -MF .dep/$(@F).d# Combine all necessary flags and optional flags.# Add target processor to flags.ALL_CFLAGS = -mcpu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)ALL_ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)# Default target.all: begin gccversion sizebefore build sizeafter finished endbuild: elf hex lss symelf: $(TARGET).elfhex: $(TARGET).hexlss: $(TARGET).lss sym: $(TARGET).sym# Eye candy.begin: @echo @echo $(MSG_BEGIN)finished: @echo $(MSG_ERRORS_NONE)end: @echo $(MSG_END) @echo# Display size of file.HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hexELFSIZE = $(SIZE) -A $(TARGET).elfsizebefore: @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fisizeafter: @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi# Display compiler version information.gccversion : @$(CC) --version# Program the device. program: $(TARGET).hex @echo @echo $(MSG_LPC21_RESETREMINDER) $(LPC21ISP) $(LPC21ISP_CONTROL) $(LPC21ISP_DEBUG) $(LPC21ISP_FLASHFILE) $(LPC21ISP_PORT) $(LPC21ISP_BAUD) $(LPC21ISP_XTAL)# Create final output files (.hex, .eep) from ELF output file.# TODO: handling the .eeprom-section should be redundant%.hex: %.elf @echo @echo $(MSG_FLASH) $@ $(OBJCOPY) -O $(FORMAT) $< $@# Create extended listing file from ELF output file.%.lss: %.elf @echo @echo $(MSG_EXTENDED_LISTING) $@ $(OBJDUMP) -h -S $< > $@# Create a symbol table from ELF output file.%.sym: %.elf @echo @echo $(MSG_SYMBOL_TABLE) $@ $(NM) -n $< > $@# Link: create ELF output file from object files..SECONDARY : $(TARGET).elf.PRECIOUS : $(OBJ)%.elf: $(OBJ) @echo @echo $(MSG_LINKING) $@ $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)# Compile: create object files from C source files.%.o : %.c @echo @echo $(MSG_COMPILING) $< $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create assembler files from C source files.%.s : %.c $(CC) -S $(ALL_CFLAGS) $< -o $@# Assemble: create object files from assembler source files.%.o : %.S @echo @echo $(MSG_ASSEMBLING) $< $(CC) -c $(ALL_ASFLAGS) $< -o $@# Target: clean project.clean: begin clean_list finished endclean_list : @echo @echo $(MSG_CLEANING) $(REMOVE) $(TARGET).hex $(REMOVE) $(TARGET).obj $(REMOVE) $(TARGET).elf $(REMOVE) $(TARGET).map $(REMOVE) $(TARGET).obj $(REMOVE) $(TARGET).a90 $(REMOVE) $(TARGET).sym $(REMOVE) $(TARGET).lnk $(REMOVE) $(TARGET).lss $(REMOVE) $(OBJ) $(REMOVE) $(LST) $(REMOVE) $(SRC:.c=.s) $(REMOVE) $(SRC:.c=.d) $(REMOVE) .dep/*# Include the dependency files.-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)# Listing of phony targets..PHONY : all begin finish end sizebefore sizeafter gccversion \build elf hex lss sym \clean clean_list program
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -