summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile112
1 files changed, 112 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000..024a57134b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,112 @@
+ifndef VERBOSE
+.SILENT:
+endif
+
+starting_makefile := $(abspath $(firstword $(MAKEFILE_LIST)))
+mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
+tmk_root := $(patsubst %/,%,$(dir $(mkfile_path)))
+
+ifneq (,$(findstring /keyboard/,$(starting_makefile)))
+ possible_keyboard:=$(patsubst %/,%,$(dir $(patsubst $(tmk_root)/keyboard/%,%,$(starting_makefile))))
+ ifneq (,$(findstring /keymaps/,$(possible_keyboard)))
+ KEYBOARD_DIR:=$(firstword $(subst /keymaps/, ,$(possible_keyboard)))
+ KEYMAP_DIR:=$(lastword $(subst /keymaps/, ,$(possible_keyboard)))
+ else
+ KEYBOARD_DIR:=$(possible_keyboard)
+ KEYMAP_DIR:=default
+ endif
+endif
+
+# $(info $(KEYBOARD_DIR))
+# $(info $(KEYMAP_DIR))
+
+# Directory common source filess exist
+TOP_DIR = $(tmk_root)
+TMK_DIR = tmk_core
+TMK_PATH = $(TOP_DIR)/$(TMK_DIR)
+
+QUANTUM_DIR = quantum
+QUANTUM_PATH = $(TOP_DIR)/$(QUANTUM_DIR)
+
+ifdef keyboard
+ KEYBOARD ?= $(keyboard)
+endif
+ifdef KEYBOARD_DIR
+ KEYBOARD ?= $(KEYBOARD_DIR)
+endif
+ifndef KEYBOARD
+ KEYBOARD=planck
+endif
+KEYBOARD_PATH = $(TOP_DIR)/keyboard/$(KEYBOARD)
+ifneq ("$(wildcard $(KEYBOARD_PATH)/$(KEYBOARD).c)","")
+ KEYBOARD_FILE = keyboard/$(KEYBOARD)/$(KEYBOARD).c
+ ifndef ARCH
+ include $(KEYBOARD_PATH)/Makefile
+ endif
+else
+$(error "$(KEYBOARD_PATH)/$(KEYBOARD).c" does not exist)
+endif
+
+ifdef keymap
+ KEYMAP ?= $(keymap)
+endif
+ifdef KEYMAP_DIR
+ KEYMAP ?= $(KEYMAP_DIR)
+endif
+ifndef KEYMAP
+ KEYMAP = default
+endif
+KEYMAP_PATH = $(KEYBOARD_PATH)/keymaps/$(KEYMAP)
+ifneq ("$(wildcard $(KEYMAP_PATH)/keymap.c)","")
+ KEYMAP_FILE = keyboard/$(KEYBOARD)/keymaps/$(KEYMAP)/keymap.c
+ -include $(KEYMAP_PATH)/Makefile
+else
+$(error "$(KEYMAP_PATH)/keymap.c" does not exist)
+endif
+
+TARGET = $(KEYBOARD)_$(KEYMAP)
+
+ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
+ CONFIG_H = $(KEYMAP_PATH)/config.h
+else
+ CONFIG_H = $(KEYBOARD_PATH)/config.h
+endif
+
+# # project specific files
+SRC += $(KEYBOARD_FILE) \
+ $(KEYMAP_FILE) \
+ $(QUANTUM_DIR)/quantum.c \
+ $(QUANTUM_DIR)/keymap_common.c \
+ $(QUANTUM_DIR)/led.c
+
+ifndef CUSTOM_MATRIX
+ SRC += $(QUANTUM_DIR)/matrix.c
+endif
+
+ifeq ($(strip $(AUDIO_ENABLE)), yes)
+ SRC += $(QUANTUM_DIR)/audio/audio.c
+ SRC += $(QUANTUM_DIR)/audio/voices.c
+ SRC += $(QUANTUM_DIR)/audio/luts.c
+endif
+
+ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
+ SRC += $(QUANTUM_DIR)/light_ws2812.c
+ SRC += $(QUANTUM_DIR)/rgblight.c
+ OPT_DEFS += -DRGBLIGHT_ENABLE
+endif
+
+# Optimize size but this may cause error "relocation truncated to fit"
+#EXTRALDFLAGS = -Wl,--relax
+
+# Search Path
+VPATH += $(KEYMAP_PATH)
+VPATH += $(KEYBOARD_PATH)
+VPATH += $(TOP_DIR)
+VPATH += $(TMK_PATH)
+VPATH += $(QUANTUM_PATH)
+VPATH += $(QUANTUM_PATH)/keymap_extras
+VPATH += $(QUANTUM_PATH)/audio
+
+include $(TMK_PATH)/protocol/lufa.mk
+include $(TMK_PATH)/common.mk
+include $(TMK_PATH)/rules.mk \ No newline at end of file