aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2016-08-08 10:26:23 +0300
committerFred Sundvik <fsundvik@gmail.com>2016-08-20 03:56:30 +0300
commit67b294ca66fd9da341ab93019a380d91ac589c96 (patch)
tree43ce564d34fc93154476ef777202b2e245fb7805
parentdb5c3b74fb6541879bfad9930d2a659b1d89cd83 (diff)
downloadfirmware-67b294ca66fd9da341ab93019a380d91ac589c96.tar.gz
firmware-67b294ca66fd9da341ab93019a380d91ac589c96.tar.bz2
firmware-67b294ca66fd9da341ab93019a380d91ac589c96.zip
Actual compilation
-rw-r--r--Makefile26
-rw-r--r--build_keyboard.mk171
-rw-r--r--message.mk3
3 files changed, 59 insertions, 141 deletions
diff --git a/Makefile b/Makefile
index e5becd7ad..fc6157209 100644
--- a/Makefile
+++ b/Makefile
@@ -228,17 +228,19 @@ define PARSE_KEYMAP
KB_SP := $(CURRENT_KB)/$$(CURRENT_SP)
endif
KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR)
+ MAKE_VARS := KEYBOARD=$$(CURRENT_KB) SUBPROJECT=$$(CURRENT_SP) KEYMAP=$$(CURRENT_KM)
+ MAKE_VARS += VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=false
COMMAND_$$(COMMAND) := \
- printf "Compiling $$(KB_SP) with $(BOLD)$$(CURRENT_KM)$(NO_COLOR)" | \
- $(AWK) '{ printf "%-118s", $$$$0;}'; \
- LOG=$$$$(echo "$$(MAKE) -c $(ROOT_DIR) -f build_keyboard.mk VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=true" 2>&1) ; \
- if [ $$$$? -gt 0 ]; \
- then $$(PRINT_ERROR_PLAIN); \
- elif [ "$$$$LOG" != "" ] ; \
- then $$(PRINT_WARNING_PLAIN); \
- else \
- $$(PRINT_OK); \
- fi;
+ printf "Compiling $$(KB_SP) with $(BOLD)$$(CURRENT_KM)$(NO_COLOR)" | \
+ $(AWK) '{ printf "%-118s", $$$$0;}'; \
+ LOG=$$$$($$(MAKE) -C $(ROOT_DIR) -f build_keyboard.mk $$(MAKE_VARS) 2>&1) ; \
+ if [ $$$$? -gt 0 ]; \
+ then $$(PRINT_ERROR_PLAIN); \
+ elif [ "$$$$LOG" != "" ] ; \
+ then $$(PRINT_WARNING_PLAIN); \
+ else \
+ $$(PRINT_OK); \
+ fi;
endef
define PARSE_ALL_KEYMAPS
@@ -258,9 +260,11 @@ SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile)))
$(SUBPROJECTS): %: %-allkm
.PHONY: %
-%:
+%:
+ cmp --version >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
$(eval $(call PARSE_RULE,$@))
$(foreach COMMAND,$(COMMANDS),$(RUN_COMMAND))
+
.PHONY: all
all: all-keyboards
diff --git a/build_keyboard.mk b/build_keyboard.mk
index 053c8532a..b0cb22e6a 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)
diff --git a/message.mk b/message.mk
index 2ebf76a58..08a4e02ab 100644
--- a/message.mk
+++ b/message.mk
@@ -32,4 +32,5 @@ PRINT_WARNING = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB
PRINT_ERROR_PLAIN = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN) && exit 1
PRINT_WARNING_PLAIN = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN)
PRINT_OK = $(SILENT) || printf " $(OK_STRING)" | $(AWK_STATUS)
-BUILD_CMD = LOG=$$($(CMD) 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING); else $(PRINT_OK); fi; \ No newline at end of file
+BUILD_CMD = LOG=$$($(CMD) 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING); else $(PRINT_OK); fi;
+MSG_NO_CMP = $(ERROR_COLOR)Error:$(NO_COLOR)$(BOLD) cmp command not found, please install diffutils\n$(NO_COLOR) \ No newline at end of file