diff options
| -rw-r--r-- | build_keyboard.mk | 19 | ||||
| -rw-r--r-- | docs/hardware_keyboard_guidelines.md | 28 |
2 files changed, 47 insertions, 0 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk index 37fa6852f..420643c3e 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk | |||
| @@ -115,6 +115,7 @@ include $(INFO_RULES_MK) | |||
| 115 | # Check for keymap.json first, so we can regenerate keymap.c | 115 | # Check for keymap.json first, so we can regenerate keymap.c |
| 116 | include build_json.mk | 116 | include build_json.mk |
| 117 | 117 | ||
| 118 | # Pull in keymap level rules.mk | ||
| 118 | ifeq ("$(wildcard $(KEYMAP_PATH))", "") | 119 | ifeq ("$(wildcard $(KEYMAP_PATH))", "") |
| 119 | # Look through the possible keymap folders until we find a matching keymap.c | 120 | # Look through the possible keymap folders until we find a matching keymap.c |
| 120 | ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","") | 121 | ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","") |
| @@ -345,6 +346,7 @@ ifeq ("$(USER_NAME)","") | |||
| 345 | endif | 346 | endif |
| 346 | USER_PATH := users/$(USER_NAME) | 347 | USER_PATH := users/$(USER_NAME) |
| 347 | 348 | ||
| 349 | # Pull in user level rules.mk | ||
| 348 | -include $(USER_PATH)/rules.mk | 350 | -include $(USER_PATH)/rules.mk |
| 349 | ifneq ("$(wildcard $(USER_PATH)/config.h)","") | 351 | ifneq ("$(wildcard $(USER_PATH)/config.h)","") |
| 350 | CONFIG_H += $(USER_PATH)/config.h | 352 | CONFIG_H += $(USER_PATH)/config.h |
| @@ -356,6 +358,23 @@ endif | |||
| 356 | # Disable features that a keyboard doesn't support | 358 | # Disable features that a keyboard doesn't support |
| 357 | -include disable_features.mk | 359 | -include disable_features.mk |
| 358 | 360 | ||
| 361 | # Pull in post_rules.mk files from all our subfolders | ||
| 362 | ifneq ("$(wildcard $(KEYBOARD_PATH_1)/post_rules.mk)","") | ||
| 363 | include $(KEYBOARD_PATH_1)/post_rules.mk | ||
| 364 | endif | ||
| 365 | ifneq ("$(wildcard $(KEYBOARD_PATH_2)/post_rules.mk)","") | ||
| 366 | include $(KEYBOARD_PATH_2)/post_rules.mk | ||
| 367 | endif | ||
| 368 | ifneq ("$(wildcard $(KEYBOARD_PATH_3)/post_rules.mk)","") | ||
| 369 | include $(KEYBOARD_PATH_3)/post_rules.mk | ||
| 370 | endif | ||
| 371 | ifneq ("$(wildcard $(KEYBOARD_PATH_4)/post_rules.mk)","") | ||
| 372 | include $(KEYBOARD_PATH_4)/post_rules.mk | ||
| 373 | endif | ||
| 374 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_rules.mk)","") | ||
| 375 | include $(KEYBOARD_PATH_5)/post_rules.mk | ||
| 376 | endif | ||
| 377 | |||
| 359 | ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") | 378 | ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") |
| 360 | CONFIG_H += $(KEYMAP_PATH)/config.h | 379 | CONFIG_H += $(KEYMAP_PATH)/config.h |
| 361 | endif | 380 | endif |
diff --git a/docs/hardware_keyboard_guidelines.md b/docs/hardware_keyboard_guidelines.md index 7630b44e0..17be7ee6a 100644 --- a/docs/hardware_keyboard_guidelines.md +++ b/docs/hardware_keyboard_guidelines.md | |||
| @@ -144,10 +144,38 @@ The `rules.mk` file can also be placed in a sub-folder, and its reading order is | |||
| 144 | * `keyboards/top_folder/sub_1/sub_2/sub_3/sub_4/rules.mk` | 144 | * `keyboards/top_folder/sub_1/sub_2/sub_3/sub_4/rules.mk` |
| 145 | * `keyboards/top_folder/keymaps/a_keymap/rules.mk` | 145 | * `keyboards/top_folder/keymaps/a_keymap/rules.mk` |
| 146 | * `users/a_user_folder/rules.mk` | 146 | * `users/a_user_folder/rules.mk` |
| 147 | * `keyboards/top_folder/sub_1/sub_2/sub_3/sub_4/post_rules.mk` | ||
| 148 | * `keyboards/top_folder/sub_1/sub_2/sub_3/post_rules.mk` | ||
| 149 | * `keyboards/top_folder/sub_1/sub_2/post_rules.mk` | ||
| 150 | * `keyboards/top_folder/sub_1/post_rules.mk` | ||
| 151 | * `keyboards/top_folder/post_rules.mk` | ||
| 147 | * `common_features.mk` | 152 | * `common_features.mk` |
| 148 | 153 | ||
| 149 | Many of the settings written in the `rules.mk` file are interpreted by `common_features.mk`, which sets the necessary source files and compiler options. | 154 | Many of the settings written in the `rules.mk` file are interpreted by `common_features.mk`, which sets the necessary source files and compiler options. |
| 150 | 155 | ||
| 156 | The `post_rules.mk` file can interpret `features` of a keyboard-level before `common_features.mk`. For example, when your designed keyboard has the option to implement backlighting or underglow using rgblight.c, writing the following in the `post_rules.mk` makes it easier for the user to configure the `rules.mk`. | ||
| 157 | |||
| 158 | * `keyboards/top_folder/keymaps/a_keymap/rules.mk` | ||
| 159 | ```makefile | ||
| 160 | # Please set the following according to the selection of the hardware implementation option. | ||
| 161 | RGBLED_OPTION_TYPE = backlight ## none, backlight or underglow | ||
| 162 | ``` | ||
| 163 | * `keyboards/top_folder/post_rules.mk` | ||
| 164 | ```makefile | ||
| 165 | ifeq ($(filter $(strip $(RGBLED_OPTION_TYPE))x, nonex backlightx underglowx x),) | ||
| 166 | $(error unknown RGBLED_OPTION_TYPE value "$(RGBLED_OPTION_TYPE)") | ||
| 167 | endif | ||
| 168 | |||
| 169 | ifeq ($(strip $(RGBLED_OPTION_TYPE)),backlight) | ||
| 170 | RGBLIGHT_ENABLE = yes | ||
| 171 | OPT_DEFS += -DRGBLED_NUM=30 | ||
| 172 | endif | ||
| 173 | ifeq ($(strip $(RGBLED_OPTION_TYPE)),underglow) | ||
| 174 | RGBLIGHT_ENABLE = yes | ||
| 175 | OPT_DEFS += -DRGBLED_NUM=6 | ||
| 176 | endif | ||
| 177 | ``` | ||
| 178 | |||
| 151 | ?> See `build_keyboard.mk` and `common_features.mk` for more details. | 179 | ?> See `build_keyboard.mk` and `common_features.mk` for more details. |
| 152 | 180 | ||
| 153 | ### `<keyboard_name.c>` | 181 | ### `<keyboard_name.c>` |
