10 TARGET ?= $(KEYBOARD)_$(SUBPROJECT)_$(KEYMAP)
11 KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD)_$(SUBPROJECT)
13 TARGET ?= $(KEYBOARD)_$(KEYMAP)
14 KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD)
26 ifeq ($(MASTER),right)
27 OPT_DEFS += -DMASTER_IS_ON_RIGHT
29 ifneq ($(MASTER),left)
30 $(error MASTER does not have a valid value(left/right))
34 KEYBOARD_PATH := keyboards/$(KEYBOARD)
35 KEYBOARD_C := $(KEYBOARD_PATH)/$(KEYBOARD).c
37 ifneq ("$(wildcard $(KEYBOARD_C))","")
38 include $(KEYBOARD_PATH)/rules.mk
40 $(error "$(KEYBOARD_C)" does not exist)
43 ifneq ($(SUBPROJECT),)
44 SUBPROJECT_PATH := keyboards/$(KEYBOARD)/$(SUBPROJECT)
45 SUBPROJECT_C := $(SUBPROJECT_PATH)/$(SUBPROJECT).c
46 ifneq ("$(wildcard $(SUBPROJECT_C))","")
47 OPT_DEFS += -DSUBPROJECT_$(SUBPROJECT)
48 include $(SUBPROJECT_PATH)/rules.mk
50 $(error "$(SUBPROJECT_PATH)/$(SUBPROJECT).c" does not exist)
54 # We can assume a ChibiOS target When MCU_FAMILY is defined, since it's not used for LUFA
61 ifeq ($(PLATFORM),CHIBIOS)
62 include $(TMK_PATH)/protocol/chibios.mk
63 include $(TMK_PATH)/chibios.mk
65 ifneq ("$(wildcard $(SUBPROJECT_PATH)/bootloader_defs.h)","")
66 OPT_DEFS += -include $(SUBPROJECT_PATH)/bootloader_defs.h
67 else ifneq ("$(wildcard $(SUBPROJECT_PATH)/boards/$(BOARD)/bootloader_defs.h)","")
68 OPT_DEFS += -include $(SUBPROJECT_PATH)/boards/$(BOARD)/bootloader_defs.h
69 else ifneq ("$(wildcard $(KEYBOARD_PATH)/bootloader_defs.h)","")
70 OPT_DEFS += -include $(KEYBOARD_PATH)/bootloader_defs.h
71 else ifneq ("$(wildcard $(KEYBOARD_PATH)/boards/$(BOARD)/bootloader_defs.h)","")
72 OPT_DEFS += -include $(KEYBOARD_PATH)/boards/$(BOARD)/bootloader_defs.h
76 CONFIG_H = $(KEYBOARD_PATH)/config.h
77 ifneq ($(SUBPROJECT),)
78 ifneq ("$(wildcard $(SUBPROJECT_C))","")
79 CONFIG_H = $(SUBPROJECT_PATH)/config.h
83 # Save the defines and includes here, so we don't include any keymap specific ones
84 PROJECT_DEFS := $(OPT_DEFS)
85 PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(SUBPROJECT_PATH) $(KEYBOARD_PATH)
86 PROJECT_CONFIG := $(CONFIG_H)
88 MAIN_KEYMAP_PATH := $(KEYBOARD_PATH)/keymaps/$(KEYMAP)
89 MAIN_KEYMAP_C := $(MAIN_KEYMAP_PATH)/keymap.c
90 SUBPROJ_KEYMAP_PATH := $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)
91 SUBPROJ_KEYMAP_C := $(SUBPROJ_KEYMAP_PATH)/keymap.c
92 ifneq ("$(wildcard $(SUBPROJ_KEYMAP_C))","")
93 -include $(SUBPROJ_KEYMAP_PATH)/Makefile
94 KEYMAP_C := $(SUBPROJ_KEYMAP_C)
95 KEYMAP_PATH := $(SUBPROJ_KEYMAP_PATH)
96 else ifneq ("$(wildcard $(MAIN_KEYMAP_C))","")
97 -include $(MAIN_KEYMAP_PATH)/Makefile
98 KEYMAP_C := $(MAIN_KEYMAP_C)
99 KEYMAP_PATH := $(MAIN_KEYMAP_PATH)
101 $(error "$(MAIN_KEYMAP_C)/keymap.c" does not exist)
105 # Object files directory
106 # To put object files in current directory, use a dot (.), do NOT make
107 # this an empty or blank macro!
108 KEYMAP_OUTPUT := $(BUILD_DIR)/obj_$(TARGET)
111 ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
112 CONFIG_H = $(KEYMAP_PATH)/config.h
115 # # project specific files
116 SRC += $(KEYBOARD_C) \
120 ifneq ($(SUBPROJECT),)
121 SRC += $(SUBPROJECT_C)
124 # Optimize size but this may cause error "relocation truncated to fit"
125 #EXTRALDFLAGS = -Wl,--relax
128 VPATH += $(KEYMAP_PATH)
129 ifneq ($(SUBPROJECT),)
130 VPATH += $(SUBPROJECT_PATH)
132 VPATH += $(KEYBOARD_PATH)
133 VPATH += $(COMMON_VPATH)
135 include common_features.mk
136 include $(TMK_PATH)/protocol.mk
137 include $(TMK_PATH)/common.mk
139 SRC += $(TMK_COMMON_SRC)
140 OPT_DEFS += $(TMK_COMMON_DEFS)
141 EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS)
143 ifeq ($(PLATFORM),AVR)
144 ifeq ($(strip $(PROTOCOL)), VUSB)
145 include $(TMK_PATH)/protocol/vusb.mk
147 include $(TMK_PATH)/protocol/lufa.mk
149 include $(TMK_PATH)/avr.mk
152 ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
153 VISUALIZER_DIR = $(QUANTUM_DIR)/visualizer
154 VISUALIZER_PATH = $(QUANTUM_PATH)/visualizer
155 include $(VISUALIZER_PATH)/visualizer.mk
158 OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
159 $(KEYMAP_OUTPUT)_SRC := $(SRC)
160 $(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) $(GFXDEFS) -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\"
161 $(KEYMAP_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS)
162 $(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H)
163 $(KEYBOARD_OUTPUT)_SRC := $(CHIBISRC) $(GFXSRC)
164 $(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS) $(GFXDEFS)
165 $(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC) $(GFXINC)
166 $(KEYBOARD_OUTPUT)_CONFIG := $(PROJECT_CONFIG)
171 # Change the build target to build a HEX file or a library.
173 #build: elf hex eep lss sym
177 include $(TMK_PATH)/rules.mk