diff options
| -rw-r--r-- | tmk_core/rules.mk | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index 352e9314b..a518fc0c3 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk | |||
| @@ -271,23 +271,10 @@ ALL_CPPFLAGS = $(MCUFLAGS) -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS) | |||
| 271 | ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) | 271 | ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) |
| 272 | 272 | ||
| 273 | # Default target. | 273 | # Default target. |
| 274 | all: | 274 | all: build sizeafter |
| 275 | @$(MAKE) begin | ||
| 276 | @$(MAKE) gccversion | ||
| 277 | @$(MAKE) sizebefore | ||
| 278 | @$(MAKE) clean_list # force clean each time | ||
| 279 | @$(MAKE) build | ||
| 280 | @$(MAKE) sizeafter | ||
| 281 | @$(MAKE) end | ||
| 282 | 275 | ||
| 283 | # Quick make that doesn't clean | 276 | # Quick make that doesn't clean |
| 284 | quick: | 277 | quick: build sizeafter |
| 285 | @$(MAKE) begin | ||
| 286 | @$(MAKE) gccversion | ||
| 287 | @$(MAKE) sizebefore | ||
| 288 | @$(MAKE) build | ||
| 289 | @$(MAKE) sizeafter | ||
| 290 | @$(MAKE) end | ||
| 291 | 278 | ||
| 292 | # Change the build target to build a HEX file or a library. | 279 | # Change the build target to build a HEX file or a library. |
| 293 | build: elf hex | 280 | build: elf hex |
| @@ -303,13 +290,7 @@ sym: $(BUILD_DIR)/$(TARGET).sym | |||
| 303 | LIBNAME=lib$(TARGET).a | 290 | LIBNAME=lib$(TARGET).a |
| 304 | lib: $(LIBNAME) | 291 | lib: $(LIBNAME) |
| 305 | 292 | ||
| 306 | 293 | check_submodule: | |
| 307 | |||
| 308 | # Eye candy. | ||
| 309 | # AVR Studio 3.x does not check make's exit code but relies on | ||
| 310 | # the following magic strings to be generated by the compile job. | ||
| 311 | begin: | ||
| 312 | @$(SECHO) $(MSG_BEGIN) | ||
| 313 | git submodule status --recursive | \ | 294 | git submodule status --recursive | \ |
| 314 | while IFS= read -r x; do \ | 295 | while IFS= read -r x; do \ |
| 315 | case "$$x" in \ | 296 | case "$$x" in \ |
| @@ -318,10 +299,6 @@ begin: | |||
| 318 | esac \ | 299 | esac \ |
| 319 | done | 300 | done |
| 320 | 301 | ||
| 321 | end: | ||
| 322 | @$(SECHO) $(MSG_END) | ||
| 323 | |||
| 324 | |||
| 325 | # Display size of file. | 302 | # Display size of file. |
| 326 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex | 303 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
| 327 | #ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf | 304 | #ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf |
| @@ -331,7 +308,7 @@ sizebefore: | |||
| 331 | @if test -f $(TARGET).hex; then $(SECHO) $(MSG_SIZE_BEFORE); $(SILENT) || $(HEXSIZE); \ | 308 | @if test -f $(TARGET).hex; then $(SECHO) $(MSG_SIZE_BEFORE); $(SILENT) || $(HEXSIZE); \ |
| 332 | 2>/dev/null; $(SECHO); fi | 309 | 2>/dev/null; $(SECHO); fi |
| 333 | 310 | ||
| 334 | sizeafter: | 311 | sizeafter: $(BUILD_DIR)/$(TARGET).hex |
| 335 | @if test -f $(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(HEXSIZE); \ | 312 | @if test -f $(TARGET).hex; then $(SECHO); $(SECHO) $(MSG_SIZE_AFTER); $(SILENT) || $(HEXSIZE); \ |
| 336 | 2>/dev/null; $(SECHO); fi | 313 | 2>/dev/null; $(SECHO); fi |
| 337 | # test file sizes eventually | 314 | # test file sizes eventually |
| @@ -386,9 +363,9 @@ gccversion : | |||
| 386 | # Link: create ELF output file from object files. | 363 | # Link: create ELF output file from object files. |
| 387 | .SECONDARY : $(BUILD_DIR)/$(TARGET).elf | 364 | .SECONDARY : $(BUILD_DIR)/$(TARGET).elf |
| 388 | .PRECIOUS : $(OBJ) | 365 | .PRECIOUS : $(OBJ) |
| 389 | %.elf: $(OBJ) | 366 | %.elf: gccversion sizebefore check_submodule $(OBJ) |
| 390 | @$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD) | 367 | @$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD) |
| 391 | $(eval CMD=$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)) | 368 | $(eval CMD=$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)) |
| 392 | @$(BUILD_CMD) | 369 | @$(BUILD_CMD) |
| 393 | 370 | ||
| 394 | # Compile: create object files from C source files. | 371 | # Compile: create object files from C source files. |
| @@ -429,14 +406,7 @@ $(OBJDIR)/%.o : %.S | |||
| 429 | $(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@ | 406 | $(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@ |
| 430 | 407 | ||
| 431 | # Target: clean project. | 408 | # Target: clean project. |
| 432 | clean: begin clean_list end | 409 | clean: |
| 433 | |||
| 434 | clean_list : | ||
| 435 | @$(REMOVE) -r $(BUILD_DIR) | ||
| 436 | @$(REMOVE) -r $(TOP_DIR)/$(BUILD_DIR) | ||
| 437 | @$(REMOVE) -r $(KEYBOARD_PATH)/$(BUILD_DIR) | ||
| 438 | @if $$SUBPROJECT; then $(REMOVE) -r $(SUBPROJECT_PATH)/$(BUILD_DIR); fi | ||
| 439 | @$(REMOVE) -r $(KEYMAP_PATH)/$(BUILD_DIR) | ||
| 440 | 410 | ||
| 441 | show_path: | 411 | show_path: |
| 442 | @echo VPATH=$(VPATH) | 412 | @echo VPATH=$(VPATH) |
| @@ -496,6 +466,19 @@ all-keymaps-%: | |||
| 496 | 466 | ||
| 497 | all-keymaps: all-keymaps-all | 467 | all-keymaps: all-keymaps-all |
| 498 | 468 | ||
| 469 | GOAL=$(MAKECMDGOALS) | ||
| 470 | ifeq ($(MAKECMDGOALS),) | ||
| 471 | GOAL = all | ||
| 472 | endif | ||
| 473 | CLEANING_GOALS=clean clean_list all | ||
| 474 | ifneq ($(findstring $(GOAL),$(CLEANING_GOALS)),) | ||
| 475 | $(shell $(REMOVE) -r $(BUILD_DIR) 2>/dev/null) | ||
| 476 | $(shell $(REMOVE) -r $(TOP_DIR)/$(BUILD_DIR)) | ||
| 477 | $(shell $(REMOVE) -r $(KEYBOARD_PATH)/$(BUILD_DIR)) | ||
| 478 | $(shell if $$SUBPROJECT; then $(REMOVE) -r $(SUBPROJECT_PATH)/$(BUILD_DIR); fi) | ||
| 479 | $(shell $(REMOVE) -r $(KEYMAP_PATH)/$(BUILD_DIR)) | ||
| 480 | endif | ||
| 481 | |||
| 499 | # Create build directory | 482 | # Create build directory |
| 500 | $(shell mkdir $(BUILD_DIR) 2>/dev/null) | 483 | $(shell mkdir $(BUILD_DIR) 2>/dev/null) |
| 501 | 484 | ||
| @@ -508,7 +491,7 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) | |||
| 508 | 491 | ||
| 509 | 492 | ||
| 510 | # Listing of phony targets. | 493 | # Listing of phony targets. |
| 511 | .PHONY : all quick begin finish end sizebefore sizeafter gccversion \ | 494 | .PHONY : all quick finish sizebefore sizeafter gccversion \ |
| 512 | build elf hex eep lss sym coff extcoff \ | 495 | build elf hex eep lss sym coff extcoff \ |
| 513 | clean clean_list debug gdb-config show_path \ | 496 | clean clean_list debug gdb-config show_path \ |
| 514 | program teensy dfu flip dfu-ee flip-ee dfu-start \ | 497 | program teensy dfu flip dfu-ee flip-ee dfu-start \ |
