Merge remote-tracking branch 'remotes/dgilbert-gitlab/tags/pull-migration-20210726a...
[qemu/armbru.git] / tests / tcg / Makefile.qemu
blob84c8543878bff136142eb8e76da590920c8a88a0
1 # -*- Mode: makefile -*-
3 # TCG tests (per-target rules)
5 # This Makefile fragment is included from the build-tcg target, once
6 # for each target we build. We have two options for compiling, either
7 # using a configured guest compiler or calling one of our docker images
8 # to do it for us.
11 # The configure script fills in extra information about
12 # useful docker images or alternative compiler flags.
14 # Usage: $(call quiet-command,command and args,"NAME","args to print")
15 # This will run "command and args", and either:
16 #  if V=1 just print the whole command and args
17 #  otherwise print the 'quiet' output in the format "  NAME     args to print"
18 # NAME should be a short name of the command, 7 letters or fewer.
19 # If called with only a single argument, will print nothing in quiet mode.
20 quiet-command-run = $(if $(V),,$(if $2,printf "  %-7s %s\n" $2 $3 && ))$1
21 quiet-@ = $(if $(V),,@)
22 quiet-command = $(quiet-@)$(call quiet-command-run,$1,$2,$3)
24 CROSS_CC_GUEST:=
25 CROSS_AS_GUEST:=
26 CROSS_LD_GUEST:=
27 DOCKER_IMAGE:=
29 -include tests/tcg/config-$(TARGET).mak
31 GUEST_BUILD=
32 TCG_MAKE=../Makefile.target
34 # We also need the Docker make rules to depend on
35 SKIP_DOCKER_BUILD=1
36 include $(SRC_PATH)/tests/docker/Makefile.include
38 # Support installed Cross Compilers
40 ifdef CROSS_CC_GUEST
42 .PHONY: cross-build-guest-tests
43 cross-build-guest-tests:
44         $(call quiet-command, \
45            (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
46             $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
47                         $(if $(CROSS_AS_GUEST),AS="$(CROSS_AS_GUEST)") \
48                         $(if $(CROSS_LD_GUEST),LD="$(CROSS_LD_GUEST)") \
49                         SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
50                         EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
51         "BUILD","$(TARGET) guest-tests with $(CROSS_CC_GUEST)")
53 GUEST_BUILD=cross-build-guest-tests
55 endif
57 # Support building with Docker
59 ifneq ($(DOCKER_IMAGE),)
61 DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
62                 --cc $(DOCKER_CROSS_CC_GUEST) \
63                 -i qemu/$(DOCKER_IMAGE) \
64                 -s $(SRC_PATH) -- "
66 DOCKER_AS_CMD=$(if $(DOCKER_CROSS_AS_GUEST),"$(DOCKER_SCRIPT) cc \
67                 --cc $(DOCKER_CROSS_AS_GUEST) \
68                 -i qemu/$(DOCKER_IMAGE) \
69                 -s $(SRC_PATH) -- ")
71 DOCKER_LD_CMD=$(if $(DOCKER_CROSS_LD_GUEST),"$(DOCKER_SCRIPT) cc \
72                 --cc $(DOCKER_CROSS_LD_GUEST) \
73                 -i qemu/$(DOCKER_IMAGE) \
74                 -s $(SRC_PATH) -- ")
77 .PHONY: docker-build-guest-tests
78 docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
79         $(call quiet-command, \
80           (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
81            $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC=$(DOCKER_COMPILE_CMD) \
82                         $(if $(DOCKER_AS_CMD),AS=$(DOCKER_AS_CMD)) \
83                         $(if $(DOCKER_LD_CMD),LD=$(DOCKER_LD_CMD)) \
84                         SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
85                         EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
86         "BUILD","$(TARGET) guest-tests with docker qemu/$(DOCKER_IMAGE)")
88 GUEST_BUILD=docker-build-guest-tests
90 endif
92 # Final targets
93 all:
94         @echo "Do not invoke this Makefile directly"; exit 1
96 .PHONY: guest-tests
98 ifneq ($(GUEST_BUILD),)
99 guest-tests: $(GUEST_BUILD)
101 run-guest-tests: guest-tests
102         $(call quiet-command, \
103         (cd tests/tcg/$(TARGET) && \
104          $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" \
105                         SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run), \
106         "RUN", "tests for $(TARGET_NAME)")
108 else
109 guest-tests:
110         $(call quiet-command, true, "BUILD", \
111                 "$(TARGET) guest-tests SKIPPED")
113 run-guest-tests:
114         $(call quiet-command, true, "RUN", \
115                 "tests for $(TARGET) SKIPPED")
116 endif
118 # It doesn't matter if these don't exits
119 .PHONY: clean-guest-tests
120 clean-guest-tests:
121         rm -rf tests/tcg/$(TARGET)