apres quelques investigations laborieuses, il semblerait que ca vienne
du aversive_project.mk.
je regarderai ca en detail demain, c'est l'heure du dodo maintenant.
si qqun a une brillante idée...
1c1
< # Microb Technology, Eirbot, Droids-corp 2007 - Zer0
---
> # Microb Technology, Eirbot, Droids-corp 2005 - Zer0
12a13,17
> # make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
> #
> # make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
> # 4.07 or greater).
> #
28,32d32
< # absolute path to avoid some editors from beeing confused with vpath when
< # searching files
< ABS_AVERSIVE_DIR:=$(shell cd $(AVERSIVE_DIR) ; pwd)
< ABS_PROJECT_DIR:=$(shell pwd)
<
34c34
< MODULES_INC = $(addprefix $(ABS_AVERSIVE_DIR)/modules/,$(MODULES))
---
> MODULES_INC = $(addprefix $(AVERSIVE_DIR)/modules/,$(MODULES))
38,43c38
< EXTRAINCDIRS += . $(ABS_AVERSIVE_DIR)/include $(ABS_AVERSIVE_DIR)/modules
$(MODULES_INC)
< # base/utils, base/wait and base/list are deprecated dirs, we need them for
compatibility
< EXTRAINCDIRS += $(ABS_AVERSIVE_DIR)/modules/base/utils
< EXTRAINCDIRS += $(ABS_AVERSIVE_DIR)/modules/base/wait
< EXTRAINCDIRS += $(ABS_AVERSIVE_DIR)/modules/base/list
<
---
> EXTRAINCDIRS += . $(AVERSIVE_DIR)/include $(AVERSIVE_DIR)/modules
> $(MODULES_INC)
46c41
< # -g: generate debugging information
---
> # -g: generate debugging information (for GDB, or for COFF conversion)
84c79,82
< # -gstabs: have the assembler create line number information
---
> # -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]
114,120c112
< AVRDUDE_FLAGS = -e -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -q
<
< ifneq ($(AVRDUDE_DELAY),)
< AVRDUDE_FLAGS += -i $(AVRDUDE_DELAY)
< endif
<
< export AVRDUDE_FLAGS
---
> export AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
> -q
181,182d172
< export PROGRAMMER
<
191a182,183
> MSG_COFF = Converting to AVR COFF:
> MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
198d189
< MSG_PREPROC = Preprocessing:
213,217c204
< ifneq ($(P),)
< PREPROC= $(addprefix compiler_files/,$(SRC:.c=.$(HOST).preproc))
< else
< PREPROC=
< endif
---
>
220c207
< export AVERSIVE_DIR ABS_AVERSIVE_DIR
---
> export AVERSIVE_DIR
243c230
< @$(MAKE) VPATH=$(ABS_AVERSIVE_DIR)/modules/$@ -f
$(AVERSIVE_DIR)/modules/$@/Makefile
---
> @$(MAKE) VPATH=$(AVERSIVE_DIR)/modules/$@ -f
> $(AVERSIVE_DIR)/modules/$@/Makefile
246c233
< $(OUTPUT): $(PREPROC) $(OBJ) $(MODULES_LIB)
---
> $(OUTPUT): $(OBJ) $(MODULES_LIB)
253,258d239
< compiler_files/%.$(HOST).preproc : %.c
< @echo
< @echo $(MSG_PREPROC) $<
< $(CC) -E $(ALL_CFLAGS) $< -o $@
<
< # Compile: create object files from C source files.
262c243
< $(CC) -c $(ALL_CFLAGS) $(ABS_PROJECT_DIR)/$< -o $@
---
> $(CC) -c $(ALL_CFLAGS) $< -o $@
303a285,305
> # Convert ELF to COFF for use in debugging / simulating in
> # AVR Studio or VMLAB.
> COFFCONVERT=$(OBJCOPY) --debugging \
> --change-section-address .data-0x800000 \
> --change-section-address .bss-0x800000 \
> --change-section-address .noinit-0x800000 \
> --change-section-address .eeprom-0x810000
>
> coff: $(TARGET).elf
> @echo
> @echo $(MSG_COFF) $(TARGET).cof
> $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
>
>
> extcoff: $(TARGET).elf
> @echo
> @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
> $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
>
>
>
328d329
< echo $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
$(AVRDUDE_WRITE_EEPROM) ;\
332d332
< echo $(AVARICE) $(AVARICE_FLAGS) $(AVARICE_WRITE_FLASH)
$(AVARICE_WRITE_EEPROM) ;\
336,345d335
< # Program the device.
< erase: $(TARGET).$(FORMAT_EXTENSION) $(TARGET).eep
< @if [ "$(PROGRAMMER)" = "avrdude" ]; then \
< echo $(AVRDUDE) $(AVRDUDE_FLAGS) -e ;\
< $(AVRDUDE) $(AVRDUDE_FLAGS) -e ;\
< fi
< @if [ "$(PROGRAMMER)" = "avarice" ]; then \
< echo "Not supported now." ; \
< fi
<
349d338
< echo $(AVRDUDE) $(AVRDUDE_FLAGS) ;\
361d349
< echo $(AVARICE) $(AVARICE_FLAGS) :$(AVARICE_DEBUG_PORT) ;\
404c392
< @$(MAKE) VPATH=$(ABS_AVERSIVE_DIR)/modules/$(@:_clean=) -f
$(ABS_AVERSIVE_DIR)/modules/$(@:_clean=)/Makefile clean
---
> @$(MAKE) VPATH=$(AVERSIVE_DIR)/modules/$(@:_clean=) -f
> $(AVERSIVE_DIR)/modules/$(@:_clean=)/Makefile clean
413d400
< $(REMOVE) $(PREPROC)
428c415
< @$(MAKE) VPATH=$(ABS_AVERSIVE_DIR)/modules/$(@:_depclean=) -f
$(ABS_AVERSIVE_DIR)/modules/$(@:_depclean=)/Makefile depclean
---
> @$(MAKE) VPATH=$(AVERSIVE_DIR)/modules/$(@:_depclean=) -f
> $(AVERSIVE_DIR)/modules/$(@:_depclean=)/Makefile depclean
492c479
< .PHONY : all sizebefore sizeafter gccversion \
---
> .PHONY : all sizebefore sizeafter gccversion coff extcoff \
# Microb Technology, Eirbot, Droids-corp 2005 - Zer0
# Makefile for projects
#
# Inspired by the WinAVR Sample makefile written by Eric
# B. Weddington, J÷rg Wunsch, et al.
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
#
# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
# 4.07 or greater).
#
# make program = Download the hex file to the device, using avrdude/avarice.
Please
# customize the settings below first!
#
# make filename.s = Just compile filename.c into the assembler code only
#
# To rebuild project do "make clean" then "make all".
#
# default HOST is avr
ifeq ($(H),)
export HOST=avr
else
export HOST=host
endif
# includes for modules
MODULES_INC = $(addprefix $(AVERSIVE_DIR)/modules/,$(MODULES))
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
EXTRAINCDIRS += . $(AVERSIVE_DIR)/include $(AVERSIVE_DIR)/modules $(MODULES_INC)
# Optional compiler flags.
# -g: generate debugging information (for GDB, or for COFF conversion)
# -O*: optimization level
# -f...: tuning, see gcc manual and avr-libc documentation
# -Wall...: warning level
CFLAGS += -g
CFLAGS += -O$(OPT)
CFLAGS += -Wall -Wstrict-prototypes
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
CFLAGS += -std=gnu99
# specific arch flags
ifeq ($(HOST),avr)
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-mmcu=$(MCU)
else
CFLAGS += -DHOST_VERSION
endif
ALL_CFLAGS += $(CFLAGS)
# specific arch flags
ifeq ($(HOST),avr)
# Combine all necessary flags and optional flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create assembler listing
ALL_CFLAGS += -Wa,-adhlns=$(addprefix compiler_files/,$(<:.c=.$(HOST).lst))
else
ALL_CFLAGS +=
endif
#common asflags
ASFLAGS +=
ifeq ($(HOST),avr)
# Optional 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 += -mmcu=$(MCU) $(patsubst %,-I%,$(EXTRAINCDIRS))
ASFLAGS += -Wa,-gstabs
ASFLAGS += -x assembler-with-cpp
else
ASFLAGS +=
endif
# Optional linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
# Some variables are generated by config, see in .aversive_conf
ifeq ($(HOST),avr)
LDFLAGS += -mmcu=$(MCU) $(PRINTF_LDFLAGS)
LDFLAGS += -Wl,-Map=$(addprefix compiler_files/,$(TARGET).map),--cref
else
LDFLAGS +=
endif
LDFLAGS += $(MATH_LIB)
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).$(FORMAT_EXTENSION)
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
export AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -q
# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.
#AVRDUDE_ERASE += -y
# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.
#AVRDUDE_FLAGS += -V
# Increase verbosity level. Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_FLAGS += -v -v
AVARICE_WRITE_FLASH = --erase --program --file $(TARGET).$(FORMAT_EXTENSION)
#AVARICE_WRITE_EEPROM = XXX
export AVARICE_FLAGS = -P $(MCU) --jtag $(AVARICE_PORT) --$(AVARICE_PROGRAMMER)
# ---------------------------------------------------------------------------
# Define programs and commands.
ifeq ($(HOST),avr)
export CC = avr-gcc
export AS = avr-as
export AR = avr-ar
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
NM = avr-nm
OUTPUT = $(TARGET).elf
OTHER_OUTPUT = $(TARGET).$(FORMAT_EXTENSION) $(TARGET).eep
compiler_files/$(TARGET).lss compiler_files/$(TARGET).sym
else
export CC = gcc
export AS = as
export AR = ar
OBJCOPY = objcopy
OBJDUMP = objdump
SIZE = size --format=Berkeley
NM = nm
OUTPUT = $(TARGET)
endif
export HOSTCC = gcc
export REMOVE = rm -f
export COPY = cp
export SHELL = sh
DATE=`date`
MD5 = md5sum
export AVRDUDE = avrdude
export AVARICE = avarice
HEXSIZE = $(SIZE) --target=$(FORMAT) $(OUTPUT)
ELFSIZE = $(SIZE) $(OUTPUT)
ELFMD5 = $(MD5) $(OUTPUT) | cut -b1-4
export AVRDUDE_PORT
export AVRDUDE_PROGRAMMER
export MCU
# ---------------------------------------------------------------------------
# Define Messages
# English
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_COFF = Converting to AVR COFF:
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
MSG_FLASH = Creating load file for Flash:
MSG_EEPROM = Creating load file for EEPROM:
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_MD5_BEFORE = Processing MD5:
MSG_MD5_AFTER = Processing MD5:
MSG_DEPCLEAN = Cleaning deps:
MSG_MODULE = ------ Compiling Module:
# ---------------------------------------------------------------------------
OBJ = $(addprefix compiler_files/,$(SRC:.c=.$(HOST).o) $(ASRC:.S=.$(HOST).o))
DEPS = $(addprefix compiler_files/,$(SRC:.c=.$(HOST).d))
LST = $(OBJ:.o=.lst)
MODULES_LIB = $(addprefix compiler_files/,$(notdir $(MODULES:=.$(HOST).a)))
# Variables n{\'e}cessaires pour les Makefile des modules
export AVERSIVE_DIR
export CFLAGS EXTRAINCDIRS
# Default target.
all: compiler_files gccversion sizebefore md5sumbefore modules $(OUTPUT)
$(OTHER_OUTPUT) sizeafter md5sumafter
# only compile project files
project: compiler_files gccversion sizebefore md5sumbefore $(OUTPUT)
$(OTHER_OUTPUT) sizeafter md5sumafter
compiler_files:
@mkdir -p compiler_files
# ------ Compilation/link/assemble targets
# Compile modules and create a library for each
modules: $(MODULES)
$(MODULES):
@echo
@echo $(MSG_MODULE) $@
@$(MAKE) VPATH=$(AVERSIVE_DIR)/modules/$@ -f
$(AVERSIVE_DIR)/modules/$@/Makefile
# Link: create ELF output file from object files.
$(OUTPUT): $(OBJ) $(MODULES_LIB)
@echo
@echo $(MSG_LINKING) $@
$(CC) $(OBJ) $(MODULES_LIB) --output $@ $(LDFLAGS)
# Compile: create object files from C source files.
compiler_files/%.$(HOST).o : %.c
@echo
@echo $(MSG_COMPILING) $<
$(CC) -c $(ALL_CFLAGS) $< -o $@
# Compile: create assembler files from C source files.
compiler_files/%.$(HOST).s : %.c
$(CC) -S $(ALL_CFLAGS) $< -o $@
# Assemble: create object files from assembler source files.
compiler_files/%.$(HOST).o : %.S
@echo
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(ASFLAGS) $< -o $@
# ------ Conversion/listings targets
# Create final output files (.hex, .eep) from ELF output file.
%.$(FORMAT_EXTENSION): %.elf
@echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
%.eep: %.elf
@echo
@echo $(MSG_EEPROM) $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
compiler_files/%.lss: %.elf
@echo
@echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S $< > $@
# Create a symbol table from ELF output file.
compiler_files/%.sym: %.elf
@echo
@echo $(MSG_SYMBOL_TABLE) $@
$(NM) -n $< > $@
# Convert ELF to COFF for use in debugging / simulating in
# AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000
coff: $(TARGET).elf
@echo
@echo $(MSG_COFF) $(TARGET).cof
$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
extcoff: $(TARGET).elf
@echo
@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
# ------ utils targets
# Display size/md5 of file.
sizebefore:
@if [ -f $(OUTPUT) ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE);
echo; fi
sizeafter:
@if [ -f $(OUTPUT) ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE);
echo; fi
md5sumbefore:
@if [ -f $(OUTPUT) ]; then echo; echo $(MSG_MD5_BEFORE); $(ELFMD5);
echo; fi
md5sumafter:
@if [ -f $(OUTPUT) ]; then echo; echo $(MSG_MD5_AFTER); $(ELFMD5);
echo; fi
# Display compiler version information.
gccversion :
@$(CC) --version
# Program the device.
program: $(TARGET).$(FORMAT_EXTENSION) $(TARGET).eep
@if [ "$(PROGRAMMER)" = "avrdude" ]; then \
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
$(AVRDUDE_WRITE_EEPROM) ;\
fi
@if [ "$(PROGRAMMER)" = "avarice" ]; then \
$(AVARICE) $(AVARICE_FLAGS) $(AVARICE_WRITE_FLASH)
$(AVARICE_WRITE_EEPROM) ;\
fi
# reset the device.
reset:
@if [ "$(PROGRAMMER)" = "avrdude" ]; then \
$(AVRDUDE) $(AVRDUDE_FLAGS) ;\
fi
@if [ "$(PROGRAMMER)" = "avarice" ]; then \
echo "Not supported now." ; \
fi
debug: $(TARGET).$(FORMAT_EXTENSION)
@if [ "$(PROGRAMMER)" = "avrdude" ]; then \
echo "Cannot debug with avrdude" ; \
fi
@if [ "$(PROGRAMMER)" = "avarice" ]; then \
$(AVARICE) $(AVARICE_FLAGS) :$(AVARICE_DEBUG_PORT) ;\
fi
fuse:
@$(AVERSIVE_DIR)/config/prog_fuses.sh
$(AVERSIVE_DIR)/config/fuses_defs/$(MCU)
# ------ config targets
config:
@sh -n $(AVERSIVE_DIR)/config/config.in
@HELP_FILE=$(AVERSIVE_DIR)/config/Configure.help \
AUTOCONF_FILE=autoconf.h \
sh $(AVERSIVE_DIR)/config/scripts/Configure
$(AVERSIVE_DIR)/config/config.in
noconfig:
@sh -n $(AVERSIVE_DIR)/config/config.in
@HELP_FILE=$(AVERSIVE_DIR)/config/Configure.help \
AUTOCONF_FILE=autoconf.h \
sh $(AVERSIVE_DIR)/config/scripts/Configure -d
$(AVERSIVE_DIR)/config/config.in
menuconfig:
@sh -n $(AVERSIVE_DIR)/config/config.in
@make -C $(AVERSIVE_DIR)/config/scripts/lxdialog all
@HELP_FILE=$(AVERSIVE_DIR)/config/Configure.help \
AUTOCONF_FILE=autoconf.h \
sh $(AVERSIVE_DIR)/config/scripts/Menuconfig
$(AVERSIVE_DIR)/config/config.in
# ------ clean targets
mrproper: clean_list
$(REMOVE) compiler_files/*
clean: depclean clean_list modules_clean
# clean modules files
modules_clean: $(patsubst %,%_clean,$(MODULES))
$(patsubst %,%_clean,$(MODULES)):
@$(MAKE) VPATH=$(AVERSIVE_DIR)/modules/$(@:_clean=) -f
$(AVERSIVE_DIR)/modules/$(@:_clean=)/Makefile clean
clean_list :
@echo
@echo $(MSG_CLEANING)
$(REMOVE) $(OUTPUT) $(OTHER_OUTPUT)
$(REMOVE) compiler_files/$(TARGET).map
$(REMOVE) $(OBJ)
$(REMOVE) $(LST)
# ------ dependencies targets
depclean: dep_list modules_depclean
modules_depclean: $(patsubst %,%_depclean,$(MODULES))
$(patsubst %,%_depclean,$(MODULES)):
@$(MAKE) VPATH=$(AVERSIVE_DIR)/modules/$(@:_depclean=) -f
$(AVERSIVE_DIR)/modules/$(@:_depclean=)/Makefile depclean
dep_list:
@echo
@echo $(MSG_DEPCLEAN)
$(REMOVE) $(DEPS)
# Automatically generate C source code dependencies.
compiler_files/%.$(HOST).d: %.c
@mkdir -p compiler_files ; \
error=0; \
for conf_file in .config autoconf.h .aversive_conf; do \
if [ ! -f $$conf_file ]; then \
echo "$$conf_file file is missing"; \
error=1; \
fi ; \
done; \
for module in `echo $(MODULES)`; do \
conf=`basename $$module"_config.h"`; \
if [ -f $$module/config/$$conf ]; then \
if [ ! -f $$conf ]; then \
echo "$$conf file is missing"; \
error=1; \
fi ; \
fi ; \
done; \
if [ $$error -eq 1 ]; then \
echo "Missing config files, please run make menuconfig or make
config"; \
exit 1; \
fi
@echo Generating $@
@set -e; rm -f $@; \
$(CC) -M $(CFLAGS) $< > [EMAIL PROTECTED]; \
sed 's,\($*\)\.o[ :]*,compiler_files/\1.$(HOST).o $@ : ,g' < [EMAIL
PROTECTED] > $@; \
rm -f [EMAIL PROTECTED]
# include the deps file only for other targets than menuconfig or config
ifeq (,$(findstring config,$(MAKECMDGOALS)))
ifeq (,$(wildcard .config))
$(error You need to call make config or make menuconfig first)
endif
ifeq (,$(wildcard autoconf.h))
$(error Missing autoconf.h -- You need to call make noconfig)
endif
ifeq (,$(wildcard .aversive_conf))
$(error Missing .aversive_conf -- You need to call make noconfig)
endif
ifeq (,$(findstring mrproper,$(MAKECMDGOALS)))
-include $(addprefix compiler_files/,$(SRC:.c=.$(HOST).d))
endif
else
ifneq (1,$(words $(MAKECMDGOALS)))
$(error You need to call make config or make menuconfig without other targets)
endif
endif
# ------ Listing of phony targets.
.PHONY : all sizebefore sizeafter gccversion coff extcoff \
clean clean_list program md5sumafter md5sumbefore \
depclean dep_list modules $(MODULES) \
menuconfig config
# Microb Technology, Eirbot, Droids-corp 2007 - Zer0
# Makefile for projects
#
# Inspired by the WinAVR Sample makefile written by Eric
# B. Weddington, J÷rg Wunsch, et al.
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make program = Download the hex file to the device, using avrdude/avarice.
Please
# customize the settings below first!
#
# make filename.s = Just compile filename.c into the assembler code only
#
# To rebuild project do "make clean" then "make all".
#
# default HOST is avr
ifeq ($(H),)
export HOST=avr
else
export HOST=host
endif
# absolute path to avoid some editors from beeing confused with vpath when
# searching files
ABS_AVERSIVE_DIR:=$(shell cd $(AVERSIVE_DIR) ; pwd)
ABS_PROJECT_DIR:=$(shell pwd)
# includes for modules
MODULES_INC = $(addprefix $(ABS_AVERSIVE_DIR)/modules/,$(MODULES))
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
EXTRAINCDIRS += . $(ABS_AVERSIVE_DIR)/include $(ABS_AVERSIVE_DIR)/modules
$(MODULES_INC)
# base/utils, base/wait and base/list are deprecated dirs, we need them for
compatibility
EXTRAINCDIRS += $(ABS_AVERSIVE_DIR)/modules/base/utils
EXTRAINCDIRS += $(ABS_AVERSIVE_DIR)/modules/base/wait
EXTRAINCDIRS += $(ABS_AVERSIVE_DIR)/modules/base/list
# Optional compiler flags.
# -g: generate debugging information
# -O*: optimization level
# -f...: tuning, see gcc manual and avr-libc documentation
# -Wall...: warning level
CFLAGS += -g
CFLAGS += -O$(OPT)
CFLAGS += -Wall -Wstrict-prototypes
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
CFLAGS += -std=gnu99
# specific arch flags
ifeq ($(HOST),avr)
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-mmcu=$(MCU)
else
CFLAGS += -DHOST_VERSION
endif
ALL_CFLAGS += $(CFLAGS)
# specific arch flags
ifeq ($(HOST),avr)
# Combine all necessary flags and optional flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create assembler listing
ALL_CFLAGS += -Wa,-adhlns=$(addprefix compiler_files/,$(<:.c=.$(HOST).lst))
else
ALL_CFLAGS +=
endif
#common asflags
ASFLAGS +=
ifeq ($(HOST),avr)
# Optional assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -gstabs: have the assembler create line number information
ASFLAGS += -mmcu=$(MCU) $(patsubst %,-I%,$(EXTRAINCDIRS))
ASFLAGS += -Wa,-gstabs
ASFLAGS += -x assembler-with-cpp
else
ASFLAGS +=
endif
# Optional linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
# Some variables are generated by config, see in .aversive_conf
ifeq ($(HOST),avr)
LDFLAGS += -mmcu=$(MCU) $(PRINTF_LDFLAGS)
LDFLAGS += -Wl,-Map=$(addprefix compiler_files/,$(TARGET).map),--cref
else
LDFLAGS +=
endif
LDFLAGS += $(MATH_LIB)
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).$(FORMAT_EXTENSION)
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
AVRDUDE_FLAGS = -e -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -q
ifneq ($(AVRDUDE_DELAY),)
AVRDUDE_FLAGS += -i $(AVRDUDE_DELAY)
endif
export AVRDUDE_FLAGS
# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.
#AVRDUDE_ERASE += -y
# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.
#AVRDUDE_FLAGS += -V
# Increase verbosity level. Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_FLAGS += -v -v
AVARICE_WRITE_FLASH = --erase --program --file $(TARGET).$(FORMAT_EXTENSION)
#AVARICE_WRITE_EEPROM = XXX
export AVARICE_FLAGS = -P $(MCU) --jtag $(AVARICE_PORT) --$(AVARICE_PROGRAMMER)
# ---------------------------------------------------------------------------
# Define programs and commands.
ifeq ($(HOST),avr)
export CC = avr-gcc
export AS = avr-as
export AR = avr-ar
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
NM = avr-nm
OUTPUT = $(TARGET).elf
OTHER_OUTPUT = $(TARGET).$(FORMAT_EXTENSION) $(TARGET).eep
compiler_files/$(TARGET).lss compiler_files/$(TARGET).sym
else
export CC = gcc
export AS = as
export AR = ar
OBJCOPY = objcopy
OBJDUMP = objdump
SIZE = size --format=Berkeley
NM = nm
OUTPUT = $(TARGET)
endif
export HOSTCC = gcc
export REMOVE = rm -f
export COPY = cp
export SHELL = sh
DATE=`date`
MD5 = md5sum
export AVRDUDE = avrdude
export AVARICE = avarice
HEXSIZE = $(SIZE) --target=$(FORMAT) $(OUTPUT)
ELFSIZE = $(SIZE) $(OUTPUT)
ELFMD5 = $(MD5) $(OUTPUT) | cut -b1-4
export AVRDUDE_PORT
export AVRDUDE_PROGRAMMER
export MCU
export PROGRAMMER
# ---------------------------------------------------------------------------
# Define Messages
# English
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_FLASH = Creating load file for Flash:
MSG_EEPROM = Creating load file for EEPROM:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling:
MSG_PREPROC = Preprocessing:
MSG_ASSEMBLING = Assembling:
MSG_CLEANING = Cleaning project:
MSG_MD5_BEFORE = Processing MD5:
MSG_MD5_AFTER = Processing MD5:
MSG_DEPCLEAN = Cleaning deps:
MSG_MODULE = ------ Compiling Module:
# ---------------------------------------------------------------------------
OBJ = $(addprefix compiler_files/,$(SRC:.c=.$(HOST).o) $(ASRC:.S=.$(HOST).o))
DEPS = $(addprefix compiler_files/,$(SRC:.c=.$(HOST).d))
LST = $(OBJ:.o=.lst)
MODULES_LIB = $(addprefix compiler_files/,$(notdir $(MODULES:=.$(HOST).a)))
ifneq ($(P),)
PREPROC= $(addprefix compiler_files/,$(SRC:.c=.$(HOST).preproc))
else
PREPROC=
endif
# Variables n{\'e}cessaires pour les Makefile des modules
export AVERSIVE_DIR ABS_AVERSIVE_DIR
export CFLAGS EXTRAINCDIRS
# Default target.
all: compiler_files gccversion sizebefore md5sumbefore modules $(OUTPUT)
$(OTHER_OUTPUT) sizeafter md5sumafter
# only compile project files
project: compiler_files gccversion sizebefore md5sumbefore $(OUTPUT)
$(OTHER_OUTPUT) sizeafter md5sumafter
compiler_files:
@mkdir -p compiler_files
# ------ Compilation/link/assemble targets
# Compile modules and create a library for each
modules: $(MODULES)
$(MODULES):
@echo
@echo $(MSG_MODULE) $@
@$(MAKE) VPATH=$(ABS_AVERSIVE_DIR)/modules/$@ -f
$(AVERSIVE_DIR)/modules/$@/Makefile
# Link: create ELF output file from object files.
$(OUTPUT): $(PREPROC) $(OBJ) $(MODULES_LIB)
@echo
@echo $(MSG_LINKING) $@
$(CC) $(OBJ) $(MODULES_LIB) --output $@ $(LDFLAGS)
# Compile: create object files from C source files.
compiler_files/%.$(HOST).preproc : %.c
@echo
@echo $(MSG_PREPROC) $<
$(CC) -E $(ALL_CFLAGS) $< -o $@
# Compile: create object files from C source files.
compiler_files/%.$(HOST).o : %.c
@echo
@echo $(MSG_COMPILING) $<
$(CC) -c $(ALL_CFLAGS) $(ABS_PROJECT_DIR)/$< -o $@
# Compile: create assembler files from C source files.
compiler_files/%.$(HOST).s : %.c
$(CC) -S $(ALL_CFLAGS) $< -o $@
# Assemble: create object files from assembler source files.
compiler_files/%.$(HOST).o : %.S
@echo
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(ASFLAGS) $< -o $@
# ------ Conversion/listings targets
# Create final output files (.hex, .eep) from ELF output file.
%.$(FORMAT_EXTENSION): %.elf
@echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
%.eep: %.elf
@echo
@echo $(MSG_EEPROM) $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
compiler_files/%.lss: %.elf
@echo
@echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S $< > $@
# Create a symbol table from ELF output file.
compiler_files/%.sym: %.elf
@echo
@echo $(MSG_SYMBOL_TABLE) $@
$(NM) -n $< > $@
# ------ utils targets
# Display size/md5 of file.
sizebefore:
@if [ -f $(OUTPUT) ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE);
echo; fi
sizeafter:
@if [ -f $(OUTPUT) ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE);
echo; fi
md5sumbefore:
@if [ -f $(OUTPUT) ]; then echo; echo $(MSG_MD5_BEFORE); $(ELFMD5);
echo; fi
md5sumafter:
@if [ -f $(OUTPUT) ]; then echo; echo $(MSG_MD5_AFTER); $(ELFMD5);
echo; fi
# Display compiler version information.
gccversion :
@$(CC) --version
# Program the device.
program: $(TARGET).$(FORMAT_EXTENSION) $(TARGET).eep
@if [ "$(PROGRAMMER)" = "avrdude" ]; then \
echo $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
$(AVRDUDE_WRITE_EEPROM) ;\
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
$(AVRDUDE_WRITE_EEPROM) ;\
fi
@if [ "$(PROGRAMMER)" = "avarice" ]; then \
echo $(AVARICE) $(AVARICE_FLAGS) $(AVARICE_WRITE_FLASH)
$(AVARICE_WRITE_EEPROM) ;\
$(AVARICE) $(AVARICE_FLAGS) $(AVARICE_WRITE_FLASH)
$(AVARICE_WRITE_EEPROM) ;\
fi
# Program the device.
erase: $(TARGET).$(FORMAT_EXTENSION) $(TARGET).eep
@if [ "$(PROGRAMMER)" = "avrdude" ]; then \
echo $(AVRDUDE) $(AVRDUDE_FLAGS) -e ;\
$(AVRDUDE) $(AVRDUDE_FLAGS) -e ;\
fi
@if [ "$(PROGRAMMER)" = "avarice" ]; then \
echo "Not supported now." ; \
fi
# reset the device.
reset:
@if [ "$(PROGRAMMER)" = "avrdude" ]; then \
echo $(AVRDUDE) $(AVRDUDE_FLAGS) ;\
$(AVRDUDE) $(AVRDUDE_FLAGS) ;\
fi
@if [ "$(PROGRAMMER)" = "avarice" ]; then \
echo "Not supported now." ; \
fi
debug: $(TARGET).$(FORMAT_EXTENSION)
@if [ "$(PROGRAMMER)" = "avrdude" ]; then \
echo "Cannot debug with avrdude" ; \
fi
@if [ "$(PROGRAMMER)" = "avarice" ]; then \
echo $(AVARICE) $(AVARICE_FLAGS) :$(AVARICE_DEBUG_PORT) ;\
$(AVARICE) $(AVARICE_FLAGS) :$(AVARICE_DEBUG_PORT) ;\
fi
fuse:
@$(AVERSIVE_DIR)/config/prog_fuses.sh
$(AVERSIVE_DIR)/config/fuses_defs/$(MCU)
# ------ config targets
config:
@sh -n $(AVERSIVE_DIR)/config/config.in
@HELP_FILE=$(AVERSIVE_DIR)/config/Configure.help \
AUTOCONF_FILE=autoconf.h \
sh $(AVERSIVE_DIR)/config/scripts/Configure
$(AVERSIVE_DIR)/config/config.in
noconfig:
@sh -n $(AVERSIVE_DIR)/config/config.in
@HELP_FILE=$(AVERSIVE_DIR)/config/Configure.help \
AUTOCONF_FILE=autoconf.h \
sh $(AVERSIVE_DIR)/config/scripts/Configure -d
$(AVERSIVE_DIR)/config/config.in
menuconfig:
@sh -n $(AVERSIVE_DIR)/config/config.in
@make -C $(AVERSIVE_DIR)/config/scripts/lxdialog all
@HELP_FILE=$(AVERSIVE_DIR)/config/Configure.help \
AUTOCONF_FILE=autoconf.h \
sh $(AVERSIVE_DIR)/config/scripts/Menuconfig
$(AVERSIVE_DIR)/config/config.in
# ------ clean targets
mrproper: clean_list
$(REMOVE) compiler_files/*
clean: depclean clean_list modules_clean
# clean modules files
modules_clean: $(patsubst %,%_clean,$(MODULES))
$(patsubst %,%_clean,$(MODULES)):
@$(MAKE) VPATH=$(ABS_AVERSIVE_DIR)/modules/$(@:_clean=) -f
$(ABS_AVERSIVE_DIR)/modules/$(@:_clean=)/Makefile clean
clean_list :
@echo
@echo $(MSG_CLEANING)
$(REMOVE) $(OUTPUT) $(OTHER_OUTPUT)
$(REMOVE) compiler_files/$(TARGET).map
$(REMOVE) $(OBJ)
$(REMOVE) $(PREPROC)
$(REMOVE) $(LST)
# ------ dependencies targets
depclean: dep_list modules_depclean
modules_depclean: $(patsubst %,%_depclean,$(MODULES))
$(patsubst %,%_depclean,$(MODULES)):
@$(MAKE) VPATH=$(ABS_AVERSIVE_DIR)/modules/$(@:_depclean=) -f
$(ABS_AVERSIVE_DIR)/modules/$(@:_depclean=)/Makefile depclean
dep_list:
@echo
@echo $(MSG_DEPCLEAN)
$(REMOVE) $(DEPS)
# Automatically generate C source code dependencies.
compiler_files/%.$(HOST).d: %.c
@mkdir -p compiler_files ; \
error=0; \
for conf_file in .config autoconf.h .aversive_conf; do \
if [ ! -f $$conf_file ]; then \
echo "$$conf_file file is missing"; \
error=1; \
fi ; \
done; \
for module in `echo $(MODULES)`; do \
conf=`basename $$module"_config.h"`; \
if [ -f $$module/config/$$conf ]; then \
if [ ! -f $$conf ]; then \
echo "$$conf file is missing"; \
error=1; \
fi ; \
fi ; \
done; \
if [ $$error -eq 1 ]; then \
echo "Missing config files, please run make menuconfig or make
config"; \
exit 1; \
fi
@echo Generating $@
@set -e; rm -f $@; \
$(CC) -M $(CFLAGS) $< > [EMAIL PROTECTED]; \
sed 's,\($*\)\.o[ :]*,compiler_files/\1.$(HOST).o $@ : ,g' < [EMAIL
PROTECTED] > $@; \
rm -f [EMAIL PROTECTED]
# include the deps file only for other targets than menuconfig or config
ifeq (,$(findstring config,$(MAKECMDGOALS)))
ifeq (,$(wildcard .config))
$(error You need to call make config or make menuconfig first)
endif
ifeq (,$(wildcard autoconf.h))
$(error Missing autoconf.h -- You need to call make noconfig)
endif
ifeq (,$(wildcard .aversive_conf))
$(error Missing .aversive_conf -- You need to call make noconfig)
endif
ifeq (,$(findstring mrproper,$(MAKECMDGOALS)))
-include $(addprefix compiler_files/,$(SRC:.c=.$(HOST).d))
endif
else
ifneq (1,$(words $(MAKECMDGOALS)))
$(error You need to call make config or make menuconfig without other targets)
endif
endif
# ------ Listing of phony targets.
.PHONY : all sizebefore sizeafter gccversion \
clean clean_list program md5sumafter md5sumbefore \
depclean dep_list modules $(MODULES) \
menuconfig config
_______________________________________________
Avr-list mailing list
Avr-list@droids-corp.org
CVSWEB : http://cvsweb.droids-corp.org/cgi-bin/viewcvs.cgi/aversive
WIKI : http://wiki.droids-corp.org/index.php/Aversive
DOXYGEN : http://zer0.droids-corp.org/doxygen_aversive/html/
BUGZILLA : http://bugzilla.droids-corp.org
COMMIT LOGS : http://zer0.droids-corp.org/aversive_commitlog