# ENV ifeq (,$(shell which uv)) ifeq (,$(shell python3 -m uv --help||python3 -m pip install --user uv)) # detect uv install UV ?= false endif UV ?= python3 -m uv endif UV ?= uv RUFF ?= $(UV) run --active ruff TY ?= $(UV) run --active ty MAKE := $(MAKE) --no-print-directory RASP_USER ?= forge RASP_BOOTFS ?= /run/media/$(shell whoami)/bootfs RASP_ROOTFS ?= /run/media/$(shell whoami)/rootfs RELATIVE_PROJECT_PATH ?= /opt/forge-invar RASP_PROJECT_PATH ?= $(RASP_ROOTFS)$(RELATIVE_PROJECT_PATH) GLSL_GLYPHS_DIR ?= forge-steel/glsl-glyphs GLSL_GLYPHS ?= $(UV) run --directory $(GLSL_GLYPHS_DIR) glsl-glyphs # DOCS .PHONY: help help: ## show this message @echo "Usage: $(MAKE) [target1] [target2] ..." @echo "" @echo "Commands/Targets:" @cat $(MAKEFILE_LIST) | grep -E '(^[a-zA-Z0-9_%-]+:.*?##.*$$)|(^##)' | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-20s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' @echo "" @echo "Environment:" @cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z0-9_-]+\s*\??=.*$$' | grep -Eo '^[a-zA-Z0-9_-]+' | xargs -I {} $(MAKE) -s print-{} 2> /dev/null .PHONY: print-% print-%: @echo -e '\033[32m$*\033[0m = $($*)' # FILES .venv: uv.lock $(MAKE) uv-sync sentences.txt: cp sentences.example.txt sentences.txt project/inc_sentences.glsl: sentences.txt $(MAKE) glsl-glyphs-sentences # ACTIONS .PHONY: init init: uv-sync git-submodule-update sentences ## install project .PHONY: update update: uv-upgrade ## update project dependencies .PHONY: format format: ruff-fix ruff-format ## format project .PHONY: lint lint: ruff ruff-format-check ty ## lint project .PHONY: gen-img gen-img: uv-run-invar-mode-gen-img ## generate resources/*.png .PHONY: debug-img debug-img: uv-run-invar-mode-debug-img ## debug i2c screen with mock data .PHONY: sentences sentences: glsl-glyphs-sentences ## generate project/inc_sentences.glsl .PHONY: rasp-init rasp-init: rasp-chmod-opt rasp-rsync rasp-unmount ## init raspberry .PHONY: rasp-install rasp-install: rasp-install-pal ## setup raspberry .PHONY: rasp-install-% rasp-install-%: ## setup raspberry (PAL/NTSC/HDMI) $(MAKE) git-submodule-update sentences rasp-rsync rasp-setup-config-$* rasp-setup-cmdline-$* rasp-setup-start-$* rasp-unmount .PHONY: rasp-reset rasp-reset: rasp-rsync rasp-setup-config-hdmi rasp-reset-cmdline rasp-reset-start rasp-unmount ## reset raspberry to console mode # TOOLS .PHONY: uv-sync uv-sync: ## uv sync $(UV) sync --active .PHONY: uv-update uv-upgrade: ## uv sync upgrade $(UV) sync --active --upgrade .PHONY: uv-run-invar-mode-% uv-run-invar-mode-%: .venv ## uv run forge-invar --mode=(tool) $(UV) run --active forge-invar --mode=$* .PHONY: ruff ruff: .venv ## ruff check $(RUFF) check .PHONY: ruff-fix ruff-fix: .venv ## ruff check (and fix) $(RUFF) check --fix --unsafe-fixes .PHONY: ruff-format ruff-format: .venv ## ruff format $(RUFF) format .PHONY: ruff-format-check ruff-format-check: .venv ## ruff format (check only) $(RUFF) format --check .PHONY: ty ty: .venv ## ty check $(TY) check .PHONY: git-submodule-update git-submodule-update: ## prepare git submodules git submodule update --init --recursive .PHONY: glsl-glyphs-sentences glsl-glyphs-sentences: sentences.txt ## glsl-glyphs --sentences-only $(GLSL_GLYPHS) \ --name cp437 \ --functions \ --includes \ --glyph-names sample/cp437_names.txt \ --sentences-only \ --sentences-input ../../sentences.txt \ --sentences-output ../../project/inc_sentences.glsl .PHONY: forge-run forge-run: $(BUILD_DIR)/$(TARGET) ## run locally $(BUILD_DIR)/$(TARGET) $(RUN_ARGS) .PHONY: rasp-chmod-opt rasp-chmod-opt: ## chmod remote project sudo chmod -R a+rwx $(RASP_ROOTFS)/opt .PHONY: rasp-remove-motd rasp-remove-motd: ## sudo rm -rf $(RASP_ROOTFS)/etc/motd sudo rm -rf $(RASP_ROOTFS)/etc/issue sudo rm -rf $(RASP_ROOTFS)/etc/update-motd.d/* .PHONY: rasp-rsync rasp-rsync: ## sync remote project rsync -av --del --include=project/inc_sentences.glsl --exclude='*/.git/*' --exclude-from=.gitignore $(PWD) $(RASP_ROOTFS)/opt .PHONY: rasp-setup-custom-% rasp-setup-custom-%: ## setup custom remote config.txt cp $(PROJECT_DIR)/system/$*/config.ini $(RASP_BOOTFS)/custom.txt .PHONY: rasp-reset-config rasp-reset-config: ## remove include in remote config.txt sed -i '/include custom.txt/d' $(RASP_BOOTFS)/config.txt .PHONY: rasp-setup-config-% rasp-setup-config-%: ## setup include in remote config.txt $(MAKE) rasp-setup-custom-$* rasp-reset-config echo "include custom.txt" >> $(RASP_BOOTFS)/config.txt .PHONY: rasp-reset-cmdline rasp-reset-cmdline: ## remove custom line from remove cmdline.txt sed -i '2,$$d' $(RASP_BOOTFS)/cmdline.txt sed -i 's/console=tty3/console=tty1/g' $(RASP_BOOTFS)/cmdline.txt .PHONY: rasp-setup-cmdline-% rasp-setup-cmdline-%: rasp-reset-cmdline ## add custom line to remove cmdline.txt sed -i 's/console=tty1/console=tty3/g' $(RASP_BOOTFS)/cmdline.txt cat $(PROJECT_DIR)/system/$*/cmdline.txt >> $(RASP_BOOTFS)/cmdline.txt .PHONY: rasp-reset-start rasp-reset-start: ## remove custom .bashrc start rm -f $(RASP_ROOTFS)/home/$(RASP_USER)/.bash_aliases .PHONY: rasp-setup-start-% rasp-setup-start-%: ## install custom .bashrc start cp -f $(PROJECT_DIR)/system/$*/start.sh $(RASP_ROOTFS)/home/$(RASP_USER)/.bash_aliases .PHONY: rasp-unmount rasp-unmount: ## unmount rootfs/bootfs sudo umount -R $(RASP_BOOTFS) sudo umount -R $(RASP_ROOTFS) .PHONY: rasp-force-rebuild rasp-force-rebuild: ## rm remote project/build rm -rf $(RASP_PROJECT_PATH)/build .PHONY: rasp-import-logs rasp-import-logs: ## import remote logs cp -f $(RASP_PROJECT_PATH)/*.log .