xref: /openbmc/qemu/tests/vm/Makefile.include (revision 8e6fe6b8)
1# Makefile for VM tests
2
3.PHONY: vm-build-all vm-clean-all
4
5IMAGES := ubuntu.i386 freebsd netbsd openbsd centos
6IMAGES_DIR := $(HOME)/.cache/qemu-vm/images
7IMAGE_FILES := $(patsubst %, $(IMAGES_DIR)/%.img, $(IMAGES))
8
9.PRECIOUS: $(IMAGE_FILES)
10
11vm-test:
12	@echo "vm-test: Test QEMU in preconfigured virtual machines"
13	@echo
14	@echo "  vm-build-ubuntu.i386            - Build QEMU in ubuntu i386 VM"
15	@echo "  vm-build-freebsd                - Build QEMU in FreeBSD VM"
16	@echo "  vm-build-netbsd                 - Build QEMU in NetBSD VM"
17	@echo "  vm-build-openbsd                - Build QEMU in OpenBSD VM"
18	@echo "  vm-build-centos                 - Build QEMU in CentOS VM, with Docker"
19	@echo ""
20	@echo "  vm-build-all                    - Build QEMU in all VMs"
21	@echo "  vm-clean-all                    - Clean up VM images"
22	@echo
23	@echo "Special variables:"
24	@echo "    BUILD_TARGET=foo		 - Override the build target"
25	@echo "    TARGET_LIST=a,b,c    	 - Override target list in builds"
26	@echo '    EXTRA_CONFIGURE_OPTS="..."'
27	@echo "    J=[0..9]*            	 - Override the -jN parameter for make commands"
28	@echo "    DEBUG=1              	 - Enable verbose output on host and interactive debugging"
29	@echo "    V=1				 - Enable verbose ouput on host and guest commands"
30	@echo "    QEMU=/path/to/qemu		 - Change path to QEMU binary"
31
32vm-build-all: $(addprefix vm-build-, $(IMAGES))
33
34vm-clean-all:
35	rm -f $(IMAGE_FILES)
36
37$(IMAGES_DIR)/%.img:	$(SRC_PATH)/tests/vm/% \
38			$(SRC_PATH)/tests/vm/basevm.py \
39			$(SRC_PATH)/tests/vm/Makefile.include
40	@mkdir -p $(IMAGES_DIR)
41	$(call quiet-command, \
42		$(PYTHON) $< \
43		$(if $(V)$(DEBUG), --debug) \
44		--image "$@" \
45		--force \
46		--build-image $@, \
47		"  VM-IMAGE $*")
48
49
50# Build in VM $(IMAGE)
51vm-build-%: $(IMAGES_DIR)/%.img
52	$(call quiet-command, \
53		$(PYTHON) $(SRC_PATH)/tests/vm/$* \
54		$(if $(V)$(DEBUG), --debug) \
55		$(if $(DEBUG), --interactive) \
56		$(if $(J),--jobs $(J)) \
57		$(if $(V),--verbose) \
58		--image "$<" \
59		$(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \
60		--build-qemu $(SRC_PATH) -- \
61		$(if $(TARGET_LIST),--target-list=$(TARGET_LIST)) \
62		$(if $(EXTRA_CONFIGURE_OPTS),$(EXTRA_CONFIGURE_OPTS)), \
63		"  VM-BUILD $*")
64
65