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