Пример make-файла для тестового проекта PORTB LED FLASH

Материал из roboforum.ru Wiki
Версия от 18:07, 24 июля 2008; =DeaD= (обсуждение | вклад) (Новая: Ниже пример '''Makefile''' для сборки тестового проекта PORTB_LED_FLASH: '''Makefile''': <source lang="bash"> target := main f_cpu := 14745600UL mcu...)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Ниже пример Makefile для сборки тестового проекта PORTB_LED_FLASH:

Makefile: <source lang="bash"> target := main f_cpu := 14745600UL mcu := atmega32 src_dirs := . cc := avr-g++ objcpy := avr-objcopy cflags := -Wall -g -O2 -DF_CPU=$(f_cpu) -mmcu=$(mcu) lflags := -Wl -g -mmcu=$(mcu) cclog := compile.log doxylog := doxy.log programmer := uisp -dprog=abb -dlpt=/dev/parport0 --erase --upload --verify if=./$(addsuffix .hex,$(target)) size := avr-size xmlconf := project.xml


  1. - do not need to edit -------------------------------------------------------------------------------

rm := rm -rf doxygen := doxygen VPATH := $(src_dirs) search := $(addsuffix /*.cpp,$(src_dirs)) ELFSIZE := $(size) --mcu=$(mcu) --format=avr $(addsuffix .elf,$(target))

  1. -----------------------------------------------------------------------------------------------------

all: elf hex eep rmlogifclean size

  1. - create elf file -----------------------------------------------------------------------------------

elf: $(addsuffix .elf,$(target))

$(addsuffix .elf,$(target)): $(notdir $(patsubst %.cpp,%.o, $(wildcard $(search)))) $(cc) $(lflags) $^ -o $(addsuffix .elf,$(target)) 2>>$(cclog)

  1. - create hex file -----------------------------------------------------------------------------------

hex: $(addsuffix .hex,$(target))

$(addsuffix .hex,$(target)): elf $(objcpy) -R.eeprom -O ihex $(addsuffix .elf,$(target)) $(addsuffix .hex,$(target)) 2>>$(cclog)

  1. - create eep file -----------------------------------------------------------------------------------

eep: $(addsuffix .eep,$(target))

$(addsuffix .eep,$(target)): elf -$(objcpy) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 --no-change-warnings -O ihex \ $(addsuffix .elf,$(target)) $(addsuffix .eep,$(target)) 2>>$(cclog)


  1. - create coff file ----------------------------------------------------------------------------------

coffconv := $(objcpy) --debugging --change-section-address .data-0x800000 \ --change-section-address .bss-0x800000 \ --change-section-address .noinit-0x800000 \ --change-section-address .eeprom-0x810000

coff: elf $(coffconv) -O coff-avr $(addsuffix .elf,$(target)) $(addsuffix .cof,$(target)) 2>>$(cclog) extcoff: elf $(coffconv) -O coff-ext-avr $(addsuffix .elf,$(target)) $(addsuffix .cof,$(target)) 2>>$(cclog)

  1. - create o file -------------------------------------------------------------------------------------

%.o: %.cpp $(cc) $(cflags) $(addprefix -I,$(src_dirs)) -MD -c $< 2>>$(cclog)

  1. - create doxygen documentation ----------------------------------------------------------------------

dox: $(rm) $(doxylog) $(cog) Doxyfile $(doxygen) 2>> $(doxylog)

  1. - create program chip -------------------------------------------------------------------------------

program: $(programmer)

  1. - see size of program (WIN only) --------------------------------------------------------------------

size: if [ `echo ${OS} | grep "win" -i` ]; then echo; $(ELFSIZE); fi

  1. - clean garbage -------------------------------------------------------------------------------------

garbage: $(rm) $(wildcard *.d) $(wildcard *.o) $(cclog) $(doxylog) $(wildcard *.DBK) $(wildcard *.PWI) rmlogifclean: if [ `du $(cclog) | cut -f1 ` -eq '0' ]; then echo rm log; $(rm) $(cclog); fi if [ `du $(doxylog) | cut -f1 ` -eq '0' ]; then echo rm log; $(rm) $(doxylog); fi

  1. - clean and deep clean ------------------------------------------------------------------------------

clean: $(rm) $(addsuffix .elf,$(target)) $(addsuffix .hex,$(target)) $(wildcard *.d) $(wildcard *.o) \ $(wildcard *.hex) $(cclog) $(doxylog) $(wildcard *.DBK) $(wildcard *.PWI) deepclean: $(rm) $(addsuffix .elf,$(target)) $(addsuffix .hex,$(target)) $(wildcard *.d) $(wildcard *.o) \ $(wildcard *.hex) $(cclog) $(doxylog) doc $(wildcard *.DBK) $(wildcard *.PWI) $(cog) -x

  1. -----------------------------------------------------------------------------------------------------

include $(wildcard *.d) </source>