From a624f3dc91e197afe92f7abb5da80690c05ce55f Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Mon, 5 Feb 2018 11:17:22 -0500 Subject: [PATCH] Makefile improved a lot --- Makefile | 28 ++++++++++++++++++++-------- README.md | 6 +++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 673ede9..53f7dd4 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,29 @@ -.PHONY: docker-image docker-shell +.PHONY: help docker-image docker-shell citadel-image citadel-kernel user-rootfs BASE_DIR = $(shell pwd) BASE_BINDMOUNT = type=bind,source=$(BASE_DIR),target=/home/builder/citadel +DOCKER_RUN = docker run -it --mount $(BASE_BINDMOUNT) citadel-builder +DOCKER_RUN_PRIV = docker run -it --privileged --mount $(BASE_BINDMOUNT) citadel-builder -all: docker-image docker-shell +# +# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +# +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -docker-image: +docker-image: ## Create docker builder image. You need to run this one time before running anything else. docker build -t citadel-builder scripts/docker -docker-shell: - docker run -it --mount $(BASE_BINDMOUNT) citadel-builder +docker-shell: ## Open an interactive shell in the docker build container configured for running bitbake commands. + $(DOCKER_RUN) -user-rootfs: +citadel-image: ## Build citadel-image with bitbake + $(DOCKER_RUN) bash -c "source setup-build-env && bitbake citadel-image" + +citadel-kernel: ## Build citadel-kernel with bitbake + $(DOCKER_RUN) bash -c "source setup-build-env && bitbake citadel-kernel" + +user-rootfs: ## Build user-rootfs tarball with debootstrap and configuration scripts mkdir -p build/debootstrap - docker run -it --privileged --mount $(BASE_BINDMOUNT) citadel-builder sudo scripts/build-user-rootfs-stage-one | tee build/debootstrap/build-user-rootfs.log - + $(DOCKER_RUN_PRIV) sudo scripts/build-user-rootfs-stage-one | tee build/debootstrap/build-user-rootfs.log diff --git a/README.md b/README.md index 147dde8..30c2f6c 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,10 @@ Docker will realize that the Dockerfile has not changed and do nothing. $ make docker-image +To list available make targets, run `make help` or just `make` as this is the default target: + + $ make help + To run a shell inside the docker build container: $ make docker-shell @@ -43,7 +47,7 @@ The shell will run in the build directory and be configured to run build command To build a full citadel image: - $ bitbake citadel-image + $ make citadel-image The build will take several hours the first time, but for later builds the build system will use cached artifacts stored in `citadel/build/sstate-cache` for components that have not changed and new builds will usually only take a few minutes.