aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2016-08-04 08:49:44 +0300
committerFred Sundvik <fsundvik@gmail.com>2016-08-20 03:24:40 +0300
commit9b02e66ce0f703480e42038a5084174a45b54b1d (patch)
tree5251dba7e0244fa4df1251ffea59563766f215b2 /Makefile
parentf97ae2b199df087f4b48c7019c2d887089d81614 (diff)
downloadfirmware-9b02e66ce0f703480e42038a5084174a45b54b1d.tar.gz
firmware-9b02e66ce0f703480e42038a5084174a45b54b1d.tar.bz2
firmware-9b02e66ce0f703480e42038a5084174a45b54b1d.zip
Add keymap parsing
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile34
1 files changed, 31 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index b24270ad1..b4204478e 100644
--- a/Makefile
+++ b/Makefile
@@ -71,12 +71,28 @@ define PARSE_ALL_KEYBOARDS
COMMAND_allkb := "All keyboards with $$(RULE)"
endef
+# $1 = Keyboard
define PARSE_KEYBOARD
- COMMANDS += $1
- #$$(info $$(RULE))
- COMMAND_$1 := "Keyboard $1 with $$(RULE)"
+ $$(eval $$(call COMPARE_AND_REMOVE_FROM_RULE,allkm))
+ ifeq ($$(RULE_FOUND),true)
+ $$(eval $$(call PARSE_ALL_KEYMAPS, $1))
+ else
+ KEYMAPS := $(notdir $(patsubst %/.,%,$(wildcard $(ROOT_DIR)/keyboards/$1/keymaps/*/.)))
+ $$(eval $$(call TRY_PARSE_KEYMAP,$$(KEYMAPS),$1))
+ endif
+endef
+
+define PARSE_ALL_KEYMAPS
+ COMMANDS += ALL_KEYMAPS
+ COMMAND_ALL_KEYMAPS := All keymaps in $1
endef
+# $1 Keyboard
+# $2 Keymap
+define PARSE_KEYMAP
+ COMMANDS += KEYBOARD_$1_KEYMAP_$2
+ COMMAND_KEYBOARD_$1_KEYMAP_$2 := Keyboard $1, Keymap $2
+endef
# Recursively try to find a matching keyboard
# During the first call $1 contains a list of all keyboards
@@ -91,6 +107,18 @@ define TRY_PARSE_KEYBOARD
endif
endef
+# $1 list of keymaps
+# $2 keyboard
+define TRY_PARSE_KEYMAP
+ CURRENT_KM := $$(firstword $1)
+ $$(eval $$(call COMPARE_AND_REMOVE_FROM_RULE,$$(CURRENT_KM)))
+ ifeq ($$(RULE_FOUND),true)
+ $$(eval $$(call PARSE_KEYMAP,$2,$$(CURRENT_KM)))
+ else ifneq ($1,)
+ $$(eval $$(call TRY_PARSE_KEYMAP,$$(wordlist 2,9999,$1),$2))
+ endif
+endef
+
define PARSE_RULE
RULE := $1
COMMANDS :=