mb/google/skyrim: Enable ACPI tables
[coreboot.git] / util / docker / Makefile
blobcbe34f92912407cfd0c50ed07b35cf1901a3ca9a
1 ##
2 ## SPDX-License-Identifier: GPL-2.0-only
4 export top=$(abspath $(CURDIR)/../..)
5 export crossgcc_version=$(shell $(top)/util/crossgcc/buildgcc --version | grep 'cross toolchain' | sed 's/^.*\sv//' | sed 's/\s.*$$//')
6 export DOCKER:=$(shell $(SHELL) -c "command -v docker")
8 # Local port to forward to the jenkins image for the test server
9 export COREBOOT_JENKINS_PORT?=49151
11 # Local cache directory - for storing files shared with the docker image
12 export COREBOOT_JENKINS_CACHE_DIR?=/srv/docker/coreboot-builder/cache
14 # Name of the jenkins container
15 export COREBOOT_JENKINS_CONTAINER?=coreboot_jenkins
17 # Version of the jenkins / sdk container
18 export COREBOOT_IMAGE_TAG?=$(crossgcc_version)
20 # Commit id to build from
21 export DOCKER_COMMIT?=$(shell git log -n 1 --pretty=%h)
23 # .ccache dir to use
24 export DOCKER_CCACHE?=$(HOME)/.ccache
26 # SDK architecture
27 export COREBOOT_CROSSGCC_PARAM?=all
29 UID ?= $(shell id -u)
30 GID ?= $(shell id -g)
32 test-docker:
33 $(if $(DOCKER),,\
34 $(warning Error: Docker command not found. Please install docker) \
35 $(warning Instructions: https://docs.docker.com/engine/install/ ) \
36 $(error halting))
38 test-docker-login: test-docker
39 $(if $(shell if [ ! -f ~/.docker/config.json ]; then \
40 echo "docker authentication file not found"; fi), \
41 $(error Docker authentication file not found. Run 'docker login'))
43 coreboot-sdk: test-docker
44 @echo "Building coreboot SDK $(crossgcc_version) from commit $(DOCKER_COMMIT)"
45 cat coreboot-sdk/Dockerfile | \
46 sed "s/{{DOCKER_COMMIT}}/$(DOCKER_COMMIT)/g" | \
47 sed "s/{{SDK_VERSION}}/$(COREBOOT_IMAGE_TAG)/g" | \
48 sed "s/{{CROSSGCC_PARAM}}/$(COREBOOT_CROSSGCC_PARAM)/g" | \
49 $(DOCKER) build -t coreboot/coreboot-sdk:$(COREBOOT_IMAGE_TAG) -
51 upload-coreboot-sdk: test-docker-login
52 $(DOCKER) push coreboot/coreboot-sdk:$(COREBOOT_IMAGE_TAG)
54 coreboot-jenkins-node: test-docker
55 cat coreboot-jenkins-node/Dockerfile | \
56 sed "s/{{SDK_VERSION}}/$(COREBOOT_IMAGE_TAG)/g" | \
57 sed "s|{{SSH_KEY}}|$$(cat coreboot-jenkins-node/authorized_keys)|" | \
58 $(DOCKER) build -t coreboot/coreboot-jenkins-node:$(COREBOOT_IMAGE_TAG) -
60 upload-coreboot-jenkins-node: test-docker-login
61 $(DOCKER) push coreboot/coreboot-jenkins-node:$(COREBOOT_IMAGE_TAG)
63 doc.coreboot.org: test-docker
64 $(DOCKER) build --force-rm -t doc.coreboot.org \
65 $(top)/util/docker/doc.coreboot.org/
67 docker-killall: test-docker
68 @if [ -n "$$($(DOCKER) ps | grep 'coreboot')" ]; then \
69 $(DOCKER) kill $$($(DOCKER) ps | grep 'coreboot' | cut -f1 -d ' '); \
72 clean-coreboot-containers: docker-killall
73 @if [ -n "$$($(DOCKER) ps -a | grep 'coreboot')" ]; then \
74 $(DOCKER) rm $$($(DOCKER) ps -a | grep 'coreboot' | sed 's|\s.*$$||'); \
77 clean-coreboot-images: docker-killall
78 @if [ -n "$$($(DOCKER) images | grep 'coreboot')" ]; then \
79 $(DOCKER) rmi $$($(DOCKER) images | grep coreboot | sed 's|^\S\+\s\+\S\+\s\+||' | sed 's|\s.*$$||'); \
82 docker-clean: clean-coreboot-containers
83 @$(MAKE) clean-coreboot-images
85 docker-cleanall: test-docker
86 ifeq ($(Y),1)
87 @if [ -n "$$($(DOCKER) ps -a | grep -v "CONTAINER")" ]; then \
88 $(DOCKER) kill $$($(DOCKER) ps | grep -v "CONTAINER" | sed 's|\s.*$$||') ; \
89 $(DOCKER) rm $$($(DOCKER) ps -a | grep -v "CONTAINER" | sed 's|\s.*$$||'); \
91 @if [ -n "$$($(DOCKER) images | grep -v "REPOSITORY")" ]; then \
92 $(DOCKER) rmi $$($(DOCKER) images | grep -v "REPOSITORY" | tr -s ' ' | cut -f3 -d ' '); \
94 else
95 echo "This will remove *ALL* docker containers from your machine."
96 echo "If this is what you want, run 'make docker-cleanall Y=1'"
97 endif
99 $(DOCKER_CCACHE):
100 @mkdir -p $@
102 docker-run-local: test-docker $(DOCKER_CCACHE)
103 $(DOCKER) run -it --rm \
104 --volume $(DOCKER_CCACHE):/home/coreboot/.ccache \
105 --volume $(top):/home/coreboot/coreboot \
106 --env HOME=/home/coreboot \
107 --user $(UID):$(GID) \
108 coreboot/coreboot-sdk:$(COREBOOT_IMAGE_TAG) \
109 /bin/bash -c 'cd $${HOME}/coreboot && $(DOCKER_RUN_LOCAL)'
111 docker-build-coreboot: docker-run-local
112 docker-build-coreboot: override DOCKER_RUN_LOCAL := \
113 make clean && make $(BUILD_CMD)
115 docker-abuild: docker-run-local
116 docker-abuild: override DOCKER_RUN_LOCAL := \
117 make clean && util/abuild/abuild $(ABUILD_ARGS)
119 docker-what-jenkins-does: docker-run-local
120 docker-what-jenkins-does: override DOCKER_RUN_LOCAL := \
121 make clean && make what-jenkins-does CPUS=$(CPUS)
123 docker-jenkins-server: test-docker
124 @if [ ! -d "$(COREBOOT_JENKINS_CACHE_DIR)" ]; then \
125 printf "\nError: %s does not exist.\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
126 printf "Please run:\nsudo mkdir -p %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
127 false; \
129 @if ! touch "$(COREBOOT_JENKINS_CACHE_DIR)/testfile" 2>/dev/null; then \
130 printf "\nError: Cannot create file in %s." "$(COREBOOT_JENKINS_CACHE_DIR)"; \
131 printf "Please run:\nsudo chown -R $(whoami):$(whoami) %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
132 else \
133 rm -f "$(COREBOOT_JENKINS_CACHE_DIR)/testfile"; \
135 $(DOCKER) run -d --privileged --restart=always \
136 -p $(COREBOOT_JENKINS_PORT):49151 \
137 -v $(COREBOOT_JENKINS_CACHE_DIR):/data/cache \
138 --name=$(COREBOOT_JENKINS_CONTAINER) \
139 coreboot/coreboot-jenkins-node:$(COREBOOT_IMAGE_TAG)
141 docker-jenkins-shell: test-docker
142 @if [ ! -d $(COREBOOT_JENKINS_CACHE_DIR) ]; then printf "\nError: %s does not exist.\nPlease run:\nsudo mkdir -p %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)" "$(COREBOOT_JENKINS_CACHE_DIR)"; false; fi
143 $(DOCKER) run -u root -it --privileged \
144 --entrypoint="/bin/bash" \
145 -p $(COREBOOT_JENKINS_PORT):49151 \
146 -v $(top):/home/coreboot/coreboot \
147 -v $(COREBOOT_JENKINS_CACHE_DIR):/data/cache \
148 --name=$(COREBOOT_JENKINS_CONTAINER) \
149 --rm coreboot/coreboot-jenkins-node:$(COREBOOT_IMAGE_TAG)
151 docker-shell: USER=coreboot
152 docker-shell: test-docker
153 $(DOCKER) run -u $(USER) -it \
154 -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) -e TERM=$(TERM) \
155 -w /home/coreboot/coreboot \
156 -v $(top):/home/coreboot/coreboot \
157 --rm coreboot/coreboot-sdk:$(COREBOOT_IMAGE_TAG) \
158 /bin/bash -l
160 docker-jenkins-attach: USER=root
161 docker-jenkins-attach: test-docker
162 $(DOCKER) exec --user $(USER) \
163 -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) -e TERM=$(TERM) \
164 -it "$$(docker ps | grep coreboot-jenkins-node | cut -f1 -d' ')" \
165 /bin/bash -l
167 docker-build-docs: test-docker
168 docker-build-docs:
169 $(DOCKER) run -it --rm \
170 --user $(UID):$(GID) \
171 -v "$(top)/:/data-in/:ro" \
172 -v "$(top)/Documentation/_build/:/data-out/" \
173 doc.coreboot.org
175 docker-livehtml-docs: test-docker
176 docker-livehtml-docs:
177 $(DOCKER) run -it --rm \
178 --net=host -v "$(top)/:/data-in/:ro" \
179 doc.coreboot.org livehtml
181 help:
182 @echo "Commands for working with docker images:"
183 @echo " coreboot-sdk - Build coreboot-sdk container"
184 @echo " upload-coreboot-sdk - Upload coreboot-sdk to hub.docker.com"
185 @echo " coreboot-jenkins-node - Build coreboot-jenkins-node container"
186 @echo " upload-coreboot-jenkins-node - Upload coreboot-jenkins-node to hub.docker.com"
187 @echo " doc.coreboot.org - Build doc.coreboot.org container"
188 @echo " clean-coreboot-containers - Remove all docker coreboot containers"
189 @echo " clean-coreboot-images - Remove all docker coreboot images"
190 @echo " docker-clean - Remove docker coreboot containers & images"
191 @echo
192 @echo "Commands for using docker images"
193 @echo " docker-build-coreboot - Build coreboot under coreboot-sdk"
194 @echo " <BUILD_CMD=target> "
195 @echo " docker-abuild - Run abuild under coreboot-sdk"
196 @echo " <ABUILD_ARGS='-a -B'>"
197 @echo " docker-what-jenkins-does - Run 'what-jenkins-does' target"
198 @echo " docker-shell - Bash prompt in coreboot-jenkins-node"
199 @echo " <USER=root or USER=coreboot>"
200 @echo " docker-jenkins-server - Run coreboot-jenkins-node image (for server)"
201 @echo " docker-jenkins-attach - Open shell in running jenkins server"
202 @echo " docker-build-docs - Build the documentation"
203 @echo " docker-livehtml-docs - Run sphinx-autobuild"
204 @echo
205 @echo "Variables:"
206 @echo " COREBOOT_JENKINS_PORT=$(COREBOOT_JENKINS_PORT)"
207 @echo " COREBOOT_JENKINS_CACHE_DIR=$(COREBOOT_JENKINS_CACHE_DIR)"
208 @echo " COREBOOT_JENKINS_CONTAINER=$(COREBOOT_JENKINS_CONTAINER)"
209 @echo " COREBOOT_IMAGE_TAG=$(COREBOOT_IMAGE_TAG)"
210 @echo " DOCKER_COMMIT=$(DOCKER_COMMIT)"
212 .PHONY: test-docker test-docker-login
213 .PHONY: coreboot-jenkins-node upload-coreboot-jenkins-node
214 .PHONY: coreboot-sdk upload-coreboot-sdk
215 .PHONY: doc.coreboot.org
216 .PHONY: clean-coreboot-containers clean-coreboot-images
217 .PHONY: docker-abuild
218 .PHONY: docker-what-jenkins-does docker-shell docker-jenkins-server docker-jenkins-attach
219 .PHONY: docker-build-docs docker-livehtml-docs
220 .PHONY: help