blob: 4120979c6136e0087538162725c8065a13c33559 [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
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
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 Huber34846e42022-12-10 23:45:38 +010052$(ALL_TAGS): export TEST_REVISION?=master
Nico Huberaa359a72022-12-10 23:52:46 +010053$(ALL_TAGS): export TEST_REMOTE?=origin
Nico Huberbfe64842022-12-10 23:54:24 +010054$(ALL_TAGS): %: %-check-build mani-net
Nico Huberc0b52db2022-12-15 12:42:32 +000055 $(QUIET_TEST)docker rm -f mani_$(call ident,$*) >/dev/null 2>&1 || true
56 $(QUIET_TEST)\
57 docker run \
58 --env IDENT=$(call ident,$*) \
59 --volume manicache:/home/mani/.ccache \
Nico Huberbfe64842022-12-10 23:54:24 +010060 --network=manibuilder \
Nico Huberc0b52db2022-12-15 12:42:32 +000061 --name mani_$(call ident,$*) mani/$* \
Nico Huberaa359a72022-12-10 23:52:46 +010062 "git fetch $(TEST_REMOTE) $(TEST_REVISION) && \
Nico Huberc0b52db2022-12-15 12:42:32 +000063 git checkout FETCH_HEAD && \
64 $(MAKECMD) clean && $(MAKECMD) -j$${CPUS:-1} CC='$(CC)' \
65 $(if $(STRIP),STRIP='$(STRIP)') \
66 $(if $(LIBS_BASE),LIBS_BASE='$(LIBS_BASE)') \
67 $(MAKEARGS)" \
68 $(if $(QUIET_TEST),>/dev/null 2>&1) || echo $*: $$?
69
70$(addsuffix -shell,$(ALL_TAGS)): %-shell: %-check-build
71 $(QUIET_SETUP)\
72 if [ $$(docker ps -a -q -f name=mani_$(call ident,$*)) ]; then \
73 docker commit mani_$(call ident,$*) mani_run/$* && \
74 docker run --rm -it \
75 --env IDENT=$(call ident,$*) \
76 --volume manicache:/home/mani/.ccache \
Nico Huberbfe64842022-12-10 23:54:24 +010077 --network=manibuilder \
Nico Huberc0b52db2022-12-15 12:42:32 +000078 --entrypoint /bin/sh mani_run/$* \
79 /home/mani/mani-wrapper.sh \
80 $(patsubst %,"%",$(SHELL_ARG)); \
81 docker image rm mani_run/$*; \
82 else \
83 docker run --rm -it \
84 --env IDENT=$(call ident,$*) \
85 --volume manicache:/home/mani/.ccache \
Nico Huberbfe64842022-12-10 23:54:24 +010086 --network=manibuilder \
Nico Huberc0b52db2022-12-15 12:42:32 +000087 mani/$* $(patsubst %,"%",$(SHELL_ARG)); \
88 fi
89
90.PHONY: $(foreach s,-build -check-build -shell, $(addsuffix $(s),$(ALL_TAGS)))
91
92register:
93 docker build . \
94 -f Dockerfile.qemu-user-static \
95 -t mani/qemu-user-static:register
96 docker run --rm --privileged mani/qemu-user-static:register --reset
97
Nico Huberbfe64842022-12-10 23:54:24 +010098mani-net:
99 $(QUIET_SETUP)\
100 if [ -z "$$(docker network ls -qf name=manibuilder)" ]; then \
101 docker network create manibuilder \
102 $(if $(QUIET_SETUP),>/dev/null); \
103 fi
104
105.PHONY: register mani-net