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 2022 Oxide Computer Company
13
14include $(SRC)/cmd/Makefile.cmd
15include $(SRC)/cmd/Makefile.cmd.64
16include $(SRC)/test/Makefile.com
17
18PROG =	vpmtmr_freq \
19	vhpet_freq \
20	vlapic_freq \
21	vlapic_freq_periodic \
22	vlapic_mmio_access \
23	vlapic_msr_access \
24	vatpit_freq
25
26PAYLOADS = $(PROG)
27include ../Makefile.in_guest
28
29COMMON_OBJS =	in_guest.o
30
31CLEANFILES =	$(COMMON_OBJS) $(PAYLOAD_CLEANFILES) payload_utils.o
32CLOBBERFILES =	$(PROG)
33
34ROOTOPTPKG = $(ROOT)/opt/bhyve-tests
35TESTDIR = $(ROOTOPTPKG)/tests/kdev
36
37CMDS = $(PROG:%=$(TESTDIR)/%)
38$(CMDS) := FILEMODE = 0555
39
40CSTD=		$(CSTD_GNU99)
41CPPFLAGS =	-I$(COMPAT)/bhyve -I$(CONTRIB)/bhyve \
42		-I$(COMPAT)/bhyve/amd64 -I$(CONTRIB)/bhyve/amd64 \
43		$(CPPFLAGS.master) \
44		-I$(SRC)/uts/intel/io/vmm \
45		-I$(SRC)/uts/intel \
46		-I../common
47
48ASFLAGS += 	-D_ASM
49ASFLAGS64 += 	-D_ASM
50
51
52CFLAGS = -m64
53$(PROG) :=	LDLIBS += -lvmmapi
54
55all: $(PROG)
56
57install: all $(CMDS)
58
59clean:
60	-$(RM) $(CLEANFILES)
61clobber: clean
62	-$(RM) $(CLOBBERFILES)
63
64$(CMDS): $(TESTDIR) $(PROG)
65
66$(TESTDIR):
67	$(INS.dir)
68
69$(TESTDIR)/%: %
70	$(INS.file)
71
72%: %.c pobj_%.o $(COMMON_OBJS)
73	$(LINK.c) -o $@ $^ $(LDLIBS)
74	$(POST_PROCESS)
75
76%: %.o
77	$(LINK.c) -o $@ $^ $(LDLIBS)
78	$(POST_PROCESS)
79
80$(PAYLOADS:%=payload_%): payload_utils.o
81