ifdef CONFIG_H
CFLAGS += -include $(CONFIG_H)
endif
+ifdef CONFIG_USER_H
+ CFLAGS += -include $(CONFIG_USER_H)
+endif
#---------------- Compiler Options C++ ----------------
ifdef CONFIG_H
CPPFLAGS += -include $(CONFIG_H)
endif
+ifdef CONFIG_USER_H
+ CPPFLAGS += -include $(CONFIG_USER_H)
+endif
#---------------- Assembler Options ----------------
ifdef CONFIG_H
ASFLAGS += -include $(CONFIG_H)
endif
+ifdef CONFIG_USER_H
+ ASFLAGS += -include $(CONFIG_USER_H)
+endif
#---------------- Library Options ----------------
REMOVEDIR = rmdir
COPY = cp
WINSHELL = cmd
-
+# Autodecct teensy loader
+ifneq (, $(shell which teensy-loader-cli 2>/dev/null))
+ TEENSY_LOADER_CLI = teensy-loader-cli
+else
+ TEENSY_LOADER_CLI = teensy_loader_cli
+endif
# Define Messages
# English
# Default target.
-all: begin gccversion sizebefore build sizeafter end
+all:
+ $(MAKE) begin
+ $(MAKE) gccversion
+ $(MAKE) sizebefore
+ $(MAKE) build
+ $(MAKE) sizeafter
+ $(MAKE) end
# Change the build target to build a HEX file or a library.
build: elf hex eep lss sym
# AVR Studio 3.x does not check make's exit code but relies on
# the following magic strings to be generated by the compile job.
begin:
- @echo
@echo $(MSG_BEGIN)
end:
@echo $(MSG_END)
- @echo
# Display size of file.
$(PROGRAM_CMD)
teensy: $(TARGET).hex
- teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
+ $(TEENSY_LOADER_CLI) -mmcu=$(MCU) -w -v $(TARGET).hex
flip: $(TARGET).hex
batchisp -hardware usb -device $(MCU) -operation erase f
batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program
batchisp -hardware usb -device $(MCU) -operation start reset 0
-dfu: $(TARGET).hex
+dfu: $(TARGET).hex sizeafter
ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
dfu-programmer $(MCU) erase --force
else
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
# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
- @echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@
%.eep: %.elf
- @echo
@echo $(MSG_EEPROM) $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
# Create extended listing file from ELF output file.
%.lss: %.elf
- @echo
@echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S -z $< > $@
# Create a symbol table from ELF output file.
%.sym: %.elf
- @echo
@echo $(MSG_SYMBOL_TABLE) $@
$(NM) -n $< > $@
.SECONDARY : $(TARGET).a
.PRECIOUS : $(OBJ)
%.a: $(OBJ)
- @echo
@echo $(MSG_CREATING_LIBRARY) $@
$(AR) $@ $(OBJ)
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(OBJ)
%.elf: $(OBJ)
- @echo
@echo $(MSG_LINKING) $@
$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
# Compile: create object files from C source files.
$(OBJDIR)/%.o : %.c
- @echo
mkdir -p $(@D)
@echo $(MSG_COMPILING) $<
$(CC) -c $(ALL_CFLAGS) $< -o $@
# Compile: create object files from C++ source files.
$(OBJDIR)/%.o : %.cpp
- @echo
mkdir -p $(@D)
@echo $(MSG_COMPILING_CPP) $<
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
# Assemble: create object files from assembler source files.
$(OBJDIR)/%.o : %.S
- @echo
mkdir -p $(@D)
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $@
clean: begin clean_list end
clean_list :
- @echo
$(REMOVE) $(TARGET).hex
$(REMOVE) $(TARGET).eep
$(REMOVE) $(TARGET).cof