From e8e300d5c4dd05b806869b648b93feeff1f8a7dc Mon Sep 17 00:00:00 2001
From: Fred Sundvik <fsundvik@gmail.com>
Date: Fri, 8 Jul 2016 22:59:09 +0300
Subject: [PATCH 1/2] Fix name of makefile dep files

The files can't start with a .dot, as the wildcard function wont
find them. So this is fixed by removing the BUILD_DIR from the
name.
---
 tmk_core/rules.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index 543d3da8a..8d843cc98 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -260,7 +260,7 @@ LST = $(patsubst %.c,$(OBJDIR)/%.lst,$(patsubst %.cpp,$(OBJDIR)/%.lst,$(patsubst
 
 # Compiler flags to generate dependency files.
 #GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
-GENDEPFLAGS = -MMD -MP -MF $(BUILD_DIR)/.dep/$(subst /,_,$@).d
+GENDEPFLAGS = -MMD -MP -MF $(BUILD_DIR)/.dep/$(subst /,_,$(subst $(BUILD_DIR)/,,$@)).d
 
 
 # Combine all necessary flags and optional flags.

From 6911ead027202da981862c9259ff4d962d51a519 Mon Sep 17 00:00:00 2001
From: Fred Sundvik <fsundvik@gmail.com>
Date: Fri, 8 Jul 2016 23:19:48 +0300
Subject: [PATCH 2/2] Use order only prerequisites to avoid re-linking

The prerequisites at the start of the build process are order-only
so that the trget don't link again. Also added as a dependency to
the compilation to force the messages to be printed at the start
---
 tmk_core/rules.mk | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index 8d843cc98..f13351ea1 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -360,49 +360,51 @@ gccversion :
 	$(eval CMD=$(AR) $@ $(OBJ) )
 	@$(BUILD_CMD)
 
+BEGIN = gccversion check_submodule sizebefore
+
 # Link: create ELF output file from object files.
 .SECONDARY : $(BUILD_DIR)/$(TARGET).elf
 .PRECIOUS : $(OBJ)
-%.elf: gccversion sizebefore check_submodule $(OBJ)
+%.elf: $(OBJ) | $(BEGIN)
 	@$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD)
-	$(eval CMD=$(CC) $(ALL_CFLAGS) $(filter-out gccversion sizebefore check_submodule,$^) --output $@ $(LDFLAGS))
+	$(eval CMD=$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS))
 	@$(BUILD_CMD)
 
 # Compile: create object files from C source files.
-$(OBJDIR)/%.o : %.c
+$(OBJDIR)/%.o : %.c | $(BEGIN)
 	@mkdir -p $(@D)
 	@$(SILENT) || printf "$(MSG_COMPILING) $<" | $(AWK_CMD)
 	$(eval CMD=$(CC) -c $(ALL_CFLAGS) $< -o $@)
 	@$(BUILD_CMD)
 
 # Compile: create object files from C++ source files.
-$(OBJDIR)/%.o : %.cpp
+$(OBJDIR)/%.o : %.cpp | $(BEGIN)
 	@mkdir -p $(@D)
 	@$(SILENT) || printf "$(MSG_COMPILING_CPP) $<" | $(AWK_CMD)
 	$(eval CMD=$(CC) -c $(ALL_CPPFLAGS) $< -o $@)
 	@$(BUILD_CMD)
 
 # Compile: create assembler files from C source files.
-%.s : %.c
+%.s : %.c | $(BEGIN)
 	@$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
 	$(eval CMD=$(CC) -S $(ALL_CFLAGS) $< -o $@)
 	@$(BUILD_CMD)
 
 # Compile: create assembler files from C++ source files.
-%.s : %.cpp
+%.s : %.cpp | $(BEGIN)
 	@$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
 	$(eval CMD=$(CC) -S $(ALL_CPPFLAGS) $< -o $@)
 	@$(BUILD_CMD)
 
 # Assemble: create object files from assembler source files.
-$(OBJDIR)/%.o : %.S
+$(OBJDIR)/%.o : %.S | $(BEGIN)
 	@mkdir -p $(@D)
 	@$(SILENT) || printf "$(MSG_ASSEMBLING) $<" | $(AWK_CMD)
 	$(eval CMD=$(CC) -c $(ALL_ASFLAGS) $< -o $@)
 	@$(BUILD_CMD)
 
 # Create preprocessed source for use in sending a bug report.
-%.i : %.c
+%.i : %.c | $(BEGIN)
 	$(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@
 
 # Target: clean project.
@@ -492,7 +494,7 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
 
 # Listing of phony targets.
 .PHONY : all quick finish sizebefore sizeafter gccversion \
-build elf hex eep lss sym coff extcoff \
+build elf hex eep lss sym coff extcoff check_submodule \
 clean clean_list debug gdb-config show_path \
 program teensy dfu flip dfu-ee flip-ee dfu-start \
 all-keyboards-defaults all-keyboards all-keymaps \