From 86706de036cf7ad52b679b259ca8f980057d0da5 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Mon, 1 Aug 2016 09:23:37 +0300 Subject: Parsing of makefile variables from starting dir --- build_keyboard.mk | 276 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 build_keyboard.mk (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk new file mode 100644 index 0000000000..053c8532af --- /dev/null +++ b/build_keyboard.mk @@ -0,0 +1,276 @@ +ifndef VERBOSE +.SILENT: +endif + +.DEFAULT_GOAL := all + +space := $(subst ,, ) +ESCAPED_ABS_PATH = $(subst $(space),_SPACE_,$(abspath $1)) +starting_makefile := $(call ESCAPED_ABS_PATH,$(firstword $(MAKEFILE_LIST))) +mkfile_path := $(call ESCAPED_ABS_PATH,$(lastword $(MAKEFILE_LIST)))) +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))) + KEYMAP_DIR:=$(lastword $(subst /keymaps/, ,$(possible_keyboard))) + 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 + KEYMAP_DIR:=default + 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) +TMK_DIR = tmk_core +TMK_PATH = $(TOP_DIR)/$(TMK_DIR) +LIB_PATH = $(TOP_DIR)/lib + +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 + +MASTER ?= left +ifdef master + MASTER = $(master) +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 + ifneq ($(call ESCAPED_ABS_PATH,$(KEYBOARD_PATH)/Makefile),$(starting_makefile)) + -include $(KEYBOARD_PATH)/Makefile + 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 + ifneq ($(call ESCAPED_ABS_PATH,$(SUBPROJECT_PATH)/Makefile),$(starting_makefile)) + -include $(SUBPROJECT_PATH)/Makefile + endif + else +$(error "$(SUBPROJECT_PATH)/$(SUBPROJECT).c" does not exist) + endif +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 = keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/keymap.c + ifneq ($(call ESCAPED_ABS_PATH,$(KEYMAP_PATH)/Makefile),$(starting_makefile)) + -include $(KEYMAP_PATH)/Makefile + endif +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 + ifneq ($(call ESCAPED_ABS_PATH,$(KEYMAP_PATH)/Makefile),$(starting_makefile)) + -include $(KEYMAP_PATH)/Makefile + endif + endif +endif + +ifdef SUBPROJECT + TARGET ?= $(KEYBOARD)_$(SUBPROJECT)_$(KEYMAP) +else + TARGET ?= $(KEYBOARD)_$(KEYMAP) +endif + +BUILD_DIR = $(TOP_DIR)/.build + +# Object files directory +# To put object files in current directory, use a dot (.), do NOT make +# this an empty or blank macro! +OBJDIR = $(BUILD_DIR)/obj_$(TARGET) + + + +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 +SRC += $(KEYBOARD_FILE) \ + $(KEYMAP_FILE) \ + $(QUANTUM_DIR)/quantum.c \ + $(QUANTUM_DIR)/keymap_common.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_midi.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 +endif + +ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) + OPT_DEFS += -DTAP_DANCE_ENABLE + SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c +endif + +ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) + SERIAL_DIR = $(QUANTUM_DIR)/serial_link + SERIAL_PATH = $(QUANTUM_PATH)/serial_link + SERIAL_SRC = $(wildcard $(SERIAL_PATH)/protocol/*.c) + SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c) + SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) + OPT_DEFS += -DSERIAL_LINK_ENABLE + VAPTH += $(SERIAL_PATH) +endif + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax + +# 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 + + +# We can assume a ChibiOS target When MCU_FAMILY is defined, since it's not used for LUFA +ifdef MCU_FAMILY + PLATFORM=CHIBIOS +else + PLATFORM=AVR +endif + +include $(TMK_PATH)/common.mk +ifeq ($(PLATFORM),AVR) + include $(TMK_PATH)/protocol/lufa.mk + include $(TMK_PATH)/avr.mk +else ifeq ($(PLATFORM),CHIBIOS) + include $(TMK_PATH)/protocol/chibios.mk + include $(TMK_PATH)/chibios.mk + OPT_OS = chibios +else + $(error Unknown platform) +endif + +ifeq ($(strip $(VISUALIZER_ENABLE)), yes) + VISUALIZER_DIR = $(QUANTUM_DIR)/visualizer + VISUALIZER_PATH = $(QUANTUM_PATH)/visualizer + include $(VISUALIZER_PATH)/visualizer.mk +endif + +include $(TMK_PATH)/rules.mk + +GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S") +BUILD_DATE := $(shell date +"%Y-%m-%d-%H:%M:%S") +OPT_DEFS += -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\" + +$(shell echo '#define QMK_VERSION "$(GIT_VERSION)"' > $(QUANTUM_PATH)/version.h) +$(shell echo '#define QMK_BUILDDATE "$(BUILD_DATE)"' >> $(QUANTUM_PATH)/version.h) \ No newline at end of file -- cgit v1.2.3 From 67b294ca66fd9da341ab93019a380d91ac589c96 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Mon, 8 Aug 2016 10:26:23 +0300 Subject: Actual compilation --- build_keyboard.mk | 171 ++++++++++++++---------------------------------------- 1 file changed, 42 insertions(+), 129 deletions(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index 053c8532af..b0cb22e6ac 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -4,44 +4,9 @@ endif .DEFAULT_GOAL := all -space := $(subst ,, ) -ESCAPED_ABS_PATH = $(subst $(space),_SPACE_,$(abspath $1)) -starting_makefile := $(call ESCAPED_ABS_PATH,$(firstword $(MAKEFILE_LIST))) -mkfile_path := $(call ESCAPED_ABS_PATH,$(lastword $(MAKEFILE_LIST)))) -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))) - KEYMAP_DIR:=$(lastword $(subst /keymaps/, ,$(possible_keyboard))) - 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 - KEYMAP_DIR:=default - 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) +TOP_DIR = . TMK_DIR = tmk_core TMK_PATH = $(TOP_DIR)/$(TMK_DIR) LIB_PATH = $(TOP_DIR)/lib @@ -50,92 +15,49 @@ 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 - MASTER ?= left ifdef master MASTER = $(master) endif +KEYBOARD_PATH := keyboards/$(KEYBOARD) +KEYBOARD_C := $(KEYBOARD_PATH)/$(KEYBOARD).c -# 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 - ifneq ($(call ESCAPED_ABS_PATH,$(KEYBOARD_PATH)/Makefile),$(starting_makefile)) - -include $(KEYBOARD_PATH)/Makefile - endif +ifneq ("$(wildcard $(KEYBOARD_C))","") + include $(KEYBOARD_PATH)/rules.mk 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 - ifneq ($(call ESCAPED_ABS_PATH,$(SUBPROJECT_PATH)/Makefile),$(starting_makefile)) - -include $(SUBPROJECT_PATH)/Makefile - endif - else -$(error "$(SUBPROJECT_PATH)/$(SUBPROJECT).c" does not exist) - endif -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 = keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/keymap.c - ifneq ($(call ESCAPED_ABS_PATH,$(KEYMAP_PATH)/Makefile),$(starting_makefile)) - -include $(KEYMAP_PATH)/Makefile - endif -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 - ifneq ($(call ESCAPED_ABS_PATH,$(KEYMAP_PATH)/Makefile),$(starting_makefile)) - -include $(KEYMAP_PATH)/Makefile - endif - endif + $(error "$(KEYBOARD_C)" does not exist) +endif + + +ifneq ($(SUBPROJECT),) + SUBPROJECT_PATH := keyboards/$(KEYBOARD)/$(SUBPROJECT) + SUBPROJECT_C := $(SUBPROJECT_PATH)/$(SUBPROJECT).c + ifneq ("$(wildcard $(SUBPROJECT_C))","") + OPT_DEFS += -DSUBPROJECT_$(SUBPROJECT) + include $(SUBPROJECT_PATH)/rules.mk + else + $(error "$(SUBPROJECT_PATH)/$(SUBPROJECT).c" does not exist) + endif +endif + +MAIN_KEYMAP_PATH := $(KEYBOARD_PATH)/keymaps/$(KEYMAP) +MAIN_KEYMAP_C := $(MAIN_KEYMAP_PATH)/keymap.c +SUBPROJ_KEYMAP_PATH := $(SUBPROJECT_PATH)/keymaps/$(KEYMAP) +SUBPROJ_KEYMAP_C := $(SUBPROJ_KEYMAP_PATH)/keymap.c +ifneq ("$(wildcard $(SUBPROJ_KEYMAP_C))","") + -include $(SUBPROJ_KEYMAP_PATH)/Makefile + KEYMAP_C := $(SUBPROJ_KEYMAP_C) + KEYMAP_PATH := $(SUBPROJ_KEYMAP_PATH) +else ifneq ("$(wildcard $(MAIN_KEYMAP_C))","") + -include $(MAIN_KEYMAP_PATH)/Makefile + KEYMAP_C := $(MAIN_KEYMAP_C) + KEYMAP_PATH := $(MAIN_KEYMAP_PATH) +else + $(error "$(MAIN_KEYMAP_C)/keymap.c" does not exist) endif -ifdef SUBPROJECT +ifneq ($(SUBPROJECT),) TARGET ?= $(KEYBOARD)_$(SUBPROJECT)_$(KEYMAP) else TARGET ?= $(KEYBOARD)_$(KEYMAP) @@ -149,36 +71,27 @@ BUILD_DIR = $(TOP_DIR)/.build OBJDIR = $(BUILD_DIR)/obj_$(TARGET) - 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)","") + ifneq ($(SUBPROJECT),) + ifneq ("$(wildcard $(SUBPROJECT_C))","") CONFIG_H = $(SUBPROJECT_PATH)/config.h endif endif endif # # project specific files -SRC += $(KEYBOARD_FILE) \ - $(KEYMAP_FILE) \ +SRC += $(KEYBOARD_C) \ + $(KEYMAP_C) \ $(QUANTUM_DIR)/quantum.c \ $(QUANTUM_DIR)/keymap_common.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) +ifneq ($(SUBPROJECT),) + SRC += $(SUBPROJECT_C) endif ifndef CUSTOM_MATRIX @@ -229,7 +142,7 @@ endif # Search Path VPATH += $(KEYMAP_PATH) -ifdef SUBPROJECT +ifneq ($(SUBPROJECT),) VPATH += $(SUBPROJECT_PATH) endif VPATH += $(KEYBOARD_PATH) -- cgit v1.2.3 From cc2df445ab3b0fd3998de7861b1c9ba0ad64aa8a Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Mon, 8 Aug 2016 11:06:47 +0300 Subject: Remove unneded code from tmk_core/rules.mk --- build_keyboard.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index b0cb22e6ac..7493c13285 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -4,6 +4,8 @@ endif .DEFAULT_GOAL := all +include message.mk + # Directory common source filess exist TOP_DIR = . @@ -68,7 +70,7 @@ BUILD_DIR = $(TOP_DIR)/.build # Object files directory # To put object files in current directory, use a dot (.), do NOT make # this an empty or blank macro! -OBJDIR = $(BUILD_DIR)/obj_$(TARGET) +OBJDIR := $(BUILD_DIR)/obj_$(TARGET) ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") -- cgit v1.2.3 From 60c6e79ecb032e9726809a295ab3e0011e6b2fb4 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Mon, 8 Aug 2016 11:19:29 +0300 Subject: Move git submodule check and version generation to main Makefile --- build_keyboard.mk | 5 ----- 1 file changed, 5 deletions(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index 7493c13285..7d284cfa7b 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -183,9 +183,4 @@ endif include $(TMK_PATH)/rules.mk -GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S") -BUILD_DATE := $(shell date +"%Y-%m-%d-%H:%M:%S") OPT_DEFS += -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\" - -$(shell echo '#define QMK_VERSION "$(GIT_VERSION)"' > $(QUANTUM_PATH)/version.h) -$(shell echo '#define QMK_BUILDDATE "$(BUILD_DATE)"' >> $(QUANTUM_PATH)/version.h) \ No newline at end of file -- cgit v1.2.3 From 3aac4e95c91be3244d68f27159c2667904c8fddd Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Mon, 15 Aug 2016 08:20:16 +0300 Subject: More general system for generating several outputs --- build_keyboard.mk | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index 7d284cfa7b..d10412ea57 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -43,6 +43,9 @@ ifneq ($(SUBPROJECT),) endif endif +# Save the defs here, so we don't include any keymap specific ones +PROJECT_DEFS := $(OPT_DEFS) + MAIN_KEYMAP_PATH := $(KEYBOARD_PATH)/keymaps/$(KEYMAP) MAIN_KEYMAP_C := $(MAIN_KEYMAP_PATH)/keymap.c SUBPROJ_KEYMAP_PATH := $(SUBPROJECT_PATH)/keymaps/$(KEYMAP) @@ -59,18 +62,33 @@ else $(error "$(MAIN_KEYMAP_C)/keymap.c" does not exist) endif +BUILD_DIR = $(TOP_DIR)/.build + ifneq ($(SUBPROJECT),) TARGET ?= $(KEYBOARD)_$(SUBPROJECT)_$(KEYMAP) + KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD)_$(SUBPROJECT) else TARGET ?= $(KEYBOARD)_$(KEYMAP) + KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD) endif -BUILD_DIR = $(TOP_DIR)/.build +# We can assume a ChibiOS target When MCU_FAMILY is defined, since it's not used for LUFA +ifdef MCU_FAMILY + PLATFORM=CHIBIOS +else + PLATFORM=AVR +endif + +ifeq ($(PLATFORM),CHIBIOS) + include $(TMK_PATH)/protocol/chibios.mk + include $(TMK_PATH)/chibios.mk + OPT_OS = chibios +endif # Object files directory # To put object files in current directory, use a dot (.), do NOT make # this an empty or blank macro! -OBJDIR := $(BUILD_DIR)/obj_$(TARGET) +KEYMAP_OUTPUT := $(BUILD_DIR)/obj_$(TARGET) ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") @@ -156,23 +174,10 @@ VPATH += $(QUANTUM_PATH)/audio VPATH += $(QUANTUM_PATH)/process_keycode -# We can assume a ChibiOS target When MCU_FAMILY is defined, since it's not used for LUFA -ifdef MCU_FAMILY - PLATFORM=CHIBIOS -else - PLATFORM=AVR -endif - include $(TMK_PATH)/common.mk ifeq ($(PLATFORM),AVR) include $(TMK_PATH)/protocol/lufa.mk include $(TMK_PATH)/avr.mk -else ifeq ($(PLATFORM),CHIBIOS) - include $(TMK_PATH)/protocol/chibios.mk - include $(TMK_PATH)/chibios.mk - OPT_OS = chibios -else - $(error Unknown platform) endif ifeq ($(strip $(VISUALIZER_ENABLE)), yes) @@ -181,6 +186,13 @@ ifeq ($(strip $(VISUALIZER_ENABLE)), yes) include $(VISUALIZER_PATH)/visualizer.mk endif + +OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT) +$(KEYMAP_OUTPUT)_SRC := $(SRC) +$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\" +$(KEYBOARD_OUTPUT)_SRC := $(CHIBISRC) +$(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS) + + include $(TMK_PATH)/rules.mk -OPT_DEFS += -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\" -- cgit v1.2.3 From 33fbd3be36bf58c6a02fb6b4ae99dc5bca7c8e58 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Mon, 15 Aug 2016 08:45:36 +0300 Subject: Output specific include paths --- build_keyboard.mk | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index d10412ea57..0debc49259 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -43,8 +43,22 @@ ifneq ($(SUBPROJECT),) endif endif -# Save the defs here, so we don't include any keymap specific ones +# We can assume a ChibiOS target When MCU_FAMILY is defined, since it's not used for LUFA +ifdef MCU_FAMILY + PLATFORM=CHIBIOS +else + PLATFORM=AVR +endif + +ifeq ($(PLATFORM),CHIBIOS) + include $(TMK_PATH)/protocol/chibios.mk + include $(TMK_PATH)/chibios.mk + OPT_OS = chibios +endif + +# Save the defines and includes here, so we don't include any keymap specific ones PROJECT_DEFS := $(OPT_DEFS) +PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(SUBPROJECT_PATH) $(KEYBOARD_PATH) MAIN_KEYMAP_PATH := $(KEYBOARD_PATH)/keymaps/$(KEYMAP) MAIN_KEYMAP_C := $(MAIN_KEYMAP_PATH)/keymap.c @@ -72,19 +86,6 @@ else KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD) endif -# We can assume a ChibiOS target When MCU_FAMILY is defined, since it's not used for LUFA -ifdef MCU_FAMILY - PLATFORM=CHIBIOS -else - PLATFORM=AVR -endif - -ifeq ($(PLATFORM),CHIBIOS) - include $(TMK_PATH)/protocol/chibios.mk - include $(TMK_PATH)/chibios.mk - OPT_OS = chibios -endif - # Object files directory # To put object files in current directory, use a dot (.), do NOT make # this an empty or blank macro! @@ -190,8 +191,10 @@ endif OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT) $(KEYMAP_OUTPUT)_SRC := $(SRC) $(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\" +$(KEYMAP_OUTPUT)_INC := $(EXTRAINCDIRS) $(VPATH) $(KEYBOARD_OUTPUT)_SRC := $(CHIBISRC) $(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS) +$(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC) include $(TMK_PATH)/rules.mk -- cgit v1.2.3 From 9028a412eaf95e37e98a9f2e4573653ec70d7e18 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Mon, 15 Aug 2016 08:58:05 +0300 Subject: Add output specific config file --- build_keyboard.mk | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index 0debc49259..a6b578efbc 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -56,9 +56,17 @@ ifeq ($(PLATFORM),CHIBIOS) OPT_OS = chibios endif +CONFIG_H = $(KEYBOARD_PATH)/config.h +ifneq ($(SUBPROJECT),) + ifneq ("$(wildcard $(SUBPROJECT_C))","") + CONFIG_H = $(SUBPROJECT_PATH)/config.h + endif +endif + # Save the defines and includes here, so we don't include any keymap specific ones PROJECT_DEFS := $(OPT_DEFS) PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(SUBPROJECT_PATH) $(KEYBOARD_PATH) +PROJECT_CONFIG := $(CONFIG_H) MAIN_KEYMAP_PATH := $(KEYBOARD_PATH)/keymaps/$(KEYMAP) MAIN_KEYMAP_C := $(MAIN_KEYMAP_PATH)/keymap.c @@ -94,13 +102,6 @@ KEYMAP_OUTPUT := $(BUILD_DIR)/obj_$(TARGET) ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") CONFIG_H = $(KEYMAP_PATH)/config.h -else - CONFIG_H = $(KEYBOARD_PATH)/config.h - ifneq ($(SUBPROJECT),) - ifneq ("$(wildcard $(SUBPROJECT_C))","") - CONFIG_H = $(SUBPROJECT_PATH)/config.h - endif - endif endif # # project specific files @@ -192,9 +193,11 @@ OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT) $(KEYMAP_OUTPUT)_SRC := $(SRC) $(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\" $(KEYMAP_OUTPUT)_INC := $(EXTRAINCDIRS) $(VPATH) +$(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H) $(KEYBOARD_OUTPUT)_SRC := $(CHIBISRC) $(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS) $(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC) +$(KEYBOARD_OUTPUT)_CONFIG := $(PROJECT_CONFIG) include $(TMK_PATH)/rules.mk -- cgit v1.2.3 From 3442e216dcec3ce6c8ba1c755b0d647a7f384f01 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Mon, 15 Aug 2016 09:07:32 +0300 Subject: Move bootloader_defs include to build_keyboard Also fix it for subprojects --- build_keyboard.mk | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index a6b578efbc..e8d8f3572b 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -54,6 +54,15 @@ ifeq ($(PLATFORM),CHIBIOS) include $(TMK_PATH)/protocol/chibios.mk include $(TMK_PATH)/chibios.mk OPT_OS = chibios + ifneq ("$(wildcard $(SUBPROJECT_PATH)/bootloader_defs.h)","") + OPT_DEFS += -include $(SUBPROJECT_PATH)/bootloader_defs.h + else ifneq ("$(wildcard $(SUBPROJECT_PATH)/boards/$(BOARD)/bootloader_defs.h)","") + OPT_DEFS += -include $(SUBPROJECT_PATH)/boards/$(BOARD)/bootloader_defs.h + else ifneq ("$(wildcard $(KEYBOARD_PATH)/bootloader_defs.h)","") + OPT_DEFS += -include $(KEYBOARD_PATH)/bootloader_defs.h + else ifneq ("$(wildcard $(KEYBOARD_PATH)/boards/$(BOARD)/bootloader_defs.h)","") + OPT_DEFS += -include $(KEYBOARD_PATH)/boards/$(BOARD)/bootloader_defs.h + endif endif CONFIG_H = $(KEYBOARD_PATH)/config.h -- cgit v1.2.3 From 8f16403179dde51af1826fbc9b65ce0e29fd33ad Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 21 Aug 2016 13:53:36 +0300 Subject: Change order of variable assignment BUILD_DIR and TARGET was assigned too late, so the dfu-util target, which depends on them did not work. --- build_keyboard.mk | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index e8d8f3572b..a2a2871e6e 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -16,6 +16,19 @@ LIB_PATH = $(TOP_DIR)/lib QUANTUM_DIR = quantum QUANTUM_PATH = $(TOP_DIR)/$(QUANTUM_DIR) +BUILD_DIR := $(TOP_DIR)/.build + +ifneq ($(SUBPROJECT),) + TARGET ?= $(KEYBOARD)_$(SUBPROJECT)_$(KEYMAP) + KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD)_$(SUBPROJECT) +else + TARGET ?= $(KEYBOARD)_$(KEYMAP) + KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD) +endif + +# Force expansion +TARGET := $(TARGET) + MASTER ?= left ifdef master @@ -93,15 +106,6 @@ else $(error "$(MAIN_KEYMAP_C)/keymap.c" does not exist) endif -BUILD_DIR = $(TOP_DIR)/.build - -ifneq ($(SUBPROJECT),) - TARGET ?= $(KEYBOARD)_$(SUBPROJECT)_$(KEYMAP) - KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD)_$(SUBPROJECT) -else - TARGET ?= $(KEYBOARD)_$(KEYMAP) - KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD) -endif # Object files directory # To put object files in current directory, use a dot (.), do NOT make -- cgit v1.2.3 From 27a673f5cf75747fe73641059aae60e9b53a1c78 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 21 Aug 2016 17:14:38 +0300 Subject: The makefile actually calls build_test --- build_keyboard.mk | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index f843572f66..bbe5718459 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -4,19 +4,7 @@ endif .DEFAULT_GOAL := all -include message.mk - - -# Directory common source filess exist -TOP_DIR = . -TMK_DIR = tmk_core -TMK_PATH = $(TOP_DIR)/$(TMK_DIR) -LIB_PATH = $(TOP_DIR)/lib - -QUANTUM_DIR = quantum -QUANTUM_PATH = $(TOP_DIR)/$(QUANTUM_DIR) - -BUILD_DIR := $(TOP_DIR)/.build +include common.mk ifneq ($(SUBPROJECT),) TARGET ?= $(KEYBOARD)_$(SUBPROJECT)_$(KEYMAP) -- cgit v1.2.3 From 8a9aac6e3237a505682cc7249a8dfff6cb964343 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Mon, 22 Aug 2016 09:16:08 +0300 Subject: Rules for compiling and linking google test --- build_keyboard.mk | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index bbe5718459..869d672b01 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -204,6 +204,14 @@ $(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS) $(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC) $(KEYBOARD_OUTPUT)_CONFIG := $(PROJECT_CONFIG) +# Default target. +all: build sizeafter + +# Change the build target to build a HEX file or a library. +build: elf hex +#build: elf hex eep lss sym +#build: lib + include $(TMK_PATH)/rules.mk -- cgit v1.2.3 From 0a11460175d6a838c71343c19eb4ce4699936247 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Wed, 24 Aug 2016 22:23:17 +0300 Subject: Build actual tests, convert byte_stuffer_tests --- build_keyboard.mk | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index 869d672b01..164794c634 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -155,12 +155,8 @@ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) endif ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) - SERIAL_DIR = $(QUANTUM_DIR)/serial_link - SERIAL_PATH = $(QUANTUM_PATH)/serial_link - SERIAL_SRC = $(wildcard $(SERIAL_PATH)/protocol/*.c) - SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c) SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) - OPT_DEFS += -DSERIAL_LINK_ENABLE + OPT_DEFS += $(SERIAL_DEFS) VAPTH += $(SERIAL_PATH) endif -- cgit v1.2.3 From c692fd1d55cb2103e9f7c40c8953ec92b5178c52 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 27 Aug 2016 13:43:12 +0300 Subject: More common settings for unit tests and keyboards --- build_keyboard.mk | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index 164794c634..5bec4ecf66 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -23,6 +23,16 @@ ifdef master MASTER = $(master) endif +ifeq ($(MASTER),right) + OPT_DEFS += -DMASTER_IS_ON_RIGHT +else + ifneq ($(MASTER),left) +$(error MASTER does not have a valid value(left/right)) + endif +endif + + + KEYBOARD_PATH := keyboards/$(KEYBOARD) KEYBOARD_C := $(KEYBOARD_PATH)/$(KEYBOARD).c @@ -169,15 +179,14 @@ ifneq ($(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 +VPATH += $(COMMON_VPATH) include $(TMK_PATH)/common.mk +SRC += $(TMK_COMMON_SRC) +OPT_DEFS += $(TMK_COMMON_DEFS) +EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS) + ifeq ($(PLATFORM),AVR) include $(TMK_PATH)/protocol/lufa.mk include $(TMK_PATH)/avr.mk @@ -189,11 +198,13 @@ ifeq ($(strip $(VISUALIZER_ENABLE)), yes) include $(VISUALIZER_PATH)/visualizer.mk endif +$(info $(VPATH)) + OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT) $(KEYMAP_OUTPUT)_SRC := $(SRC) $(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\" -$(KEYMAP_OUTPUT)_INC := $(EXTRAINCDIRS) $(VPATH) +$(KEYMAP_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS) $(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H) $(KEYBOARD_OUTPUT)_SRC := $(CHIBISRC) $(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS) -- cgit v1.2.3 From 6410f0c021792ebbbd279fc6150f197274e914c8 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 27 Aug 2016 18:13:01 +0300 Subject: The all target makes all keyboards and all tests --- build_keyboard.mk | 3 --- 1 file changed, 3 deletions(-) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index 5bec4ecf66..04632c1c94 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -198,9 +198,6 @@ ifeq ($(strip $(VISUALIZER_ENABLE)), yes) include $(VISUALIZER_PATH)/visualizer.mk endif -$(info $(VPATH)) - - OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT) $(KEYMAP_OUTPUT)_SRC := $(SRC) $(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYMAP=\"$(KEYMAP)\" -- cgit v1.2.3 From 2f0395ce725581b93b68a88899c207014ee68901 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 29 Aug 2016 11:30:38 +0200 Subject: build_keyboard.mk: Restore UCIS_ENABLE support During the build system refactor, support for enabling UCIS seems to have been lost. This little patch adds that back, so that keymaps using UCIS can be compiled again. Signed-off-by: Gergely Nagy --- build_keyboard.mk | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'build_keyboard.mk') diff --git a/build_keyboard.mk b/build_keyboard.mk index 04632c1c94..03a69b1464 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -148,6 +148,11 @@ ifeq ($(strip $(AUDIO_ENABLE)), yes) SRC += $(QUANTUM_DIR)/audio/luts.c endif +ifeq ($(strip $(UCIS_ENABLE)), yes) + OPT_DEFS += -DUCIS_ENABLE + UNICODE_ENABLE = yes +endif + ifeq ($(strip $(UNICODE_ENABLE)), yes) OPT_DEFS += -DUNICODE_ENABLE SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c -- cgit v1.2.3