blob: 8f864cfbb691a64a282192aafb983ea9147994c4 [file] [log] [blame]
Thomas Gleixnerec8f24b2019-05-19 13:07:45 +01001# SPDX-License-Identifier: GPL-2.0-only
Paolo Bonzinic2390f12019-04-11 15:51:19 +02002include ../../../../scripts/Kbuild.include
3
Paolo Bonzini783e9e52018-03-27 11:49:19 +02004all:
5
Andrew Jonescc687652018-09-18 19:54:26 +02006top_srcdir = ../../../..
Shuah Khan211929f2018-12-12 20:25:14 -07007KSFT_KHDR_INSTALL := 1
Paolo Bonzini783e9e52018-03-27 11:49:19 +02008UNAME_M := $(shell uname -m)
9
Andrew Jones14c47b72018-09-18 19:54:25 +020010LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/ucall.c lib/sparsebit.c
Andrew Jonescc687652018-09-18 19:54:26 +020011LIBKVM_x86_64 = lib/x86_64/processor.c lib/x86_64/vmx.c
Andrew Jonesfff8dcd2018-09-18 19:54:32 +020012LIBKVM_aarch64 = lib/aarch64/processor.c
Paolo Bonzini783e9e52018-03-27 11:49:19 +020013
Aaron Lewis61cfcd52019-05-21 17:13:58 +000014TEST_GEN_PROGS_x86_64 = x86_64/cr4_cpuid_sync_test
Vitaly Kuznetsov18178ff2018-10-16 18:50:11 +020015TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test
Vitaly Kuznetsov7edcb732018-12-10 18:21:59 +010016TEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid
Aaron Lewis4b350ae2019-05-02 11:31:59 -070017TEST_GEN_PROGS_x86_64 += x86_64/kvm_create_max_vcpus
Aaron Lewis61cfcd52019-05-21 17:13:58 +000018TEST_GEN_PROGS_x86_64 += x86_64/platform_info_test
19TEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test
20TEST_GEN_PROGS_x86_64 += x86_64/smm_test
21TEST_GEN_PROGS_x86_64 += x86_64/state_test
22TEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test
23TEST_GEN_PROGS_x86_64 += x86_64/vmx_close_while_nested_test
Aaron Lewisda1e3072019-05-02 11:31:41 -070024TEST_GEN_PROGS_x86_64 += x86_64/vmx_set_nested_state_test
Aaron Lewis61cfcd52019-05-21 17:13:58 +000025TEST_GEN_PROGS_x86_64 += x86_64/vmx_tsc_adjust_test
Paolo Bonzini2a31b9d2018-10-23 02:36:47 +020026TEST_GEN_PROGS_x86_64 += clear_dirty_log_test
Aaron Lewis61cfcd52019-05-21 17:13:58 +000027TEST_GEN_PROGS_x86_64 += dirty_log_test
Andrew Jonesfff8dcd2018-09-18 19:54:32 +020028
Paolo Bonzini2a31b9d2018-10-23 02:36:47 +020029TEST_GEN_PROGS_aarch64 += clear_dirty_log_test
Aaron Lewis61cfcd52019-05-21 17:13:58 +000030TEST_GEN_PROGS_aarch64 += dirty_log_test
Paolo Bonzini783e9e52018-03-27 11:49:19 +020031
32TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
33LIBKVM += $(LIBKVM_$(UNAME_M))
34
35INSTALL_HDR_PATH = $(top_srcdir)/usr
36LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
Andrew Jonescc687652018-09-18 19:54:26 +020037LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
Thomas Huth319f6f92019-05-17 11:04:45 +020038CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
39 -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
40 -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(UNAME_M) -I..
Paolo Bonzinic2390f12019-04-11 15:51:19 +020041
42no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
43 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
44
45LDFLAGS += -pthread $(no-pie-option)
Paolo Bonzini783e9e52018-03-27 11:49:19 +020046
47# After inclusion, $(OUTPUT) is defined and
48# $(TEST_GEN_PROGS) starts with $(OUTPUT)/
49include ../lib.mk
50
51STATIC_LIBS := $(OUTPUT)/libkvm.a
52LIBKVM_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM))
Andrew Joneseea192b2018-09-18 19:54:27 +020053EXTRA_CLEAN += $(LIBKVM_OBJ) $(STATIC_LIBS) cscope.*
Paolo Bonzini783e9e52018-03-27 11:49:19 +020054
55x := $(shell mkdir -p $(sort $(dir $(LIBKVM_OBJ))))
56$(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c
57 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
58
59$(OUTPUT)/libkvm.a: $(LIBKVM_OBJ)
60 $(AR) crs $@ $^
61
Anders Roxellb2d35fa2018-09-04 12:47:21 +020062all: $(STATIC_LIBS)
Paolo Bonzini783e9e52018-03-27 11:49:19 +020063$(TEST_GEN_PROGS): $(STATIC_LIBS)
Andrew Joneseea192b2018-09-18 19:54:27 +020064
65cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
66cscope:
67 $(RM) cscope.*
68 (find $(include_paths) -name '*.h' \
69 -exec realpath --relative-base=$(PWD) {} \;; \
70 find . -name '*.c' \
71 -exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files
72 cscope -b