Files
IronOS/Makefile
Ivan Zorin 311dbeac6f Fix echo in top-level Makefile for some environments (#1737)
* Makefile: fix echo for some environments by replacing escape chars with explicit formatting by spaces and new lines

* Dockerfile: extend comments for documentation purpose & switch WORKDIR to IronOS source tree root dir for the seamless workflow
2023-07-09 22:01:44 +10:00

140 lines
5.1 KiB
Makefile

#!/usr/bin/env make
INFO:=top-level Makefile for IronOS - Soldering Iron Open Source Firmware Project.
### global adjustable variables
# command for "docker compose" from DOCKER env. var.
ifdef DOCKER
DOCKER_BIN:=$(DOCKER)
else
DOCKER_BIN:=
endif
# detect availability of docker
ifndef DOCKER_BIN
DOCKER_COMPOSE:=$(shell command -v docker-compose 2>/dev/null)
DOCKER_TOOL:=$(shell command -v docker 2>/dev/null)
ifdef DOCKER_COMPOSE
DOCKER_BIN:=$(DOCKER_COMPOSE)
else ifdef DOCKER_TOOL
DOCKER_BIN:=$(DOCKER_TOOL) compose
endif # DOCKER_* checks
endif # DOCKER_BIN
# command for python-based mkdocs tool
ifndef MKDOCS
MKDOCS:=mkdocs
endif
### global static variables
# docker-related files
DOCKER_YML=$(CURDIR)/Env.yml
DOCKER_FILE=$(CURDIR)/scripts/IronOS.Dockerfile
# docker dependencies
DOCKER_DEPS=$(DOCKER_YML) $(DOCKER_FILE)
# compose docker-compose command
DOCKER_CMD=$(DOCKER_BIN) -f $(DOCKER_YML) run --rm builder
# MkDocs config
MKDOCS_YML=$(CURDIR)/scripts/IronOS-mkdocs.yml
### targets
# default target to show help
help:
@echo
@echo "Welcome!"
@echo "This is $(INFO)"
@echo "To read more about supported commands (aka \"targets\"), type \"make list\"."
@echo "But if you're impatient then just type \"make docker-build\" - it will:"
@echo " * download, configure & start docker container"
@echo " * compile builds of IronOS firmware for all supported models inside that container"
@echo " * export generated binaries to \"scripts/ci/artefacts/\" local directory"
@echo "Patches are welcome. Happy Hacking!"
@echo
# target to list supported targets with additional info
list:
@echo
@echo "Supported top-level targets:"
@echo " * help - shows short basic help"
@echo " * list - this output"
@echo " * docker-shell - start docker container with shell inside to work on IronOS with all tools needed"
@echo " * docker-build - compile builds of IronOS for supported models inside docker container and place them to \"scripts/ci/artefacts/\""
@echo " * docker-clean - delete created docker container (but not pre-downloaded data for it)"
@echo " * docs - generate \"site\"/ directory with documentation in a form of static html files using ReadTheDocs framework and $(MKDOCS_YML) local config file"
@echo " * docs-deploy - generate & deploy docs online to gh-pages branch of current github repo"
@echo " * clean-build - delete generated files & dirs produced during builds EXCEPT generated docker container image"
@echo " * clean-full - delete generated files & dirs produced during builds INCLUDING generated docker container image"
@echo ""
@echo "NOTES on supported pass-trough targets:"
@echo " * main Makefile is located in source/ directory and used to build the firmware itself;"
@echo " * this top-level Makefile supports to call targets from source/Makefile;"
@echo " * if you set up development environment right on your host, then to build firmware locally, you can just type right from here:"
@echo
@echo " $$ make firmware-LANG_ID model=MODEL_ID"
@echo
@echo "Full list of current supported IDs:"
@echo " * LANG_ID: BE BG CS DA DE EL EN ES FI FR HR HU IT JA_JP LT NB NL_BE NL PL PT RO RU SK SL SR_CYRL SR_LATN SV TR UK VI YUE_HK ZH_CN ZH_TW"
@echo " * MODEL_ID: TS100 TS101 TS80 TS80P MHP30 Pinecil Pinecilv2 S60"
@echo
@echo "For example, to make a local build of IronOS firmware for TS100 with English language, just type:"
@echo
@echo " $$ make firmware-EN model=TS100"
@echo
# bash one-liner to generate langs for "make list":
# echo "`ls Translations/ | grep -e "^translation_.*.json$" | sed -e 's,^translation_,,g; s,\.json$,,g; ' | tr '\n' ' '`"
# detect availability of docker
docker-check:
ifeq ($(DOCKER_BIN),)
@echo "ERROR: Can't find docker-compose nor docker tool. Please, install docker and try again"
@exit 1
else
@true
endif
# former start_dev.sh
docker-shell: docker-check $(DOCKER_DEPS)
$(DOCKER_CMD)
# former build.sh
docker-build: docker-check $(DOCKER_DEPS)
$(DOCKER_CMD) /bin/bash /build/ci/buildAll.sh
# delete container
docker-clean: docker-check
-docker rmi ironos-builder:latest
# generate docs in site/ directory (DIR for -d is relative to mkdocs.yml file location, hence use default name/location site by setting up ../site)
docs: $(MKDOCS_YML) Documentation/* Documentation/Flashing/* Documentation/images/*
$(MKDOCS) build -f $(MKDOCS_YML) -d ../site
# deploy docs to gh-pages branch of current repo automagically using ReadTheDocs framework
docs-deploy: $(MKDOCS_YML) Documentation/* Documentation/Flashing/* Documentation/images/*
$(MKDOCS) gh-deploy -f $(MKDOCS_YML) -d ../site
# pass-through target for Makefile inside source/ dir
%:
make -C source/ $@
# global clean-up target for produced/generated files inside tree
clean-build:
make -C source/ clean-all
rm -Rf site
rm -Rf scripts/ci/artefacts
# global clean-up target
clean-full: clean-build docker-clean
# phony targets
.PHONY: help list docker-check docker-shell docker-build docker-clean docs docs-deploy clean-build clean-full