Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 1 | QUIET_TEST := @ |
| 2 | |
| 3 | include Makefile.targets |
| 4 | |
| 5 | CC := ccache cc |
| 6 | MAKECMD := make |
| 7 | MAKEARGS := CONFIG_EVERYTHING=yes |
| 8 | |
| 9 | spc := |
| 10 | spc := $(spc) $(spc) |
| 11 | |
| 12 | stem = $(word 1,$(subst :,$(spc),$(subst \:,$(spc),$(1)))) |
| 13 | ident = $(subst :,_,$(subst \:,_,$(1))) |
| 14 | |
| 15 | include Makefile.anita |
| 16 | |
| 17 | define build_template |
| 18 | Dockerfile.$(call ident,$(1)): Dockerfile.$(call stem,$(1)) mani-wrapper.sh |
| 19 | $(QUIET_SETUP)sed -e 's|^FROM manibase|FROM $(2)/$(1)|' $$< >$$@ |
| 20 | |
| 21 | .INTERMEDIATE: Dockerfile.$(call ident,$(1)) |
| 22 | |
| 23 | $(1)-build: Dockerfile.$(call ident,$(1)) |
| 24 | $(QUIET_SETUP)docker build . -f $$< -t mani/$(1) $$(DOCKER_BUILD_ARGS) |
| 25 | endef |
| 26 | |
| 27 | $(foreach tag,$(MULTIARCH_TAGS), \ |
| 28 | $(eval $(call build_template,$(tag),multiarch))) |
| 29 | |
| 30 | $(addsuffix -build,$(filter alpine%v3.7 alpine%v3.8,$(MULTIARCH_TAGS))): \ |
| 31 | DOCKER_BUILD_ARGS = --build-arg PROTO=http |
| 32 | |
| 33 | djgpp\:6.1.0-build: %-build: Dockerfile.djgpp mani-wrapper.sh |
| 34 | $(QUIET_SETUP)docker build . -f $< -t mani/$* |
| 35 | |
| 36 | $(addsuffix -check-build,$(ALL_TAGS)): %-check-build: |
| 37 | $(QUIET_SETUP)\ |
| 38 | [ $$(docker image ls -q mani/$*) ] \ |
| 39 | || $(MAKE) $*-build $(if $(QUIET_SETUP),>/dev/null 2>/dev/null) |
| 40 | |
| 41 | $(filter centos%,$(MULTIARCH_TAGS)) anita\:7.1-sparc: CC=cc |
| 42 | djgpp\:6.1.0: CC=ccache i586-pc-msdosdjgpp-gcc |
| 43 | djgpp\:6.1.0: STRIP=i586-pc-msdosdjgpp-strip |
| 44 | djgpp\:6.1.0: LIBS_BASE=../ |
| 45 | djgpp\:6.1.0: MAKEARGS+=strip CONFIG_JLINK_SPI=no |
| 46 | $(ANITA_TAGS): MAKECMD=gmake |
| 47 | $(ANITA_TAGS): MAKEARGS+=CONFIG_JLINK_SPI=no WARNERROR=no |
| 48 | $(filter alpine% centos%,$(MULTIARCH_TAGS)): MAKEARGS+=CONFIG_JLINK_SPI=no |
| 49 | $(filter %-xenial %-stretch,$(MULTIARCH_TAGS)): MAKEARGS+=CONFIG_JLINK_SPI=no |
| 50 | $(filter centos%,$(MULTIARCH_TAGS)): MAKEARGS+=WARNERROR=no |
| 51 | $(ALL_TAGS): export QUIET_SETUP=$(QUIET_TEST) |
| 52 | $(ALL_TAGS): %: %-check-build |
| 53 | $(QUIET_TEST)docker rm -f mani_$(call ident,$*) >/dev/null 2>&1 || true |
| 54 | $(QUIET_TEST)\ |
| 55 | docker run \ |
| 56 | --env IDENT=$(call ident,$*) \ |
| 57 | --volume manicache:/home/mani/.ccache \ |
| 58 | --name mani_$(call ident,$*) mani/$* \ |
| 59 | "git fetch origin $${TEST_REVISION:-master} && \ |
| 60 | git checkout FETCH_HEAD && \ |
| 61 | $(MAKECMD) clean && $(MAKECMD) -j$${CPUS:-1} CC='$(CC)' \ |
| 62 | $(if $(STRIP),STRIP='$(STRIP)') \ |
| 63 | $(if $(LIBS_BASE),LIBS_BASE='$(LIBS_BASE)') \ |
| 64 | $(MAKEARGS)" \ |
| 65 | $(if $(QUIET_TEST),>/dev/null 2>&1) || echo $*: $$? |
| 66 | |
| 67 | $(addsuffix -shell,$(ALL_TAGS)): %-shell: %-check-build |
| 68 | $(QUIET_SETUP)\ |
| 69 | if [ $$(docker ps -a -q -f name=mani_$(call ident,$*)) ]; then \ |
| 70 | docker commit mani_$(call ident,$*) mani_run/$* && \ |
| 71 | docker run --rm -it \ |
| 72 | --env IDENT=$(call ident,$*) \ |
| 73 | --volume manicache:/home/mani/.ccache \ |
| 74 | --entrypoint /bin/sh mani_run/$* \ |
| 75 | /home/mani/mani-wrapper.sh \ |
| 76 | $(patsubst %,"%",$(SHELL_ARG)); \ |
| 77 | docker image rm mani_run/$*; \ |
| 78 | else \ |
| 79 | docker run --rm -it \ |
| 80 | --env IDENT=$(call ident,$*) \ |
| 81 | --volume manicache:/home/mani/.ccache \ |
| 82 | mani/$* $(patsubst %,"%",$(SHELL_ARG)); \ |
| 83 | fi |
| 84 | |
| 85 | .PHONY: $(foreach s,-build -check-build -shell, $(addsuffix $(s),$(ALL_TAGS))) |
| 86 | |
| 87 | register: |
| 88 | docker build . \ |
| 89 | -f Dockerfile.qemu-user-static \ |
| 90 | -t mani/qemu-user-static:register |
| 91 | docker run --rm --privileged mani/qemu-user-static:register --reset |
| 92 | |
| 93 | .PHONY: register |