summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile113
1 files changed, 105 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index ffbdf742c3..f9b865b9f8 100644
--- a/Makefile
+++ b/Makefile
@@ -10,19 +10,32 @@ abs_tmk_root := $(patsubst %/,%,$(dir $(mkfile_path)))
ifneq (,$(findstring /keyboards/,$(starting_makefile)))
possible_keyboard:=$(patsubst %/,%,$(dir $(patsubst $(abs_tmk_root)/keyboards/%,%,$(starting_makefile))))
ifneq (,$(findstring /keymaps/,$(possible_keyboard)))
- KEYBOARD_DIR:=$(firstword $(subst /keymaps/, ,$(possible_keyboard)))
KEYMAP_DIR:=$(lastword $(subst /keymaps/, ,$(possible_keyboard)))
- tmk_root = ../../../..
+ KEYBOARD_DIR:=$(firstword $(subst /keymaps/, ,$(possible_keyboard)))
+ ifneq (,$(findstring /,$(KEYBOARD_DIR)))
+ # SUBPROJECT_DIR:=$(lastword $(subst /, ,$(KEYBOARD_DIR)))
+ # KEYBOARD_DIR:=$(firstword $(subst /, ,$(KEYBOARD_DIR)))
+ tmk_root = ../../..
+ else
+ tmk_root = ../../../..
+ endif
else
- KEYBOARD_DIR:=$(possible_keyboard)
KEYMAP_DIR:=default
- tmk_root = ../..
+ KEYBOARD_DIR:=$(possible_keyboard)
+ ifneq (,$(findstring /,$(KEYBOARD_DIR)))
+ # SUBPROJECT_DIR:=$(lastword $(subst /, ,$(KEYBOARD_DIR)))
+ # KEYBOARD_DIR:=$(firstword $(subst /, ,$(KEYBOARD_DIR)))
+ tmk_root = ../../..
+ else
+ tmk_root = ../..
+ endif
endif
else
tmk_root = .
endif
# $(info $(KEYBOARD_DIR))
# $(info $(KEYMAP_DIR))
+# $(info $(SUBPROJECT_DIR))
# Directory common source filess exist
TOP_DIR = $(tmk_root)
@@ -32,6 +45,7 @@ TMK_PATH = $(TOP_DIR)/$(TMK_DIR)
QUANTUM_DIR = quantum
QUANTUM_PATH = $(TOP_DIR)/$(QUANTUM_DIR)
+
ifdef keyboard
KEYBOARD ?= $(keyboard)
endif
@@ -41,16 +55,49 @@ endif
ifndef KEYBOARD
KEYBOARD=planck
endif
+
+# converts things to keyboards/subproject
+ifneq (,$(findstring /,$(KEYBOARD)))
+ TEMP:=$(KEYBOARD)
+ KEYBOARD:=$(firstword $(subst /, ,$(TEMP)))
+ SUBPROJECT:=$(lastword $(subst /, ,$(TEMP)))
+endif
+
KEYBOARD_PATH = $(TOP_DIR)/keyboards/$(KEYBOARD)
+
+ifdef sub
+ SUBPROJECT=$(sub)
+endif
+ifdef subproject
+ SUBPROJECT=$(subproject)
+endif
+
ifneq ("$(wildcard $(KEYBOARD_PATH)/$(KEYBOARD).c)","")
KEYBOARD_FILE = keyboards/$(KEYBOARD)/$(KEYBOARD).c
ifndef ARCH
- include $(KEYBOARD_PATH)/Makefile
+ ifneq ("$(wildcard $(KEYBOARD_PATH)/Makefile)","")
+ include $(KEYBOARD_PATH)/Makefile
+ endif
endif
else
$(error "$(KEYBOARD_PATH)/$(KEYBOARD).c" does not exist)
endif
+ifdef SUBPROJECT_DEFAULT
+ SUBPROJECT?=$(SUBPROJECT_DEFAULT)
+endif
+
+ifdef SUBPROJECT
+ SUBPROJECT_PATH = $(TOP_DIR)/keyboards/$(KEYBOARD)/$(SUBPROJECT)
+ ifneq ("$(wildcard $(SUBPROJECT_PATH)/$(SUBPROJECT).c)","")
+ OPT_DEFS += -DSUBPROJECT_$(SUBPROJECT)
+ SUBPROJECT_FILE = keyboards/$(KEYBOARD)/$(SUBPROJECT)/$(SUBPROJECT).c
+ -include $(SUBPROJECT_PATH)/Makefile
+ else
+$(error "$(SUBPROJECT_PATH)/$(SUBPROJECT).c" does not exist)
+ endif
+endif
+
ifdef keymap
KEYMAP ?= $(keymap)
endif
@@ -65,15 +112,31 @@ ifneq ("$(wildcard $(KEYMAP_PATH)/keymap.c)","")
KEYMAP_FILE = keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/keymap.c
-include $(KEYMAP_PATH)/Makefile
else
+ ifeq ("$(wildcard $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)/keymap.c)","")
$(error "$(KEYMAP_PATH)/keymap.c" does not exist)
+ else
+ KEYMAP_PATH = $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)
+ KEYMAP_FILE = keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/$(KEYMAP)/keymap.c
+ -include $(KEYMAP_PATH)/Makefile
+ endif
+endif
+
+ifdef SUBPROJECT
+ TARGET ?= $(KEYBOARD)_$(SUBPROJECT)_$(KEYMAP)
+else
+ TARGET ?= $(KEYBOARD)_$(KEYMAP)
endif
-TARGET ?= $(KEYBOARD)_$(KEYMAP)
ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
CONFIG_H = $(KEYMAP_PATH)/config.h
else
CONFIG_H = $(KEYBOARD_PATH)/config.h
+ ifdef SUBPROJECT
+ ifneq ("$(wildcard $(SUBPROJECT_PATH)/$(SUBPROJECT).c)","")
+ CONFIG_H = $(SUBPROJECT_PATH)/config.h
+ endif
+ endif
endif
# # project specific files
@@ -81,22 +144,52 @@ SRC += $(KEYBOARD_FILE) \
$(KEYMAP_FILE) \
$(QUANTUM_DIR)/quantum.c \
$(QUANTUM_DIR)/keymap.c \
- $(QUANTUM_DIR)/keycode_config.c
+ $(QUANTUM_DIR)/keycode_config.c \
+ $(QUANTUM_DIR)/process_keycode/process_leader.c
+
+ifdef SUBPROJECT
+ SRC += $(SUBPROJECT_FILE)
+endif
+
+ifdef SUBPROJECT
+ SRC += $(SUBPROJECT_FILE)
+endif
+
+ifdef SUBPROJECT
+ SRC += $(SUBPROJECT_FILE)
+endif
ifndef CUSTOM_MATRIX
SRC += $(QUANTUM_DIR)/matrix.c
endif
+ifeq ($(strip $(MIDI_ENABLE)), yes)
+ OPT_DEFS += -DMIDI_ENABLE
+ SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
+endif
+
ifeq ($(strip $(AUDIO_ENABLE)), yes)
+ OPT_DEFS += -DAUDIO_ENABLE
+ SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
SRC += $(QUANTUM_DIR)/audio/audio.c
SRC += $(QUANTUM_DIR)/audio/voices.c
SRC += $(QUANTUM_DIR)/audio/luts.c
endif
+ifeq ($(strip $(UNICODE_ENABLE)), yes)
+ OPT_DEFS += -DUNICODE_ENABLE
+ SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
+endif
+
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
+ OPT_DEFS += -DRGBLIGHT_ENABLE
SRC += $(QUANTUM_DIR)/light_ws2812.c
SRC += $(QUANTUM_DIR)/rgblight.c
- OPT_DEFS += -DRGBLIGHT_ENABLE
+endif
+
+ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
+ OPT_DEFS += -DTAP_DANCE_ENABLE
+ SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
endif
# Optimize size but this may cause error "relocation truncated to fit"
@@ -104,12 +197,16 @@ endif
# Search Path
VPATH += $(KEYMAP_PATH)
+ifdef SUBPROJECT
+ VPATH += $(SUBPROJECT_PATH)
+endif
VPATH += $(KEYBOARD_PATH)
VPATH += $(TOP_DIR)
VPATH += $(TMK_PATH)
VPATH += $(QUANTUM_PATH)
VPATH += $(QUANTUM_PATH)/keymap_extras
VPATH += $(QUANTUM_PATH)/audio
+VPATH += $(QUANTUM_PATH)/process_keycode
include $(TMK_PATH)/protocol/lufa.mk
include $(TMK_PATH)/common.mk