Peter's keyboard firmware (QMK) https://qmk.fm/
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

build_keyboard.mk 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. ifndef VERBOSE
  2. .SILENT:
  3. endif
  4. .DEFAULT_GOAL := all
  5. include common.mk
  6. # 5/4/3/2/1
  7. KEYBOARD_FOLDER_PATH_1 := $(KEYBOARD)
  8. KEYBOARD_FOLDER_PATH_2 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_1)))
  9. KEYBOARD_FOLDER_PATH_3 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_2)))
  10. KEYBOARD_FOLDER_PATH_4 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_3)))
  11. KEYBOARD_FOLDER_PATH_5 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_4)))
  12. KEYBOARD_FOLDER_1 := $(notdir $(KEYBOARD_FOLDER_PATH_1))
  13. KEYBOARD_FOLDER_2 := $(notdir $(KEYBOARD_FOLDER_PATH_2))
  14. KEYBOARD_FOLDER_3 := $(notdir $(KEYBOARD_FOLDER_PATH_3))
  15. KEYBOARD_FOLDER_4 := $(notdir $(KEYBOARD_FOLDER_PATH_4))
  16. KEYBOARD_FOLDER_5 := $(notdir $(KEYBOARD_FOLDER_PATH_5))
  17. KEYBOARD_FILESAFE := $(subst /,_,$(KEYBOARD))
  18. TARGET ?= $(KEYBOARD_FILESAFE)_$(KEYMAP)
  19. KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD_FILESAFE)
  20. # Force expansion
  21. TARGET := $(TARGET)
  22. MASTER ?= left
  23. ifdef master
  24. MASTER = $(master)
  25. endif
  26. ifeq ($(MASTER),right)
  27. OPT_DEFS += -DMASTER_IS_ON_RIGHT
  28. else
  29. ifneq ($(MASTER),left)
  30. $(error MASTER does not have a valid value(left/right))
  31. endif
  32. endif
  33. KEYBOARD_PATHS :=
  34. KEYBOARD_PATH_1 := keyboards/$(KEYBOARD_FOLDER_PATH_1)
  35. KEYBOARD_PATH_2 := keyboards/$(KEYBOARD_FOLDER_PATH_2)
  36. KEYBOARD_PATH_3 := keyboards/$(KEYBOARD_FOLDER_PATH_3)
  37. KEYBOARD_PATH_4 := keyboards/$(KEYBOARD_FOLDER_PATH_4)
  38. KEYBOARD_PATH_5 := keyboards/$(KEYBOARD_FOLDER_PATH_5)
  39. ifneq ("$(wildcard $(KEYBOARD_PATH_5)/rules.mk)","")
  40. KEYBOARD_PATHS += $(KEYBOARD_PATH_5)
  41. include $(KEYBOARD_PATH_5)/rules.mk
  42. endif
  43. ifneq ("$(wildcard $(KEYBOARD_PATH_4)/rules.mk)","")
  44. KEYBOARD_PATHS += $(KEYBOARD_PATH_4)
  45. include $(KEYBOARD_PATH_4)/rules.mk
  46. endif
  47. ifneq ("$(wildcard $(KEYBOARD_PATH_3)/rules.mk)","")
  48. KEYBOARD_PATHS += $(KEYBOARD_PATH_3)
  49. include $(KEYBOARD_PATH_3)/rules.mk
  50. endif
  51. ifneq ("$(wildcard $(KEYBOARD_PATH_2)/rules.mk)","")
  52. KEYBOARD_PATHS += $(KEYBOARD_PATH_2)
  53. include $(KEYBOARD_PATH_2)/rules.mk
  54. endif
  55. ifneq ("$(wildcard $(KEYBOARD_PATH_1)/rules.mk)","")
  56. KEYBOARD_PATHS += $(KEYBOARD_PATH_1)
  57. include $(KEYBOARD_PATH_1)/rules.mk
  58. endif
  59. KEYBOARD_SRC :=
  60. KEYBOARD_C_1 := $(KEYBOARD_PATH_1)/$(KEYBOARD_FOLDER_1).c
  61. KEYBOARD_C_2 := $(KEYBOARD_PATH_2)/$(KEYBOARD_FOLDER_2).c
  62. KEYBOARD_C_3 := $(KEYBOARD_PATH_3)/$(KEYBOARD_FOLDER_3).c
  63. KEYBOARD_C_4 := $(KEYBOARD_PATH_4)/$(KEYBOARD_FOLDER_4).c
  64. KEYBOARD_C_5 := $(KEYBOARD_PATH_5)/$(KEYBOARD_FOLDER_5).c
  65. ifneq ("$(wildcard $(KEYBOARD_C_5))","")
  66. KEYBOARD_SRC += $(KEYBOARD_C_5)
  67. endif
  68. ifneq ("$(wildcard $(KEYBOARD_C_4))","")
  69. KEYBOARD_SRC += $(KEYBOARD_C_4)
  70. endif
  71. ifneq ("$(wildcard $(KEYBOARD_C_3))","")
  72. KEYBOARD_SRC += $(KEYBOARD_C_3)
  73. endif
  74. ifneq ("$(wildcard $(KEYBOARD_C_2))","")
  75. KEYBOARD_SRC += $(KEYBOARD_C_2)
  76. endif
  77. ifneq ("$(wildcard $(KEYBOARD_C_1))","")
  78. KEYBOARD_SRC += $(KEYBOARD_C_1)
  79. endif
  80. OPT_DEFS += -DKEYBOARD_$(KEYBOARD_FILESAFE)
  81. # We can assume a ChibiOS target When MCU_FAMILY is defined , since it's not used for LUFA
  82. ifdef MCU_FAMILY
  83. PLATFORM=CHIBIOS
  84. else
  85. PLATFORM=AVR
  86. endif
  87. ifeq ($(PLATFORM),CHIBIOS)
  88. include $(TMK_PATH)/protocol/chibios.mk
  89. include $(TMK_PATH)/chibios.mk
  90. OPT_OS = chibios
  91. ifneq ("$(wildcard $(KEYBOARD_PATH_5)/bootloader_defs.h)","")
  92. OPT_DEFS += -include $(KEYBOARD_PATH_5)/bootloader_defs.h
  93. else ifneq ("$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/bootloader_defs.h)","")
  94. OPT_DEFS += -include $(KEYBOARD_PATH_5)/boards/$(BOARD)/bootloader_defs.h
  95. else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/bootloader_defs.h)","")
  96. OPT_DEFS += -include $(KEYBOARD_PATH_4)/bootloader_defs.h
  97. else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/boards/$(BOARD)/bootloader_defs.h)","")
  98. OPT_DEFS += -include $(KEYBOARD_PATH_4)/boards/$(BOARD)/bootloader_defs.h
  99. else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/bootloader_defs.h)","")
  100. OPT_DEFS += -include $(KEYBOARD_PATH_3)/bootloader_defs.h
  101. else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/boards/$(BOARD)/bootloader_defs.h)","")
  102. OPT_DEFS += -include $(KEYBOARD_PATH_3)/boards/$(BOARD)/bootloader_defs.h
  103. else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/bootloader_defs.h)","")
  104. OPT_DEFS += -include $(KEYBOARD_PATH_2)/bootloader_defs.h
  105. else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/boards/$(BOARD)/bootloader_defs.h)","")
  106. OPT_DEFS += -include $(KEYBOARD_PATH_2)/boards/$(BOARD)/bootloader_defs.h
  107. else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/bootloader_defs.h)","")
  108. OPT_DEFS += -include $(KEYBOARD_PATH_1)/bootloader_defs.h
  109. else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/boards/$(BOARD)/bootloader_defs.h)","")
  110. OPT_DEFS += -include $(KEYBOARD_PATH_1)/boards/$(BOARD)/bootloader_defs.h
  111. endif
  112. endif
  113. CONFIG_H :=
  114. ifneq ("$(wildcard $(KEYBOARD_PATH_5)/config.h)","")
  115. CONFIG_H += $(KEYBOARD_PATH_5)/config.h
  116. endif
  117. ifneq ("$(wildcard $(KEYBOARD_PATH_4)/config.h)","")
  118. CONFIG_H += $(KEYBOARD_PATH_4)/config.h
  119. endif
  120. ifneq ("$(wildcard $(KEYBOARD_PATH_3)/config.h)","")
  121. CONFIG_H += $(KEYBOARD_PATH_3)/config.h
  122. endif
  123. ifneq ("$(wildcard $(KEYBOARD_PATH_2)/config.h)","")
  124. CONFIG_H += $(KEYBOARD_PATH_2)/config.h
  125. endif
  126. ifneq ("$(wildcard $(KEYBOARD_PATH_1)/config.h)","")
  127. CONFIG_H += $(KEYBOARD_PATH_1)/config.h
  128. endif
  129. # Save the defines and includes here, so we don't include any keymap specific ones
  130. PROJECT_DEFS := $(OPT_DEFS)
  131. PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(KEYBOARD_PATHS)
  132. PROJECT_CONFIG := $(CONFIG_H)
  133. MAIN_KEYMAP_PATH_1 := $(KEYBOARD_PATH_1)/keymaps/$(KEYMAP)
  134. MAIN_KEYMAP_PATH_2 := $(KEYBOARD_PATH_2)/keymaps/$(KEYMAP)
  135. MAIN_KEYMAP_PATH_3 := $(KEYBOARD_PATH_3)/keymaps/$(KEYMAP)
  136. MAIN_KEYMAP_PATH_4 := $(KEYBOARD_PATH_4)/keymaps/$(KEYMAP)
  137. MAIN_KEYMAP_PATH_5 := $(KEYBOARD_PATH_5)/keymaps/$(KEYMAP)
  138. ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","")
  139. -include $(MAIN_KEYMAP_PATH_5)/rules.mk
  140. KEYMAP_C := $(MAIN_KEYMAP_PATH_5)/keymap.c
  141. KEYMAP_PATH := $(MAIN_KEYMAP_PATH_5)
  142. else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_4)/keymap.c)","")
  143. -include $(MAIN_KEYMAP_PATH_4)/rules.mk
  144. KEYMAP_C := $(MAIN_KEYMAP_PATH_4)/keymap.c
  145. KEYMAP_PATH := $(MAIN_KEYMAP_PATH_4)
  146. else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_3)/keymap.c)","")
  147. -include $(MAIN_KEYMAP_PATH_3)/rules.mk
  148. KEYMAP_C := $(MAIN_KEYMAP_PATH_3)/keymap.c
  149. KEYMAP_PATH := $(MAIN_KEYMAP_PATH_3)
  150. else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_2)/keymap.c)","")
  151. -include $(MAIN_KEYMAP_PATH_2)/rules.mk
  152. KEYMAP_C := $(MAIN_KEYMAP_PATH_2)/keymap.c
  153. KEYMAP_PATH := $(MAIN_KEYMAP_PATH_2)
  154. else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.c)","")
  155. -include $(MAIN_KEYMAP_PATH_1)/rules.mk
  156. KEYMAP_C := $(MAIN_KEYMAP_PATH_1)/keymap.c
  157. KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
  158. else ifneq ($(LAYOUTS),)
  159. include build_layout.mk
  160. else
  161. $(error Could not find keymap)
  162. # this state should never be reached
  163. endif
  164. # Object files directory
  165. # To put object files in current directory, use a dot (.), do NOT make
  166. # this an empty or blank macro!
  167. KEYMAP_OUTPUT := $(BUILD_DIR)/obj_$(TARGET)
  168. ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
  169. CONFIG_H += $(KEYMAP_PATH)/config.h
  170. endif
  171. # # project specific files
  172. SRC += $(KEYBOARD_SRC) \
  173. $(KEYMAP_C) \
  174. $(QUANTUM_SRC)
  175. # Optimize size but this may cause error "relocation truncated to fit"
  176. #EXTRALDFLAGS = -Wl,--relax
  177. # Search Path
  178. VPATH += $(KEYMAP_PATH)
  179. VPATH += $(KEYBOARD_PATHS)
  180. VPATH += $(COMMON_VPATH)
  181. include common_features.mk
  182. include $(TMK_PATH)/protocol.mk
  183. include $(TMK_PATH)/common.mk
  184. SRC += $(TMK_COMMON_SRC)
  185. OPT_DEFS += $(TMK_COMMON_DEFS)
  186. EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS)
  187. ifeq ($(PLATFORM),AVR)
  188. ifeq ($(strip $(PROTOCOL)), VUSB)
  189. include $(TMK_PATH)/protocol/vusb.mk
  190. else
  191. include $(TMK_PATH)/protocol/lufa.mk
  192. endif
  193. include $(TMK_PATH)/avr.mk
  194. endif
  195. ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
  196. VISUALIZER_DIR = $(QUANTUM_DIR)/visualizer
  197. VISUALIZER_PATH = $(QUANTUM_PATH)/visualizer
  198. include $(VISUALIZER_PATH)/visualizer.mk
  199. endif
  200. OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
  201. $(KEYMAP_OUTPUT)_SRC := $(SRC)
  202. $(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) $(GFXDEFS) \
  203. -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(KEYBOARD_FOLDER_1).h\" -DQMK_KEYBOARD_CONFIG_H=\"$(KEYBOARD_PATH_1)/config.h\" \
  204. -DQMK_KEYMAP=\"$(KEYMAP)\" -DQMK_KEYMAP_H=\"$(KEYMAP).h\" -DQMK_KEYMAP_CONFIG_H=\"$(KEYMAP_PATH)/config.h\" \
  205. -DQMK_SUBPROJECT -DQMK_SUBPROJECT_H -DQMK_SUBPROJECT_CONFIG_H
  206. $(KEYMAP_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS)
  207. $(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H)
  208. $(KEYBOARD_OUTPUT)_SRC := $(CHIBISRC) $(GFXSRC)
  209. $(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS) $(GFXDEFS)
  210. $(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC) $(GFXINC)
  211. $(KEYBOARD_OUTPUT)_CONFIG := $(PROJECT_CONFIG)
  212. # Default target.
  213. all: build sizeafter
  214. # Change the build target to build a HEX file or a library.
  215. build: elf hex
  216. #build: elf hex eep lss sym
  217. #build: lib
  218. include $(TMK_PATH)/rules.mk