4815b97add
This adds the keyboard and keymap built, along with the QMK firmware's git hash (or a timestamp), to OPT_DEFS. That, in turn, allows keymaps to make use of these information, and do whatever they want with it. For example, one could print them on `LEADER v` like this: ```c SEQ_ONE_KEY (KC_V) { SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); } ``` This addresses #366. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
120 lines
3 KiB
Makefile
120 lines
3 KiB
Makefile
ifndef VERBOSE
|
|
.SILENT:
|
|
endif
|
|
|
|
starting_makefile := $(abspath $(firstword $(MAKEFILE_LIST)))
|
|
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
abs_tmk_root := $(patsubst %/,%,$(dir $(mkfile_path)))
|
|
|
|
ifneq (,$(findstring /keyboard/,$(starting_makefile)))
|
|
possible_keyboard:=$(patsubst %/,%,$(dir $(patsubst $(abs_tmk_root)/keyboard/%,%,$(starting_makefile))))
|
|
ifneq (,$(findstring /keymaps/,$(possible_keyboard)))
|
|
KEYBOARD_DIR:=$(firstword $(subst /keymaps/, ,$(possible_keyboard)))
|
|
KEYMAP_DIR:=$(lastword $(subst /keymaps/, ,$(possible_keyboard)))
|
|
tmk_root = ../../../..
|
|
else
|
|
KEYBOARD_DIR:=$(possible_keyboard)
|
|
KEYMAP_DIR:=default
|
|
tmk_root = ../..
|
|
endif
|
|
else
|
|
tmk_root = .
|
|
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
|
|
|
|
GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d")
|
|
|
|
OPT_DEFS += -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\"
|
|
OPT_DEFS += -DQMK_VERSION=\"$(GIT_VERSION)\"
|