summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2016-07-08 12:01:32 -0400
committerGitHub <noreply@github.com>2016-07-08 12:01:32 -0400
commit8610481c372e9de02fe1ec7b77a9f3598a72a372 (patch)
tree600fae09c11f89bb4bbd0e35ee025a453c7a7f13
parentb6e47f7a5ffd95078b36cb88167ba12cb9dcff08 (diff)
parent1e3db59097f8c396d69179fdd66ef0131a6ba80d (diff)
Merge pull request #496 from fredizzimo/makefile_optimization
Makefile optimization
-rw-r--r--tmk_core/common.mk2
-rw-r--r--tmk_core/rules.mk59
2 files changed, 22 insertions, 39 deletions
diff --git a/tmk_core/common.mk b/tmk_core/common.mk
index 5bae0d762f..aa05b9491d 100644
--- a/tmk_core/common.mk
+++ b/tmk_core/common.mk
@@ -107,7 +107,7 @@ endif
# Version string
-OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null)
+OPT_DEFS += -DVERSION=$(GIT_VERSION)
# Bootloader address
ifdef STM32_BOOTLOADER_ADDRESS
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index 352e9314b6..543d3da8a0 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -271,23 +271,10 @@ ALL_CPPFLAGS = $(MCUFLAGS) -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS)
ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS)
# Default target.
-all:
- @$(MAKE) begin
- @$(MAKE) gccversion
- @$(MAKE) sizebefore
- @$(MAKE) clean_list # force clean each time
- @$(MAKE) build
- @$(MAKE) sizeafter
- @$(MAKE) end
+all: build sizeafter
# Quick make that doesn't clean
-quick:
- @$(MAKE) begin
- @$(MAKE) gccversion
- @$(MAKE) sizebefore
- @$(MAKE) build
- @$(MAKE) sizeafter
- @$(MAKE) end
+quick: build sizeafter
# Change the build target to build a HEX file or a library.
build: elf hex
@@ -303,13 +290,7 @@ sym: $(BUILD_DIR)/$(TARGET).sym
LIBNAME=lib$(TARGET).a
lib: $(LIBNAME)
-
-
-# Eye candy.
-# 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:
- @$(SECHO) $(MSG_BEGIN)
+check_submodule:
git submodule status --recursive | \
while IFS= read -r x; do \
case "$$x" in \
@@ -318,10 +299,6 @@ begin:
esac \
done
-end:
- @$(SECHO) $(MSG_END)
-
-
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
#ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
@@ -331,7 +308,7 @@ sizebefore:
@if test -f $(TARGET).hex; then $(SECHO) $(MSG_SIZE_BEFORE); $(SILENT) || $(HEXSIZE); \
2>/dev/null; $(SECHO); fi
-sizeafter:
+sizeafter: $(BUILD_DIR)/$(TARGET).hex
@if test -f $(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(HEXSIZE); \
2>/dev/null; $(SECHO); fi
# test file sizes eventually
@@ -386,9 +363,9 @@ gccversion :
# Link: create ELF output file from object files.
.SECONDARY : $(BUILD_DIR)/$(TARGET).elf
.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
+%.elf: gccversion sizebefore check_submodule $(OBJ)
@$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD)
- $(eval CMD=$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS))
+ $(eval CMD=$(CC) $(ALL_CFLAGS) $(filter-out gccversion sizebefore check_submodule,$^) --output $@ $(LDFLAGS))
@$(BUILD_CMD)
# Compile: create object files from C source files.
@@ -429,14 +406,7 @@ $(OBJDIR)/%.o : %.S
$(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@
# Target: clean project.
-clean: begin clean_list end
-
-clean_list :
- @$(REMOVE) -r $(BUILD_DIR)
- @$(REMOVE) -r $(TOP_DIR)/$(BUILD_DIR)
- @$(REMOVE) -r $(KEYBOARD_PATH)/$(BUILD_DIR)
- @if $$SUBPROJECT; then $(REMOVE) -r $(SUBPROJECT_PATH)/$(BUILD_DIR); fi
- @$(REMOVE) -r $(KEYMAP_PATH)/$(BUILD_DIR)
+clean:
show_path:
@echo VPATH=$(VPATH)
@@ -496,6 +466,19 @@ all-keymaps-%:
all-keymaps: all-keymaps-all
+GOAL=$(MAKECMDGOALS)
+ifeq ($(MAKECMDGOALS),)
+GOAL = all
+endif
+CLEANING_GOALS=clean clean_list all
+ifneq ($(findstring $(GOAL),$(CLEANING_GOALS)),)
+$(shell $(REMOVE) -r $(BUILD_DIR) 2>/dev/null)
+$(shell $(REMOVE) -r $(TOP_DIR)/$(BUILD_DIR))
+$(shell $(REMOVE) -r $(KEYBOARD_PATH)/$(BUILD_DIR))
+$(shell if $$SUBPROJECT; then $(REMOVE) -r $(SUBPROJECT_PATH)/$(BUILD_DIR); fi)
+$(shell $(REMOVE) -r $(KEYMAP_PATH)/$(BUILD_DIR))
+endif
+
# Create build directory
$(shell mkdir $(BUILD_DIR) 2>/dev/null)
@@ -508,7 +491,7 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
# Listing of phony targets.
-.PHONY : all quick begin finish end sizebefore sizeafter gccversion \
+.PHONY : all quick finish sizebefore sizeafter gccversion \
build elf hex eep lss sym coff extcoff \
clean clean_list debug gdb-config show_path \
program teensy dfu flip dfu-ee flip-ee dfu-start \