Makefile 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. ifndef VERBOSE
  2. .SILENT:
  3. endif
  4. # Allow the silent with lower caps to work the same way as upper caps
  5. ifdef silent
  6. SILENT = $(silent)
  7. endif
  8. ifdef SILENT
  9. SUB_IS_SILENT := $(SILENT)
  10. endif
  11. # We need to make sure that silent is always turned off at the top level
  12. # Otherwise the [OK], [ERROR] and [WARN] messags won't be displayed correctly
  13. override SILENT := false
  14. ON_ERROR := error_occured=1
  15. STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST))
  16. ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
  17. ROOT_DIR := $(dir $(ROOT_MAKEFILE))
  18. ifeq ($(ROOT_DIR),)
  19. ROOT_DIR := .
  20. endif
  21. ABS_STARTING_MAKEFILE := $(abspath $(STARTING_MAKEFILE))
  22. ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE))
  23. ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE))
  24. ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE))
  25. STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR))
  26. MAKEFILE_INCLUDED=yes
  27. # Helper function to process the newt element of a space separated path
  28. # It works a bit like the traditional functional head tail
  29. # so the CURRENT_PATH_ELEMENT will beome the new head
  30. # and the PATH_ELEMENTS are the rest that are still unprocessed
  31. define NEXT_PATH_ELEMENT
  32. $$(eval CURRENT_PATH_ELEMENT := $$(firstword $$(PATH_ELEMENTS)))
  33. $$(eval PATH_ELEMENTS := $$(wordlist 2,9999,$$(PATH_ELEMENTS)))
  34. endef
  35. # We change the / to spaces so that we more easily can work with the elements
  36. # separately
  37. PATH_ELEMENTS := $(subst /, ,$(STARTING_DIR))
  38. # Initialize the path elements list for further processing
  39. $(eval $(call NEXT_PATH_ELEMENT))
  40. # This function sets the KEYBOARD; KEYMAP and SUBPROJECT to the correct
  41. # variables depending on which directory you stand in.
  42. # It's really a very simple if else chain, if you squint enough,
  43. # but the makefile syntax makes it very verbose.
  44. # If we are in a subfolder of keyboards
  45. ifeq ($(CURRENT_PATH_ELEMENT),keyboards)
  46. $(eval $(call NEXT_PATH_ELEMENT))
  47. KEYBOARD := $(CURRENT_PATH_ELEMENT)
  48. $(eval $(call NEXT_PATH_ELEMENT))
  49. # If we are in a subfolder of keymaps, or in other words in a keymap
  50. # folder
  51. ifeq ($(CURRENT_PATH_ELEMENT),keymaps)
  52. $(eval $(call NEXT_PATH_ELEMENT))
  53. KEYMAP := $(CURRENT_PATH_ELEMENT)
  54. # else if we are not in the keyboard folder itself
  55. else ifneq ($(CURRENT_PATH_ELEMENT),)
  56. # the we can assume it's a subproject, as no other folders
  57. # should have make files in them
  58. SUBPROJECT := $(CURRENT_PATH_ELEMENT)
  59. $(eval $(call NEXT_PATH_ELEMENT))
  60. # if we are inside a keymap folder of a subproject
  61. ifeq ($(CURRENT_PATH_ELEMENT),keymaps)
  62. $(eval $(call NEXT_PATH_ELEMENT))
  63. KEYMAP := $(CURRENT_PATH_ELEMENT)
  64. endif
  65. endif
  66. endif
  67. # Only consider folders with makefiles, to prevent errors in case there are extra folders
  68. KEYBOARDS := $(notdir $(patsubst %/Makefile,%,$(wildcard $(ROOT_DIR)/keyboards/*/Makefile)))
  69. #Compability with the old make variables, anything you specify directly on the command line
  70. # always overrides the detected folders
  71. ifdef keyboard
  72. KEYBOARD := $(keyboard)
  73. endif
  74. ifdef sub
  75. SUBPROJECT := $(sub)
  76. endif
  77. ifdef subproject
  78. SUBPROJECT := $(subproject)
  79. endif
  80. ifdef keymap
  81. KEYMAP := $(keymap)
  82. endif
  83. # Uncomment these for debugging
  84. #$(info Keyboard: $(KEYBOARD))
  85. #$(info Keymap: $(KEYMAP))
  86. #$(info Subproject: $(SUBPROJECT))
  87. #$(info Keyboards: $(KEYBOARDS))
  88. # Set the default goal depening on where we are running make from
  89. # this handles the case where you run make without any arguments
  90. .DEFAULT_GOAL := all
  91. ifneq ($(KEYMAP),)
  92. ifeq ($(SUBPROJECT),)
  93. # Inside a keymap folder, just build the keymap, with the
  94. # default subproject
  95. .DEFAULT_GOAL := $(KEYBOARD)-$(KEYMAP)
  96. else
  97. # Inside a subproject keyamp folder, build the keymap
  98. # for that subproject
  99. .DEFAULT_GOAL := $(KEYBOARD)-$(SUBPROJECT)-$(KEYMAP)
  100. endif
  101. else ifneq ($(SUBPROJECT),)
  102. # Inside a subproject folder, build all keymaps for that subproject
  103. .DEFAULT_GOAL := $(KEYBOARD)-$(SUBPROJECT)-allkm
  104. else ifneq ($(KEYBOARD),)
  105. # Inside a keyboard folder, build all keymaps for all subprojects
  106. # Note that this is different from the old behaviour, which would
  107. # build only the default keymap of the default keyboard
  108. .DEFAULT_GOAL := $(KEYBOARD)-allsp-allkm
  109. endif
  110. # Compare the start of the RULE variable with the first argument($1)
  111. # If the rules equals $1 or starts with $1-, RULE_FOUND is set to true
  112. # and $1 is removed from the RULE variable
  113. # Otherwise the RULE_FOUND variable is set to false, and RULE left as it was
  114. # The function is a bit tricky, since there's no built in $(startswith) function
  115. define COMPARE_AND_REMOVE_FROM_RULE_HELPER
  116. ifeq ($1,$$(RULE))
  117. RULE:=
  118. RULE_FOUND := true
  119. else
  120. STARTDASH_REMOVED=$$(subst START$1-,,START$$(RULE))
  121. ifneq ($$(STARTDASH_REMOVED),START$$(RULE))
  122. RULE_FOUND := true
  123. RULE := $$(STARTDASH_REMOVED)
  124. else
  125. RULE_FOUND := false
  126. endif
  127. endif
  128. endef
  129. # This makes it easier to call COMPARE_AND_REMOVE_FROM_RULE, since it makes it behave like
  130. # a function that returns the value
  131. COMPARE_AND_REMOVE_FROM_RULE = $(eval $(call COMPARE_AND_REMOVE_FROM_RULE_HELPER,$1))$(RULE_FOUND)
  132. # Recursively try to find a match for the start of the rule to be checked
  133. # $1 The list to be checked
  134. # If a match is found, then RULE_FOUND is set to true
  135. # and MATCHED_ITEM to the item that was matched
  136. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER3
  137. ifneq ($1,)
  138. ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,$$(firstword $1)),true)
  139. MATCHED_ITEM := $$(firstword $1)
  140. else
  141. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$$(wordlist 2,9999,$1)))
  142. endif
  143. endif
  144. endef
  145. # A recursive helper function for finding the longest match
  146. # $1 The list to be checed
  147. # It works by always removing the currently matched item from the list
  148. # and call itself recursively, until a match is found
  149. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER2
  150. # Stop the recursion when the list is empty
  151. ifneq ($1,)
  152. RULE_BEFORE := $$(RULE)
  153. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$1))
  154. # If a match is found in the current list, otherwise just return what we had before
  155. ifeq ($$(RULE_FOUND),true)
  156. # Save the best match so far and call itself recursivel
  157. BEST_MATCH := $$(MATCHED_ITEM)
  158. BEST_MATCH_RULE := $$(RULE)
  159. RULE_FOUND := false
  160. RULE := $$(RULE_BEFORE)
  161. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER2,$$(filter-out $$(MATCHED_ITEM),$1)))
  162. endif
  163. endif
  164. endef
  165. # Recursively try to find the longest match for the start of the rule to be checked
  166. # $1 The list to be checked
  167. # If a match is found, then RULE_FOUND is set to true
  168. # and MATCHED_ITEM to the item that was matched
  169. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER
  170. BEST_MATCH :=
  171. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER2,$1))
  172. ifneq ($$(BEST_MATCH),)
  173. RULE_FOUND := true
  174. RULE := $$(BEST_MATCH_RULE)
  175. MATCHED_ITEM := $$(BEST_MATCH)
  176. else
  177. RULE_FOUND := false
  178. MATCHED_ITEM :=
  179. endif
  180. endef
  181. # Make it easier to call TRY_TO_MATCH_RULE_FROM_LIST
  182. TRY_TO_MATCH_RULE_FROM_LIST = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER,$1))$(RULE_FOUND)
  183. define ALL_IN_LIST_LOOP
  184. OLD_RULE$1 := $$(RULE)
  185. $$(eval $$(call $1,$$(ITEM$1)))
  186. RULE := $$(OLD_RULE$1)
  187. endef
  188. define PARSE_ALL_IN_LIST
  189. $$(foreach ITEM$1,$2,$$(eval $$(call ALL_IN_LIST_LOOP,$1)))
  190. endef
  191. # The entry point for rule parsing
  192. # parses a rule in the format <keyboard>-<subproject>-<keymap>-<target>
  193. # but this particular function only deals with the first <keyboard> part
  194. define PARSE_RULE
  195. RULE := $1
  196. COMMANDS :=
  197. # If the rule starts with allkb, then continue the parsing from
  198. # PARSE_ALL_KEYBOARDS
  199. ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,allkb),true)
  200. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  201. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,test),true)
  202. $$(eval $$(call PARSE_TEST))
  203. # If the rule starts with the name of a known keyboard, then continue
  204. # the parsing from PARSE_KEYBOARD
  205. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYBOARDS)),true)
  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. # Notice the tab instead of spaces below!
  214. exit 1
  215. endif
  216. endef
  217. # $1 = Keyboard
  218. # Parses a rule in the format <subproject>-<keymap>-<target>
  219. # the keyboard is already known when entering this function
  220. define PARSE_KEYBOARD
  221. CURRENT_KB := $1
  222. # A subproject is any keyboard subfolder with a makefile
  223. SUBPROJECTS := $$(notdir $$(patsubst %/Makefile,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/*/Makefile)))
  224. # if the rule starts with allsp, then continue with looping over all subprojects
  225. ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,allsp),true)
  226. $$(eval $$(call PARSE_ALL_SUBPROJECTS))
  227. # A special case for matching the defaultsp (default subproject)
  228. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,defaultsp),true)
  229. $$(eval $$(call PARSE_SUBPROJECT,defaultsp))
  230. # If the rule starts with the name of a known subproject
  231. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(SUBPROJECTS)),true)
  232. $$(eval $$(call PARSE_SUBPROJECT,$$(MATCHED_ITEM)))
  233. # Try to use the SUBPROJECT variable, which is either determined by the
  234. # directory which invoked make, or passed as an argument to make
  235. else ifneq ($$(SUBPROJECT),)
  236. $$(eval $$(call PARSE_SUBPROJECT,$$(SUBPROJECT)))
  237. # If there's no matching subproject, we assume it's the default
  238. # This will allow you to leave the subproject part of the target out
  239. else
  240. $$(eval $$(call PARSE_SUBPROJECT,))
  241. endif
  242. endef
  243. # if we are going to compile all keyboards, match the rest of the rule
  244. # for each of them
  245. define PARSE_ALL_KEYBOARDS
  246. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(KEYBOARDS)))
  247. endef
  248. # $1 Subproject
  249. # When entering this, the keyboard and subproject are known, so now we need
  250. # to determine which keymaps are going to get compiled
  251. define PARSE_SUBPROJECT
  252. # If we want to compile the default subproject, then we need to
  253. # include the correct makefile to determine the actual name of it
  254. CURRENT_SP := $1
  255. ifeq ($$(CURRENT_SP),)
  256. CURRENT_SP := defaultsp
  257. endif
  258. ifeq ($$(CURRENT_SP),defaultsp)
  259. SUBPROJECT_DEFAULT=
  260. $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/Makefile)
  261. CURRENT_SP := $$(SUBPROJECT_DEFAULT)
  262. endif
  263. # If current subproject is empty (the default was not defined), and we have a list of subproject
  264. # then make all of them
  265. ifeq ($$(CURRENT_SP),)
  266. ifneq ($$(SUBPROJECTS),)
  267. CURRENT_SP := allsp
  268. endif
  269. endif
  270. # The special allsp is handled later
  271. ifneq ($$(CURRENT_SP),allsp)
  272. # get a list of all keymaps
  273. KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/keymaps/*/.)))
  274. ifneq ($$(CURRENT_SP),)
  275. # if the subproject is defined, then also look for keymaps inside the subproject folder
  276. SP_KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/$$(CURRENT_SP)/keymaps/*/.)))
  277. KEYMAPS := $$(sort $$(KEYMAPS) $$(SP_KEYMAPS))
  278. endif
  279. # if the rule after removing the start of it is empty (we haven't specified a kemap or target)
  280. # compile all the keymaps
  281. ifeq ($$(RULE),)
  282. $$(eval $$(call PARSE_ALL_KEYMAPS))
  283. # The same if allkm was specified
  284. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,allkm),true)
  285. $$(eval $$(call PARSE_ALL_KEYMAPS))
  286. # Try to match the specified keyamp with the list of known keymaps
  287. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYMAPS)),true)
  288. $$(eval $$(call PARSE_KEYMAP,$$(MATCHED_ITEM)))
  289. # Otherwise try to match the keymap from the current folder, or arguments to the make command
  290. else ifneq ($$(KEYMAP),)
  291. $$(eval $$(call PARSE_KEYMAP,$$(KEYMAP)))
  292. # No matching keymap found, so we assume that the rest of the rule is the target
  293. # If we haven't been able to parse out a subproject, then make all of them
  294. # This is consistent with running make without any arguments from the keyboard
  295. # folder
  296. else ifeq ($1,)
  297. $$(eval $$(call PARSE_ALL_SUBPROJECTS))
  298. # Otherwise, make all keymaps, again this is consistent with how it works without
  299. # any arguments
  300. else
  301. $$(eval $$(call PARSE_ALL_KEYMAPS))
  302. endif
  303. else
  304. # As earlier mentione,d when allsb is specified, we call our self recursively
  305. # for all of the subprojects
  306. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_SUBPROJECT,$(SUBPROJECTS)))
  307. endif
  308. endef
  309. # If we want to parse all subprojects, but the keyboard doesn't have any,
  310. # then use defaultsp instead
  311. define PARSE_ALL_SUBPROJECTS
  312. ifeq ($$(SUBPROJECTS),)
  313. $$(eval $$(call PARSE_SUBPROJECT,defaultsp))
  314. else
  315. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_SUBPROJECT,$$(SUBPROJECTS)))
  316. endif
  317. endef
  318. # $1 Keymap
  319. # This is the meat of compiling a keyboard, when entering this, everything is known
  320. # keyboard, subproject, and keymap
  321. # Note that we are not directly calling the command here, but instead building a list,
  322. # which will later be processed
  323. define PARSE_KEYMAP
  324. CURRENT_KM = $1
  325. # The rest of the rule is the target
  326. # Remove the leading "-" from the target, as it acts as a separator
  327. MAKE_TARGET := $$(patsubst -%,%,$$(RULE))
  328. # We need to generate an unique indentifer to append to the COMMANDS list
  329. COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM)
  330. # If we are compiling a keyboard without a subproject, we want to display just the name
  331. # of the keyboard, otherwise keyboard/subproject
  332. ifeq ($$(CURRENT_SP),)
  333. KB_SP := $(CURRENT_KB)
  334. else
  335. KB_SP := $(CURRENT_KB)/$$(CURRENT_SP)
  336. endif
  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) SUBPROJECT=$$(CURRENT_SP) KEYMAP=$$(CURRENT_KM)
  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" != "" ] ; \
  359. then $$(PRINT_WARNING_PLAIN); \
  360. else \
  361. $$(PRINT_OK); \
  362. fi;
  363. COMMAND_false_$$(COMMAND) := \
  364. printf "$$(MAKE_MSG)\n\n"; \
  365. $$(MAKE_CMD) $$(MAKE_VARS) SILENT=false;
  366. endef
  367. # Just parse all the keymaps for a specifc keyboard
  368. define PARSE_ALL_KEYMAPS
  369. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
  370. endef
  371. define BUILD_TEST
  372. TEST_NAME := $1
  373. MAKE_TARGET := $2
  374. COMMAND := $1
  375. MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET)
  376. MAKE_VARS := TEST=$$(TEST_NAME)
  377. MAKE_MSG := $$(MSG_MAKE_TEST)
  378. $$(eval $$(call BUILD))
  379. endef
  380. define PARSE_TEST
  381. TEST_NAME := $$(firstword $$(subst -, ,$$(RULE)))
  382. TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME)-,,$$(RULE)))
  383. MATCHED_TESTS := $$(foreach TEST,$$(TEST_LIST),$$(if $$(findstring $$(TEST_NAME),$$(TEST)),$$(TEST),))
  384. $$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(TEST_TARGET))))
  385. endef
  386. # Set the silent mode depending on if we are trying to compile multiple keyboards or not
  387. # By default it's on in that case, but it can be overriden by specifying silent=false
  388. # from the command line
  389. define SET_SILENT_MODE
  390. ifdef SUB_IS_SILENT
  391. SILENT_MODE := $(SUB_IS_SILENT)
  392. else ifeq ($$(words $$(COMMANDS)),1)
  393. SILENT_MODE := false
  394. else
  395. SILENT_MODE := true
  396. endif
  397. endef
  398. include $(ROOT_DIR)/message.mk
  399. RUN_COMMAND = \
  400. $(COMMAND_$(SILENT_MODE)_$(COMMAND))
  401. # Allow specifying just the subproject, in the keyboard directory, which will compile all keymaps
  402. SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile)))
  403. .PHONY: $(SUBPROJECTS)
  404. $(SUBPROJECTS): %: %-allkm
  405. # Let's match everything, we handle all the rule parsing ourselves
  406. .PHONY: %
  407. %:
  408. # Check if we have the CMP tool installed
  409. cmp --version >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
  410. # Check if the submodules are dirty, and display a warning if they are
  411. git submodule status --recursive 2>/dev/null | \
  412. while IFS= read -r x; do \
  413. case "$$x" in \
  414. \ *) ;; \
  415. *) printf "$(MSG_SUBMODULE_DIRTY)";break;; \
  416. esac \
  417. done
  418. $(eval $(call PARSE_RULE,$@))
  419. $(eval $(call SET_SILENT_MODE))
  420. # Run all the commands in the same shell, notice the + at the first line
  421. # it has to be there to allow parallel execution of the submake
  422. # This always tries to compile everything, even if error occurs in the middle
  423. # But we return the error code at the end, to trigger travis failures
  424. +error_occured=0; \
  425. $(foreach COMMAND,$(COMMANDS),$(RUN_COMMAND)) \
  426. if [ $$error_occured -gt 0 ]; then printf "$(MSG_ERRORS)" & exit $$error_occured; fi
  427. # All should compile everything
  428. .PHONY: all
  429. all: all-keyboards
  430. # Define some shortcuts, mostly for compability with the old syntax
  431. .PHONY: all-keyboards
  432. all-keyboards: allkb-allsp-allkm
  433. .PHONY: all-keyboards-defaults
  434. all-keyboards-defaults: allkb-allsp-default
  435. # Generate the version.h file
  436. GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
  437. BUILD_DATE := $(shell date +"%Y-%m-%d-%H:%M:%S")
  438. $(shell echo '#define QMK_VERSION "$(GIT_VERSION)"' > $(ROOT_DIR)/quantum/version.h)
  439. $(shell echo '#define QMK_BUILDDATE "$(BUILD_DATE)"' >> $(ROOT_DIR)/quantum/version.h)
  440. include $(ROOT_DIR)/testlist.mk