soc/amd/common/psp/psp_def.h: increase P2C_BUFFER_MAXSIZE
[coreboot.git] / util / docker / Makefile
blob45562d7a7bc9d24627c5c85a9621b6fe5c2ab205
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 $(DOCKER) build \
46 --tag coreboot/coreboot-sdk:$(COREBOOT_IMAGE_TAG) \
47 --build-arg=SDK_VERSION="$(COREBOOT_IMAGE_TAG)" \
48 --build-arg=DOCKER_COMMIT="$(DOCKER_COMMIT)" \
49 --build-arg=CROSSGCC_PARAM="$(COREBOOT_CROSSGCC_PARAM)" \
50 coreboot-sdk
52 coreboot-jenkins-test: test-docker
53 @echo "Testing coreboot SDK and jenkins node version $(crossgcc_version), built from commit $(DOCKER_COMMIT)"
54 $(DOCKER) build \
55 --tag coreboot/coreboot-jenkins-test:$(COREBOOT_IMAGE_TAG) \
56 --build-arg=SDK_VERSION="$(COREBOOT_IMAGE_TAG)" \
57 coreboot-jenkins-test
59 upload-coreboot-sdk: test-docker-login
60 $(DOCKER) push coreboot/coreboot-sdk:$(COREBOOT_IMAGE_TAG)
62 coreboot-jenkins-node: test-docker
63 cat coreboot-jenkins-node/Dockerfile | \
64 sed "s/{{SDK_VERSION}}/$(COREBOOT_IMAGE_TAG)/g" | \
65 sed "s|{{SSH_KEY}}|$$(cat coreboot-jenkins-node/authorized_keys)|" | \
66 $(DOCKER) build -t coreboot/coreboot-jenkins-node:$(COREBOOT_IMAGE_TAG) -
68 upload-coreboot-jenkins-node: test-docker-login
69 $(DOCKER) push coreboot/coreboot-jenkins-node:$(COREBOOT_IMAGE_TAG)
71 doc.coreboot.org: test-docker
72 $(DOCKER) build --force-rm -t doc.coreboot.org \
73 $(top)/util/docker/doc.coreboot.org/
75 docker-killall: test-docker
76 @if [ -n "$$($(DOCKER) ps | grep 'coreboot')" ]; then \
77 $(DOCKER) kill $$($(DOCKER) ps | grep 'coreboot' | cut -f1 -d ' '); \
80 clean-coreboot-containers: docker-killall
81 @if [ -n "$$($(DOCKER) ps -a | grep 'coreboot')" ]; then \
82 $(DOCKER) rm $$($(DOCKER) ps -a | grep 'coreboot' | sed 's|\s.*$$||'); \
85 clean-coreboot-images: docker-killall
86 @if [ -n "$$($(DOCKER) images | grep 'coreboot')" ]; then \
87 $(DOCKER) rmi $$($(DOCKER) images | grep coreboot | sed 's|^\S\+\s\+\S\+\s\+||' | sed 's|\s.*$$||'); \
90 docker-clean: clean-coreboot-containers
91 @$(MAKE) clean-coreboot-images
93 docker-cleanall: test-docker
94 ifeq ($(Y),1)
95 @if [ -n "$$($(DOCKER) ps -a | grep -v "CONTAINER")" ]; then \
96 $(DOCKER) kill $$($(DOCKER) ps | grep -v "CONTAINER" | sed 's|\s.*$$||') ; \
97 $(DOCKER) rm $$($(DOCKER) ps -a | grep -v "CONTAINER" | sed 's|\s.*$$||'); \
99 @if [ -n "$$($(DOCKER) images | grep -v "REPOSITORY")" ]; then \
100 $(DOCKER) rmi $$($(DOCKER) images | grep -v "REPOSITORY" | tr -s ' ' | cut -f3 -d ' '); \
102 else
103 echo "This will remove *ALL* docker containers from your machine."
104 echo "If this is what you want, run 'make docker-cleanall Y=1'"
105 endif
107 $(DOCKER_CCACHE):
108 @mkdir -p $@
110 docker-run-local: test-docker $(DOCKER_CCACHE)
111 $(DOCKER) run -it --rm \
112 --volume $(DOCKER_CCACHE):/home/coreboot/.ccache \
113 --volume $(top):/home/coreboot/coreboot \
114 --env HOME=/home/coreboot \
115 --user $(UID):$(GID) \
116 coreboot/coreboot-sdk:$(COREBOOT_IMAGE_TAG) \
117 /bin/bash -c 'cd $${HOME}/coreboot && $(DOCKER_RUN_LOCAL)'
119 docker-build-coreboot: docker-run-local
120 docker-build-coreboot: override DOCKER_RUN_LOCAL := \
121 make clean && make $(BUILD_CMD)
123 docker-abuild: docker-run-local
124 docker-abuild: override DOCKER_RUN_LOCAL := \
125 make clean && util/abuild/abuild $(ABUILD_ARGS)
127 docker-what-jenkins-does: docker-run-local
128 docker-what-jenkins-does: override DOCKER_RUN_LOCAL := \
129 make clean && make what-jenkins-does CPUS=$(CPUS)
131 test-docker-cache-dir:
132 @if [ ! -d "$(COREBOOT_JENKINS_CACHE_DIR)" ]; then \
133 printf "\nError: %s does not exist.\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
134 printf "Please run:\nsudo mkdir -p %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
135 printf "sudo chown -R $$(whoami):$$(whoami) %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
136 false; \
138 @if ! touch "$(COREBOOT_JENKINS_CACHE_DIR)/testfile" 2>/dev/null; then \
139 printf "\nError: Cannot create file in %s." "$(COREBOOT_JENKINS_CACHE_DIR)"; \
140 printf "Please run:\nsudo chown -R $$(whoami):$$(whoami) %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
141 false; \
142 else \
143 rm -f "$(COREBOOT_JENKINS_CACHE_DIR)/testfile"; \
146 docker-jenkins-server: test-docker-cache-dir test-docker
147 $(DOCKER) run -d --privileged --restart=always \
148 -p $(COREBOOT_JENKINS_PORT):49151 \
149 -v $(COREBOOT_JENKINS_CACHE_DIR):/data/cache \
150 --name=$(COREBOOT_JENKINS_CONTAINER) \
151 coreboot/coreboot-jenkins-node:$(COREBOOT_IMAGE_TAG)
153 docker-jenkins-shell: test-docker-cache-dir test-docker
154 $(DOCKER) run -u root -it --privileged \
155 --entrypoint="/bin/bash" \
156 -p $(COREBOOT_JENKINS_PORT):49151 \
157 -v $(top):/home/coreboot/coreboot \
158 -v $(COREBOOT_JENKINS_CACHE_DIR):/data/cache \
159 --name=$(COREBOOT_JENKINS_CONTAINER) \
160 --rm coreboot/coreboot-jenkins-node:$(COREBOOT_IMAGE_TAG)
162 docker-shell: USER=coreboot
163 docker-shell: test-docker
164 $(DOCKER) run -u $(USER) -it \
165 -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) -e TERM=$(TERM) \
166 -w /home/coreboot/coreboot \
167 -v $(top):/home/coreboot/coreboot \
168 --rm coreboot/coreboot-sdk:$(COREBOOT_IMAGE_TAG) \
169 /bin/bash -l
171 docker-jenkins-attach: USER=root
172 docker-jenkins-attach: test-docker
173 $(DOCKER) exec --user $(USER) \
174 -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) -e TERM=$(TERM) \
175 -it "$$(docker ps | grep coreboot-jenkins-node | cut -f1 -d' ')" \
176 /bin/bash -l
178 docker-build-docs: test-docker
179 docker-build-docs:
180 mkdir -p $(top)/Documentation/_build
181 $(DOCKER) run -it --rm \
182 --user $(UID):$(GID) \
183 -v "$(top)/:/data-in/:ro" \
184 -v "$(top)/Documentation/_build/:/data-out/" \
185 doc.coreboot.org
187 docker-livehtml-docs: test-docker
188 docker-livehtml-docs:
189 $(DOCKER) run -it --rm \
190 --net=host -v "$(top)/:/data-in/:ro" \
191 doc.coreboot.org livehtml
193 help:
194 @echo "Commands for working with docker images:"
195 @echo " coreboot-sdk - Build coreboot-sdk container"
196 @echo " coreboot-jenkins-test - Test the coreboot-jenkins-node build functionality"
197 @echo " upload-coreboot-sdk - Upload coreboot-sdk to hub.docker.com"
198 @echo " coreboot-jenkins-node - Build coreboot-jenkins-node container"
199 @echo " upload-coreboot-jenkins-node - Upload coreboot-jenkins-node to hub.docker.com"
200 @echo " doc.coreboot.org - Build doc.coreboot.org container"
201 @echo " clean-coreboot-containers - Remove all docker coreboot containers"
202 @echo " clean-coreboot-images - Remove all docker coreboot images"
203 @echo " docker-clean - Remove docker coreboot containers & images"
204 @echo
205 @echo "Commands for using docker images"
206 @echo " docker-build-coreboot - Build coreboot under coreboot-sdk"
207 @echo " <BUILD_CMD=target> "
208 @echo " docker-abuild - Run abuild under coreboot-sdk"
209 @echo " <ABUILD_ARGS='-a -B'>"
210 @echo " docker-what-jenkins-does - Run 'what-jenkins-does' target"
211 @echo " docker-jenkins-shell - Bash prompt in coreboot-jenkins-node"
212 @echo " <USER=root or USER=coreboot>"
213 @echo " docker-shell - Bash prompt in coreboot-sdk"
214 @echo " <USER=root or USER=coreboot>"
215 @echo " docker-jenkins-server - Run coreboot-jenkins-node image (for server)"
216 @echo " docker-jenkins-attach - Open shell in running jenkins server"
217 @echo " docker-build-docs - Build the documentation"
218 @echo " docker-livehtml-docs - Run sphinx-autobuild"
219 @echo
220 @echo "Variables:"
221 @echo " COREBOOT_JENKINS_PORT=$(COREBOOT_JENKINS_PORT)"
222 @echo " COREBOOT_JENKINS_CACHE_DIR=$(COREBOOT_JENKINS_CACHE_DIR)"
223 @echo " COREBOOT_JENKINS_CONTAINER=$(COREBOOT_JENKINS_CONTAINER)"
224 @echo " COREBOOT_IMAGE_TAG=$(COREBOOT_IMAGE_TAG)"
225 @echo " DOCKER_COMMIT=$(DOCKER_COMMIT)"
227 .PHONY: test-docker test-docker-login test-docker-cache-dir
228 .PHONY: coreboot-jenkins-node upload-coreboot-jenkins-node coreboot-jenkins-test
229 .PHONY: coreboot-sdk upload-coreboot-sdk
230 .PHONY: doc.coreboot.org
231 .PHONY: clean-coreboot-containers clean-coreboot-images docker-cleanall
232 .PHONY: docker-abuild
233 .PHONY: docker-shell docker-jenkins-shell
234 .PHONY: docker-what-jenkins-does docker-jenkins-server docker-jenkins-attach
235 .PHONY: docker-build-docs docker-livehtml-docs
236 .PHONY: help