aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile509
1 files changed, 509 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..88f430619
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,509 @@
1ifndef VERBOSE
2.SILENT:
3endif
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
10ifdef silent
11 SILENT = $(silent)
12endif
13
14ifdef SILENT
15 SUB_IS_SILENT := $(SILENT)
16endif
17
18# We need to make sure that silent is always turned off at the top level
19# Otherwise the [OK], [ERROR] and [WARN] messages won't be displayed correctly
20override SILENT := false
21
22ifndef SUB_IS_SILENT
23ifndef SKIP_GIT
24 QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null)
25endif
26
27ifneq ($(QMK_VERSION),)
28$(info QMK Firmware $(QMK_VERSION))
29endif
30endif
31
32# Determine which qmk cli to use
33QMK_BIN := qmk
34
35# avoid 'Entering|Leaving directory' messages
36MAKEFLAGS += --no-print-directory
37
38ON_ERROR := error_occurred=1
39
40BREAK_ON_ERRORS = no
41
42STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST))
43ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
44ROOT_DIR := $(dir $(ROOT_MAKEFILE))
45ifeq ($(ROOT_DIR),)
46 ROOT_DIR := .
47endif
48ABS_STARTING_MAKEFILE := $(abspath $(STARTING_MAKEFILE))
49ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE))
50ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE))
51ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE))
52STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR))
53BUILD_DIR := $(ROOT_DIR)/.build
54TEST_DIR := $(BUILD_DIR)/test
55ERROR_FILE := $(BUILD_DIR)/error_occurred
56
57# Helper function to process the newt element of a space separated path
58# It works a bit like the traditional functional head tail
59# so the CURRENT_PATH_ELEMENT will become the new head
60# and the PATH_ELEMENTS are the rest that are still unprocessed
61define NEXT_PATH_ELEMENT
62 $$(eval CURRENT_PATH_ELEMENT := $$(firstword $$(PATH_ELEMENTS)))
63 $$(eval PATH_ELEMENTS := $$(wordlist 2,9999,$$(PATH_ELEMENTS)))
64endef
65
66# We change the / to spaces so that we more easily can work with the elements
67# separately
68PATH_ELEMENTS := $(subst /, ,$(STARTING_DIR))
69# Initialize the path elements list for further processing
70$(eval $(call NEXT_PATH_ELEMENT))
71
72
73# Phony targets to enable a few simple make commands outside the main processing below.
74.PHONY: list-keyboards
75list-keyboards:
76 util/list_keyboards.sh | sort -u | tr '\n' ' '
77
78.PHONY: generate-keyboards-file
79generate-keyboards-file:
80 util/list_keyboards.sh | sort -u
81
82.PHONY: clean
83clean:
84 echo -n 'Deleting .build/ ... '
85 rm -rf $(BUILD_DIR)
86 echo 'done.'
87
88.PHONY: distclean
89distclean: clean
90 echo -n 'Deleting *.bin, *.hex, and *.uf2 ... '
91 rm -f *.bin *.hex *.uf2
92 echo 'done.'
93
94
95.DEFAULT_GOAL := all:all
96
97
98# Compare the start of the RULE variable with the first argument($1)
99# If the rules equals $1 or starts with $1:, RULE_FOUND is set to true
100# and $1 is removed from the RULE variable
101# Otherwise the RULE_FOUND variable is set to false, and RULE left as it was
102# The function is a bit tricky, since there's no built in $(startswith) function
103define COMPARE_AND_REMOVE_FROM_RULE_HELPER
104 ifeq ($1,$$(RULE))
105 RULE:=
106 RULE_FOUND := true
107 else
108 STARTCOLON_REMOVED=$$(subst START$1:,,START$$(RULE))
109 ifneq ($$(STARTCOLON_REMOVED),START$$(RULE))
110 RULE_FOUND := true
111 RULE := $$(STARTCOLON_REMOVED)
112 else
113 RULE_FOUND := false
114 endif
115 endif
116endef
117
118# This makes it easier to call COMPARE_AND_REMOVE_FROM_RULE, since it makes it behave like
119# a function that returns the value
120COMPARE_AND_REMOVE_FROM_RULE = $(eval $(call COMPARE_AND_REMOVE_FROM_RULE_HELPER,$1))$(RULE_FOUND)
121
122
123# Recursively try to find a match for the start of the rule to be checked
124# $1 The list to be checked
125# If a match is found, then RULE_FOUND is set to true
126# and MATCHED_ITEM to the item that was matched
127define TRY_TO_MATCH_RULE_FROM_LIST_HELPER3
128 ifneq ($1,)
129 ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,$$(firstword $1)),true)
130 MATCHED_ITEM := $$(firstword $1)
131 else
132 $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$$(wordlist 2,9999,$1)))
133 endif
134 endif
135endef
136
137# A recursive helper function for finding the longest match
138# $1 The list to be checked
139# It works by always removing the currently matched item from the list
140define TRY_TO_MATCH_RULE_FROM_LIST_HELPER2
141 # Stop the recursion when the list is empty
142 ifneq ($1,)
143 RULE_BEFORE := $$(RULE)
144 $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$1))
145 # If a match is found in the current list, otherwise just return what we had before
146 ifeq ($$(RULE_FOUND),true)
147 # Save the best match so far and call itself recursively
148 BEST_MATCH := $$(MATCHED_ITEM)
149 BEST_MATCH_RULE := $$(RULE)
150 RULE_FOUND := false
151 RULE := $$(RULE_BEFORE)
152 $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER2,$$(filter-out $$(MATCHED_ITEM),$1)))
153 endif
154 endif
155endef
156
157
158# Recursively try to find the longest match for the start of the rule to be checked
159# $1 The list to be checked
160# If a match is found, then RULE_FOUND is set to true
161# and MATCHED_ITEM to the item that was matched
162define TRY_TO_MATCH_RULE_FROM_LIST_HELPER
163 BEST_MATCH :=
164 $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER2,$1))
165 ifneq ($$(BEST_MATCH),)
166 RULE_FOUND := true
167 RULE := $$(BEST_MATCH_RULE)
168 MATCHED_ITEM := $$(BEST_MATCH)
169 else
170 RULE_FOUND := false
171 MATCHED_ITEM :=
172 endif
173endef
174
175# Make it easier to call TRY_TO_MATCH_RULE_FROM_LIST
176TRY_TO_MATCH_RULE_FROM_LIST = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER,$1))$(RULE_FOUND)
177
178define ALL_IN_LIST_LOOP
179 OLD_RULE$1 := $$(RULE)
180 $$(eval $$(call $1,$$(ITEM$1)))
181 RULE := $$(OLD_RULE$1)
182endef
183
184define PARSE_ALL_IN_LIST
185 $$(foreach ITEM$1,$2,$$(eval $$(call ALL_IN_LIST_LOOP,$1)))
186endef
187
188# The entry point for rule parsing
189# parses a rule in the format <keyboard>:<keymap>:<target>
190# but this particular function only deals with the first <keyboard> part
191define PARSE_RULE
192 RULE := $1
193 COMMANDS :=
194 REQUIRE_PLATFORM_KEY :=
195 # If the rule starts with all, then continue the parsing from
196 # PARSE_ALL_KEYBOARDS
197 ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
198 KEYBOARD_RULE=all
199 $$(eval $$(call PARSE_ALL_KEYBOARDS))
200 else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-avr),true)
201 KEYBOARD_RULE=all
202 REQUIRE_PLATFORM_KEY := avr
203 $$(eval $$(call PARSE_ALL_KEYBOARDS))
204 else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-chibios),true)
205 KEYBOARD_RULE=all
206 REQUIRE_PLATFORM_KEY := chibios
207 $$(eval $$(call PARSE_ALL_KEYBOARDS))
208 else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-arm_atsam),true)
209 KEYBOARD_RULE=all
210 REQUIRE_PLATFORM_KEY := arm_atsam
211 $$(eval $$(call PARSE_ALL_KEYBOARDS))
212 else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,test),true)
213 $$(eval $$(call PARSE_TEST))
214 # If the rule starts with the name of a known keyboard, then continue
215 # the parsing from PARSE_KEYBOARD
216 else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(shell util/list_keyboards.sh | sort -u)),true)
217 KEYBOARD_RULE=$$(MATCHED_ITEM)
218 $$(eval $$(call PARSE_KEYBOARD,$$(MATCHED_ITEM)))
219 else
220 $$(info make: *** No rule to make target '$1'. Stop.)
221 $$(info |)
222 $$(info | QMK's make format is:)
223 $$(info | make keyboard_folder:keymap_folder[:target])
224 $$(info |)
225 $$(info | Where `keyboard_folder` is the path to the keyboard relative to)
226 $$(info | `qmk_firmware/keyboards/`, and `keymap_folder` is the name of the)
227 $$(info | keymap folder under that board's `keymaps/` directory.)
228 $$(info |)
229 $$(info | Examples:)
230 $$(info | keyboards/dz60, keyboards/dz60/keymaps/default)
231 $$(info | -> make dz60:default)
232 $$(info | -> qmk compile -kb dz60 -km default)
233 $$(info | keyboards/planck/rev6, keyboards/planck/keymaps/default)
234 $$(info | -> make planck/rev6:default:flash)
235 $$(info | -> qmk flash -kb planck/rev6 -km default)
236 $$(info |)
237 endif
238endef
239
240# $1 = Keyboard
241# Parses a rule in the format <keymap>:<target>
242# the keyboard is already known when entering this function
243define PARSE_KEYBOARD
244 # If we want to compile the default subproject, then we need to
245 # include the correct makefile to determine the actual name of it
246 CURRENT_KB := $1
247
248 # KEYBOARD_FOLDERS := $$(subst /, , $(CURRENT_KB))
249
250 DEFAULT_FOLDER := $$(CURRENT_KB)
251
252 # We assume that every rules.mk will contain the full default value
253 $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk)
254 ifneq ($$(DEFAULT_FOLDER),$$(CURRENT_KB))
255 $$(eval include $(ROOT_DIR)/keyboards/$$(DEFAULT_FOLDER)/rules.mk)
256 endif
257 CURRENT_KB := $$(DEFAULT_FOLDER)
258
259 # 5/4/3/2/1
260 KEYBOARD_FOLDER_PATH_1 := $$(CURRENT_KB)
261 KEYBOARD_FOLDER_PATH_2 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_1)))
262 KEYBOARD_FOLDER_PATH_3 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_2)))
263 KEYBOARD_FOLDER_PATH_4 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_3)))
264 KEYBOARD_FOLDER_PATH_5 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_4)))
265
266 KEYMAPS :=
267 # get a list of all keymaps
268 KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/keymaps/*/.)))
269 KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/keymaps/*/.)))
270 KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.)))
271 KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.)))
272 KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.)))
273
274 KEYBOARD_LAYOUTS := $(shell $(QMK_BIN) list-layouts --keyboard $1)
275 LAYOUT_KEYMAPS :=
276 $$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
277
278 KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS))
279
280 # if the rule after removing the start of it is empty (we haven't specified a kemap or target)
281 # compile all the keymaps
282 ifeq ($$(RULE),)
283 $$(eval $$(call PARSE_ALL_KEYMAPS))
284 # The same if all was specified
285 else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
286 $$(eval $$(call PARSE_ALL_KEYMAPS))
287 # List all keymaps for the given keyboard
288 else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,list-keymaps),true)
289 $$(eval $$(call LIST_ALL_KEYMAPS))
290 # Try to match the specified keyamp with the list of known keymaps
291 else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYMAPS)),true)
292 $$(eval $$(call PARSE_KEYMAP,$$(MATCHED_ITEM)))
293 # Otherwise try to match the keymap from the current folder, or arguments to the make command
294 else ifneq ($$(KEYMAP),)
295 $$(eval $$(call PARSE_KEYMAP,$$(KEYMAP)))
296 # Otherwise if we are running make all:<user> just skip
297 else ifeq ($$(KEYBOARD_RULE),all)
298 # $$(info Skipping: No user keymap for $$(CURRENT_KB))
299 # Otherwise, make all keymaps, again this is consistent with how it works without
300 # any arguments
301 else
302 $$(eval $$(call PARSE_ALL_KEYMAPS))
303 endif
304endef
305
306# if we are going to compile all keyboards, match the rest of the rule
307# for each of them
308define PARSE_ALL_KEYBOARDS
309 $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(shell util/list_keyboards.sh noci | sort -u)))
310endef
311
312# Prints a list of all known keymaps for the given keyboard
313define 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
320endef
321
322# $1 Keymap
323# This is the meat of compiling a keyboard, when entering this, everything is known
324# keyboard, subproject, and keymap
325# Note that we are not directly calling the command here, but instead building a list,
326# which will later be processed
327define PARSE_KEYMAP
328 CURRENT_KM = $1
329 # The rest of the rule is the target
330 # Remove the leading ":" from the target, as it acts as a separator
331 MAKE_TARGET := $$(patsubst :%,%,$$(RULE))
332 # We need to generate an unique indentifer to append to the COMMANDS list
333 CURRENT_KB_UNDER := $$(subst /,_,$$(CURRENT_KB))
334 COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB_UNDER)_KEYMAP_$$(CURRENT_KM)
335 # If we are compiling a keyboard without a subproject, we want to display just the name
336 # of the keyboard, otherwise keyboard/subproject
337 KB_SP := $$(CURRENT_KB)
338 # Format it in bold
339 KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR)
340 # Specify the variables that we are passing forward to submake
341 MAKE_VARS := KEYBOARD=$$(CURRENT_KB) KEYMAP=$$(CURRENT_KM) REQUIRE_PLATFORM_KEY=$$(REQUIRE_PLATFORM_KEY) QMK_BIN=$$(QMK_BIN)
342 # And the first part of the make command
343 MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_keyboard.mk $$(MAKE_TARGET)
344 # The message to display
345 MAKE_MSG := $$(MSG_MAKE_KB)
346 # We run the command differently, depending on if we want more output or not
347 # The true version for silent output and the false version otherwise
348 $$(eval $$(call BUILD))
349endef
350
351define BUILD
352 MAKE_VARS += VERBOSE=$(VERBOSE) COLOR=$(COLOR)
353 COMMANDS += $$(COMMAND)
354 COMMAND_true_$$(COMMAND) := \
355 printf "$$(MAKE_MSG)" | \
356 $$(MAKE_MSG_FORMAT); \
357 LOG=$$$$($$(MAKE_CMD) $$(MAKE_VARS) SILENT=true 2>&1) ; \
358 if [ $$$$? -gt 0 ]; \
359 then $$(PRINT_ERROR_PLAIN); \
360 elif [ "$$$$LOG" = "skipped" ] ; \
361 then $$(PRINT_SKIPPED_PLAIN); \
362 elif [ "$$$$LOG" != "" ] ; \
363 then $$(PRINT_WARNING_PLAIN); \
364 else \
365 $$(PRINT_OK); \
366 fi;
367 COMMAND_false_$$(COMMAND) := \
368 printf "$$(MAKE_MSG)\n\n"; \
369 $$(MAKE_CMD) $$(MAKE_VARS) SILENT=false; \
370 if [ $$$$? -gt 0 ]; \
371 then error_occurred=1; \
372 fi;
373endef
374
375# Just parse all the keymaps for a specific keyboard
376define PARSE_ALL_KEYMAPS
377 $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
378endef
379
380define BUILD_TEST
381 TEST_PATH := $1
382 TEST_NAME := $$(notdir $$(TEST_PATH))
383 MAKE_TARGET := $2
384 COMMAND := $1
385 MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET)
386 MAKE_VARS := TEST=$$(TEST_NAME) TEST_PATH=$$(TEST_PATH) FULL_TESTS="$$(FULL_TESTS)"
387 MAKE_MSG := $$(MSG_MAKE_TEST)
388 $$(eval $$(call BUILD))
389 ifneq ($$(MAKE_TARGET),clean)
390 TEST_EXECUTABLE := $$(TEST_DIR)/$$(TEST_NAME).elf
391 TESTS += $$(TEST_NAME)
392 TEST_MSG := $$(MSG_TEST)
393 $$(TEST_NAME)_COMMAND := \
394 printf "$$(TEST_MSG)\n"; \
395 $$(TEST_EXECUTABLE); \
396 if [ $$$$? -gt 0 ]; \
397 then error_occurred=1; \
398 fi; \
399 printf "\n";
400 endif
401endef
402
403define PARSE_TEST
404 TESTS :=
405 TEST_NAME := $$(firstword $$(subst :, ,$$(RULE)))
406 TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME):,,$$(RULE)))
407 ifeq ($$(TEST_NAME),all)
408 MATCHED_TESTS := $$(TEST_LIST)
409 else
410 MATCHED_TESTS := $$(foreach TEST, $$(TEST_LIST),$$(if $$(findstring $$(TEST_NAME), $$(notdir $$(TEST))), $$(TEST),))
411 endif
412 $$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(TEST_TARGET))))
413endef
414
415
416# Set the silent mode depending on if we are trying to compile multiple keyboards or not
417# By default it's on in that case, but it can be overridden by specifying silent=false
418# from the command line
419define SET_SILENT_MODE
420 ifdef SUB_IS_SILENT
421 SILENT_MODE := $(SUB_IS_SILENT)
422 else ifeq ($$(words $$(COMMANDS)),1)
423 SILENT_MODE := false
424 else
425 SILENT_MODE := true
426 endif
427endef
428
429include paths.mk
430include $(BUILDDEFS_PATH)/message.mk
431
432ifeq ($(strip $(BREAK_ON_ERRORS)), yes)
433HANDLE_ERROR = exit 1
434else
435HANDLE_ERROR = echo $$error_occurred > $(ERROR_FILE)
436endif
437
438# The empty line is important here, as it will force a new shell to be created for each command
439# Otherwise the command line will become too long with a lot of keyboards and keymaps
440define RUN_COMMAND
441+error_occurred=0;\
442$(COMMAND_$(SILENT_MODE)_$(COMMAND))\
443if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
444
445
446endef
447define RUN_TEST
448+error_occurred=0;\
449$($(TEST)_COMMAND)\
450if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
451
452
453endef
454
455# Catch everything and parse the command line ourselves.
456.PHONY: %
457%:
458 # Check if we have the CMP tool installed
459 cmp $(ROOT_DIR)/Makefile $(ROOT_DIR)/Makefile >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
460 # Ensure that $(QMK_BIN) works.
461 if ! $(QMK_BIN) hello 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; exit 1; fi
462 # Check if the submodules are dirty, and display a warning if they are
463ifndef SKIP_GIT
464 if [ ! -e lib/chibios ]; then git submodule sync lib/chibios && git submodule update --depth 50 --init lib/chibios; fi
465 if [ ! -e lib/chibios-contrib ]; then git submodule sync lib/chibios-contrib && git submodule update --depth 50 --init lib/chibios-contrib; fi
466 if [ ! -e lib/lufa ]; then git submodule sync lib/lufa && git submodule update --depth 50 --init lib/lufa; fi
467 if [ ! -e lib/vusb ]; then git submodule sync lib/vusb && git submodule update --depth 50 --init lib/vusb; fi
468 if [ ! -e lib/printf ]; then git submodule sync lib/printf && git submodule update --depth 50 --init lib/printf; fi
469 git submodule status --recursive 2>/dev/null | \
470 while IFS= read -r x; do \
471 case "$$x" in \
472 \ *) ;; \
473 *) printf "$(MSG_SUBMODULE_DIRTY)";break;; \
474 esac \
475 done
476endif
477 rm -f $(ERROR_FILE) > /dev/null 2>&1
478 $(eval $(call PARSE_RULE,$@))
479 $(eval $(call SET_SILENT_MODE))
480 # Run all the commands in the same shell, notice the + at the first line
481 # it has to be there to allow parallel execution of the submake
482 # This always tries to compile everything, even if error occurs in the middle
483 # But we return the error code at the end, to trigger travis failures
484 # The sort at this point is to remove duplicates
485 $(foreach COMMAND,$(sort $(COMMANDS)),$(RUN_COMMAND))
486 if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
487 $(foreach TEST,$(sort $(TESTS)),$(RUN_TEST))
488 if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
489
490lib/%:
491 git submodule sync $?
492 git submodule update --init $?
493
494.PHONY: git-submodule
495git-submodule:
496 git submodule sync --recursive
497 git submodule update --init --recursive --progress
498
499# Generate the version.h file
500ifdef SKIP_GIT
501VERSION_H_FLAGS := --skip-git
502endif
503ifdef SKIP_VERSION
504VERSION_H_FLAGS := --skip-all
505SKIP_GIT := yes
506endif
507$(shell $(QMK_BIN) generate-version-h $(VERSION_H_FLAGS) -q -o quantum/version.h)
508
509include $(ROOT_DIR)/testlist.mk