diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2017-10-14 11:32:19 -1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-14 11:32:19 -1000 |
| commit | 800ec55dfca06b4630acf62cbb5f130c4031e4f1 (patch) | |
| tree | 718e43d976bc71627558b5f9e1b657e8a64e4131 /Makefile | |
| parent | e5dc2253e26a105a11e0fad3e4e39c306e49cc92 (diff) | |
| download | qmk_firmware-800ec55dfca06b4630acf62cbb5f130c4031e4f1.tar.gz qmk_firmware-800ec55dfca06b4630acf62cbb5f130c4031e4f1.zip | |
Make arguments redo, subproject elimination (#1784)
* redo make args to use colons, better folder structuring system [skip ci]
* don't put spaces after statements - hard lessons in makefile development
* fix-up some other rules.mk
* give travis a chance
* reset KEYMAPS variable
* start converting keyboards to new system
* try making all with travis
* redo make args to use colons, better folder structuring system [skip ci]
* don't put spaces after statements - hard lessons in makefile development
* fix-up some other rules.mk
* give travis a chance
* reset KEYMAPS variable
* start converting keyboards to new system
* try making all with travis
* start to update readmes and keyboards
* look in keyboard directories for board.mk
* update visualizer rules
* fix up some other keyboards/keymaps
* fix arm board ld includes
* fix board rules
* fix up remaining keyboards
* reset layout variable
* reset keyboard_layouts
* fix remainging keymaps/boards
* update readmes, docs
* add note to makefile error
* update readmes
* remove planck keymap warnings
* update references and docs
* test out tarvis build stages
* don't use stages for now
* don't use stages for now
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 360 |
1 files changed, 182 insertions, 178 deletions
| @@ -21,7 +21,7 @@ override SILENT := false | |||
| 21 | 21 | ||
| 22 | QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null) | 22 | QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null) |
| 23 | ifneq ($(QMK_VERSION),) | 23 | ifneq ($(QMK_VERSION),) |
| 24 | $(info QMK Firmware v$(QMK_VERSION)) | 24 | $(info QMK Firmware $(QMK_VERSION)) |
| 25 | endif | 25 | endif |
| 26 | 26 | ||
| 27 | ON_ERROR := error_occurred=1 | 27 | ON_ERROR := error_occurred=1 |
| @@ -65,80 +65,86 @@ $(eval $(call NEXT_PATH_ELEMENT)) | |||
| 65 | # It's really a very simple if else chain, if you squint enough, | 65 | # It's really a very simple if else chain, if you squint enough, |
| 66 | # but the makefile syntax makes it very verbose. | 66 | # but the makefile syntax makes it very verbose. |
| 67 | # If we are in a subfolder of keyboards | 67 | # If we are in a subfolder of keyboards |
| 68 | ifeq ($(CURRENT_PATH_ELEMENT),keyboards) | 68 | # |
| 69 | $(eval $(call NEXT_PATH_ELEMENT)) | 69 | # *** No longer needed ** |
| 70 | KEYBOARD := $(CURRENT_PATH_ELEMENT) | 70 | # |
| 71 | $(eval $(call NEXT_PATH_ELEMENT)) | 71 | # ifeq ($(CURRENT_PATH_ELEMENT),keyboards) |
| 72 | # If we are in a subfolder of keymaps, or in other words in a keymap | 72 | # $(eval $(call NEXT_PATH_ELEMENT)) |
| 73 | # folder | 73 | # KEYBOARD := $(CURRENT_PATH_ELEMENT) |
| 74 | ifeq ($(CURRENT_PATH_ELEMENT),keymaps) | 74 | # $(eval $(call NEXT_PATH_ELEMENT)) |
| 75 | $(eval $(call NEXT_PATH_ELEMENT)) | 75 | # # If we are in a subfolder of keymaps, or in other words in a keymap |
| 76 | KEYMAP := $(CURRENT_PATH_ELEMENT) | 76 | # # folder |
| 77 | # else if we are not in the keyboard folder itself | 77 | # ifeq ($(CURRENT_PATH_ELEMENT),keymaps) |
| 78 | else ifneq ($(CURRENT_PATH_ELEMENT),) | 78 | # $(eval $(call NEXT_PATH_ELEMENT)) |
| 79 | # the we can assume it's a subproject, as no other folders | 79 | # KEYMAP := $(CURRENT_PATH_ELEMENT) |
| 80 | # should have make files in them | 80 | # # else if we are not in the keyboard folder itself |
| 81 | SUBPROJECT := $(CURRENT_PATH_ELEMENT) | 81 | # else ifneq ($(CURRENT_PATH_ELEMENT),) |
| 82 | $(eval $(call NEXT_PATH_ELEMENT)) | 82 | # # the we can assume it's a subproject, as no other folders |
| 83 | # if we are inside a keymap folder of a subproject | 83 | # # should have make files in them |
| 84 | ifeq ($(CURRENT_PATH_ELEMENT),keymaps) | 84 | # SUBPROJECT := $(CURRENT_PATH_ELEMENT) |
| 85 | $(eval $(call NEXT_PATH_ELEMENT)) | 85 | # $(eval $(call NEXT_PATH_ELEMENT)) |
| 86 | KEYMAP := $(CURRENT_PATH_ELEMENT) | 86 | # # if we are inside a keymap folder of a subproject |
| 87 | endif | 87 | # ifeq ($(CURRENT_PATH_ELEMENT),keymaps) |
| 88 | endif | 88 | # $(eval $(call NEXT_PATH_ELEMENT)) |
| 89 | endif | 89 | # KEYMAP := $(CURRENT_PATH_ELEMENT) |
| 90 | # endif | ||
| 91 | # endif | ||
| 92 | # endif | ||
| 93 | |||
| 94 | define GET_KEYBOARDS | ||
| 95 | All_RULES_MK := $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/rules.mk)) | ||
| 96 | All_RULES_MK += $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/*/rules.mk)) | ||
| 97 | All_RULES_MK += $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/*/*/rules.mk)) | ||
| 98 | All_RULES_MK += $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/*/*/*/rules.mk)) | ||
| 99 | |||
| 100 | KEYMAPS_MK := $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/keymaps/*/rules.mk)) | ||
| 101 | KEYMAPS_MK += $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/*/keymaps/*/rules.mk)) | ||
| 102 | KEYMAPS_MK += $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/*/*/keymaps/*/rules.mk)) | ||
| 103 | KEYMAPS_MK += $$(patsubst $(ROOT_DIR)/keyboards/%/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/*/*/*/*/keymaps/*/rules.mk)) | ||
| 104 | |||
| 105 | KEYBOARDS := $$(sort $$(filter-out $$(KEYMAPS_MK), $$(All_RULES_MK))) | ||
| 106 | endef | ||
| 107 | |||
| 108 | $(eval $(call GET_KEYBOARDS)) | ||
| 90 | 109 | ||
| 91 | # Only consider folders with makefiles, to prevent errors in case there are extra folders | 110 | # Only consider folders with makefiles, to prevent errors in case there are extra folders |
| 92 | KEYBOARDS := $(notdir $(patsubst %/rules.mk,%,$(wildcard $(ROOT_DIR)/keyboards/*/rules.mk))) | 111 | #KEYBOARDS += $(patsubst $(ROOD_DIR)/keyboards/%/rules.mk,%,$(wildcard $(ROOT_DIR)/keyboards/*/*/rules.mk)) |
| 112 | |||
| 113 | list-keyboards: | ||
| 114 | echo $(KEYBOARDS) | ||
| 115 | exit 0 | ||
| 93 | 116 | ||
| 94 | #Compatibility with the old make variables, anything you specify directly on the command line | 117 | #Compatibility with the old make variables, anything you specify directly on the command line |
| 95 | # always overrides the detected folders | 118 | # always overrides the detected folders |
| 96 | ifdef keyboard | 119 | ifdef keyboard |
| 97 | KEYBOARD := $(keyboard) | 120 | KEYBOARD := $(keyboard) |
| 98 | endif | 121 | endif |
| 99 | ifdef sub | ||
| 100 | SUBPROJECT := $(sub) | ||
| 101 | endif | ||
| 102 | ifdef subproject | ||
| 103 | SUBPROJECT := $(subproject) | ||
| 104 | endif | ||
| 105 | ifdef keymap | 122 | ifdef keymap |
| 106 | KEYMAP := $(keymap) | 123 | KEYMAP := $(keymap) |
| 107 | endif | 124 | endif |
| 108 | 125 | ||
| 109 | # Uncomment these for debugging | 126 | # Uncomment these for debugging |
| 110 | #$(info Keyboard: $(KEYBOARD)) | 127 | # $(info Keyboard: $(KEYBOARD)) |
| 111 | #$(info Keymap: $(KEYMAP)) | 128 | # $(info Keymap: $(KEYMAP)) |
| 112 | #$(info Subproject: $(SUBPROJECT)) | 129 | # $(info Subproject: $(SUBPROJECT)) |
| 113 | #$(info Keyboards: $(KEYBOARDS)) | 130 | # $(info Keyboards: $(KEYBOARDS)) |
| 114 | 131 | ||
| 115 | 132 | ||
| 116 | # Set the default goal depending on where we are running make from | 133 | # Set the default goal depending on where we are running make from |
| 117 | # this handles the case where you run make without any arguments | 134 | # this handles the case where you run make without any arguments |
| 118 | .DEFAULT_GOAL := all | 135 | .DEFAULT_GOAL := all:all |
| 119 | ifneq ($(KEYMAP),) | 136 | ifneq ($(KEYMAP),) |
| 120 | ifeq ($(SUBPROJECT),) | 137 | .DEFAULT_GOAL := $(KEYBOARD):$(KEYMAP) |
| 121 | # Inside a keymap folder, just build the keymap, with the | ||
| 122 | # default subproject | ||
| 123 | .DEFAULT_GOAL := $(KEYBOARD)-$(KEYMAP) | ||
| 124 | else | ||
| 125 | # Inside a subproject keyamp folder, build the keymap | ||
| 126 | # for that subproject | ||
| 127 | .DEFAULT_GOAL := $(KEYBOARD)-$(SUBPROJECT)-$(KEYMAP) | ||
| 128 | endif | ||
| 129 | else ifneq ($(SUBPROJECT),) | ||
| 130 | # Inside a subproject folder, build all keymaps for that subproject | ||
| 131 | .DEFAULT_GOAL := $(KEYBOARD)-$(SUBPROJECT)-allkm | ||
| 132 | else ifneq ($(KEYBOARD),) | 138 | else ifneq ($(KEYBOARD),) |
| 133 | # Inside a keyboard folder, build all keymaps for all subprojects | 139 | # Inside a keyboard folder, build all keymaps for all subprojects |
| 134 | # Note that this is different from the old behaviour, which would | 140 | # Note that this is different from the old behaviour, which would |
| 135 | # build only the default keymap of the default keyboard | 141 | # build only the default keymap of the default keyboard |
| 136 | .DEFAULT_GOAL := $(KEYBOARD)-allsp-allkm | 142 | .DEFAULT_GOAL := $(KEYBOARD):all |
| 137 | endif | 143 | endif |
| 138 | 144 | ||
| 139 | 145 | ||
| 140 | # Compare the start of the RULE variable with the first argument($1) | 146 | # Compare the start of the RULE variable with the first argument($1) |
| 141 | # If the rules equals $1 or starts with $1-, RULE_FOUND is set to true | 147 | # If the rules equals $1 or starts with $1:, RULE_FOUND is set to true |
| 142 | # and $1 is removed from the RULE variable | 148 | # and $1 is removed from the RULE variable |
| 143 | # Otherwise the RULE_FOUND variable is set to false, and RULE left as it was | 149 | # Otherwise the RULE_FOUND variable is set to false, and RULE left as it was |
| 144 | # The function is a bit tricky, since there's no built in $(startswith) function | 150 | # The function is a bit tricky, since there's no built in $(startswith) function |
| @@ -147,10 +153,10 @@ define COMPARE_AND_REMOVE_FROM_RULE_HELPER | |||
| 147 | RULE:= | 153 | RULE:= |
| 148 | RULE_FOUND := true | 154 | RULE_FOUND := true |
| 149 | else | 155 | else |
| 150 | STARTDASH_REMOVED=$$(subst START$1-,,START$$(RULE)) | 156 | STARTCOLON_REMOVED=$$(subst START$1:,,START$$(RULE)) |
| 151 | ifneq ($$(STARTDASH_REMOVED),START$$(RULE)) | 157 | ifneq ($$(STARTCOLON_REMOVED),START$$(RULE)) |
| 152 | RULE_FOUND := true | 158 | RULE_FOUND := true |
| 153 | RULE := $$(STARTDASH_REMOVED) | 159 | RULE := $$(STARTCOLON_REMOVED) |
| 154 | else | 160 | else |
| 155 | RULE_FOUND := false | 161 | RULE_FOUND := false |
| 156 | endif | 162 | endif |
| @@ -229,14 +235,14 @@ define PARSE_ALL_IN_LIST | |||
| 229 | endef | 235 | endef |
| 230 | 236 | ||
| 231 | # The entry point for rule parsing | 237 | # The entry point for rule parsing |
| 232 | # parses a rule in the format <keyboard>-<subproject>-<keymap>-<target> | 238 | # parses a rule in the format <keyboard>:<keymap>:<target> |
| 233 | # but this particular function only deals with the first <keyboard> part | 239 | # but this particular function only deals with the first <keyboard> part |
| 234 | define PARSE_RULE | 240 | define PARSE_RULE |
| 235 | RULE := $1 | 241 | RULE := $1 |
| 236 | COMMANDS := | 242 | COMMANDS := |
| 237 | # If the rule starts with allkb, then continue the parsing from | 243 | # If the rule starts with all, then continue the parsing from |
| 238 | # PARSE_ALL_KEYBOARDS | 244 | # PARSE_ALL_KEYBOARDS |
| 239 | ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,allkb),true) | 245 | ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true) |
| 240 | $$(eval $$(call PARSE_ALL_KEYBOARDS)) | 246 | $$(eval $$(call PARSE_ALL_KEYBOARDS)) |
| 241 | else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,test),true) | 247 | else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,test),true) |
| 242 | $$(eval $$(call PARSE_TEST)) | 248 | $$(eval $$(call PARSE_TEST)) |
| @@ -250,35 +256,106 @@ define PARSE_RULE | |||
| 250 | $$(eval $$(call PARSE_KEYBOARD,$$(KEYBOARD))) | 256 | $$(eval $$(call PARSE_KEYBOARD,$$(KEYBOARD))) |
| 251 | else | 257 | else |
| 252 | $$(info make: *** No rule to make target '$1'. Stop.) | 258 | $$(info make: *** No rule to make target '$1'. Stop.) |
| 253 | # Notice the tab instead of spaces below! | 259 | $$(info |) |
| 254 | exit 1 | 260 | $$(info | QMK's make format recently changed to use folder locations and colons:) |
| 261 | $$(info | make project_folder:keymap[:target]) | ||
| 262 | $$(info | Examples:) | ||
| 263 | $$(info | make planck/rev4:default:dfu) | ||
| 264 | $$(info | make planck:default) | ||
| 265 | $$(info |) | ||
| 255 | endif | 266 | endif |
| 256 | endef | 267 | endef |
| 257 | 268 | ||
| 258 | # $1 = Keyboard | 269 | # $1 = Keyboard |
| 259 | # Parses a rule in the format <subproject>-<keymap>-<target> | 270 | # Parses a rule in the format <keymap>:<target> |
| 260 | # the keyboard is already known when entering this function | 271 | # the keyboard is already known when entering this function |
| 261 | define PARSE_KEYBOARD | 272 | define PARSE_KEYBOARD |
| 273 | # If we want to compile the default subproject, then we need to | ||
| 274 | # include the correct makefile to determine the actual name of it | ||
| 262 | CURRENT_KB := $1 | 275 | CURRENT_KB := $1 |
| 263 | # A subproject is any keyboard subfolder with a makefile | 276 | |
| 264 | SUBPROJECTS := $$(notdir $$(patsubst %/rules.mk,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/*/rules.mk))) | 277 | # KEYBOARD_FOLDERS := $$(subst /, , $(CURRENT_KB)) |
| 265 | # if the rule starts with allsp, then continue with looping over all subprojects | 278 | |
| 266 | ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,allsp),true) | 279 | DEFAULT_FOLDER := $$(CURRENT_KB) |
| 267 | $$(eval $$(call PARSE_ALL_SUBPROJECTS)) | 280 | |
| 268 | # A special case for matching the defaultsp (default subproject) | 281 | # We assume that every rules.mk will contain the full default value |
| 269 | else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,defaultsp),true) | 282 | $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk) |
| 270 | $$(eval $$(call PARSE_SUBPROJECT,defaultsp)) | 283 | ifneq ($$(DEFAULT_FOLDER),$$(CURRENT_KB)) |
| 271 | # If the rule starts with the name of a known subproject | 284 | $$(eval include $(ROOT_DIR)/keyboards/$$(DEFAULT_FOLDER)/rules.mk) |
| 272 | else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(SUBPROJECTS)),true) | 285 | endif |
| 273 | $$(eval $$(call PARSE_SUBPROJECT,$$(MATCHED_ITEM))) | 286 | CURRENT_KB := $$(DEFAULT_FOLDER) |
| 274 | # Try to use the SUBPROJECT variable, which is either determined by the | 287 | |
| 275 | # directory which invoked make, or passed as an argument to make | 288 | # 5/4/3/2/1 |
| 276 | else ifneq ($$(SUBPROJECT),) | 289 | KEYBOARD_FOLDER_PATH_1 := $$(CURRENT_KB) |
| 277 | $$(eval $$(call PARSE_SUBPROJECT,$$(SUBPROJECT))) | 290 | KEYBOARD_FOLDER_PATH_2 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_1))) |
| 278 | # If there's no matching subproject, we assume it's the default | 291 | KEYBOARD_FOLDER_PATH_3 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_2))) |
| 279 | # This will allow you to leave the subproject part of the target out | 292 | KEYBOARD_FOLDER_PATH_4 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_3))) |
| 293 | KEYBOARD_FOLDER_PATH_5 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_4))) | ||
| 294 | KEYBOARD_FOLDER_1 := $$(notdir $$(KEYBOARD_FOLDER_PATH_1)) | ||
| 295 | KEYBOARD_FOLDER_2 := $$(notdir $$(KEYBOARD_FOLDER_PATH_2)) | ||
| 296 | KEYBOARD_FOLDER_3 := $$(notdir $$(KEYBOARD_FOLDER_PATH_3)) | ||
| 297 | KEYBOARD_FOLDER_4 := $$(notdir $$(KEYBOARD_FOLDER_PATH_4)) | ||
| 298 | KEYBOARD_FOLDER_5 := $$(notdir $$(KEYBOARD_FOLDER_PATH_5)) | ||
| 299 | |||
| 300 | KEYMAPS := | ||
| 301 | # get a list of all keymaps | ||
| 302 | KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/keymaps/*/.))) | ||
| 303 | KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/keymaps/*/.))) | ||
| 304 | KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.))) | ||
| 305 | KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.))) | ||
| 306 | KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.))) | ||
| 307 | KEYMAPS := $$(sort $$(filter-out $$(KEYBOARD_FOLDER_1) $$(KEYBOARD_FOLDER_2) \ | ||
| 308 | $$(KEYBOARD_FOLDER_3) $$(KEYBOARD_FOLDER_4) $$(KEYBOARD_FOLDER_5), $$(KEYMAPS))) | ||
| 309 | |||
| 310 | KEYBOARD_LAYOUTS := | ||
| 311 | ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_5)/rules.mk)","") | ||
| 312 | LAYOUTS := | ||
| 313 | $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_5)/rules.mk) | ||
| 314 | KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS)) | ||
| 315 | endif | ||
| 316 | ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_4)/rules.mk)","") | ||
| 317 | LAYOUTS := | ||
| 318 | $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_4)/rules.mk) | ||
| 319 | KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS)) | ||
| 320 | endif | ||
| 321 | ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_3)/rules.mk)","") | ||
| 322 | LAYOUTS := | ||
| 323 | $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_3)/rules.mk) | ||
| 324 | KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS)) | ||
| 325 | endif | ||
| 326 | ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_2)/rules.mk)","") | ||
| 327 | LAYOUTS := | ||
| 328 | $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_2)/rules.mk) | ||
| 329 | KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS)) | ||
| 330 | endif | ||
| 331 | ifneq ("$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_1)/rules.mk)","") | ||
| 332 | LAYOUTS := | ||
| 333 | $$(eval include $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_1)/rules.mk) | ||
| 334 | KEYBOARD_LAYOUTS := $$(sort $$(LAYOUTS) $$(KEYBOARD_LAYOUTS)) | ||
| 335 | endif | ||
| 336 | |||
| 337 | LAYOUT_KEYMAPS := | ||
| 338 | $$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.))))) | ||
| 339 | |||
| 340 | KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS)) | ||
| 341 | |||
| 342 | # if the rule after removing the start of it is empty (we haven't specified a kemap or target) | ||
| 343 | # compile all the keymaps | ||
| 344 | ifeq ($$(RULE),) | ||
| 345 | $$(eval $$(call PARSE_ALL_KEYMAPS)) | ||
| 346 | # The same if all was specified | ||
| 347 | else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true) | ||
| 348 | $$(eval $$(call PARSE_ALL_KEYMAPS)) | ||
| 349 | # Try to match the specified keyamp with the list of known keymaps | ||
| 350 | else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYMAPS)),true) | ||
| 351 | $$(eval $$(call PARSE_KEYMAP,$$(MATCHED_ITEM))) | ||
| 352 | # Otherwise try to match the keymap from the current folder, or arguments to the make command | ||
| 353 | else ifneq ($$(KEYMAP),) | ||
| 354 | $$(eval $$(call PARSE_KEYMAP,$$(KEYMAP))) | ||
| 355 | # Otherwise, make all keymaps, again this is consistent with how it works without | ||
| 356 | # any arguments | ||
| 280 | else | 357 | else |
| 281 | $$(eval $$(call PARSE_SUBPROJECT,)) | 358 | $$(eval $$(call PARSE_ALL_KEYMAPS)) |
| 282 | endif | 359 | endif |
| 283 | endef | 360 | endef |
| 284 | 361 | ||
| @@ -291,86 +368,19 @@ endef | |||
| 291 | # $1 Subproject | 368 | # $1 Subproject |
| 292 | # When entering this, the keyboard and subproject are known, so now we need | 369 | # When entering this, the keyboard and subproject are known, so now we need |
| 293 | # to determine which keymaps are going to get compiled | 370 | # to determine which keymaps are going to get compiled |
| 294 | define PARSE_SUBPROJECT | 371 | # define PARSE_SUBPROJECT |
| 295 | # If we want to compile the default subproject, then we need to | ||
| 296 | # include the correct makefile to determine the actual name of it | ||
| 297 | CURRENT_SP := $1 | ||
| 298 | ifeq ($$(CURRENT_SP),) | ||
| 299 | CURRENT_SP := defaultsp | ||
| 300 | endif | ||
| 301 | ifeq ($$(CURRENT_SP),defaultsp) | ||
| 302 | SUBPROJECT_DEFAULT= | ||
| 303 | ifneq ("$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/subproject.mk)","") | ||
| 304 | $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/subproject.mk) | ||
| 305 | endif | ||
| 306 | CURRENT_SP := $$(SUBPROJECT_DEFAULT) | ||
| 307 | endif | ||
| 308 | # If current subproject is empty (the default was not defined), and we have a list of subproject | ||
| 309 | # then make all of them | ||
| 310 | ifeq ($$(CURRENT_SP),) | ||
| 311 | ifneq ($$(SUBPROJECTS),) | ||
| 312 | CURRENT_SP := allsp | ||
| 313 | endif | ||
| 314 | endif | ||
| 315 | # The special allsp is handled later | ||
| 316 | ifneq ($$(CURRENT_SP),allsp) | ||
| 317 | # get a list of all keymaps | ||
| 318 | KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/keymaps/*/.))) | ||
| 319 | LAYOUTS := | ||
| 320 | $$(eval -include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk) | ||
| 321 | KEYBOARD_LAYOUTS := $$(LAYOUTS) | ||
| 322 | ifneq ($$(CURRENT_SP),) | ||
| 323 | # if the subproject is defined, then also look for keymaps inside the subproject folder | ||
| 324 | SP_KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/$$(CURRENT_SP)/keymaps/*/.))) | ||
| 325 | KEYMAPS := $$(sort $$(KEYMAPS) $$(SP_KEYMAPS)) | ||
| 326 | # $$(eval -include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/$$(CURRENT_SP)/rules.mk) | ||
| 327 | # KEYBOARD_LAYOUTS := $$(sort $$(KEYBOARD_LAYOUTS) $$(LAYOUTS)) | ||
| 328 | endif | ||
| 329 | 372 | ||
| 330 | LAYOUT_KEYMAPS := | 373 | # endef |
| 331 | $$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.))))) | ||
| 332 | |||
| 333 | KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS)) | ||
| 334 | # if the rule after removing the start of it is empty (we haven't specified a kemap or target) | ||
| 335 | # compile all the keymaps | ||
| 336 | ifeq ($$(RULE),) | ||
| 337 | $$(eval $$(call PARSE_ALL_KEYMAPS)) | ||
| 338 | # The same if allkm was specified | ||
| 339 | else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,allkm),true) | ||
| 340 | $$(eval $$(call PARSE_ALL_KEYMAPS)) | ||
| 341 | # Try to match the specified keyamp with the list of known keymaps | ||
| 342 | else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYMAPS)),true) | ||
| 343 | $$(eval $$(call PARSE_KEYMAP,$$(MATCHED_ITEM))) | ||
| 344 | # Otherwise try to match the keymap from the current folder, or arguments to the make command | ||
| 345 | else ifneq ($$(KEYMAP),) | ||
| 346 | $$(eval $$(call PARSE_KEYMAP,$$(KEYMAP))) | ||
| 347 | # No matching keymap found, so we assume that the rest of the rule is the target | ||
| 348 | # If we haven't been able to parse out a subproject, then make all of them | ||
| 349 | # This is consistent with running make without any arguments from the keyboard | ||
| 350 | # folder | ||
| 351 | else ifeq ($1,) | ||
| 352 | $$(eval $$(call PARSE_ALL_SUBPROJECTS)) | ||
| 353 | # Otherwise, make all keymaps, again this is consistent with how it works without | ||
| 354 | # any arguments | ||
| 355 | else | ||
| 356 | $$(eval $$(call PARSE_ALL_KEYMAPS)) | ||
| 357 | endif | ||
| 358 | else | ||
| 359 | # As earlier mentioned when allsb is specified, we call our self recursively | ||
| 360 | # for all of the subprojects | ||
| 361 | $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_SUBPROJECT,$(SUBPROJECTS))) | ||
| 362 | endif | ||
| 363 | endef | ||
| 364 | 374 | ||
| 365 | # If we want to parse all subprojects, but the keyboard doesn't have any, | 375 | # If we want to parse all subprojects, but the keyboard doesn't have any, |
| 366 | # then use defaultsp instead | 376 | # then use defaultsp instead |
| 367 | define PARSE_ALL_SUBPROJECTS | 377 | # define PARSE_ALL_SUBPROJECTS |
| 368 | ifeq ($$(SUBPROJECTS),) | 378 | # ifeq ($$(SUBPROJECTS),) |
| 369 | $$(eval $$(call PARSE_SUBPROJECT,defaultsp)) | 379 | # $$(eval $$(call PARSE_SUBPROJECT,defaultsp)) |
| 370 | else | 380 | # else |
| 371 | $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_SUBPROJECT,$$(SUBPROJECTS))) | 381 | # $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_SUBPROJECT,$$(SUBPROJECTS))) |
| 372 | endif | 382 | # endif |
| 373 | endef | 383 | # endef |
| 374 | 384 | ||
| 375 | # $1 Keymap | 385 | # $1 Keymap |
| 376 | # This is the meat of compiling a keyboard, when entering this, everything is known | 386 | # This is the meat of compiling a keyboard, when entering this, everything is known |
| @@ -380,21 +390,18 @@ endef | |||
| 380 | define PARSE_KEYMAP | 390 | define PARSE_KEYMAP |
| 381 | CURRENT_KM = $1 | 391 | CURRENT_KM = $1 |
| 382 | # The rest of the rule is the target | 392 | # The rest of the rule is the target |
| 383 | # Remove the leading "-" from the target, as it acts as a separator | 393 | # Remove the leading ":" from the target, as it acts as a separator |
| 384 | MAKE_TARGET := $$(patsubst -%,%,$$(RULE)) | 394 | MAKE_TARGET := $$(patsubst :%,%,$$(RULE)) |
| 385 | # We need to generate an unique indentifer to append to the COMMANDS list | 395 | # We need to generate an unique indentifer to append to the COMMANDS list |
| 386 | COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM) | 396 | CURRENT_KB_UNDER := $$(subst /,_,$$(CURRENT_KB)) |
| 397 | COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB_UNDER)_KEYMAP_$$(CURRENT_KM) | ||
| 387 | # If we are compiling a keyboard without a subproject, we want to display just the name | 398 | # If we are compiling a keyboard without a subproject, we want to display just the name |
| 388 | # of the keyboard, otherwise keyboard/subproject | 399 | # of the keyboard, otherwise keyboard/subproject |
| 389 | ifeq ($$(CURRENT_SP),) | 400 | KB_SP := $$(CURRENT_KB) |
| 390 | KB_SP := $(CURRENT_KB) | ||
| 391 | else | ||
| 392 | KB_SP := $(CURRENT_KB)/$$(CURRENT_SP) | ||
| 393 | endif | ||
| 394 | # Format it in bold | 401 | # Format it in bold |
| 395 | KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR) | 402 | KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR) |
| 396 | # Specify the variables that we are passing forward to submake | 403 | # Specify the variables that we are passing forward to submake |
| 397 | MAKE_VARS := KEYBOARD=$$(CURRENT_KB) SUBPROJECT=$$(CURRENT_SP) KEYMAP=$$(CURRENT_KM) | 404 | MAKE_VARS := KEYBOARD=$$(CURRENT_KB) KEYMAP=$$(CURRENT_KM) |
| 398 | # And the first part of the make command | 405 | # And the first part of the make command |
| 399 | MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_keyboard.mk $$(MAKE_TARGET) | 406 | MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_keyboard.mk $$(MAKE_TARGET) |
| 400 | # The message to display | 407 | # The message to display |
| @@ -455,8 +462,8 @@ endef | |||
| 455 | 462 | ||
| 456 | define PARSE_TEST | 463 | define PARSE_TEST |
| 457 | TESTS := | 464 | TESTS := |
| 458 | TEST_NAME := $$(firstword $$(subst -, ,$$(RULE))) | 465 | TEST_NAME := $$(firstword $$(subst :, ,$$(RULE))) |
| 459 | TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME)-,,$$(RULE))) | 466 | TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME):,,$$(RULE))) |
| 460 | ifeq ($$(TEST_NAME),all) | 467 | ifeq ($$(TEST_NAME),all) |
| 461 | MATCHED_TESTS := $$(TEST_LIST) | 468 | MATCHED_TESTS := $$(TEST_LIST) |
| 462 | else | 469 | else |
| @@ -504,11 +511,6 @@ if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi; | |||
| 504 | 511 | ||
| 505 | endef | 512 | endef |
| 506 | 513 | ||
| 507 | # Allow specifying just the subproject, in the keyboard directory, which will compile all keymaps | ||
| 508 | SUBPROJECTS := $(notdir $(patsubst %/rules.mk,%,$(wildcard ./*/rules.mk))) | ||
| 509 | .PHONY: $(SUBPROJECTS) | ||
| 510 | $(SUBPROJECTS): %: %-allkm | ||
| 511 | |||
| 512 | # Let's match everything, we handle all the rule parsing ourselves | 514 | # Let's match everything, we handle all the rule parsing ourselves |
| 513 | .PHONY: % | 515 | .PHONY: % |
| 514 | %: | 516 | %: |
| @@ -539,22 +541,24 @@ endif | |||
| 539 | $(foreach TEST,$(TESTS),$(RUN_TEST)) | 541 | $(foreach TEST,$(TESTS),$(RUN_TEST)) |
| 540 | if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi; | 542 | if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi; |
| 541 | 543 | ||
| 544 | # These no longer work because of the colon system | ||
| 545 | |||
| 542 | # All should compile everything | 546 | # All should compile everything |
| 543 | .PHONY: all | 547 | # .PHONY: all |
| 544 | all: all-keyboards test-all | 548 | # all: all-keyboards test-all |
| 545 | 549 | ||
| 546 | # Define some shortcuts, mostly for compatibility with the old syntax | 550 | # Define some shortcuts, mostly for compatibility with the old syntax |
| 547 | .PHONY: all-keyboards | 551 | # .PHONY: all-keyboards |
| 548 | all-keyboards: allkb-allsp-allkm | 552 | # all-keyboards: all\:all\:all |
| 549 | 553 | ||
| 550 | .PHONY: all-keyboards-defaults | 554 | # .PHONY: all-keyboards-defaults |
| 551 | all-keyboards-defaults: allkb-allsp-default | 555 | # all-keyboards-defaults: all\:default |
| 552 | 556 | ||
| 553 | .PHONY: test | 557 | # .PHONY: test |
| 554 | test: test-all | 558 | # test: test-all |
| 555 | 559 | ||
| 556 | .PHONY: test-clean | 560 | # .PHONY: test-clean |
| 557 | test-clean: test-all-clean | 561 | # test-clean: test-all-clean |
| 558 | 562 | ||
| 559 | lib/%: | 563 | lib/%: |
| 560 | git submodule sync $? | 564 | git submodule sync $? |
