aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build_keyboard.mk4
-rw-r--r--tmk_core/rules.mk91
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
7include message.mk
8
7 9
8# Directory common source filess exist 10# Directory common source filess exist
9TOP_DIR = . 11TOP_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!
71OBJDIR = $(BUILD_DIR)/obj_$(TARGET) 73OBJDIR := $(BUILD_DIR)/obj_$(TARGET)
72 74
73 75
74ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") 76ifneq ("$(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.)
35OPT = s 35OPT = s
36 36
37COLOR ?= true
38
39ifeq ($(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
46endif
47
48AUTOGEN ?= false 37AUTOGEN ?= false
49 38
50ifneq ($(shell awk --version 2>/dev/null),)
51 AWK=awk
52else
53 AWK=cat && test
54endif
55
56OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)\n
57ERROR_STRING=$(ERROR_COLOR)[ERRORS]$(NO_COLOR)\n
58WARN_STRING=$(WARN_COLOR)[WARNINGS]$(NO_COLOR)\n
59
60ifndef $(SILENT)
61 SILENT = false
62endif
63
64TAB_LOG = printf "\n$$LOG\n\n" | $(AWK) '{ sub(/^/," | "); print }'
65TAB_LOG_PLAIN = printf "$$LOG\n"
66AWK_STATUS = $(AWK) '{ printf " %-10s\n", $$1; }'
67AWK_CMD = $(AWK) '{ printf "%-99s", $$0; }'
68PRINT_ERROR = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG) && exit 1
69PRINT_WARNING = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG)
70PRINT_ERROR_PLAIN = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN) && exit 1
71PRINT_WARNING_PLAIN = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN)
72PRINT_OK = $(SILENT) || printf " $(OK_STRING)" | $(AWK_STATUS)
73BUILD_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
467SUBDIRS := $(filter-out %/util/ %/doc/ %/keymaps/ %/old_keymap_files/,$(dir $(wildcard $(TOP_DIR)/keyboards/**/*/Makefile)))
468SUBDIRS := $(SUBDIRS) $(dir $(wildcard $(TOP_DIR)/keyboards/*/.))
469SUBDIRS := $(sort $(SUBDIRS))
470# $(error $(SUBDIRS))
471all-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
477all-keyboards-defaults: all-keyboards-defaults-all
478
479KEYBOARDS := $(SUBDIRS:$(TOP_DIR)/keyboards/%/=/keyboards/%)
480all-keyboards-all: $(addsuffix -all,$(KEYBOARDS))
481all-keyboards-clean: $(addsuffix -clean,$(KEYBOARDS))
482all-keyboards: all-keyboards-all
483
484define 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; \
493done
494endef
495
496define 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)
499endef
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
508all-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
516all-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 \
531build elf hex eep lss sym coff extcoff check_submodule \ 446build elf hex eep lss sym coff extcoff check_submodule \
532clean clean_list debug gdb-config show_path \ 447clean clean_list debug gdb-config show_path \
533program teensy dfu flip dfu-ee flip-ee dfu-start \ 448program teensy dfu flip dfu-ee flip-ee dfu-start \ No newline at end of file
534all-keyboards-defaults all-keyboards all-keymaps \
535all-keyboards-defaults-% all-keyboards-% all-keymaps-%