QMK/Makefile

76 lines
1.7 KiB
Makefile
Raw Normal View History

2022-07-09 14:25:45 -07:00
QMK_REPO := ssh://git@git.betalupi.com:33/Mark/qmk_betalupi.git
# QMK command
QMK_CONF := $(shell pwd)/qmk/qmk.conf
QMK := qmk --config-file $(QMK_CONF)
# Where to create venv
VENV := $(shell pwd)/venv
# Where to build firmware
BUILD_DIR := $(shell pwd)/build
# Path to submodules
QMK_CLI := $(shell pwd)/qmk/qmk_cli
QMK_DIR := $(shell pwd)/qmk/qmk_fw
.PHONY: git-submodule
git-submodule:
@git submodule sync --recursive
@git submodule update --init --recursive --progress
@echo ""
# Link keyboards into qmk_fw
KEYBOARDS := $(notdir $(shell find keyboards -maxdepth 1 -mindepth 1 -type d))
.PHONY: $(KEYBOARDS)
$(KEYBOARDS):
@echo "Linking keyboards into $(QMK_DIR)/keyboards..."
@ln -s \
$(shell pwd)/keyboards/$@ \
$(QMK_DIR)/keyboards/$@
@echo ""
# Clone all repos and configure qmk
.PHONY: setup
setup: git-submodule $(KEYBOARDS)
@echo "Preparing venv..."
@python -m venv $(VENV) --prompt=qmk_venv
@echo "Building and installing qmk_cli"
@source $(VENV)/bin/activate && \
cd $(QMK_CLI) && \
python3 -m pip install build --quiet && \
python3 -m build > /dev/null && \
python3 -m pip install $$(find dist -name 'qmk-*.tar.gz') --quiet
@echo ""
@echo ""
@source $(VENV)/bin/activate && \
$(QMK) config user.qmk_home=$(QMK_DIR) && \
$(QMK) doctor
# Undo all changes done in setup
.PHONY: unsetup
unsetup:
-rm -drf $(VENV) $(BUILD_DIR)
-rm $(QMK_CONF)
-rm -dr $(QMK_CLI)/dist $(QMK_CLI)/qmk.egg-info
-rm $(KEYBOARDS:%=$(QMK_DIR)/keyboards/%)
# Compile and flash a keyboard
.PHONY: flash
flash:
@source $(VENV)/bin/activate && \
$(QMK) flash \
-e AVR_CFLAGS="-Wno-array-bounds" \
-e BUILD_DIR=$(BUILD_DIR) \
-kb betalupi_ergodox \
-km default