⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makefile

📁 example lis302 lpc2142
💻
字号:
## www.embeddedboards.com WinARM Makefile## Based on WinARM template makefile  by Martin Thomas, Kaiserslautern, Germany # <eversmith@heizung-thomas.de>## On command line:## make all = Make software.# make clean = Clean out built project files.# make program = Download the hex file to the device, using lpc21isp## flash drive for DRIVE programmingFLASH_DRIVE = I:FLASH_TOOL = DRIVE# c-only (16bit compressed thumb mode)SRC = # c-only (32bit arm mode)SRCARM = main.c	LIS302.c spi0.c	# c++ (16 bit compressed thumb mode)CPPSRC = # c++ (32 bit arm mode)CPPSRCARM = # Assembler (16 bit compressed thumb mode)ASRC = # Assembler (32 bit arm mode) always capital .S at the endASRCARM = startup.S # System libraries to be linked withMY_LIBS = -lefs -lvcom -lmicro214x # Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization (if you find problems). s = optimize for size.OPT = 0# MCU name and submodelMCU = arm7tdmi-sSUBMDL = LPC2142THUMB    = -mthumbTHUMB_IW = -mthumb-interwork## Create ROM-Image (final)RUN_MODE=ROM_RUN## Create RAM-Image (debugging)#RUN_MODE=RAM_RUNBOOTLOADER-LINKSCRIPT=-8k-bootloader# Output format. (can be srec, ihex, binary)FORMAT = binary# Target file name (without extension).TARGET = main# Debugging format.DEBUG = dwarf-2# List any extra directories to look for include files here.#     Each directory must be seperated by a space.EXTRAINCDIRS = .# 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 listing## Flags for C and C++ (arm-elf-gcc/arm-elf-g++)CFLAGS = -g$(DEBUG)CFLAGS += $(CDEFS) $(CINCS)CFLAGS += -O$(OPT)CFLAGS += -Wall -Wcast-align -Wcast-qual -Wimplicit CFLAGS += -Wpointer-arith -WswitchCFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -WunusedCFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<) CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))# flags only for CCONLYFLAGS  = -Wstrict-prototypes -Wmissing-declarationsCONLYFLAGS += -Wmissing-prototypes -Wnested-externs CONLYFLAGS += $(CSTANDARD)# flags only for C++ (arm-elf-g++)# CPPFLAGS = -fno-rtti -fno-exceptionsCPPFLAGS = # 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-lpcMATH_LIB = -lmCPLUSPLUS_LIB = -lstdc++# 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) $(EFS_LIB)LDFLAGS += -lc -lgcc LDFLAGS += $(CPLUSPLUS_LIB)LDFLAGS += $(MY_LIBS)# Set Linker-Script Depending On Selected Memoryifeq ($(RUN_MODE),RAM_RUN)LDFLAGS +=-T$(SUBMDL)-RAM.ldelse LDFLAGS +=-T$(SUBMDL)-ROM$(BOOTLOADER-LINKSCRIPT).ldendif# ---------------------------------------------------------------------------# Flash-Programming support using lpc21isp by Martin Maurer # Settings and variables:#LPC21ISP = lpc21ispLPC21ISP = lpc21ispLPC21ISP_PORT = com1LPC21ISP_BAUD = 38400LPC21ISP_XTAL = 12000LPC21ISP_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-gccCPP = arm-elf-g++OBJCOPY = 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 C:MSG_COMPILING_ARM = "Compiling C (ARM-only):"MSG_COMPILINGCPP = Compiling C++:MSG_COMPILINGCPP_ARM = "Compiling C++ (ARM-only):"MSG_ASSEMBLING = Assembling:MSG_ASSEMBLING_ARM = "Assembling (ARM-only):"MSG_CLEANING = Cleaning project:MSG_LPC21_RESETREMINDER = You may have to bring the target in bootloader-mode now.# Define all object files.COBJ      = $(SRC:.c=.o) AOBJ      = $(ASRC:.S=.o)COBJARM   = $(SRCARM:.c=.o)AOBJARM   = $(ASRCARM:.S=.o)CPPOBJ    = $(CPPSRC:.cpp=.o) CPPOBJARM = $(CPPSRCARM:.cpp=.o)# Define all listing files.LST = $(ASRC:.S=.lst) $(ASRCARM:.S=.lst) $(SRC:.c=.lst) $(SRCARM:.c=.lst)LST += $(CPPSRC:.cpp=.lst) $(CPPSRCARM:.cpp=.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) $(THUMB_IW) -I. $(CFLAGS) $(GENDEPFLAGS)ALL_ASFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. -x assembler-with-cpp $(ASFLAGS)# Default target.#all: begin gccversion sizebefore build sizeafter finished endall: build sizeafterbuild: elf bin lss symelf: $(TARGET).elfbin: $(TARGET).binlss: $(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) --versionifeq ($(FLASH_TOOL),ULINK)program: $(TARGET).hex	@echo	@echo "Programming with ULINK"	C:\Keil\uv3\Uv3.exe -f ulinkflash.Uv2 -oulinkflash.txtendififeq ($(FLASH_TOOL),DRIVE)program: $(TARGET).bin	@echo	@echo "Installing firmware"	$(COPY) $(TARGET).bin $(FLASH_DRIVE)firmware.bin -fendififeq ($(FLASH_TOOL),lpc21isp)program: $(TARGET).bin	@echo	@echo $(MSG_LPC21_RESETREMINDER)	$(LPC21ISP) $(LPC21ISP_CONTROL) $(LPC21ISP_DEBUG) $(LPC21ISP_FLASHFILE) $(LPC21ISP_PORT) $(LPC21ISP_BAUD) $(LPC21ISP_XTAL)endif# Create final output files (.hex, .eep) from ELF output file.# TODO: handling the .eeprom-section should be redundant%.bin: %.elf	@echo	@echo $(MSG_FLASH) $@	$(OBJCOPY) -O $(FORMAT) $< $@# Create extended listing file from ELF output file.# testing: option -C%.lss: %.elf	@echo	@echo $(MSG_EXTENDED_LISTING) $@	$(OBJDUMP) -h -S -C $< > $@# 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 : $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)%.elf:  $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)	@echo	@echo $(MSG_LINKING) $@	$(CC) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)#	$(CPP) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)# Compile: create object files from C source files. ARM/Thumb$(COBJ) : %.o : %.c	@echo	@echo $(MSG_COMPILING) $<	$(CC) -c $(THUMB) $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@ # Compile: create object files from C source files. ARM-only$(COBJARM) : %.o : %.c	@echo	@echo $(MSG_COMPILING_ARM) $<	$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@ # Compile: create object files from C++ source files. ARM/Thumb$(CPPOBJ) : %.o : %.cpp	@echo	@echo $(MSG_COMPILINGCPP) $<	$(CPP) -c $(THUMB) $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@ # Compile: create object files from C++ source files. ARM-only$(CPPOBJARM) : %.o : %.cpp	@echo	@echo $(MSG_COMPILINGCPP_ARM) $<	$(CPP) -c $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. ARM/Thumb## does not work - TODO - hints welcome##$(COBJ) : %.s : %.c##	$(CC) $(THUMB) -S $(ALL_CFLAGS) $< -o $@# Assemble: create object files from assembler source files. ARM/Thumb$(AOBJ) : %.o : %.S	@echo	@echo $(MSG_ASSEMBLING) $<	$(CC) -c $(THUMB) $(ALL_ASFLAGS) $< -o $@# Assemble: create object files from assembler source files. ARM-only$(AOBJARM) : %.o : %.S	@echo	@echo $(MSG_ASSEMBLING_ARM) $<	$(CC) -c $(ALL_ASFLAGS) $< -o $@# Target: clean project.clean: begin clean_list finished endclean_list :	@echo	@echo $(MSG_CLEANING)	$(REMOVE) $(TARGET).hex $(TARGET).obj $(TARGET).elf $(TARGET).map $(TARGET).obj $(TARGET).a90 $(TARGET).sym $(TARGET).lnk $(TARGET).lss	$(REMOVE) $(COBJ) $(CPPOBJ) $(AOBJ) $(COBJARM) $(CPPOBJARM) $(AOBJARM) $(LST) $(SRC:.c=.s) $(SRC:.c=.d)	$(REMOVE) $(SRCARM:.c=.s) $(SRCARM:.c=.d) $(CPPSRC:.cpp=.s) $(CPPSRC:.cpp=.d) $(CPPSRCARM:.cpp=.s)  $(CPPSRCARM:.cpp=.d).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 + -