Makefile 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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. ifeq ($(shell git rev-parse --is-inside-work-tree 2>/dev/null),)
  18. export SKIP_GIT := yes
  19. export NOT_REPO := yes
  20. endif
  21. ifdef SKIP_VERSION
  22. export SKIP_GIT := yes
  23. endif
  24. ifndef SUB_IS_SILENT
  25. ifndef SKIP_GIT
  26. QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null)
  27. endif
  28. ifneq ($(QMK_VERSION),)
  29. $(info QMK Firmware $(QMK_VERSION))
  30. endif
  31. endif
  32. # Try to determine userspace from qmk config, if set.
  33. ifeq ($(QMK_USERSPACE),)
  34. QMK_USERSPACE = $(shell qmk config -ro user.overlay_dir | cut -d= -f2 | sed -e 's@^None$$@@g')
  35. endif
  36. # Determine which qmk cli to use
  37. QMK_BIN := qmk
  38. # avoid 'Entering|Leaving directory' messages
  39. MAKEFLAGS += --no-print-directory
  40. ON_ERROR := error_occurred=1
  41. BREAK_ON_ERRORS = no
  42. ROOT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
  43. ifeq ($(ROOT_DIR),)
  44. ROOT_DIR := .
  45. endif
  46. include paths.mk
  47. TEST_OUTPUT_DIR := $(BUILD_DIR)/test
  48. ERROR_FILE := $(BUILD_DIR)/error_occurred
  49. .DEFAULT_GOAL := all:all
  50. # Compare the start of the RULE variable with the first argument($1)
  51. # If the rules equals $1 or starts with $1:, RULE_FOUND is set to true
  52. # and $1 is removed from the RULE variable
  53. # Otherwise the RULE_FOUND variable is set to false, and RULE left as it was
  54. # The function is a bit tricky, since there's no built in $(startswith) function
  55. define COMPARE_AND_REMOVE_FROM_RULE_HELPER
  56. ifeq ($1,$$(RULE))
  57. RULE:=
  58. RULE_FOUND := true
  59. else
  60. STARTCOLON_REMOVED=$$(subst START$1:,,START$$(RULE))
  61. ifneq ($$(STARTCOLON_REMOVED),START$$(RULE))
  62. RULE_FOUND := true
  63. RULE := $$(STARTCOLON_REMOVED)
  64. else
  65. RULE_FOUND := false
  66. endif
  67. endif
  68. endef
  69. # This makes it easier to call COMPARE_AND_REMOVE_FROM_RULE, since it makes it behave like
  70. # a function that returns the value
  71. COMPARE_AND_REMOVE_FROM_RULE = $(eval $(call COMPARE_AND_REMOVE_FROM_RULE_HELPER,$1))$(RULE_FOUND)
  72. # Try to find a match for the start of the rule to be checked
  73. # $1 The list to be checked
  74. # If a match is found, then RULE_FOUND is set to true
  75. # and MATCHED_ITEM to the item that was matched
  76. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER
  77. # Split on ":", padding with empty strings to avoid indexing issues
  78. TOKEN1:=$$(shell python3 -c "import sys; print((sys.argv[1].split(':',1)+[''])[0])" $$(RULE))
  79. TOKENr:=$$(shell python3 -c "import sys; print((sys.argv[1].split(':',1)+[''])[1])" $$(RULE))
  80. FOUNDx:=$$(shell echo $1 | tr " " "\n" | grep -Fx $$(TOKEN1))
  81. ifneq ($$(FOUNDx),)
  82. RULE := $$(TOKENr)
  83. RULE_FOUND := true
  84. MATCHED_ITEM := $$(TOKEN1)
  85. else
  86. RULE_FOUND := false
  87. MATCHED_ITEM :=
  88. endif
  89. endef
  90. # Make it easier to call TRY_TO_MATCH_RULE_FROM_LIST
  91. TRY_TO_MATCH_RULE_FROM_LIST = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER,$1))$(RULE_FOUND)
  92. define ALL_IN_LIST_LOOP
  93. OLD_RULE$1 := $$(RULE)
  94. $$(eval $$(call $1,$$(ITEM$1)))
  95. RULE := $$(OLD_RULE$1)
  96. endef
  97. define PARSE_ALL_IN_LIST
  98. $$(foreach ITEM$1,$2,$$(eval $$(call ALL_IN_LIST_LOOP,$1)))
  99. endef
  100. # The entry point for rule parsing
  101. # parses a rule in the format <keyboard>:<keymap>:<target>
  102. # but this particular function only deals with the first <keyboard> part
  103. define PARSE_RULE
  104. RULE := $1
  105. COMMANDS :=
  106. # If the rule starts with all, then continue the parsing from
  107. # PARSE_ALL_KEYBOARDS
  108. ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
  109. KEYBOARD_RULE=all
  110. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  111. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,test),true)
  112. $$(eval $$(call PARSE_TEST))
  113. # If the rule starts with the name of a known keyboard, then continue
  114. # the parsing from PARSE_KEYBOARD
  115. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(shell $(QMK_BIN) list-keyboards --no-resolve-defaults)),true)
  116. KEYBOARD_RULE=$$(MATCHED_ITEM)
  117. $$(eval $$(call PARSE_KEYBOARD,$$(MATCHED_ITEM)))
  118. else
  119. $$(info make: *** No rule to make target '$1'. Stop.)
  120. $$(info |)
  121. $$(info | QMK's make format is:)
  122. $$(info | make keyboard_folder:keymap_folder[:target])
  123. $$(info |)
  124. $$(info | Where `keyboard_folder` is the path to the keyboard relative to)
  125. $$(info | `qmk_firmware/keyboards/`, and `keymap_folder` is the name of the)
  126. $$(info | keymap folder under that board's `keymaps/` directory.)
  127. $$(info |)
  128. $$(info | Examples:)
  129. $$(info | keyboards/dz60, keyboards/dz60/keymaps/default)
  130. $$(info | -> make dz60:default)
  131. $$(info | -> qmk compile -kb dz60 -km default)
  132. $$(info | keyboards/planck/rev6, keyboards/planck/keymaps/default)
  133. $$(info | -> make planck/rev6:default:flash)
  134. $$(info | -> qmk flash -kb planck/rev6 -km default)
  135. $$(info |)
  136. endif
  137. endef
  138. # $1 = Keyboard
  139. # Parses a rule in the format <keymap>:<target>
  140. # the keyboard is already known when entering this function
  141. define PARSE_KEYBOARD
  142. # If we want to compile the default subproject, then we need to
  143. # include the correct makefile to determine the actual name of it
  144. CURRENT_KB := $1
  145. # KEYBOARD_FOLDERS := $$(subst /, , $(CURRENT_KB))
  146. DEFAULT_FOLDER := $$(CURRENT_KB)
  147. # We assume that every rules.mk will contain the full default value
  148. $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk)
  149. ifneq ($$(DEFAULT_FOLDER),$$(CURRENT_KB))
  150. $$(eval include $(ROOT_DIR)/keyboards/$$(DEFAULT_FOLDER)/rules.mk)
  151. endif
  152. CURRENT_KB := $$(DEFAULT_FOLDER)
  153. # 5/4/3/2/1
  154. KEYBOARD_FOLDER_PATH_1 := $$(CURRENT_KB)
  155. KEYBOARD_FOLDER_PATH_2 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_1)))
  156. KEYBOARD_FOLDER_PATH_3 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_2)))
  157. KEYBOARD_FOLDER_PATH_4 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_3)))
  158. KEYBOARD_FOLDER_PATH_5 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_4)))
  159. KEYMAPS :=
  160. # get a list of all keymaps
  161. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/keymaps/*/.)))
  162. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/keymaps/*/.)))
  163. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.)))
  164. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.)))
  165. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.)))
  166. ifneq ($(QMK_USERSPACE),)
  167. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(QMK_USERSPACE)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/keymaps/*/.)))
  168. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(QMK_USERSPACE)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/keymaps/*/.)))
  169. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(QMK_USERSPACE)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.)))
  170. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(QMK_USERSPACE)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.)))
  171. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(QMK_USERSPACE)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.)))
  172. endif
  173. KEYBOARD_LAYOUTS := $(shell $(QMK_BIN) list-layouts --keyboard $1)
  174. LAYOUT_KEYMAPS :=
  175. $$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
  176. ifneq ($(QMK_USERSPACE),)
  177. $$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(QMK_USERSPACE)/layouts/$$(LAYOUT)/*/.)))))
  178. endif
  179. KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS))
  180. # if the rule after removing the start of it is empty (we haven't specified a kemap or target)
  181. # compile all the keymaps
  182. ifeq ($$(RULE),)
  183. $$(eval $$(call PARSE_ALL_KEYMAPS))
  184. # The same if all was specified
  185. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
  186. $$(eval $$(call PARSE_ALL_KEYMAPS))
  187. # List all keymaps for the given keyboard
  188. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,list-keymaps),true)
  189. $$(eval $$(call LIST_ALL_KEYMAPS))
  190. # Try to match the specified keyamp with the list of known keymaps
  191. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYMAPS)),true)
  192. $$(eval $$(call PARSE_KEYMAP,$$(MATCHED_ITEM)))
  193. # Otherwise try to match the keymap from the current folder, or arguments to the make command
  194. else ifneq ($$(KEYMAP),)
  195. $$(eval $$(call PARSE_KEYMAP,$$(KEYMAP)))
  196. # Otherwise if we are running make all:<user> just skip
  197. else ifeq ($$(KEYBOARD_RULE),all)
  198. # $$(info Skipping: No user keymap for $$(CURRENT_KB))
  199. # Otherwise, make all keymaps, again this is consistent with how it works without
  200. # any arguments
  201. else
  202. $$(eval $$(call PARSE_ALL_KEYMAPS))
  203. endif
  204. endef
  205. # if we are going to compile all keyboards, match the rest of the rule
  206. # for each of them
  207. define PARSE_ALL_KEYBOARDS
  208. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(shell $(QMK_BIN) list-keyboards --no-resolve-defaults)))
  209. endef
  210. # Prints a list of all known keymaps for the given keyboard
  211. define LIST_ALL_KEYMAPS
  212. COMMAND_true_LIST_KEYMAPS := \
  213. printf "$$(KEYMAPS)\n";
  214. COMMAND_false_LIST_KEYMAPS := \
  215. printf "$$(MSG_AVAILABLE_KEYMAPS)\n"; \
  216. printf "$$(KEYMAPS)\n";
  217. COMMANDS += LIST_KEYMAPS
  218. endef
  219. # $1 Keymap
  220. # This is the meat of compiling a keyboard, when entering this, everything is known
  221. # keyboard, subproject, and keymap
  222. # Note that we are not directly calling the command here, but instead building a list,
  223. # which will later be processed
  224. define PARSE_KEYMAP
  225. CURRENT_KM = $1
  226. # The rest of the rule is the target
  227. # Remove the leading ":" from the target, as it acts as a separator
  228. MAKE_TARGET := $$(patsubst :%,%,$$(RULE))
  229. # We need to generate an unique identifier to append to the COMMANDS list
  230. CURRENT_KB_UNDER := $$(subst /,_,$$(CURRENT_KB))
  231. COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB_UNDER)_KEYMAP_$$(CURRENT_KM)
  232. # If we are compiling a keyboard without a subproject, we want to display just the name
  233. # of the keyboard, otherwise keyboard/subproject
  234. KB_SP := $$(CURRENT_KB)
  235. # Format it in bold
  236. KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR)
  237. # Specify the variables that we are passing forward to submake
  238. MAKE_VARS := KEYBOARD=$$(CURRENT_KB) KEYMAP=$$(CURRENT_KM) QMK_BIN=$$(QMK_BIN)
  239. # And the first part of the make command
  240. MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f $(BUILDDEFS_PATH)/build_keyboard.mk $$(MAKE_TARGET)
  241. # The message to display
  242. MAKE_MSG := $$(MSG_MAKE_KB)
  243. # We run the command differently, depending on if we want more output or not
  244. # The true version for silent output and the false version otherwise
  245. $$(eval $$(call BUILD))
  246. endef
  247. define BUILD
  248. MAKE_VARS += VERBOSE=$(VERBOSE) COLOR=$(COLOR)
  249. COMMANDS += $$(COMMAND)
  250. COMMAND_true_$$(COMMAND) := \
  251. printf "$$(MAKE_MSG)" | \
  252. $$(MAKE_MSG_FORMAT); \
  253. LOG=$$$$($$(MAKE_CMD) $$(MAKE_VARS) SILENT=true 2>&1) ; \
  254. if [ $$$$? -gt 0 ]; \
  255. then $$(PRINT_ERROR_PLAIN); \
  256. elif [ "$$$$LOG" = "skipped" ] ; \
  257. then $$(PRINT_SKIPPED_PLAIN); \
  258. elif [ "$$$$LOG" != "" ] ; \
  259. then $$(PRINT_WARNING_PLAIN); \
  260. else \
  261. $$(PRINT_OK); \
  262. fi;
  263. COMMAND_false_$$(COMMAND) := \
  264. printf "$$(MAKE_MSG)\n\n"; \
  265. $$(MAKE_CMD) $$(MAKE_VARS) SILENT=false; \
  266. if [ $$$$? -gt 0 ]; \
  267. then error_occurred=1; \
  268. fi;
  269. endef
  270. # Just parse all the keymaps for a specific keyboard
  271. define PARSE_ALL_KEYMAPS
  272. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
  273. endef
  274. define BUILD_TEST
  275. TEST_PATH := $1
  276. TEST_NAME := $$(notdir $$(TEST_PATH))
  277. TEST_FULL_NAME := $$(subst /,_,$$(patsubst $$(ROOT_DIR)tests/%,%,$$(TEST_PATH)))
  278. MAKE_TARGET := $2
  279. COMMAND := $1
  280. MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f $(BUILDDEFS_PATH)/build_test.mk $$(MAKE_TARGET)
  281. MAKE_VARS := TEST=$$(TEST_NAME) TEST_OUTPUT=$$(TEST_FULL_NAME) TEST_PATH=$$(TEST_PATH) FULL_TESTS="$$(FULL_TESTS)"
  282. MAKE_MSG := $$(MSG_MAKE_TEST)
  283. $$(eval $$(call BUILD))
  284. ifneq ($$(MAKE_TARGET),clean)
  285. TEST_EXECUTABLE := $$(TEST_OUTPUT_DIR)/$$(TEST_FULL_NAME).elf
  286. TESTS += $$(TEST_FULL_NAME)
  287. TEST_MSG := $$(MSG_TEST)
  288. $$(TEST_FULL_NAME)_COMMAND := \
  289. printf "$$(TEST_MSG)\n"; \
  290. $$(TEST_EXECUTABLE); \
  291. if [ $$$$? -gt 0 ]; \
  292. then error_occurred=1; \
  293. fi; \
  294. printf "\n";
  295. endif
  296. endef
  297. define PARSE_TEST
  298. TESTS :=
  299. # list of possible targets, colon-delimited, to reassign to MAKE_TARGET and remove
  300. TARGETS := :clean:
  301. ifneq (,$$(findstring :$$(lastword $$(subst :, ,$$(RULE))):, $$(TARGETS)))
  302. MAKE_TARGET := $$(lastword $$(subst :, ,$$(RULE)))
  303. TEST_SUBPATH := $$(subst $$(eval) ,/,$$(wordlist 2, $$(words $$(subst :, ,$$(RULE))), _ $$(subst :, ,$$(RULE))))
  304. else
  305. MAKE_TARGET :=
  306. TEST_SUBPATH := $$(subst :,/,$$(RULE))
  307. endif
  308. include $(BUILDDEFS_PATH)/testlist.mk
  309. ifeq ($$(RULE),all)
  310. MATCHED_TESTS := $$(TEST_LIST)
  311. else
  312. MATCHED_TESTS := $$(foreach TEST, $$(TEST_LIST),$$(if $$(findstring /$$(TEST_SUBPATH)/, $$(patsubst %,%/,$$(TEST))), $$(TEST),))
  313. endif
  314. $$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(MAKE_TARGET))))
  315. endef
  316. # Set the silent mode depending on if we are trying to compile multiple keyboards or not
  317. # By default it's on in that case, but it can be overridden by specifying silent=false
  318. # from the command line
  319. define SET_SILENT_MODE
  320. ifdef SUB_IS_SILENT
  321. SILENT_MODE := $(SUB_IS_SILENT)
  322. else ifeq ($$(words $$(COMMANDS)),1)
  323. SILENT_MODE := false
  324. else
  325. SILENT_MODE := true
  326. endif
  327. endef
  328. include $(BUILDDEFS_PATH)/message.mk
  329. ifeq ($(strip $(BREAK_ON_ERRORS)), yes)
  330. HANDLE_ERROR = exit 1
  331. else
  332. HANDLE_ERROR = echo $$error_occurred > $(ERROR_FILE)
  333. endif
  334. # The empty line is important here, as it will force a new shell to be created for each command
  335. # Otherwise the command line will become too long with a lot of keyboards and keymaps
  336. define RUN_COMMAND
  337. +error_occurred=0;\
  338. $(COMMAND_$(SILENT_MODE)_$(COMMAND))\
  339. if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
  340. endef
  341. define RUN_TEST
  342. +error_occurred=0;\
  343. $($(TEST)_COMMAND)\
  344. if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
  345. endef
  346. # Catch everything and parse the command line ourselves.
  347. .PHONY: %
  348. %:
  349. # Ensure that $(QMK_BIN) works.
  350. if ! $(QMK_BIN) hello 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; exit 1; fi
  351. ifdef NOT_REPO
  352. printf "$(MSG_NOT_REPO)"
  353. endif
  354. ifndef SKIP_GIT
  355. $(QMK_BIN) git-submodule --sync
  356. # Check if the submodules are dirty, and display a warning if they are
  357. if ! $(QMK_BIN) git-submodule --check 1> /dev/null 2>&1; then printf "$(MSG_SUBMODULE_DIRTY)"; fi
  358. endif
  359. rm -f $(ERROR_FILE) > /dev/null 2>&1
  360. $(eval $(call PARSE_RULE,$@))
  361. $(eval $(call SET_SILENT_MODE))
  362. # Run all the commands in the same shell, notice the + at the first line
  363. # it has to be there to allow parallel execution of the submake
  364. # This always tries to compile everything, even if error occurs in the middle
  365. # But we return the error code at the end, to trigger travis failures
  366. # The sort at this point is to remove duplicates
  367. $(foreach COMMAND,$(sort $(COMMANDS)),$(RUN_COMMAND))
  368. if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
  369. $(foreach TEST,$(sort $(TESTS)),$(RUN_TEST))
  370. if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
  371. lib/%:
  372. git submodule sync $?
  373. git submodule update --init $?
  374. .PHONY: git-submodule
  375. git-submodule:
  376. $(QMK_BIN) git-submodule
  377. .PHONY: git-submodules
  378. git-submodules: git-submodule
  379. .PHONY: list-keyboards
  380. list-keyboards:
  381. $(QMK_BIN) list-keyboards --no-resolve-defaults | tr '\n' ' '
  382. .PHONY: generate-keyboards-file
  383. generate-keyboards-file:
  384. $(QMK_BIN) list-keyboards --no-resolve-defaults
  385. .PHONY: clean
  386. clean:
  387. echo -n 'Deleting .build/ ... '
  388. rm -rf $(BUILD_DIR)
  389. echo 'done.'
  390. .PHONY: distclean distclean_qmk
  391. distclean: distclean_qmk
  392. distclean_qmk: clean
  393. echo -n 'Deleting *.bin, *.hex, and *.uf2 ... '
  394. rm -f *.bin *.hex *.uf2
  395. echo 'done.'
  396. ifneq ($(QMK_USERSPACE),)
  397. .PHONY: distclean_userspace
  398. distclean: distclean_userspace
  399. distclean_userspace: clean
  400. echo -n 'Deleting userspace *.bin, *.hex, and *.uf2 ... '
  401. rm -f $(QMK_USERSPACE)/*.bin $(QMK_USERSPACE)/*.hex $(QMK_USERSPACE)/*.uf2
  402. echo 'done.'
  403. endif