summaryrefslogtreecommitdiffstats
path: root/tmk_core/rules.mk
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/rules.mk')
-rw-r--r--tmk_core/rules.mk42
1 files changed, 24 insertions, 18 deletions
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index 860fc1a931..326d2a7872 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -142,6 +142,9 @@ CFLAGS += $(CSTANDARD)
ifdef CONFIG_H
CFLAGS += -include $(CONFIG_H)
endif
+ifdef CONFIG_USER_H
+ CFLAGS += -include $(CONFIG_USER_H)
+endif
#---------------- Compiler Options C++ ----------------
@@ -176,6 +179,9 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
ifdef CONFIG_H
CPPFLAGS += -include $(CONFIG_H)
endif
+ifdef CONFIG_USER_H
+ CPPFLAGS += -include $(CONFIG_USER_H)
+endif
#---------------- Assembler Options ----------------
@@ -192,6 +198,9 @@ ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
ifdef CONFIG_H
ASFLAGS += -include $(CONFIG_H)
endif
+ifdef CONFIG_USER_H
+ ASFLAGS += -include $(CONFIG_USER_H)
+endif
#---------------- Library Options ----------------
@@ -308,7 +317,12 @@ REMOVE = rm -f
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
@@ -357,7 +371,13 @@ ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS)
# 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
@@ -378,12 +398,10 @@ lib: $(LIBNAME)
# 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.
@@ -412,14 +430,14 @@ program: $(TARGET).hex $(TARGET).eep
$(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
@@ -490,13 +508,11 @@ COFFCONVERT += --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
@@ -504,25 +520,21 @@ extcoff: $(TARGET).elf
# 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 $< > $@
@@ -532,7 +544,6 @@ extcoff: $(TARGET).elf
.SECONDARY : $(TARGET).a
.PRECIOUS : $(OBJ)
%.a: $(OBJ)
- @echo
@echo $(MSG_CREATING_LIBRARY) $@
$(AR) $@ $(OBJ)
@@ -541,14 +552,12 @@ extcoff: $(TARGET).elf
.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 $@
@@ -556,7 +565,6 @@ $(OBJDIR)/%.o : %.c
# Compile: create object files from C++ source files.
$(OBJDIR)/%.o : %.cpp
- @echo
mkdir -p $(@D)
@echo $(MSG_COMPILING_CPP) $<
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
@@ -574,7 +582,6 @@ $(OBJDIR)/%.o : %.cpp
# Assemble: create object files from assembler source files.
$(OBJDIR)/%.o : %.S
- @echo
mkdir -p $(@D)
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $@
@@ -589,7 +596,6 @@ $(OBJDIR)/%.o : %.S
clean: begin clean_list end
clean_list :
- @echo
$(REMOVE) $(TARGET).hex
$(REMOVE) $(TARGET).eep
$(REMOVE) $(TARGET).cof