xref: /aosp_15_r20/external/cpu_features/cmake/ci/Makefile (revision eca53ba6d2e951e174b64682eaf56a36b8204c89)
1*eca53ba6SRoland LevillainPROJECT := cpu_features
2*eca53ba6SRoland LevillainBRANCH := $(shell git rev-parse --abbrev-ref HEAD)
3*eca53ba6SRoland LevillainSHA1 := $(shell git rev-parse --verify HEAD)
4*eca53ba6SRoland Levillain
5*eca53ba6SRoland Levillain# General commands
6*eca53ba6SRoland Levillain.PHONY: help
7*eca53ba6SRoland LevillainBOLD=\e[1m
8*eca53ba6SRoland LevillainRESET=\e[0m
9*eca53ba6SRoland Levillain
10*eca53ba6SRoland Levillainhelp:
11*eca53ba6SRoland Levillain	@echo -e "${BOLD}SYNOPSIS${RESET}"
12*eca53ba6SRoland Levillain	@echo -e "\tmake <target> [NOCACHE=1]"
13*eca53ba6SRoland Levillain	@echo
14*eca53ba6SRoland Levillain	@echo -e "${BOLD}DESCRIPTION${RESET}"
15*eca53ba6SRoland Levillain	@echo -e "\ttest build inside docker container to have a reproductible build."
16*eca53ba6SRoland Levillain	@echo
17*eca53ba6SRoland Levillain	@echo -e "${BOLD}MAKE TARGETS${RESET}"
18*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}help${RESET}: display this help and exit."
19*eca53ba6SRoland Levillain	@echo
20*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}amd64_<stage>${RESET}: build <stage> docker image using an Ubuntu:latest x86_64 base image."
21*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}save_amd64_<stage>${RESET}: Save the <stage> docker image."
22*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}sh_amd64_<stage>${RESET}: run a container using the <stage> docker image (debug purpose)."
23*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}clean_amd64_<stage>${RESET}: Remove cache and docker image."
24*eca53ba6SRoland Levillain	@echo
25*eca53ba6SRoland Levillain	@echo -e "\tWith ${BOLD}<stage>${RESET}:"
26*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}env${RESET}"
27*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}devel${RESET}"
28*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}build${RESET}"
29*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}test${RESET}"
30*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}install_env${RESET}"
31*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}install_devel${RESET}"
32*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}install_build${RESET}"
33*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}install_test${RESET}"
34*eca53ba6SRoland Levillain	@echo -e "\te.g. 'make amd64_build'"
35*eca53ba6SRoland Levillain	@echo
36*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}<target>_<toolchain_stage>${RESET}: build <stage> docker image for a specific toolchain target."
37*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}save_<target>_<toolchain_stage>${RESET}: Save the <stage> docker image for a specific platform."
38*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}sh_<target>_<toolchain_stage>${RESET}: run a container using the <stage> docker image specified (debug purpose)."
39*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}clean_<target>_<toolchain_stage>${RESET}: Remove cache and docker image."
40*eca53ba6SRoland Levillain	@echo
41*eca53ba6SRoland Levillain	@echo -e "\tWith ${BOLD}<target>${RESET}:"
42*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}arm-linux-gnueabihf${RESET} (linaro toolchain)"
43*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}armv8l-linux-gnueabihf${RESET} (linaro toolchain)"
44*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}arm-linux-gnueabi${RESET} (linaro toolchain)"
45*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}armeb-linux-gnueabihf${RESET} (linaro toolchain)"
46*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}armeb-linux-gnueabi${RESET} (linaro toolchain)"
47*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}aarch64-linux-gnu${RESET} (linaro toolchain)"
48*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}aarch64${RESET} (bootlin toolchain)"
49*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}aarch64_be-linux-gnu${RESET} (linaro toolchain)"
50*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}aarch64be${RESET} (bootlin toolchain)"
51*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}mips32${RESET} (codespace toolchain)"
52*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}mips64${RESET} (codespace toolchain)"
53*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}mips32el${RESET} (codespace toolchain)"
54*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}mips64el${RESET} (codespace toolchain)"
55*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}ppc${RESET} (bootlin toolchain)"
56*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}ppc64${RESET} (bootlin toolchain)"
57*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}ppc64le${RESET} (bootlin toolchain)"
58*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}riscv32${RESET} (bootlin toolchain)"
59*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}riscv64${RESET} (bootlin toolchain)"
60*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}s390x${RESET} (bootlin toolchain)"
61*eca53ba6SRoland Levillain	@echo
62*eca53ba6SRoland Levillain	@echo -e "\tWith ${BOLD}<toolchain_stage>${RESET}:"
63*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}env${RESET}"
64*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}devel${RESET}"
65*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}build${RESET}"
66*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}test${RESET}"
67*eca53ba6SRoland Levillain	@echo -e "\te.g. 'make aarch64_test'"
68*eca53ba6SRoland Levillain	@echo
69*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}<VM>${RESET}: build the vagrant <VM> virtual machine."
70*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}clean_<VM>${RESET}: Remove virtual machine for the specified vm."
71*eca53ba6SRoland Levillain	@echo
72*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}<VM>${RESET}:"
73*eca53ba6SRoland Levillain	@echo -e "\t\t${BOLD}freebsd${RESET} (FreeBSD)"
74*eca53ba6SRoland Levillain	@echo
75*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}clean${RESET}: Remove cache and ALL docker images."
76*eca53ba6SRoland Levillain	@echo
77*eca53ba6SRoland Levillain	@echo -e "\t${BOLD}NOCACHE=1${RESET}: use 'docker build --no-cache' when building container (default use cache)."
78*eca53ba6SRoland Levillain	@echo
79*eca53ba6SRoland Levillain	@echo -e "branch: $(BRANCH)"
80*eca53ba6SRoland Levillain	@echo -e "sha1: $(SHA1)"
81*eca53ba6SRoland Levillain
82*eca53ba6SRoland Levillain# Need to add cmd_platform to PHONY otherwise target are ignored since they do not
83*eca53ba6SRoland Levillain# contain recipe (using FORCE do not work here)
84*eca53ba6SRoland Levillain.PHONY: all
85*eca53ba6SRoland Levillainall: build
86*eca53ba6SRoland Levillain
87*eca53ba6SRoland Levillain# Delete all implicit rules to speed up makefile
88*eca53ba6SRoland LevillainMAKEFLAGS += --no-builtin-rules
89*eca53ba6SRoland Levillain.SUFFIXES:
90*eca53ba6SRoland Levillain# Remove some rules from gmake that .SUFFIXES does not remove.
91*eca53ba6SRoland LevillainSUFFIXES =
92*eca53ba6SRoland Levillain# Keep all intermediate files
93*eca53ba6SRoland Levillain# ToDo: try to remove it later
94*eca53ba6SRoland Levillain.SECONDARY:
95*eca53ba6SRoland Levillain
96*eca53ba6SRoland Levillain# Docker image name prefix.
97*eca53ba6SRoland LevillainIMAGE := ${PROJECT}
98*eca53ba6SRoland Levillain
99*eca53ba6SRoland Levillainifdef NOCACHE
100*eca53ba6SRoland LevillainDOCKER_BUILD_CMD := docker build --no-cache
101*eca53ba6SRoland Levillainelse
102*eca53ba6SRoland LevillainDOCKER_BUILD_CMD := docker build
103*eca53ba6SRoland Levillainendif
104*eca53ba6SRoland Levillain
105*eca53ba6SRoland LevillainDOCKER_RUN_CMD := docker run --rm --init --net=host
106*eca53ba6SRoland Levillain
107*eca53ba6SRoland Levillain# $* stem
108*eca53ba6SRoland Levillain# $< first prerequist
109*eca53ba6SRoland Levillain# $@ target name
110*eca53ba6SRoland Levillain
111*eca53ba6SRoland Levillain############
112*eca53ba6SRoland Levillain## NATIVE ##
113*eca53ba6SRoland Levillain############
114*eca53ba6SRoland LevillainSTAGES = env devel build test install_env install_devel install_build install_test
115*eca53ba6SRoland Levillain
116*eca53ba6SRoland Levillaintargets_amd64 = $(addprefix amd64_, $(STAGES))
117*eca53ba6SRoland Levillain.PHONY: $(targets_amd64)
118*eca53ba6SRoland Levillain$(targets_amd64): amd64_%: docker/amd64/Dockerfile
119*eca53ba6SRoland Levillain	#@docker image rm -f ${IMAGE}:amd64_$* 2>/dev/null
120*eca53ba6SRoland Levillain	${DOCKER_BUILD_CMD} \
121*eca53ba6SRoland Levillain --tag ${IMAGE}:amd64_$* \
122*eca53ba6SRoland Levillain --target=$* \
123*eca53ba6SRoland Levillain -f $< \
124*eca53ba6SRoland Levillain ../..
125*eca53ba6SRoland Levillain
126*eca53ba6SRoland Levillain#$(info Create targets: save_amd64 $(addprefix save_amd64_, $(STAGES)) (debug).)
127*eca53ba6SRoland Levillainsave_targets_amd64 = $(addprefix save_amd64_, $(STAGES))
128*eca53ba6SRoland Levillain.PHONY: $(save_targets_amd64)
129*eca53ba6SRoland Levillain$(save_targets_amd64): save_amd64_%: cache/amd64/docker_%.tar
130*eca53ba6SRoland Levillaincache/amd64/docker_%.tar: amd64_%
131*eca53ba6SRoland Levillain	@rm -f $@
132*eca53ba6SRoland Levillain	mkdir -p cache/amd64
133*eca53ba6SRoland Levillain	docker save ${IMAGE}:amd64_$* -o $@
134*eca53ba6SRoland Levillain
135*eca53ba6SRoland Levillain#$(info Create targets: $(addprefix sh_amd64_, $(STAGES)) (debug).)
136*eca53ba6SRoland Levillainsh_targets_amd64 = $(addprefix sh_amd64_, $(STAGES))
137*eca53ba6SRoland Levillain.PHONY: $(sh_targets_amd64)
138*eca53ba6SRoland Levillain$(sh_targets_amd64): sh_amd64_%: amd64_%
139*eca53ba6SRoland Levillain	${DOCKER_RUN_CMD} -it --name ${IMAGE}_amd64_$* ${IMAGE}:amd64_$*
140*eca53ba6SRoland Levillain
141*eca53ba6SRoland Levillain#$(info Create targets: $(addprefix clean_amd64_, $(STAGES)).)
142*eca53ba6SRoland Levillainclean_targets_amd64 = $(addprefix clean_amd64_, $(STAGES))
143*eca53ba6SRoland Levillain.PHONY: clean_amd64 $(clean_targets_amd64)
144*eca53ba6SRoland Levillainclean_amd64: $(clean_targets_amd64)
145*eca53ba6SRoland Levillain$(clean_targets_amd64): clean_amd64_%:
146*eca53ba6SRoland Levillain	docker image rm -f ${IMAGE}:amd64_$* 2>/dev/null
147*eca53ba6SRoland Levillain	rm -f cache/amd64/docker_$*.tar
148*eca53ba6SRoland Levillain
149*eca53ba6SRoland Levillain
150*eca53ba6SRoland Levillain###############
151*eca53ba6SRoland Levillain## TOOLCHAIN ##
152*eca53ba6SRoland Levillain###############
153*eca53ba6SRoland LevillainTOOLCHAIN_TARGETS = \
154*eca53ba6SRoland Levillain aarch64 aarch64be \
155*eca53ba6SRoland Levillain arm-linux-gnueabihf armv8l-linux-gnueabihf arm-linux-gnueabi armeb-linux-gnueabihf armeb-linux-gnueabi \
156*eca53ba6SRoland Levillain aarch64-linux-gnu aarch64_be-linux-gnu \
157*eca53ba6SRoland Levillain mips32 mips32el mips64 mips64el \
158*eca53ba6SRoland Levillain ppc ppc64 ppc64le \
159*eca53ba6SRoland Levillain riscv32 riscv64 \
160*eca53ba6SRoland Levillain s390x
161*eca53ba6SRoland LevillainTOOLCHAIN_STAGES = env devel build test
162*eca53ba6SRoland Levillaindefine toolchain-stage-target =
163*eca53ba6SRoland Levillain#$$(info STAGE: $1)
164*eca53ba6SRoland Levillain#$$(info Create targets: toolchain_$1 $(addsuffix _$1, $(TOOLCHAIN_TARGETS)).)
165*eca53ba6SRoland Levillaintargets_toolchain_$1 = $(addsuffix _$1, $(TOOLCHAIN_TARGETS))
166*eca53ba6SRoland Levillain.PHONY: toolchain_$1 $$(targets_toolchain_$1)
167*eca53ba6SRoland Levillaintoolchain_$1: $$(targets_toolchain_$1)
168*eca53ba6SRoland Levillain$$(targets_toolchain_$1): %_$1: docker/toolchain/Dockerfile
169*eca53ba6SRoland Levillain	#@docker image rm -f ${IMAGE}:$$*_$1 2>/dev/null
170*eca53ba6SRoland Levillain	${DOCKER_BUILD_CMD} \
171*eca53ba6SRoland Levillain --tag ${IMAGE}:$$*_$1 \
172*eca53ba6SRoland Levillain --build-arg TARGET=$$* \
173*eca53ba6SRoland Levillain --target=$1 \
174*eca53ba6SRoland Levillain -f $$< \
175*eca53ba6SRoland Levillain ../..
176*eca53ba6SRoland Levillain
177*eca53ba6SRoland Levillain#$$(info Create targets: save_toolchain_$1 $(addprefix save_, $(addsuffix _$1, $(TOOLCHAIN_TARGETS))) (debug).)
178*eca53ba6SRoland Levillainsave_targets_toolchain_$1 = $(addprefix save_, $(addsuffix _$1, $(TOOLCHAIN_TARGETS)))
179*eca53ba6SRoland Levillain.PHONY: save_toolchain_$1 $$(save_targets_toolchain_$1)
180*eca53ba6SRoland Levillainsave_toolchain_$1: $$(save_targets_toolchain_$1)
181*eca53ba6SRoland Levillain$$(save_targets_toolchain_$1): save_%_$1: cache/%/docker_$1.tar
182*eca53ba6SRoland Levillaincache/%/docker_$1.tar: %_$1
183*eca53ba6SRoland Levillain	@rm -f $$@
184*eca53ba6SRoland Levillain	mkdir -p cache/$$*
185*eca53ba6SRoland Levillain	docker save ${IMAGE}:$$*_$1 -o $$@
186*eca53ba6SRoland Levillain
187*eca53ba6SRoland Levillain#$$(info Create targets: $(addprefix sh_, $(addsuffix _$1, $(TOOLCHAIN_TARGETS))) (debug).)
188*eca53ba6SRoland Levillainsh_targets_toolchain_$1 = $(addprefix sh_, $(addsuffix _$1, $(TOOLCHAIN_TARGETS)))
189*eca53ba6SRoland Levillain.PHONY: $$(sh_targets_toolchain_$1)
190*eca53ba6SRoland Levillain$$(sh_targets_toolchain_$1): sh_%_$1: %_$1
191*eca53ba6SRoland Levillain	${DOCKER_RUN_CMD} -it --name ${IMAGE}_$$*_$1 ${IMAGE}:$$*_$1
192*eca53ba6SRoland Levillain
193*eca53ba6SRoland Levillain#$$(info Create targets: clean_toolchain_$1 $(addprefix clean_, $(addsuffix _$1, $(TOOLCHAIN_TARGETS))).)
194*eca53ba6SRoland Levillainclean_targets_toolchain_$1 = $(addprefix clean_, $(addsuffix _$1, $(TOOLCHAIN_TARGETS)))
195*eca53ba6SRoland Levillain.PHONY: clean_toolchain_$1 $$(clean_targets_toolchain_$1)
196*eca53ba6SRoland Levillainclean_toolchain_$1: $$(clean_targets_toolchain_$1)
197*eca53ba6SRoland Levillain$$(clean_targets_toolchain_$1): clean_%_$1:
198*eca53ba6SRoland Levillain	docker image rm -f ${IMAGE}:$$*_$1 2>/dev/null
199*eca53ba6SRoland Levillain	rm -f cache/$$*/docker_$1.tar
200*eca53ba6SRoland Levillainendef
201*eca53ba6SRoland Levillain
202*eca53ba6SRoland Levillain$(foreach stage,$(TOOLCHAIN_STAGES),$(eval $(call toolchain-stage-target,$(stage))))
203*eca53ba6SRoland Levillain
204*eca53ba6SRoland Levillain## MERGE ##
205*eca53ba6SRoland Levillain.PHONY: clean_toolchain
206*eca53ba6SRoland Levillainclean_toolchain: $(addprefix clean_toolchain_, $(TOOLCHAIN_STAGES))
207*eca53ba6SRoland Levillain	-rmdir $(addprefix cache/, $(TOOLCHAIN_TARGETS))
208*eca53ba6SRoland Levillain
209*eca53ba6SRoland Levillain.PHONY: env devel build test
210*eca53ba6SRoland Levillainenv: amd64_env toolchain_env
211*eca53ba6SRoland Levillaindevel: amd64_devel toolchain_devel
212*eca53ba6SRoland Levillainbuild: amd64_build toolchain_build
213*eca53ba6SRoland Levillaintest: amd64_test toolchain_test
214*eca53ba6SRoland Levillain
215*eca53ba6SRoland Levillain.PHONY: install_env install_devel install_build install_test
216*eca53ba6SRoland Levillaininstall_env: amd64_install_env
217*eca53ba6SRoland Levillaininstall_devel: amd64_install_devel
218*eca53ba6SRoland Levillaininstall_build: amd64_install_build
219*eca53ba6SRoland Levillaininstall_test: amd64_install_test
220*eca53ba6SRoland Levillain
221*eca53ba6SRoland Levillain#############
222*eca53ba6SRoland Levillain## VAGRANT ##
223*eca53ba6SRoland Levillain#############
224*eca53ba6SRoland LevillainVMS = freebsd
225*eca53ba6SRoland Levillain
226*eca53ba6SRoland Levillainvms_targets = $(addsuffix _build, $(VMS))
227*eca53ba6SRoland Levillain.PHONY: $(vms_targets)
228*eca53ba6SRoland Levillain$(vms_targets): %_build: vagrant/%/Vagrantfile
229*eca53ba6SRoland Levillain	@cd vagrant/$* && vagrant destroy -f
230*eca53ba6SRoland Levillain	cd vagrant/$* && vagrant up
231*eca53ba6SRoland Levillain
232*eca53ba6SRoland Levillainclean_vms_targets = $(addprefix clean_, $(VMS))
233*eca53ba6SRoland Levillain.PHONY: clean_vms $(clean_vms_targets)
234*eca53ba6SRoland Levillainclean_vms: $(clean_vms_targets)
235*eca53ba6SRoland Levillain$(clean_vms_targets): clean_%:
236*eca53ba6SRoland Levillain	cd vagrant/$* && vagrant destroy -f
237*eca53ba6SRoland Levillain	-rm -rf vagrant/$*/.vagrant
238*eca53ba6SRoland Levillain
239*eca53ba6SRoland Levillain###########
240*eca53ba6SRoland Levillain## CLEAN ##
241*eca53ba6SRoland Levillain###########
242*eca53ba6SRoland Levillain.PHONY: clean
243*eca53ba6SRoland Levillainclean: clean_amd64 clean_toolchain clean_vms
244*eca53ba6SRoland Levillain	docker container prune -f
245*eca53ba6SRoland Levillain	docker image prune -f
246*eca53ba6SRoland Levillain	-rmdir cache
247*eca53ba6SRoland Levillain
248*eca53ba6SRoland Levillain.PHONY: distclean
249*eca53ba6SRoland Levillaindistclean: clean
250*eca53ba6SRoland Levillain	-docker container rm -f $$(docker container ls -aq)
251*eca53ba6SRoland Levillain	-docker image rm -f $$(docker image ls -aq)
252*eca53ba6SRoland Levillain	-vagrant box remove -f generic/freebsd12
253