You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

569 lines
21 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
  1. ifndef VERBOSE
  2. .SILENT:
  3. endif
  4. # Never run this makefile in parallel, as it could screw things up
  5. # It won't affect the submakes, so you still get the speedup from specifying -jx
  6. .NOTPARALLEL:
  7. # Allow the silent with lower caps to work the same way as upper caps
  8. ifdef silent
  9. SILENT = $(silent)
  10. endif
  11. ifdef SILENT
  12. SUB_IS_SILENT := $(SILENT)
  13. endif
  14. # We need to make sure that silent is always turned off at the top level
  15. # Otherwise the [OK], [ERROR] and [WARN] messages won't be displayed correctly
  16. override SILENT := false
  17. ifndef SUB_IS_SILENT
  18. ifndef SKIP_GIT
  19. QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null)
  20. endif
  21. ifneq ($(QMK_VERSION),)
  22. $(info QMK Firmware $(QMK_VERSION))
  23. endif
  24. endif
  25. # avoid 'Entering|Leaving directory' messages
  26. MAKEFLAGS += --no-print-directory
  27. ON_ERROR := error_occurred=1
  28. BREAK_ON_ERRORS = no
  29. STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST))
  30. ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
  31. ROOT_DIR := $(dir $(ROOT_MAKEFILE))
  32. ifeq ($(ROOT_DIR),)
  33. ROOT_DIR := .
  34. endif
  35. ABS_STARTING_MAKEFILE := $(abspath $(STARTING_MAKEFILE))
  36. ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE))
  37. ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE))
  38. ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE))
  39. STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR))
  40. BUILD_DIR := $(ROOT_DIR)/.build
  41. TEST_DIR := $(BUILD_DIR)/test
  42. ERROR_FILE := $(BUILD_DIR)/error_occurred
  43. MAKEFILE_INCLUDED=yes
  44. # Helper function to process the newt element of a space separated path
  45. # It works a bit like the traditional functional head tail
  46. # so the CURRENT_PATH_ELEMENT will become the new head
  47. # and the PATH_ELEMENTS are the rest that are still unprocessed
  48. define NEXT_PATH_ELEMENT
  49. $$(eval CURRENT_PATH_ELEMENT := $$(firstword $$(PATH_ELEMENTS)))
  50. $$(eval PATH_ELEMENTS := $$(wordlist 2,9999,$$(PATH_ELEMENTS)))
  51. endef
  52. # We change the / to spaces so that we more easily can work with the elements
  53. # separately
  54. PATH_ELEMENTS := $(subst /, ,$(STARTING_DIR))
  55. # Initialize the path elements list for further processing
  56. $(eval $(call NEXT_PATH_ELEMENT))
  57. # Phony targets to enable a few simple make commands outside the main processing below.
  58. .PHONY: list-keyboards
  59. list-keyboards:
  60. util/list_keyboards.sh | sort -u | tr '\n' ' '
  61. .PHONY: generate-keyboards-file
  62. generate-keyboards-file:
  63. util/list_keyboards.sh | sort -u
  64. .PHONY: clean
  65. clean:
  66. echo -n 'Deleting .build/ ... '
  67. rm -rf $(BUILD_DIR)
  68. echo 'done.'
  69. .PHONY: distclean
  70. distclean: clean
  71. echo -n 'Deleting *.bin and *.hex ... '
  72. rm -f *.bin *.hex
  73. echo 'done.'
  74. #Compatibility with the old make variables, anything you specify directly on the command line
  75. # always overrides the detected folders
  76. ifdef keyboard
  77. KEYBOARD := $(keyboard)
  78. endif
  79. ifdef keymap
  80. KEYMAP := $(keymap)
  81. endif
  82. # Uncomment these for debugging
  83. # $(info Keyboard: $(KEYBOARD))
  84. # $(info Keymap: $(KEYMAP))
  85. # Set the default goal depending on where we are running make from
  86. # this handles the case where you run make without any arguments
  87. .DEFAULT_GOAL := all:all
  88. ifneq ($(KEYMAP),)
  89. .DEFAULT_GOAL := $(KEYBOARD):$(KEYMAP)
  90. else ifneq ($(KEYBOARD),)
  91. # Inside a keyboard folder, build all keymaps for all subprojects
  92. # Note that this is different from the old behaviour, which would
  93. # build only the default keymap of the default keyboard
  94. .DEFAULT_GOAL := $(KEYBOARD):all
  95. endif
  96. # Compare the start of the RULE variable with the first argument($1)
  97. # If the rules equals $1 or starts with $1:, RULE_FOUND is set to true
  98. # and $1 is removed from the RULE variable
  99. # Otherwise the RULE_FOUND variable is set to false, and RULE left as it was
  100. # The function is a bit tricky, since there's no built in $(startswith) function
  101. define COMPARE_AND_REMOVE_FROM_RULE_HELPER
  102. ifeq ($1,$$(RULE))
  103. RULE:=
  104. RULE_FOUND := true
  105. else
  106. STARTCOLON_REMOVED=$$(subst START$1:,,START$$(RULE))
  107. ifneq ($$(STARTCOLON_REMOVED),START$$(RULE))
  108. RULE_FOUND := true
  109. RULE := $$(STARTCOLON_REMOVED)
  110. else
  111. RULE_FOUND := false
  112. endif
  113. endif
  114. endef
  115. # This makes it easier to call COMPARE_AND_REMOVE_FROM_RULE, since it makes it behave like
  116. # a function that returns the value
  117. COMPARE_AND_REMOVE_FROM_RULE = $(eval $(call COMPARE_AND_REMOVE_FROM_RULE_HELPER,$1))$(RULE_FOUND)
  118. # Recursively try to find a match for the start of the rule to be checked
  119. # $1 The list to be checked
  120. # If a match is found, then RULE_FOUND is set to true
  121. # and MATCHED_ITEM to the item that was matched
  122. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER3
  123. ifneq ($1,)
  124. ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,$$(firstword $1)),true)
  125. MATCHED_ITEM := $$(firstword $1)
  126. else
  127. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$$(wordlist 2,9999,$1)))
  128. endif
  129. endif
  130. endef
  131. # A recursive helper function for finding the longest match
  132. # $1 The list to be checked
  133. # It works by always removing the currently matched item from the list
  134. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER2
  135. # Stop the recursion when the list is empty
  136. ifneq ($1,)
  137. RULE_BEFORE := $$(RULE)
  138. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$1))
  139. # If a match is found in the current list, otherwise just return what we had before
  140. ifeq ($$(RULE_FOUND),true)
  141. # Save the best match so far and call itself recursively
  142. BEST_MATCH := $$(MATCHED_ITEM)
  143. BEST_MATCH_RULE := $$(RULE)
  144. RULE_FOUND := false
  145. RULE := $$(RULE_BEFORE)
  146. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER2,$$(filter-out $$(MATCHED_ITEM),$1)))
  147. endif
  148. endif
  149. endef
  150. # Recursively try to find the longest match for the start of the rule to be checked
  151. # $1 The list to be checked
  152. # If a match is found, then RULE_FOUND is set to true
  153. # and MATCHED_ITEM to the item that was matched
  154. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER
  155. BEST_MATCH :=
  156. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER2,$1))
  157. ifneq ($$(BEST_MATCH),)
  158. RULE_FOUND := true
  159. RULE := $$(BEST_MATCH_RULE)
  160. MATCHED_ITEM := $$(BEST_MATCH)
  161. else
  162. RULE_FOUND := false
  163. MATCHED_ITEM :=
  164. endif
  165. endef
  166. # Make it easier to call TRY_TO_MATCH_RULE_FROM_LIST
  167. TRY_TO_MATCH_RULE_FROM_LIST = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER,$1))$(RULE_FOUND)
  168. define ALL_IN_LIST_LOOP
  169. OLD_RULE$1 := $$(RULE)
  170. $$(eval $$(call $1,$$(ITEM$1)))
  171. RULE := $$(OLD_RULE$1)
  172. endef
  173. define PARSE_ALL_IN_LIST
  174. $$(foreach ITEM$1,$2,$$(eval $$(call ALL_IN_LIST_LOOP,$1)))
  175. endef
  176. # The entry point for rule parsing
  177. # parses a rule in the format <keyboard>:<keymap>:<target>
  178. # but this particular function only deals with the first <keyboard> part
  179. define PARSE_RULE
  180. RULE := $1
  181. COMMANDS :=
  182. REQUIRE_PLATFORM_KEY :=
  183. # If the rule starts with all, then continue the parsing from
  184. # PARSE_ALL_KEYBOARDS
  185. ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
  186. KEYBOARD_RULE=all
  187. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  188. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-avr),true)
  189. KEYBOARD_RULE=all
  190. REQUIRE_PLATFORM_KEY := avr
  191. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  192. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-chibios),true)
  193. KEYBOARD_RULE=all
  194. REQUIRE_PLATFORM_KEY := chibios
  195. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  196. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-arm_atsam),true)
  197. KEYBOARD_RULE=all
  198. REQUIRE_PLATFORM_KEY := arm_atsam
  199. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  200. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,test),true)
  201. $$(eval $$(call PARSE_TEST))
  202. # If the rule starts with the name of a known keyboard, then continue
  203. # the parsing from PARSE_KEYBOARD
  204. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(shell util/list_keyboards.sh | sort -u)),true)
  205. KEYBOARD_RULE=$$(MATCHED_ITEM)
  206. $$(eval $$(call PARSE_KEYBOARD,$$(MATCHED_ITEM)))
  207. # Otherwise use the KEYBOARD variable, which is determined either by
  208. # the current directory you run make from, or passed in as an argument
  209. else ifneq ($$(KEYBOARD),)
  210. $$(eval $$(call PARSE_KEYBOARD,$$(KEYBOARD)))
  211. else
  212. $$(info make: *** No rule to make target '$1'. Stop.)
  213. $$(info |)
  214. $$(info | QMK's make format recently changed to use folder locations and colons:)
  215. $$(info | make project_folder:keymap[:target])
  216. $$(info | Examples:)
  217. $$(info | make dz60:default)
  218. $$(info | make planck/rev6:default:flash)
  219. $$(info |)
  220. endif
  221. endef
  222. # $1 = Keyboard
  223. # Parses a rule in the format <keymap>:<target>
  224. # the keyboard is already known when entering this function
  225. define PARSE_KEYBOARD
  226. # If we want to compile the default subproject, then we need to
  227. # include the correct makefile to determine the actual name of it
  228. CURRENT_KB := $1
  229. # KEYBOARD_FOLDERS := $$(subst /, , $(CURRENT_KB))
  230. DEFAULT_FOLDER := $$(CURRENT_KB)
  231. # We assume that every rules.mk will contain the full default value
  232. $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk)
  233. ifneq ($$(DEFAULT_FOLDER),$$(CURRENT_KB))
  234. $$(eval include $(ROOT_DIR)/keyboards/$$(DEFAULT_FOLDER)/rules.mk)
  235. endif
  236. CURRENT_KB := $$(DEFAULT_FOLDER)
  237. # 5/4/3/2/1
  238. KEYBOARD_FOLDER_PATH_1 := $$(CURRENT_KB)
  239. KEYBOARD_FOLDER_PATH_2 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_1)))
  240. KEYBOARD_FOLDER_PATH_3 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_2)))
  241. KEYBOARD_FOLDER_PATH_4 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_3)))
  242. KEYBOARD_FOLDER_PATH_5 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_4)))
  243. KEYMAPS :=
  244. # get a list of all keymaps
  245. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/keymaps/*/.)))
  246. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/keymaps/*/.)))
  247. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.)))
  248. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.)))
  249. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.)))
  250. # this might be needed, but in a different form
  251. #KEYMAPS := $$(sort $$(filter-out $$(KEYBOARD_FOLDER_1) $$(KEYBOARD_FOLDER_2) \
  252. $$(KEYBOARD_FOLDER_3) $$(KEYBOARD_FOLDER_4) $$(KEYBOARD_FOLDER_5), $$(KEYMAPS)))
  253. KEYBOARD_LAYOUTS :=
  254. ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/rules.mk)","")
  255. LAYOUTS :=
  256. $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/rules.mk)
  257. KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS))
  258. endif
  259. ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/rules.mk)","")
  260. LAYOUTS :=
  261. $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/rules.mk)
  262. KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS))
  263. endif
  264. ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/rules.mk)","")
  265. LAYOUTS :=
  266. $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/rules.mk)
  267. KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS))
  268. endif
  269. ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/rules.mk)","")
  270. LAYOUTS :=
  271. $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/rules.mk)
  272. KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS))
  273. endif
  274. ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/rules.mk)","")
  275. LAYOUTS :=
  276. $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/rules.mk)
  277. KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS))
  278. endif
  279. LAYOUT_KEYMAPS :=
  280. $$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
  281. KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS))
  282. # if the rule after removing the start of it is empty (we haven't specified a kemap or target)
  283. # compile all the keymaps
  284. ifeq ($$(RULE),)
  285. $$(eval $$(call PARSE_ALL_KEYMAPS))
  286. # The same if all was specified
  287. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
  288. $$(eval $$(call PARSE_ALL_KEYMAPS))
  289. # List all keymaps for the given keyboard
  290. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,list-keymaps),true)
  291. $$(eval $$(call LIST_ALL_KEYMAPS))
  292. # Try to match the specified keyamp with the list of known keymaps
  293. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYMAPS)),true)
  294. $$(eval $$(call PARSE_KEYMAP,$$(MATCHED_ITEM)))
  295. # Otherwise try to match the keymap from the current folder, or arguments to the make command
  296. else ifneq ($$(KEYMAP),)
  297. $$(eval $$(call PARSE_KEYMAP,$$(KEYMAP)))
  298. # Otherwise if we are running make all:<user> just skip
  299. else ifeq ($$(KEYBOARD_RULE),all)
  300. # $$(info Skipping: No user keymap for $$(CURRENT_KB))
  301. # Otherwise, make all keymaps, again this is consistent with how it works without
  302. # any arguments
  303. else
  304. $$(eval $$(call PARSE_ALL_KEYMAPS))
  305. endif
  306. endef
  307. # if we are going to compile all keyboards, match the rest of the rule
  308. # for each of them
  309. define PARSE_ALL_KEYBOARDS
  310. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(shell util/list_keyboards.sh noci | sort -u)))
  311. endef
  312. # Prints a list of all known keymaps for the given keyboard
  313. define LIST_ALL_KEYMAPS
  314. COMMAND_true_LIST_KEYMAPS := \
  315. printf "$$(KEYMAPS)\n";
  316. COMMAND_false_LIST_KEYMAPS := \
  317. printf "$$(MSG_AVAILABLE_KEYMAPS)\n"; \
  318. printf "$$(KEYMAPS)\n";
  319. COMMANDS += LIST_KEYMAPS
  320. endef
  321. # $1 Keymap
  322. # This is the meat of compiling a keyboard, when entering this, everything is known
  323. # keyboard, subproject, and keymap
  324. # Note that we are not directly calling the command here, but instead building a list,
  325. # which will later be processed
  326. define PARSE_KEYMAP
  327. CURRENT_KM = $1
  328. # The rest of the rule is the target
  329. # Remove the leading ":" from the target, as it acts as a separator
  330. MAKE_TARGET := $$(patsubst :%,%,$$(RULE))
  331. # We need to generate an unique indentifer to append to the COMMANDS list
  332. CURRENT_KB_UNDER := $$(subst /,_,$$(CURRENT_KB))
  333. COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB_UNDER)_KEYMAP_$$(CURRENT_KM)
  334. # If we are compiling a keyboard without a subproject, we want to display just the name
  335. # of the keyboard, otherwise keyboard/subproject
  336. KB_SP := $$(CURRENT_KB)
  337. # Format it in bold
  338. KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR)
  339. # Specify the variables that we are passing forward to submake
  340. MAKE_VARS := KEYBOARD=$$(CURRENT_KB) KEYMAP=$$(CURRENT_KM) REQUIRE_PLATFORM_KEY=$$(REQUIRE_PLATFORM_KEY)
  341. # And the first part of the make command
  342. MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_keyboard.mk $$(MAKE_TARGET)
  343. # The message to display
  344. MAKE_MSG := $$(MSG_MAKE_KB)
  345. # We run the command differently, depending on if we want more output or not
  346. # The true version for silent output and the false version otherwise
  347. $$(eval $$(call BUILD))
  348. endef
  349. define BUILD
  350. MAKE_VARS += VERBOSE=$(VERBOSE) COLOR=$(COLOR)
  351. COMMANDS += $$(COMMAND)
  352. COMMAND_true_$$(COMMAND) := \
  353. printf "$$(MAKE_MSG)" | \
  354. $$(MAKE_MSG_FORMAT); \
  355. LOG=$$$$($$(MAKE_CMD) $$(MAKE_VARS) SILENT=true 2>&1) ; \
  356. if [ $$$$? -gt 0 ]; \
  357. then $$(PRINT_ERROR_PLAIN); \
  358. elif [ "$$$$LOG" = "skipped" ] ; \
  359. then $$(PRINT_SKIPPED_PLAIN); \
  360. elif [ "$$$$LOG" != "" ] ; \
  361. then $$(PRINT_WARNING_PLAIN); \
  362. else \
  363. $$(PRINT_OK); \
  364. fi;
  365. COMMAND_false_$$(COMMAND) := \
  366. printf "$$(MAKE_MSG)\n\n"; \
  367. $$(MAKE_CMD) $$(MAKE_VARS) SILENT=false; \
  368. if [ $$$$? -gt 0 ]; \
  369. then error_occurred=1; \
  370. fi;
  371. endef
  372. # Just parse all the keymaps for a specific keyboard
  373. define PARSE_ALL_KEYMAPS
  374. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
  375. endef
  376. define BUILD_TEST
  377. TEST_NAME := $1
  378. MAKE_TARGET := $2
  379. COMMAND := $1
  380. MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET)
  381. MAKE_VARS := TEST=$$(TEST_NAME) FULL_TESTS="$$(FULL_TESTS)"
  382. MAKE_MSG := $$(MSG_MAKE_TEST)
  383. $$(eval $$(call BUILD))
  384. ifneq ($$(MAKE_TARGET),clean)
  385. TEST_EXECUTABLE := $$(TEST_DIR)/$$(TEST_NAME).elf
  386. TESTS += $$(TEST_NAME)
  387. TEST_MSG := $$(MSG_TEST)
  388. $$(TEST_NAME)_COMMAND := \
  389. printf "$$(TEST_MSG)\n"; \
  390. $$(TEST_EXECUTABLE); \
  391. if [ $$$$? -gt 0 ]; \
  392. then error_occurred=1; \
  393. fi; \
  394. printf "\n";
  395. endif
  396. endef
  397. define PARSE_TEST
  398. TESTS :=
  399. TEST_NAME := $$(firstword $$(subst :, ,$$(RULE)))
  400. TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME):,,$$(RULE)))
  401. ifeq ($$(TEST_NAME),all)
  402. MATCHED_TESTS := $$(TEST_LIST)
  403. else
  404. MATCHED_TESTS := $$(foreach TEST,$$(TEST_LIST),$$(if $$(findstring $$(TEST_NAME),$$(TEST)),$$(TEST),))
  405. endif
  406. $$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(TEST_TARGET))))
  407. endef
  408. # Set the silent mode depending on if we are trying to compile multiple keyboards or not
  409. # By default it's on in that case, but it can be overridden by specifying silent=false
  410. # from the command line
  411. define SET_SILENT_MODE
  412. ifdef SUB_IS_SILENT
  413. SILENT_MODE := $(SUB_IS_SILENT)
  414. else ifeq ($$(words $$(COMMANDS)),1)
  415. SILENT_MODE := false
  416. else
  417. SILENT_MODE := true
  418. endif
  419. endef
  420. include $(ROOT_DIR)/message.mk
  421. ifeq ($(strip $(BREAK_ON_ERRORS)), yes)
  422. HANDLE_ERROR = exit 1
  423. else
  424. HANDLE_ERROR = echo $$error_occurred > $(ERROR_FILE)
  425. endif
  426. # The empty line is important here, as it will force a new shell to be created for each command
  427. # Otherwise the command line will become too long with a lot of keyboards and keymaps
  428. define RUN_COMMAND
  429. +error_occurred=0;\
  430. $(COMMAND_$(SILENT_MODE)_$(COMMAND))\
  431. if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
  432. endef
  433. define RUN_TEST
  434. +error_occurred=0;\
  435. $($(TEST)_COMMAND)\
  436. if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
  437. endef
  438. # Catch everything and parse the command line ourselves.
  439. .PHONY: %
  440. %:
  441. # Check if we have the CMP tool installed
  442. cmp $(ROOT_DIR)/Makefile $(ROOT_DIR)/Makefile >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
  443. # Ensure that bin/qmk works.
  444. if ! bin/qmk hello 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; exit 1; fi
  445. # Check if the submodules are dirty, and display a warning if they are
  446. ifndef SKIP_GIT
  447. if [ ! -e lib/chibios ]; then git submodule sync lib/chibios && git submodule update --depth 50 --init lib/chibios; fi
  448. if [ ! -e lib/chibios-contrib ]; then git submodule sync lib/chibios-contrib && git submodule update --depth 50 --init lib/chibios-contrib; fi
  449. if [ ! -e lib/ugfx ]; then git submodule sync lib/ugfx && git submodule update --depth 50 --init lib/ugfx; fi
  450. if [ ! -e lib/lufa ]; then git submodule sync lib/lufa && git submodule update --depth 50 --init lib/lufa; fi
  451. if [ ! -e lib/vusb ]; then git submodule sync lib/vusb && git submodule update --depth 50 --init lib/vusb; fi
  452. if [ ! -e lib/printf ]; then git submodule sync lib/printf && git submodule update --depth 50 --init lib/printf; fi
  453. git submodule status --recursive 2>/dev/null | \
  454. while IFS= read -r x; do \
  455. case "$$x" in \
  456. \ *) ;; \
  457. *) printf "$(MSG_SUBMODULE_DIRTY)";break;; \
  458. esac \
  459. done
  460. endif
  461. rm -f $(ERROR_FILE) > /dev/null 2>&1
  462. $(eval $(call PARSE_RULE,$@))
  463. $(eval $(call SET_SILENT_MODE))
  464. # Run all the commands in the same shell, notice the + at the first line
  465. # it has to be there to allow parallel execution of the submake
  466. # This always tries to compile everything, even if error occurs in the middle
  467. # But we return the error code at the end, to trigger travis failures
  468. # The sort at this point is to remove duplicates
  469. $(foreach COMMAND,$(sort $(COMMANDS)),$(RUN_COMMAND))
  470. if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
  471. $(foreach TEST,$(sort $(TESTS)),$(RUN_TEST))
  472. if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
  473. lib/%:
  474. git submodule sync $?
  475. git submodule update --init $?
  476. .PHONY: git-submodule
  477. git-submodule:
  478. git submodule sync --recursive
  479. git submodule update --init --recursive --progress
  480. ifdef SKIP_VERSION
  481. SKIP_GIT := yes
  482. endif
  483. # Generate the version.h file
  484. ifndef SKIP_GIT
  485. GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
  486. CHIBIOS_VERSION := $(shell cd lib/chibios && git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
  487. CHIBIOS_CONTRIB_VERSION := $(shell cd lib/chibios-contrib && git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
  488. else
  489. GIT_VERSION := NA
  490. CHIBIOS_VERSION := NA
  491. CHIBIOS_CONTRIB_VERSION := NA
  492. endif
  493. ifndef SKIP_VERSION
  494. BUILD_DATE := $(shell date +"%Y-%m-%d-%H:%M:%S")
  495. else
  496. BUILD_DATE := 2020-01-01-00:00:00
  497. endif
  498. $(shell echo '#define QMK_VERSION "$(GIT_VERSION)"' > $(ROOT_DIR)/quantum/version.h)
  499. $(shell echo '#define QMK_BUILDDATE "$(BUILD_DATE)"' >> $(ROOT_DIR)/quantum/version.h)
  500. $(shell echo '#define CHIBIOS_VERSION "$(CHIBIOS_VERSION)"' >> $(ROOT_DIR)/quantum/version.h)
  501. $(shell echo '#define CHIBIOS_CONTRIB_VERSION "$(CHIBIOS_CONTRIB_VERSION)"' >> $(ROOT_DIR)/quantum/version.h)
  502. include $(ROOT_DIR)/testlist.mk