1
0
Fork 0

Speed up compilation by not using recusive make

The cleaning is done outside the targets, by checking the
requested target name.
This commit is contained in:
Fred Sundvik 2016-07-08 17:20:37 +03:00
parent e8719e10c4
commit b86b0480d5

View file

@ -271,23 +271,10 @@ ALL_CPPFLAGS = $(MCUFLAGS) -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS)
ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS)
# Default target. # Default target.
all: all: build sizeafter
@$(MAKE) begin
@$(MAKE) gccversion
@$(MAKE) sizebefore
@$(MAKE) clean_list # force clean each time
@$(MAKE) build
@$(MAKE) sizeafter
@$(MAKE) end
# Quick make that doesn't clean # Quick make that doesn't clean
quick: quick: build sizeafter
@$(MAKE) begin
@$(MAKE) gccversion
@$(MAKE) sizebefore
@$(MAKE) build
@$(MAKE) sizeafter
@$(MAKE) end
# Change the build target to build a HEX file or a library. # Change the build target to build a HEX file or a library.
build: elf hex build: elf hex
@ -303,13 +290,7 @@ sym: $(BUILD_DIR)/$(TARGET).sym
LIBNAME=lib$(TARGET).a LIBNAME=lib$(TARGET).a
lib: $(LIBNAME) lib: $(LIBNAME)
check_submodule:
# 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)
git submodule status --recursive | \ git submodule status --recursive | \
while IFS= read -r x; do \ while IFS= read -r x; do \
case "$$x" in \ case "$$x" in \
@ -318,10 +299,6 @@ begin:
esac \ esac \
done done
end:
@$(SECHO) $(MSG_END)
# Display size of file. # Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
#ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf #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); \ @if test -f $(TARGET).hex; then $(SECHO) $(MSG_SIZE_BEFORE); $(SILENT) || $(HEXSIZE); \
2>/dev/null; $(SECHO); fi 2>/dev/null; $(SECHO); fi
sizeafter: sizeafter: $(BUILD_DIR)/$(TARGET).hex
@if test -f $(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(HEXSIZE); \ @if test -f $(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(HEXSIZE); \
2>/dev/null; $(SECHO); fi 2>/dev/null; $(SECHO); fi
# test file sizes eventually # test file sizes eventually
@ -386,9 +363,9 @@ gccversion :
# Link: create ELF output file from object files. # Link: create ELF output file from object files.
.SECONDARY : $(BUILD_DIR)/$(TARGET).elf .SECONDARY : $(BUILD_DIR)/$(TARGET).elf
.PRECIOUS : $(OBJ) .PRECIOUS : $(OBJ)
%.elf: $(OBJ) %.elf: gccversion sizebefore check_submodule $(OBJ)
@$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD) @$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD)
$(eval CMD=$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)) $(eval CMD=$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS))
@$(BUILD_CMD) @$(BUILD_CMD)
# Compile: create object files from C source files. # Compile: create object files from C source files.
@ -429,14 +406,7 @@ $(OBJDIR)/%.o : %.S
$(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@ $(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@
# Target: clean project. # Target: clean project.
clean: begin clean_list end clean:
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)
show_path: show_path:
@echo VPATH=$(VPATH) @echo VPATH=$(VPATH)
@ -496,6 +466,19 @@ all-keymaps-%:
all-keymaps: all-keymaps-all 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 # Create build directory
$(shell mkdir $(BUILD_DIR) 2>/dev/null) $(shell mkdir $(BUILD_DIR) 2>/dev/null)
@ -508,7 +491,7 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
# Listing of phony targets. # 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 \ build elf hex eep lss sym coff extcoff \
clean clean_list debug gdb-config show_path \ clean clean_list debug gdb-config show_path \
program teensy dfu flip dfu-ee flip-ee dfu-start \ program teensy dfu flip dfu-ee flip-ee dfu-start \