и был приятно удивлен на сколько просто собирается моя прога
и на сколько проще его скрипт по сравнению с мейковским:
мой Makefile (в котором я уже боюсь трогать тело т.к. уже не помню что зачем ):
- Код: Выделить всё
# Output files name (no extension)
target := main
# CPU Core freq (in Hz)
f_cpu := 14745600UL
# Chip
mcu := atmega8
# Sourcess dirs
srcdirs := . lcd wake
# compiler
cc := avr-gcc
# size
size := avr-size
# objcopy
objcopy := avr-objcopy
# objdump
objdump := avr-objdump
# compiler flags
ccflags := -Wall -x c++ -g -Os -DF_CPU=$(f_cpu) -mmcu=$(mcu)
# linker flags
ldflags := --relax -Wl -g -mmcu=$(mcu)
# compiler and linker log
cclog := cc.log
# doxygen log
doxlog := dox.log
# doxygen output dir
doxdir := ./doc
# programmer comand (full comand)
programmer := uisp -dprog=abb -dlpt=/dev/parport0 --erase --upload --verify if=./$(addsuffix .hex,$(target))
# setings out file
settings := setings.h
# project configuration file
conf := project.xml
#- - - - - - - - - - - - - - - - - - - - - - - -
rm := rm -rf
doxygen := doxygen
VPATH := $(srcdirs)
search := $(addsuffix /*.cpp,$(srcdirs))
cog := cog.py -cr -I cogpy -D xmlconf=$(conf) $(addprefix -I,$(srcdirs)) \
$(wildcard $(addsuffix /*.cpp,$(srcdirs))) \
$(wildcard $(addsuffix /*.h,$(srcdirs)))
#- - - - - - - - - - - - - - - - - - - - - - - -
all: cleanlog hex lst
#- - - - - - - - - - - - - - - - - - - - - - - -
# parse python generatogs (cogging files)
cog:
@ehco " * Cogging files:"
$(cog)
#- - - - - - - - - - - - - - - - - - - - - - - -
# create elf
elf: $(addsuffix .elf,$(target))
$(addsuffix .elf,$(target)): $(notdir $(patsubst %.cpp,%.o, $(wildcard $(search))))
@echo " * Create output elf file:"
$(cc) $(ldflags) $^ -o $(addsuffix .elf,$(target)) 2>>$(cclog)
# create hex
hex: $(addsuffix .hex,$(target))
$(addsuffix .hex,$(target)): elf
@echo " * Create hex from elf:"
-$(objcopy) -R.eeprom -O ihex $(addsuffix .elf,$(target)) $(addsuffix .hex,$(target)) 2>>$(cclog)
# create eep
eep: $(addsuffix .eep,$(target))
$(addsuffix .eep,$(target)): elf
@echo " * Create eep from elf:"
-$(objcopy) -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)
# create lst
lst: $(addsuffix .lst,$(target))
$(addsuffix .lst,$(target)): elf
@echo " * Create lst from elf:"
$(objdump) -S $(addsuffix .elf,$(target)) > $(addsuffix .lst,$(target)) 2>>$(cclog)
#- - - - - - - - - - - - - - - - - - - - - - - -
# create coff file
coffconv := $(objcopy) --debugging --change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000
coff: elf
@echo " * Create cof from elf:"
$(coffconv) -O coff-avr $(addsuffix .elf,$(target)) $(addsuffix .cof,$(target)) 2>>$(cclog)
extcoff: elf
@echo " * Create extended cof from elf:"
$(coffconv) -O coff-ext-avr $(addsuffix .elf,$(target)) $(addsuffix .cof,$(target)) 2>>$(cclog)
#- - - - - - - - - - - - - - - - - - - - - - - -
# create o file
%.o: %.cpp
$(cc) $(ccflags) $(addprefix -I,$(srcdirs)) -MD -c $< 2>>$(cclog)
#- - - - - - - - - - - - - - - - - - - - - - - -
# create doxygen documentation
dox:
@echo " * Create documentation:"
$(rm) $(doxylog)
# $(cog) Doxyfile
$(doxygen) 2>> $(doxylog)
#- - - - - - - - - - - - - - - - - - - - - - - -
program:
@echo " * Programming the chip:"
$(programmer)
#- - - - - - - - - - - - - - - - - - - - - - - -
size:
@echo " * Proramm size:"
$(size) --mcu=$(mcu) --format=avr $(addsuffix .elf,$(target))
# $(size) $(addsuffix .elf,$(target))
#- - - - - - - - - - - - - - - - - - - - - - - -
garbage:
@echo " * Garbage collection:"
$(rm) $(wildcard *.d) $(wildcard *.o) $(cclog) $(doxlog)
cleanlog:
@echo " * Cleaning log files:"
echo 'Compiller & Linker log:' > $(cclog)
echo 'Doxygen log:' > $(doxlog)
#- - - - - - - - - - - - - - - - - - - - - - - -
clean:
@echo " * Clean:"
$(rm) $(wildcard *.elf) $(wildcard *.hex) $(wildcard *.d) $(wildcard *.o) \
$(wildcard *.lst) $(cclog) $(doxlog)
deepclean:
@echo " * Deep clean:"
$(rm) $(wildcard *.elf) $(wildcard *.hex) $(wildcard *.d) $(wildcard *.o) \
$(wildcard *.lst) $(cclog) $(doxlog) $(doxdir)
# $(cog) -x
#- - - - - - - - - - - - - - - - - - - - - - - -
include $(wildcard *.d)
и SConstruct:
- Код: Выделить всё
# settings
mcu = "atmega8"
f_cpu = "14745600UL"
# flags
ccflags = "-Wall -x c++ -g -Os -DF_CPU=%(f_cpu)s -mmcu=%(mcu)s"%locals()
ldflags = "--relax -Wl -g -mmcu=%(mcu)s"%locals()
# avr tools
cc = "avr-gcc"
ranlib = "avr-ranlib"
ar = "avr-ar"
lenv = Environment(CXX=cc, AR=ar, RANLIB=ranlib, CCFLAGS=ccflags, LINKFLAGS=ldflags)
penv = Environment(CXX=cc, CCFLAGS=ccflags, LINKFLAGS=ldflags, LIBPATH='.')
# lib's
lenv.Library("wake", ["wake/wake.cpp"])
lenv.Library("pid", ["pid/pid.cpp"])
lenv.Library("lcd", ["lcd/lcd.cpp"])
penv.Program("main.elf", ["main.cpp"], LIBS=["wake", "pid", "lcd"])
# TODO cmd's: elf2hex, program, doxygen
осталось только дописать вызов avr-objdump'a и программатора
(вобще собираюсь сделать хранение параметров проекта в xml-файле,
да и гуй можно сделать, Qt4 очень удобна, и есть PyQt4,
т.к. scons полностью написан на питоне и его сборочные скрипты тоже )
а что используете вы? (или пользуетесь иде с авто-сборкой?)