blob: 60332c0a1855f2ab28eeb31e29f9a6bae769303d [file] [log] [blame]
Nico Huberc0b52db2022-12-15 12:42:32 +00001QUIET_TEST := @
2
3include Makefile.targets
4
5CC := ccache cc
6MAKECMD := make
7MAKEARGS := CONFIG_EVERYTHING=yes
8
9spc :=
10spc := $(spc) $(spc)
11
12stem = $(word 1,$(subst :,$(spc),$(subst \:,$(spc),$(1))))
13ident = $(subst :,_,$(subst \:,_,$(1)))
14
15include Makefile.anita
16
17define build_template
18Dockerfile.$(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)
25endef
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
33djgpp\:6.1.0-build: %-build: Dockerfile.djgpp mani-wrapper.sh
34 $(QUIET_SETUP)docker build . -f $< -t mani/$*
35
Nico Huberfb9c18a2022-12-10 23:59:19 +010036git-check-build $(addsuffix -check-build,$(ALL_TAGS)): %-check-build:
Nico Huberc0b52db2022-12-15 12:42:32 +000037 $(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
42djgpp\:6.1.0: CC=ccache i586-pc-msdosdjgpp-gcc
43djgpp\:6.1.0: STRIP=i586-pc-msdosdjgpp-strip
44djgpp\:6.1.0: LIBS_BASE=../
45djgpp\: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)
Nico Huber725a19e2022-12-11 00:01:04 +010052$(ALL_TAGS): export TEST_REMOTE?=$(if $(TEST_LOCAL),\
53 git://mani-git/flashrom.git,\
54 origin)
55$(ALL_TAGS): export TEST_REVISION?=$(if $(TEST_LOCAL),HEAD,master)
56$(ALL_TAGS): %: %-check-build mani-net $(if $(TEST_LOCAL),local-git)
Nico Huberc0b52db2022-12-15 12:42:32 +000057 $(QUIET_TEST)docker rm -f mani_$(call ident,$*) >/dev/null 2>&1 || true
58 $(QUIET_TEST)\
59 docker run \
Nico Huber48b1fde2022-12-11 17:15:27 +000060 $(MANI_DOCKER_ARGS) \
Nico Huberc0b52db2022-12-15 12:42:32 +000061 --env IDENT=$(call ident,$*) \
62 --volume manicache:/home/mani/.ccache \
Nico Huberbfe64842022-12-10 23:54:24 +010063 --network=manibuilder \
Nico Huberc0b52db2022-12-15 12:42:32 +000064 --name mani_$(call ident,$*) mani/$* \
Nico Huberaa359a72022-12-10 23:52:46 +010065 "git fetch $(TEST_REMOTE) $(TEST_REVISION) && \
Nico Huberc0b52db2022-12-15 12:42:32 +000066 git checkout FETCH_HEAD && \
67 $(MAKECMD) clean && $(MAKECMD) -j$${CPUS:-1} CC='$(CC)' \
68 $(if $(STRIP),STRIP='$(STRIP)') \
69 $(if $(LIBS_BASE),LIBS_BASE='$(LIBS_BASE)') \
70 $(MAKEARGS)" \
Nico Huberd4fbbb42022-12-11 17:02:57 +000071 $(if $(QUIET_TEST),>/dev/null 2>&1) \
72 || { RET=$$?; echo $*: $${RET}; exit $${RET}; }
Nico Huberc0b52db2022-12-15 12:42:32 +000073
74$(addsuffix -shell,$(ALL_TAGS)): %-shell: %-check-build
75 $(QUIET_SETUP)\
76 if [ $$(docker ps -a -q -f name=mani_$(call ident,$*)) ]; then \
77 docker commit mani_$(call ident,$*) mani_run/$* && \
78 docker run --rm -it \
Nico Huber48b1fde2022-12-11 17:15:27 +000079 $(MANI_DOCKER_ARGS) \
Nico Huberc0b52db2022-12-15 12:42:32 +000080 --env IDENT=$(call ident,$*) \
81 --volume manicache:/home/mani/.ccache \
Nico Huberbfe64842022-12-10 23:54:24 +010082 --network=manibuilder \
Nico Huberc0b52db2022-12-15 12:42:32 +000083 --entrypoint /bin/sh mani_run/$* \
84 /home/mani/mani-wrapper.sh \
85 $(patsubst %,"%",$(SHELL_ARG)); \
86 docker image rm mani_run/$*; \
87 else \
88 docker run --rm -it \
Nico Huber48b1fde2022-12-11 17:15:27 +000089 $(MANI_DOCKER_ARGS) \
Nico Huberc0b52db2022-12-15 12:42:32 +000090 --env IDENT=$(call ident,$*) \
91 --volume manicache:/home/mani/.ccache \
Nico Huberbfe64842022-12-10 23:54:24 +010092 --network=manibuilder \
Nico Huberc0b52db2022-12-15 12:42:32 +000093 mani/$* $(patsubst %,"%",$(SHELL_ARG)); \
94 fi
95
96.PHONY: $(foreach s,-build -check-build -shell, $(addsuffix $(s),$(ALL_TAGS)))
97
98register:
99 docker build . \
100 -f Dockerfile.qemu-user-static \
101 -t mani/qemu-user-static:register
102 docker run --rm --privileged mani/qemu-user-static:register --reset
103
Nico Huberbfe64842022-12-10 23:54:24 +0100104mani-net:
105 $(QUIET_SETUP)\
106 if [ -z "$$(docker network ls -qf name=manibuilder)" ]; then \
107 docker network create manibuilder \
108 $(if $(QUIET_SETUP),>/dev/null); \
109 fi
110
Nico Huberfb9c18a2022-12-10 23:59:19 +0100111git-build: Dockerfile.git
112 $(QUIET_SETUP)docker build . -f $< -t mani/git
113
114local-git: TEST_LOCAL_GIT:=$(abspath $(wildcard \
115 $(TEST_LOCAL)$(if $(filter %.git,$(TEST_LOCAL)),,/.git)))
116local-git: git-check-build mani-net
117 $(QUIET_SETUP)\
118 if [ -z "$(TEST_LOCAL_GIT)" ]; then \
119 echo '$${TEST_LOCAL} should point to a Git repository.'; \
120 exit 1; \
121 fi; \
122 if [ -n "$$(docker container ls -qf name=mani-git)" ]; then \
123 if docker inspect -f '{{ .Mounts }}' mani-git | \
124 grep -q ' $(TEST_LOCAL_GIT) '; then \
125 exit 0; \
126 else \
127 docker stop mani-git >/dev/null; \
128 fi; \
129 fi; \
130 docker run --rm --detach \
131 --name mani-git \
132 --volume=$(TEST_LOCAL_GIT):/git/flashrom.git:ro \
133 --network=manibuilder \
134 mani/git $(if $(QUIET_SETUP),>/dev/null)
135
136.PHONY: register mani-net git-build local-git