summary refs log tree commit diff
path: root/Makefile
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2016-06-11 13:31:31 -0400
committerGitHub <noreply@github.com>2016-06-11 13:31:31 -0400
commitd9e4dad0a828a8a904f44dda090a4d6d08fe2948 (patch)
treed6f002712c22e8cf4523e04a9da889c7ec379d6b /Makefile
parenta5d638ad3091e2d553eaa04d933df28eeced5a8b (diff)
Makefile redo & other features (#395)
* .build containment implemented

* no destructive variable setting - builds in either folder

* make from 3 places

* cleans before each build
* make from root with keyboard=keyboard, keymap=keymap
* make from keyboard/keyboard with keymap=keymap
* make from keymaps/keymap
* only implemented on planck

* adds color diag to avr-gcc

* makefiles for all plancks, clean-up

* quick build-all makefile for plancks

* reformatting of make output (colors)

* color toggle, tmk path corrections

* correct if statement for color

* move config.h to main makefile, updates preonic, atomic

* format update, all keyboards targets

* makefile optional for build all target, alps and arrow_pad updated

* alps updated

* make planck default, trying out travis recipe for all-keyboards

* all-keymaps target, different travis recipe

* updates alps64

* updates keyboards to new format

* updates clue* projects

* all projects updated, specialise EZ .hex, let .hex through

* updates travis

* automatically find root, keyboard, keymap

* silent echo, cleaned-up mass make output

* updates all keyboards' .hex files except EZ

* Rename Bantam44.c to bantam44.c

* Rename Bantam44.h to bantam44.h

* nananana

* adds six key keyboard

* does same to ez as rest

* updates send_string example

* brings ergodox_ez up to date

* updates template/new project script

* adds sixkeyboard

* adds readme for sixkeyboard

* adds sixkeyboard to travis

* filenames, gitignore mess

* define clock prescaler stuff manually

* make quick, size test example

* documentation and dfu-no-build
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