xref: /illumos-gate/usr/src/test/bhyve-tests/tests/inst_emul/Makefile (revision c43efa7f6b109f90d7f4962df8c0e1a94008d2d1)
1#
2# This file and its contents are supplied under the terms of the
3# Common Development and Distribution License ("CDDL"), version 1.0.
4# You may only use this file in accordance with the terms of version
5# 1.0 of the CDDL.
6#
7# A full copy of the text of the CDDL should have accompanied this
8# source.  A copy of the CDDL is also available via the Internet at
9# http://www.illumos.org/license/CDDL.
10#
11
12# Copyright 2023 Oxide Computer Company
13
14include $(SRC)/cmd/Makefile.cmd
15include $(SRC)/cmd/Makefile.cmd.64
16include $(SRC)/test/Makefile.com
17
18PROG =	rdmsr \
19	wrmsr \
20	imul \
21	cpuid
22
23# These should probably go in the `vmm` tests, but since they depend on
24# in-guest payloads, it is easier to build them here.
25PROG +=	triple_fault \
26	exit_paging \
27	page_dirty \
28	exit_consistent \
29	suspend_info \
30	vcpu_barrier
31
32# C-based payloads need additional utils object
33CPAYLOADS =	cpuid \
34		suspend_info
35
36PAYLOADS = $(PROG)
37include ../Makefile.in_guest
38
39COMMON_OBJS =	in_guest.o common.o
40
41CLEANFILES =	$(COMMON_OBJS) $(PAYLOAD_CLEANFILES) payload_utils.o
42CLOBBERFILES =	$(PROG)
43
44ROOTOPTPKG = $(ROOT)/opt/bhyve-tests
45TESTDIR = $(ROOTOPTPKG)/tests/inst_emul
46
47CMDS = $(PROG:%=$(TESTDIR)/%)
48$(CMDS) := FILEMODE = 0555
49
50CSTD=		$(CSTD_GNU99)
51CPPFLAGS =	-I$(COMPAT)/bhyve -I$(CONTRIB)/bhyve \
52		-I$(COMPAT)/bhyve/amd64 -I$(CONTRIB)/bhyve/amd64 \
53		$(CPPFLAGS.master) \
54		-I$(SRC)/uts/intel/io/vmm \
55		-I$(SRC)/uts/intel \
56		-I../common
57
58ASFLAGS +=	-D_ASM
59ASFLAGS64 +=	-D_ASM
60
61$(PROG) :=	LDLIBS += -lvmmapi
62
63all: $(PROG)
64
65install: all $(CMDS)
66
67clean:
68	-$(RM) $(CLEANFILES)
69clobber: clean
70	-$(RM) $(CLOBBERFILES)
71
72$(CMDS): $(TESTDIR) $(PROG)
73
74$(TESTDIR):
75	$(INS.dir)
76
77$(TESTDIR)/%: %
78	$(INS.file)
79
80%: %.c pobj_%.o $(COMMON_OBJS)
81	$(LINK.c) -o $@ $^ $(LDLIBS)
82	$(POST_PROCESS)
83
84%: %.o
85	$(LINK.c) -o $@ $^ $(LDLIBS)
86	$(POST_PROCESS)
87
88$(CPAYLOADS:%=payload_%): payload_utils.o
89