diff --git a/build/makefile_base.mak b/build/makefile_base.mak index e44f079d..1d4a9aaa 100644 --- a/build/makefile_base.mak +++ b/build/makefile_base.mak @@ -59,6 +59,10 @@ endif export CC export CXX +# If set below, we're invoking some build steps in a container that requires sudo -- will test sudo and show a warning +# at build start. +USING_SUDO_CONTAINER := + # Selected container mode shell DOCKER_SHELL_BASE = sudo docker run --rm --init -v $(HOME):$(HOME) -w $(CURDIR) -e HOME=$(HOME) \ -v /etc/passwd:/etc/passwd:ro -u $(shell id -u):$(shell id -g) -h $(shell hostname) \ @@ -69,12 +73,14 @@ DOCKER_SHELL_BASE = sudo docker run --rm --init -v $(HOME):$(HOME) -w $(CURDIR) ifeq ($(STEAMRT64_MODE),docker) SELECT_DOCKER_IMAGE := $(STEAMRT64_IMAGE) CONTAINER_SHELL64 := $(DOCKER_SHELL_BASE) + USING_SUDO_CONTAINER := 1 else ifneq ($(STEAMRT64_MODE),) foo := $(error Unrecognized STEAMRT64_MODE $(STEAMRT64_MODE)) endif ifeq ($(STEAMRT32_MODE),docker) SELECT_DOCKER_IMAGE := $(STEAMRT32_IMAGE) CONTAINER_SHELL32 := $(DOCKER_SHELL_BASE) + USING_SUDO_CONTAINER := 1 else ifneq ($(STEAMRT32_MODE),) foo := $(error Unrecognized STEAMRT32_MODE $(STEAMRT32_MODE)) endif @@ -96,15 +102,28 @@ ifndef CONTAINER_SHELL32 CONTAINER_SHELL32 := $(SHELL) endif -$(info Testing configured 64bit container) -ifneq ($(shell $(CONTAINER_SHELL64) -c "echo hi"), hi) -$(error "Cannot run commands in 64bit container") +# Using a sudo container? Make sure we have sudo and show warning +ifeq ($(USING_SUDO_CONTAINER),1) +$(info :: NOTE: Some build steps will run in a container, which invokes sudo automatically) +$(info :: If building in parallel (-j) this can result in sudo prompts buried in the output) +$(info :: Testing sudo access now) +ifneq ($(shell sudo echo hi),hi) +$(error Failed to invoke sudo) endif -$(info Testing configured 32bit container) -ifneq ($(shell $(CONTAINER_SHELL32) -c "echo hi"), hi) -$(error "Cannot run commands in 32bit container") endif +# Helper to test +.PHONY: test-container test-container32 test-container64 +test-container: test-container64 test-container32 + +test-container64: + @echo >&2 ":: Testing 64-bit container" + $(CONTAINER_SHELL64) -c "echo Hello World!" + +test-container32: + @echo >&2 ":: Testing 32-bit container" + $(CONTAINER_SHELL32) -c "echo Hello World!" + # Many of the configure steps below depend on the makefile itself, such that they are dirtied by changing the recipes # that create them. This can be annoying when working on the makefile, building with NO_MAKEFILE_DEPENDENCY=1 disables # this.