target/mips: Simplify meson TCG rules
[qemu/ar7.git] / tests / tcg / Makefile.qemu
bloba56564660cfa3dc3f281cbfd6435387b9bd2618f
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 DOCKER_IMAGE:=
27 -include tests/tcg/config-$(TARGET).mak
29 GUEST_BUILD=
30 TCG_MAKE=../Makefile.target
32 # We also need the Docker make rules to depend on
33 SKIP_DOCKER_BUILD=1
34 include $(SRC_PATH)/tests/docker/Makefile.include
36 # Support installed Cross Compilers
38 ifdef CROSS_CC_GUEST
40 .PHONY: cross-build-guest-tests
41 cross-build-guest-tests:
42         $(call quiet-command, \
43            (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
44             $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
45                         SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
46                         EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
47         "BUILD","$(TARGET) guest-tests with $(CROSS_CC_GUEST)")
49 GUEST_BUILD=cross-build-guest-tests
51 endif
53 # Support building with Docker
55 ifneq ($(DOCKER_IMAGE),)
57 DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
58                 --cc $(DOCKER_CROSS_CC_GUEST) \
59                 -i qemu/$(DOCKER_IMAGE) \
60                 -s $(SRC_PATH) -- "
62 .PHONY: docker-build-guest-tests
63 docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
64         $(call quiet-command, \
65           (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
66            $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC=$(DOCKER_COMPILE_CMD) \
67                         SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
68                         EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
69         "BUILD","$(TARGET) guest-tests with docker qemu/$(DOCKER_IMAGE)")
71 GUEST_BUILD=docker-build-guest-tests
73 endif
75 # Final targets
76 all:
77         @echo "Do not invoke this Makefile directly"; exit 1
79 .PHONY: guest-tests
81 ifneq ($(GUEST_BUILD),)
82 guest-tests: $(GUEST_BUILD)
84 run-guest-tests: guest-tests
85         $(call quiet-command, \
86         (cd tests/tcg/$(TARGET) && \
87          $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" \
88                         SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run), \
89         "RUN", "tests for $(TARGET_NAME)")
91 else
92 guest-tests:
93         $(call quiet-command, true, "BUILD", \
94                 "$(TARGET) guest-tests SKIPPED")
96 run-guest-tests:
97         $(call quiet-command, true, "RUN", \
98                 "tests for $(TARGET) SKIPPED")
99 endif
101 # It doesn't matter if these don't exits
102 .PHONY: clean-guest-tests
103 clean-guest-tests:
104         rm -rf tests/tcg/$(TARGET)