2018-04-06 13:08:37 +03:00
|
|
|
# -*- Mode: makefile -*-
|
|
|
|
#
|
|
|
|
# TCG tests (per-target rules)
|
|
|
|
#
|
2019-08-07 17:35:22 +03:00
|
|
|
# This Makefile fragment is included from the build-tcg target, once
|
|
|
|
# for each target we build. We have two options for compiling, either
|
|
|
|
# using a configured guest compiler or calling one of our docker images
|
|
|
|
# to do it for us.
|
2018-04-06 13:08:37 +03:00
|
|
|
#
|
|
|
|
|
2019-08-07 17:35:23 +03:00
|
|
|
# The configure script fills in extra information about
|
2018-04-06 13:08:37 +03:00
|
|
|
# useful docker images or alternative compiler flags.
|
|
|
|
|
2020-09-21 17:34:47 +03:00
|
|
|
# Usage: $(call quiet-command,command and args,"NAME","args to print")
|
|
|
|
# This will run "command and args", and either:
|
|
|
|
# if V=1 just print the whole command and args
|
|
|
|
# otherwise print the 'quiet' output in the format " NAME args to print"
|
|
|
|
# NAME should be a short name of the command, 7 letters or fewer.
|
|
|
|
# If called with only a single argument, will print nothing in quiet mode.
|
|
|
|
quiet-command-run = $(if $(V),,$(if $2,printf " %-7s %s\n" $2 $3 && ))$1
|
|
|
|
quiet-@ = $(if $(V),,@)
|
|
|
|
quiet-command = $(quiet-@)$(call quiet-command-run,$1,$2,$3)
|
|
|
|
|
2019-08-07 17:35:23 +03:00
|
|
|
CROSS_CC_GUEST:=
|
2021-05-12 13:20:31 +03:00
|
|
|
CROSS_AS_GUEST:=
|
|
|
|
CROSS_LD_GUEST:=
|
2019-08-07 17:35:23 +03:00
|
|
|
DOCKER_IMAGE:=
|
2020-09-21 17:34:47 +03:00
|
|
|
|
|
|
|
-include tests/tcg/config-$(TARGET).mak
|
2018-04-06 13:08:37 +03:00
|
|
|
|
|
|
|
GUEST_BUILD=
|
2019-08-07 17:35:22 +03:00
|
|
|
TCG_MAKE=../Makefile.target
|
2019-08-07 17:35:23 +03:00
|
|
|
|
|
|
|
# We also need the Docker make rules to depend on
|
|
|
|
SKIP_DOCKER_BUILD=1
|
|
|
|
include $(SRC_PATH)/tests/docker/Makefile.include
|
|
|
|
|
2018-04-06 13:08:37 +03:00
|
|
|
# Support installed Cross Compilers
|
|
|
|
|
|
|
|
ifdef CROSS_CC_GUEST
|
|
|
|
|
|
|
|
.PHONY: cross-build-guest-tests
|
|
|
|
cross-build-guest-tests:
|
|
|
|
$(call quiet-command, \
|
2019-08-07 17:35:23 +03:00
|
|
|
(mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
|
|
|
|
$(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
|
2021-05-12 13:20:31 +03:00
|
|
|
$(if $(CROSS_AS_GUEST),AS="$(CROSS_AS_GUEST)") \
|
|
|
|
$(if $(CROSS_LD_GUEST),LD="$(CROSS_LD_GUEST)") \
|
2019-08-07 17:35:22 +03:00
|
|
|
SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
|
2019-08-07 17:35:23 +03:00
|
|
|
EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
|
|
|
|
"BUILD","$(TARGET) guest-tests with $(CROSS_CC_GUEST)")
|
2018-04-06 13:08:37 +03:00
|
|
|
|
|
|
|
GUEST_BUILD=cross-build-guest-tests
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Support building with Docker
|
|
|
|
|
|
|
|
ifneq ($(DOCKER_IMAGE),)
|
|
|
|
|
2019-09-04 12:07:17 +03:00
|
|
|
DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
|
2019-08-07 17:35:23 +03:00
|
|
|
--cc $(DOCKER_CROSS_CC_GUEST) \
|
2020-07-01 16:56:29 +03:00
|
|
|
-i qemu/$(DOCKER_IMAGE) \
|
2018-04-06 13:08:37 +03:00
|
|
|
-s $(SRC_PATH) -- "
|
|
|
|
|
2021-05-12 13:20:31 +03:00
|
|
|
DOCKER_AS_CMD=$(if $(DOCKER_CROSS_AS_GUEST),"$(DOCKER_SCRIPT) cc \
|
|
|
|
--cc $(DOCKER_CROSS_AS_GUEST) \
|
|
|
|
-i qemu/$(DOCKER_IMAGE) \
|
|
|
|
-s $(SRC_PATH) -- ")
|
|
|
|
|
|
|
|
DOCKER_LD_CMD=$(if $(DOCKER_CROSS_LD_GUEST),"$(DOCKER_SCRIPT) cc \
|
|
|
|
--cc $(DOCKER_CROSS_LD_GUEST) \
|
|
|
|
-i qemu/$(DOCKER_IMAGE) \
|
|
|
|
-s $(SRC_PATH) -- ")
|
|
|
|
|
|
|
|
|
2018-04-06 13:08:37 +03:00
|
|
|
.PHONY: docker-build-guest-tests
|
2019-08-07 17:35:22 +03:00
|
|
|
docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
|
2018-04-06 13:08:37 +03:00
|
|
|
$(call quiet-command, \
|
2019-08-07 17:35:23 +03:00
|
|
|
(mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
|
|
|
|
$(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC=$(DOCKER_COMPILE_CMD) \
|
2021-05-12 13:20:31 +03:00
|
|
|
$(if $(DOCKER_AS_CMD),AS=$(DOCKER_AS_CMD)) \
|
|
|
|
$(if $(DOCKER_LD_CMD),LD=$(DOCKER_LD_CMD)) \
|
2019-08-07 17:35:22 +03:00
|
|
|
SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
|
2019-08-07 17:35:23 +03:00
|
|
|
EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
|
2020-07-01 16:56:29 +03:00
|
|
|
"BUILD","$(TARGET) guest-tests with docker qemu/$(DOCKER_IMAGE)")
|
2018-04-06 13:08:37 +03:00
|
|
|
|
|
|
|
GUEST_BUILD=docker-build-guest-tests
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Final targets
|
2019-08-07 17:35:22 +03:00
|
|
|
all:
|
|
|
|
@echo "Do not invoke this Makefile directly"; exit 1
|
|
|
|
|
2018-04-06 13:08:37 +03:00
|
|
|
.PHONY: guest-tests
|
|
|
|
|
|
|
|
ifneq ($(GUEST_BUILD),)
|
|
|
|
guest-tests: $(GUEST_BUILD)
|
|
|
|
|
2019-08-07 17:35:22 +03:00
|
|
|
run-guest-tests: guest-tests
|
2018-04-06 13:08:37 +03:00
|
|
|
$(call quiet-command, \
|
2019-08-07 17:35:23 +03:00
|
|
|
(cd tests/tcg/$(TARGET) && \
|
|
|
|
$(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" \
|
2019-08-07 17:35:22 +03:00
|
|
|
SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run), \
|
2018-04-06 13:08:37 +03:00
|
|
|
"RUN", "tests for $(TARGET_NAME)")
|
|
|
|
|
|
|
|
else
|
|
|
|
guest-tests:
|
2021-02-02 16:39:56 +03:00
|
|
|
$(call quiet-command, true, "BUILD", \
|
2019-08-07 17:35:23 +03:00
|
|
|
"$(TARGET) guest-tests SKIPPED")
|
2018-04-06 13:08:37 +03:00
|
|
|
|
|
|
|
run-guest-tests:
|
2021-02-02 16:39:56 +03:00
|
|
|
$(call quiet-command, true, "RUN", \
|
2019-08-07 17:35:23 +03:00
|
|
|
"tests for $(TARGET) SKIPPED")
|
2018-04-06 13:08:37 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
# It doesn't matter if these don't exits
|
|
|
|
.PHONY: clean-guest-tests
|
|
|
|
clean-guest-tests:
|
2019-08-07 17:35:23 +03:00
|
|
|
rm -rf tests/tcg/$(TARGET)
|