mb/google/poppy/variants/nocturne: Tune DPTF settings for CPU
[coreboot.git] / util / docker / Makefile
blobbeb2a7ed891ad3982f105877f2492c5bd7858677
1 ##
2 ## This file is part of the coreboot project.
3 ##
4 ## Copyright (C) 2016 Google, Inc.
5 ##
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; version 2 of the License.
9 ##
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 export top=$(abspath $(CURDIR)/../..)
16 export crossgcc_version=$(shell $(top)/util/crossgcc/buildgcc --version | grep 'cross toolchain' | sed 's/^.*\sv//' | sed 's/\s.*$$//')
17 export DOCKER:=$(shell $(SHELL) -c "command -v docker")
19 # Local port to forward to the jenkins image for the test server
20 export COREBOOT_JENKINS_PORT?=49151
22 # Local cache directory - for storing files shared with the docker image
23 export COREBOOT_JENKINS_CACHE_DIR?=/srv/docker/coreboot-builder/cache
25 # Name of the jenkins container
26 export COREBOOT_JENKINS_CONTAINER?=coreboot_jenkins
28 # Version of the jenkins / sdk container
29 export COREBOOT_CONTAINER_VERSION?=$(crossgcc_version)
31 # Commit id to build from
32 export DOCKER_COMMIT?=$(shell git log -n 1 --pretty=%h)
34 # SDK architecture
35 export COREBOOT_CROSSGCC_PARAM?=all_without_gdb
37 UID ?= $(shell id -u)
38 GID ?= $(shell id -g)
40 test-docker:
41 $(if $(DOCKER),,\
42 $(warning Docker command not found. Please install docker) \
43 $(warning https://docs.docker.com/engine/installation ) \
44 $(error halting))
46 test-docker-login: test-docker
47 $(if $(shell if [ ! -f ~/.docker/config.json ]; then \
48 echo "docker authentication file not found"; fi), \
49 $(error Docker authentication file not found. Run 'docker login'))
51 coreboot-sdk: test-docker
52 @echo "Building coreboot SDK $(crossgcc_version) from commit $(DOCKER_COMMIT)"
53 cat coreboot-sdk/Dockerfile | \
54 sed "s/{{DOCKER_COMMIT}}/$(DOCKER_COMMIT)/" | \
55 sed "s/{{SDK_VERSION}}/$(COREBOOT_CONTAINER_VERSION)/" | \
56 sed "s/{{CROSSGCC_PARAM}}/$(COREBOOT_CROSSGCC_PARAM)/" | \
57 $(DOCKER) build -t coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) -
59 upload-coreboot-sdk: test-docker-login
60 $(DOCKER) push coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION)
62 coreboot-jenkins-node: test-docker
63 cat coreboot-jenkins-node/Dockerfile | \
64 sed "s/{{SDK_VERSION}}/$(COREBOOT_CONTAINER_VERSION)/" | \
65 sed "s|{{SSH_KEY}}|$$(cat coreboot-jenkins-node/authorized_keys)|" | \
66 $(DOCKER) build -t coreboot/coreboot-jenkins-node:$(COREBOOT_CONTAINER_VERSION) -
68 upload-coreboot-jenkins-node: test-docker-login
69 $(DOCKER) push coreboot/coreboot-jenkins-node:$(COREBOOT_CONTAINER_VERSION)
71 docker-killall: test-docker
72 @if [ -n "$$($(DOCKER) ps | grep 'coreboot')" ]; then \
73 $(DOCKER) kill $$($(DOCKER) ps | grep 'coreboot' | cut -f1 -d ' '); \
76 clean-coreboot-containers: docker-killall
77 @if [ -n "$$($(DOCKER) ps -a | grep 'coreboot')" ]; then \
78 $(DOCKER) rm $$($(DOCKER) ps -a | grep 'coreboot' | sed 's|\s.*$$||'); \
81 clean-coreboot-images: docker-killall
82 @if [ -n "$$($(DOCKER) images | grep 'coreboot')" ]; then \
83 $(DOCKER) rmi $$($(DOCKER) images | grep coreboot | sed 's|^\S\+\s\+\S\+\s\+||' | sed 's|\s.*$$||'); \
86 docker-clean: clean-coreboot-containers
87 @$(MAKE) clean-coreboot-images
89 docker-cleanall:
90 @if [ -n "$$($(DOCKER) ps -a | grep -v "CONTAINER")" ]; then \
91 $(DOCKER) kill $$($(DOCKER) ps -a | grep -v "CONTAINER" | sed 's|\s.*$$||'); \
92 $(DOCKER) rm $$($(DOCKER) ps -a | grep -v "CONTAINER" | sed 's|\s.*$$||'); \
94 @if [ -n "$$($(DOCKER) images | grep -v "REPOSITORY")" ]; then \
95 $(DOCKER) rmi $$($(DOCKER) images | grep -v "REPOSITORY" | tr -s ' ' | cut -f3 -d ' '); \
98 docker-build-coreboot: test-docker
99 $(DOCKER) run -u root -it -v $(top):/home/coreboot/coreboot \
100 --user $(UID):$(GID) \
101 --rm coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) \
102 /bin/bash -c "cd /home/coreboot/coreboot && \
103 make clean && \
104 make $(BUILD_CMD); \
105 rm .xcompile"
107 docker-abuild: test-docker
108 $(DOCKER) run -u root -it -v $(top):/home/coreboot/coreboot \
109 --user $(UID):$(GID) \
110 --rm coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) \
111 /bin/bash -c "cd /home/coreboot/coreboot && \
112 make clean && \
113 util/abuild/abuild $(ABUILD_ARGS); \
114 rm -f .xcompile"
116 docker-what-jenkins-does: test-docker
117 $(DOCKER) run -u root -it -v $(top):/home/coreboot/coreboot \
118 --rm coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) \
119 /bin/bash -c "cd /home/coreboot/coreboot && \
120 make clean && make what-jenkins-does CPUS=$(CPUS)"
122 docker-jenkins-server: test-docker
123 @if [ ! -d "$(COREBOOT_JENKINS_CACHE_DIR)" ]; then \
124 printf "\nError: %s does not exist.\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
125 printf "Please run:\nsudo mkdir -p %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
126 false; \
128 @if ! touch "$(COREBOOT_JENKINS_CACHE_DIR)/testfile" 2>/dev/null; then \
129 printf "\nError: Cannot create file in %s." "$(COREBOOT_JENKINS_CACHE_DIR)"; \
130 printf "Please run:\nsudo chown -R $(whoami):$(whoami) %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
131 else \
132 rm -f "$(COREBOOT_JENKINS_CACHE_DIR)/testfile"; \
134 $(DOCKER) run -d --privileged --restart=always \
135 -p $(COREBOOT_JENKINS_PORT):49151 \
136 -v $(COREBOOT_JENKINS_CACHE_DIR):/data/cache \
137 --name=$(COREBOOT_JENKINS_CONTAINER) \
138 coreboot/coreboot-jenkins-node:$(COREBOOT_CONTAINER_VERSION)
140 docker-jenkins-shell: test-docker
141 @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
142 $(DOCKER) run -u root -it --privileged \
143 --entrypoint="/bin/bash" \
144 -p $(COREBOOT_JENKINS_PORT):49151 \
145 -v $(top):/home/coreboot/coreboot \
146 -v $(COREBOOT_JENKINS_CACHE_DIR):/data/cache \
147 --name=$(COREBOOT_JENKINS_CONTAINER) \
148 --rm coreboot/coreboot-jenkins-node:$(COREBOOT_CONTAINER_VERSION)
150 docker-shell: USER=coreboot
151 docker-shell: test-docker
152 $(DOCKER) run -u $(USER) -it \
153 -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) -e TERM=$(TERM) \
154 -w /home/coreboot/coreboot \
155 -v $(top):/home/coreboot/coreboot \
156 --rm coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) \
157 /bin/bash -l
159 docker-jenkins-attach: USER=root
160 docker-jenkins-attach:
161 docker exec --user $(USER) \
162 -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) -e TERM=$(TERM) \
163 -it "$$(docker ps | grep coreboot-jenkins-node | cut -f1 -d' ')" \
164 /bin/bash -l
166 help:
167 @echo "Commands for working with docker images:"
168 @echo " coreboot-sdk - Build coreboot-sdk container"
169 @echo " upload-coreboot-sdk - Upload coreboot-sdk to hub.docker.com"
170 @echo " coreboot-jenkins-node - Build coreboot-jenkins-node container"
171 @echo " upload-coreboot-jenkins-node - Upload coreboot-jenkins-node to hub.docker.com"
172 @echo " clean-coreboot-containers - Remove all docker coreboot containers"
173 @echo " clean-coreboot-images - Remove all docker coreboot images"
174 @echo " clean-docker - Remove docker coreboot containers & images"
175 @echo
176 @echo "Commands for using docker images"
177 @echo " docker-build-coreboot - Build coreboot under coreboot-sdk"
178 @echo " <BUILD_CMD=target> "
179 @echo " docker-abuild - Run abuild under coreboot-sdk"
180 @echo " <ABUILD_ARGS='-a -B'>"
181 @echo " docker-what-jenkins-does - Run 'what-jenkins-does' target"
182 @echo " docker-shell - Bash prompt in coreboot-jenkins-node"
183 @echo " <USER=root or USER=coreboot>"
184 @echo " docker-jenkins-server - Run coreboot-jenkins-node image (for server)"
185 @echo " docker-jenkins-attach - Open shell in running jenkins server"
186 @echo
187 @echo "Variables:"
188 @echo " COREBOOT_JENKINS_PORT=$(COREBOOT_JENKINS_PORT)"
189 @echo " COREBOOT_JENKINS_CACHE_DIR=$(COREBOOT_JENKINS_CACHE_DIR)"
190 @echo " COREBOOT_JENKINS_CONTAINER=$(COREBOOT_JENKINS_CONTAINER)"
191 @echo " COREBOOT_CONTAINER_VERSION=$(COREBOOT_CONTAINER_VERSION)"
192 @echo " DOCKER_COMMIT=$(DOCKER_COMMIT)"
194 .PHONY: test-docker test-docker-login
195 .PHONY: coreboot-jenkins-node upload-coreboot-jenkins-node
196 .PHONY: coreboot-sdk upload-coreboot-sdk
197 .PHONY: clean-coreboot-containers clean-coreboot-images
198 .PHONY: docker-abuild
199 .PHONY: docker-what-jenkins-does docker-shell docker-jenkins-server docker-jenkins-attach
200 .PHONY: help