]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - Makefile
Remove the "lib/%" rule.
[qmk_firmware.git] / Makefile
index 9cc77c55ccaecb2d610e4d21cda6dc84c351393f..b97d33c5fca750217427001dd922ad1fd9f00ca6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,10 +16,17 @@ ifdef SILENT
 endif
 
 # We need to make sure that silent is always turned off at the top level
-# Otherwise the [OK], [ERROR] and [WARN] messags won't be displayed correctly
+# Otherwise the [OK], [ERROR] and [WARN] messages won't be displayed correctly
 override SILENT := false
 
-ON_ERROR := error_occured=1
+QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null)
+ifneq ($(QMK_VERSION),)
+$(info QMK Firmware v$(QMK_VERSION))
+endif
+
+ON_ERROR := error_occurred=1
+
+BREAK_ON_ERRORS = no
 
 STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST))
 ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
@@ -34,13 +41,13 @@ ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE))
 STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR))
 BUILD_DIR := $(ROOT_DIR)/.build
 TEST_DIR := $(BUILD_DIR)/test
-ERROR_FILE := $(BUILD_DIR)/error_occured
+ERROR_FILE := $(BUILD_DIR)/error_occurred
 
 MAKEFILE_INCLUDED=yes
 
 # Helper function to process the newt element of a space separated path
 # It works a bit like the traditional functional head tail
-# so the CURRENT_PATH_ELEMENT will beome the new head
+# so the CURRENT_PATH_ELEMENT will become the new head
 # and the PATH_ELEMENTS are the rest that are still unprocessed
 define NEXT_PATH_ELEMENT
     $$(eval CURRENT_PATH_ELEMENT := $$(firstword  $$(PATH_ELEMENTS)))
@@ -84,7 +91,7 @@ endif
 # Only consider folders with makefiles, to prevent errors in case there are extra folders
 KEYBOARDS := $(notdir $(patsubst %/Makefile,%,$(wildcard $(ROOT_DIR)/keyboards/*/Makefile)))
 
-#Compability with the old make variables, anything you specify directly on the command line
+#Compatibility with the old make variables, anything you specify directly on the command line
 # always overrides the detected folders
 ifdef keyboard
     KEYBOARD := $(keyboard)
@@ -106,7 +113,7 @@ endif
 #$(info Keyboards: $(KEYBOARDS))
 
 
-# Set the default goal depening on where we are running make from
+# Set the default goal depending on where we are running make from
 # this handles the case where you run make without any arguments
 .DEFAULT_GOAL := all
 ifneq ($(KEYMAP),)
@@ -170,7 +177,7 @@ define TRY_TO_MATCH_RULE_FROM_LIST_HELPER3
 endef
 
 # A recursive helper function for finding the longest match
-# $1 The list to be checed
+# $1 The list to be checked
 # It works by always removing the currently matched item from the list
 # and call itself recursively, until a match is found
 define TRY_TO_MATCH_RULE_FROM_LIST_HELPER2
@@ -180,7 +187,7 @@ define TRY_TO_MATCH_RULE_FROM_LIST_HELPER2
         $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$1))
         # If a match is found in the current list, otherwise just return what we had before
         ifeq ($$(RULE_FOUND),true)
-            # Save the best match so far and call itself recursivel
+            # Save the best match so far and call itself recursively
             BEST_MATCH := $$(MATCHED_ITEM)
             BEST_MATCH_RULE := $$(RULE)
             RULE_FOUND := false
@@ -307,11 +314,21 @@ define PARSE_SUBPROJECT
     ifneq ($$(CURRENT_SP),allsp)
         # get a list of all keymaps
         KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/keymaps/*/.)))
+        LAYOUTS :=
+        $$(eval -include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk)
+        KEYBOARD_LAYOUTS := $$(LAYOUTS)
         ifneq ($$(CURRENT_SP),)
             # if the subproject is defined, then also look for keymaps inside the subproject folder
             SP_KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/$$(CURRENT_SP)/keymaps/*/.)))
             KEYMAPS := $$(sort $$(KEYMAPS) $$(SP_KEYMAPS))
+               # $$(eval -include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/$$(CURRENT_SP)/rules.mk)
+               # KEYBOARD_LAYOUTS := $$(sort $$(KEYBOARD_LAYOUTS) $$(LAYOUTS))
         endif
+
+        LAYOUT_KEYMAPS :=
+        $$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
+        
+        KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS))
         # if the rule after removing the start of it is empty (we haven't specified a kemap or target)
         # compile all the keymaps
         ifeq ($$(RULE),)
@@ -337,7 +354,7 @@ define PARSE_SUBPROJECT
             $$(eval $$(call PARSE_ALL_KEYMAPS))
         endif
     else
-        # As earlier mentione,d when allsb is specified, we call our self recursively
+        # As earlier mentioned when allsb is specified, we call our self recursively
         # for all of the subprojects
         $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_SUBPROJECT,$(SUBPROJECTS)))
     endif
@@ -403,11 +420,11 @@ define BUILD
         printf "$$(MAKE_MSG)\n\n"; \
         $$(MAKE_CMD) $$(MAKE_VARS) SILENT=false; \
         if [ $$$$? -gt 0 ]; \
-            then error_occured=1; \
+            then error_occurred=1; \
         fi;
 endef
 
-# Just parse all the keymaps for a specifc keyboard
+# Just parse all the keymaps for a specific keyboard
 define PARSE_ALL_KEYMAPS
     $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
 endef
@@ -417,7 +434,7 @@ define BUILD_TEST
     MAKE_TARGET := $2
     COMMAND := $1
     MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET)
-    MAKE_VARS := TEST=$$(TEST_NAME)
+    MAKE_VARS := TEST=$$(TEST_NAME) FULL_TESTS="$$(FULL_TESTS)"
     MAKE_MSG := $$(MSG_MAKE_TEST)
     $$(eval $$(call BUILD))
     ifneq ($$(MAKE_TARGET),clean)
@@ -428,7 +445,7 @@ define BUILD_TEST
             printf "$$(TEST_MSG)\n"; \
             $$(TEST_EXECUTABLE); \
             if [ $$$$? -gt 0 ]; \
-                then error_occured=1; \
+                then error_occurred=1; \
             fi; \
             printf "\n";
     endif
@@ -448,7 +465,7 @@ endef
 
 
 # Set the silent mode depending on if we are trying to compile multiple keyboards or not
-# By default it's on in that case, but it can be overriden by specifying silent=false
+# By default it's on in that case, but it can be overridden by specifying silent=false
 # from the command line
 define SET_SILENT_MODE
     ifdef SUB_IS_SILENT
@@ -462,19 +479,26 @@ endef
 
 include $(ROOT_DIR)/message.mk
 
+ifeq ($(strip $(BREAK_ON_ERRORS)), yes)
+HANDLE_ERROR = exit 1
+else
+HANDLE_ERROR = echo $$error_occurred > $(ERROR_FILE)
+endif
+
 # The empty line is important here, as it will force a new shell to be created for each command
 # Otherwise the command line will become too long with a lot of keyboards and keymaps
 define RUN_COMMAND
-+error_occured=0;\
++error_occurred=0;\
 $(COMMAND_$(SILENT_MODE)_$(COMMAND))\
-if [ $$error_occured -gt 0 ]; then echo $$error_occured > $(ERROR_FILE); fi;
+if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
 
 
 endef
 define RUN_TEST
-+error_occured=0;\
++error_occurred=0;\
 $($(TEST)_COMMAND)\
-if [ $$error_occured -gt 0 ]; then echo $$error_occured > $(ERROR_FILE); fi;
+if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
+
 
 endef
 
@@ -487,9 +511,12 @@ $(SUBPROJECTS): %: %-allkm
 .PHONY: %
 %:
        # Check if we have the CMP tool installed
-       cmp --version >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
+       cmp $(ROOT_DIR)/Makefile $(ROOT_DIR)/Makefile >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
        # Check if the submodules are dirty, and display a warning if they are
 ifndef SKIP_GIT
+       if [ ! -e lib/chibios ]; then git submodule sync lib/chibios && git submodule update --init lib/chibios; fi
+       if [ ! -e lib/chibios-contrib ]; then git submodule sync lib/chibios-contrib && git submodule update --init lib/chibios-contrib; fi
+       if [ ! -e lib/ugfx ]; then git submodule sync lib/ugfx && git submodule update --init lib/ugfx; fi
        git submodule status --recursive 2>/dev/null | \
        while IFS= read -r x; do \
                case "$$x" in \
@@ -514,7 +541,7 @@ endif
 .PHONY: all
 all: all-keyboards test-all
 
-# Define some shortcuts, mostly for compability with the old syntax
+# Define some shortcuts, mostly for compatibility with the old syntax
 .PHONY: all-keyboards
 all-keyboards: allkb-allsp-allkm
 
@@ -527,14 +554,26 @@ test: test-all
 .PHONY: test-clean
 test-clean: test-all-clean
 
+git-submodule:
+       git submodule sync --recursive
+       git submodule update --init --recursive
+
+ifdef SKIP_VERSION
+SKIP_GIT := yes
+endif
+
 # Generate the version.h file
 ifndef SKIP_GIT
     GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
 else
     GIT_VERSION := NA
 endif
+ifndef SKIP_VERSION
 BUILD_DATE := $(shell date +"%Y-%m-%d-%H:%M:%S")
 $(shell echo '#define QMK_VERSION "$(GIT_VERSION)"' > $(ROOT_DIR)/quantum/version.h)
 $(shell echo '#define QMK_BUILDDATE "$(BUILD_DATE)"' >> $(ROOT_DIR)/quantum/version.h)
+else
+BUILD_DATE := NA
+endif
 
-include $(ROOT_DIR)/testlist.mk
\ No newline at end of file
+include $(ROOT_DIR)/testlist.mk