diff options
| -rw-r--r-- | build_keyboard.mk | 4 | ||||
| -rw-r--r-- | tmk_core/rules.mk | 91 |
2 files changed, 5 insertions, 90 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk index b0cb22e6a..7493c1328 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk | |||
| @@ -4,6 +4,8 @@ endif | |||
| 4 | 4 | ||
| 5 | .DEFAULT_GOAL := all | 5 | .DEFAULT_GOAL := all |
| 6 | 6 | ||
| 7 | include message.mk | ||
| 8 | |||
| 7 | 9 | ||
| 8 | # Directory common source filess exist | 10 | # Directory common source filess exist |
| 9 | TOP_DIR = . | 11 | TOP_DIR = . |
| @@ -68,7 +70,7 @@ BUILD_DIR = $(TOP_DIR)/.build | |||
| 68 | # Object files directory | 70 | # Object files directory |
| 69 | # To put object files in current directory, use a dot (.), do NOT make | 71 | # To put object files in current directory, use a dot (.), do NOT make |
| 70 | # this an empty or blank macro! | 72 | # this an empty or blank macro! |
| 71 | OBJDIR = $(BUILD_DIR)/obj_$(TARGET) | 73 | OBJDIR := $(BUILD_DIR)/obj_$(TARGET) |
| 72 | 74 | ||
| 73 | 75 | ||
| 74 | ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") | 76 | ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") |
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index d2350f27c..9aa4ac8cf 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk | |||
| @@ -34,43 +34,8 @@ FORMAT = ihex | |||
| 34 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) | 34 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
| 35 | OPT = s | 35 | OPT = s |
| 36 | 36 | ||
| 37 | COLOR ?= true | ||
| 38 | |||
| 39 | ifeq ($(COLOR),true) | ||
| 40 | NO_COLOR=\033[0m | ||
| 41 | OK_COLOR=\033[32;01m | ||
| 42 | ERROR_COLOR=\033[31;01m | ||
| 43 | WARN_COLOR=\033[33;01m | ||
| 44 | BLUE=\033[0;34m | ||
| 45 | BOLD=\033[1m | ||
| 46 | endif | ||
| 47 | |||
| 48 | AUTOGEN ?= false | 37 | AUTOGEN ?= false |
| 49 | 38 | ||
| 50 | ifneq ($(shell awk --version 2>/dev/null),) | ||
| 51 | AWK=awk | ||
| 52 | else | ||
| 53 | AWK=cat && test | ||
| 54 | endif | ||
| 55 | |||
| 56 | OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)\n | ||
| 57 | ERROR_STRING=$(ERROR_COLOR)[ERRORS]$(NO_COLOR)\n | ||
| 58 | WARN_STRING=$(WARN_COLOR)[WARNINGS]$(NO_COLOR)\n | ||
| 59 | |||
| 60 | ifndef $(SILENT) | ||
| 61 | SILENT = false | ||
| 62 | endif | ||
| 63 | |||
| 64 | TAB_LOG = printf "\n$$LOG\n\n" | $(AWK) '{ sub(/^/," | "); print }' | ||
| 65 | TAB_LOG_PLAIN = printf "$$LOG\n" | ||
| 66 | AWK_STATUS = $(AWK) '{ printf " %-10s\n", $$1; }' | ||
| 67 | AWK_CMD = $(AWK) '{ printf "%-99s", $$0; }' | ||
| 68 | PRINT_ERROR = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG) && exit 1 | ||
| 69 | PRINT_WARNING = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG) | ||
| 70 | PRINT_ERROR_PLAIN = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN) && exit 1 | ||
| 71 | PRINT_WARNING_PLAIN = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN) | ||
| 72 | PRINT_OK = $(SILENT) || printf " $(OK_STRING)" | $(AWK_STATUS) | ||
| 73 | BUILD_CMD = LOG=$$($(CMD) 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING); else $(PRINT_OK); fi; | ||
| 74 | 39 | ||
| 75 | # List any extra directories to look for include files here. | 40 | # List any extra directories to look for include files here. |
| 76 | # Each directory must be seperated by a space. | 41 | # Each directory must be seperated by a space. |
| @@ -432,6 +397,7 @@ DEPS = $(patsubst %.o,%.d,$(OBJ)) | |||
| 432 | .PRECIOUS: $(DEPS) | 397 | .PRECIOUS: $(DEPS) |
| 433 | # Empty rule to force recompilation if the .d file is missing | 398 | # Empty rule to force recompilation if the .d file is missing |
| 434 | $(DEPS): | 399 | $(DEPS): |
| 400 | |||
| 435 | 401 | ||
| 436 | # Since the object files could be in two different folders, generate | 402 | # Since the object files could be in two different folders, generate |
| 437 | # separate rules for them, rather than having too generic rules | 403 | # separate rules for them, rather than having too generic rules |
| @@ -464,57 +430,6 @@ show_path: | |||
| 464 | @echo VPATH=$(VPATH) | 430 | @echo VPATH=$(VPATH) |
| 465 | @echo SRC=$(SRC) | 431 | @echo SRC=$(SRC) |
| 466 | 432 | ||
| 467 | SUBDIRS := $(filter-out %/util/ %/doc/ %/keymaps/ %/old_keymap_files/,$(dir $(wildcard $(TOP_DIR)/keyboards/**/*/Makefile))) | ||
| 468 | SUBDIRS := $(SUBDIRS) $(dir $(wildcard $(TOP_DIR)/keyboards/*/.)) | ||
| 469 | SUBDIRS := $(sort $(SUBDIRS)) | ||
| 470 | # $(error $(SUBDIRS)) | ||
| 471 | all-keyboards-defaults-%: | ||
| 472 | @for x in $(SUBDIRS) ; do \ | ||
| 473 | printf "Compiling with default: $$x" | $(AWK_CMD); \ | ||
| 474 | LOG=$$($(MAKE) -C $$x $(subst all-keyboards-defaults-,,$@) VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=true 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR_PLAIN); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING_PLAIN); else $(PRINT_OK); fi; \ | ||
| 475 | done | ||
| 476 | |||
| 477 | all-keyboards-defaults: all-keyboards-defaults-all | ||
| 478 | |||
| 479 | KEYBOARDS := $(SUBDIRS:$(TOP_DIR)/keyboards/%/=/keyboards/%) | ||
| 480 | all-keyboards-all: $(addsuffix -all,$(KEYBOARDS)) | ||
| 481 | all-keyboards-clean: $(addsuffix -clean,$(KEYBOARDS)) | ||
| 482 | all-keyboards: all-keyboards-all | ||
| 483 | |||
| 484 | define make_keyboard | ||
| 485 | $(eval KEYBOARD=$(patsubst /keyboards/%,%,$1)) | ||
| 486 | $(eval SUBPROJECT=$(lastword $(subst /, ,$(KEYBOARD)))) | ||
| 487 | $(eval KEYBOARD=$(firstword $(subst /, ,$(KEYBOARD)))) | ||
| 488 | $(eval KEYMAPS=$(notdir $(patsubst %/.,%,$(wildcard $(TOP_DIR)/keyboards/$(KEYBOARD)/keymaps/*/.)))) | ||
| 489 | $(eval KEYMAPS+=$(notdir $(patsubst %/.,%,$(wildcard $(TOP_DIR)/keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/*/.)))) | ||
| 490 | @for x in $(KEYMAPS) ; do \ | ||
| 491 | printf "Compiling $(BOLD)$(KEYBOARD)/$(SUBPROJECT)$(NO_COLOR) with $(BOLD)$$x$(NO_COLOR)" | $(AWK) '{ printf "%-118s", $$0; }'; \ | ||
| 492 | LOG=$$($(MAKE) -C $(TOP_DIR)$1 $2 keymap=$$x VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=true 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR_PLAIN); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING_PLAIN); else $(PRINT_OK); fi; \ | ||
| 493 | done | ||
| 494 | endef | ||
| 495 | |||
| 496 | define make_keyboard_helper | ||
| 497 | # Just remove the -all and so on from the first argument and pass it forward | ||
| 498 | $(call make_keyboard,$(subst -$2,,$1),$2) | ||
| 499 | endef | ||
| 500 | |||
| 501 | /keyboards/%-all: | ||
| 502 | $(call make_keyboard_helper,$@,all) | ||
| 503 | /keyboards/%-clean: | ||
| 504 | $(call make_keyboard_helper,$@,clean) | ||
| 505 | /keyboards/%: | ||
| 506 | $(call make_keyboard_helper,$@,all) | ||
| 507 | |||
| 508 | all-keymaps-%: | ||
| 509 | $(eval MAKECONFIG=$(call get_target,all-keymaps,$@)) | ||
| 510 | $(eval KEYMAPS=$(notdir $(patsubst %/.,%,$(wildcard $(TOP_DIR)/keyboards/$(KEYBOARD)/keymaps/*/.)))) | ||
| 511 | @for x in $(KEYMAPS) ; do \ | ||
| 512 | printf "Compiling $(BOLD)$(KEYBOARD)$(NO_COLOR) with $(BOLD)$$x$(NO_COLOR)" | $(AWK) '{ printf "%-118s", $$0; }'; \ | ||
| 513 | LOG=$$($(MAKE) $(subst all-keymaps-,,$@) keyboard=$(KEYBOARD) keymap=$$x VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=true 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR_PLAIN); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING_PLAIN); else $(PRINT_OK); fi; \ | ||
| 514 | done | ||
| 515 | |||
| 516 | all-keymaps: all-keymaps-all | ||
| 517 | |||
| 518 | # Create build directory | 433 | # Create build directory |
| 519 | $(shell mkdir $(BUILD_DIR) 2>/dev/null) | 434 | $(shell mkdir $(BUILD_DIR) 2>/dev/null) |
| 520 | 435 | ||
| @@ -530,6 +445,4 @@ $(shell mkdir $(KBOBJDIR) 2>/dev/null) | |||
| 530 | .PHONY : all finish sizebefore sizeafter gccversion \ | 445 | .PHONY : all finish sizebefore sizeafter gccversion \ |
| 531 | build elf hex eep lss sym coff extcoff check_submodule \ | 446 | build elf hex eep lss sym coff extcoff check_submodule \ |
| 532 | clean clean_list debug gdb-config show_path \ | 447 | clean clean_list debug gdb-config show_path \ |
| 533 | program teensy dfu flip dfu-ee flip-ee dfu-start \ | 448 | program teensy dfu flip dfu-ee flip-ee dfu-start \ No newline at end of file |
| 534 | all-keyboards-defaults all-keyboards all-keymaps \ | ||
| 535 | all-keyboards-defaults-% all-keyboards-% all-keymaps-% | ||
