blob: 6b7b3617d25c93ec89bcfcbea807f3ea432d3b65 [file] [log] [blame]
Paolo Bonzinic2390f12019-04-11 15:51:19 +02001include ../../../../scripts/Kbuild.include
2
Paolo Bonzini783e9e52018-03-27 11:49:19 +02003all:
4
Andrew Jonescc687652018-09-18 19:54:26 +02005top_srcdir = ../../../..
Shuah Khan211929f2018-12-12 20:25:14 -07006KSFT_KHDR_INSTALL := 1
Paolo Bonzini783e9e52018-03-27 11:49:19 +02007UNAME_M := $(shell uname -m)
8
Andrew Jones14c47b72018-09-18 19:54:25 +02009LIBKVM = 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 +020010LIBKVM_x86_64 = lib/x86_64/processor.c lib/x86_64/vmx.c
Andrew Jonesfff8dcd2018-09-18 19:54:32 +020011LIBKVM_aarch64 = lib/aarch64/processor.c
Paolo Bonzini783e9e52018-03-27 11:49:19 +020012
Andrew Jonescc687652018-09-18 19:54:26 +020013TEST_GEN_PROGS_x86_64 = x86_64/platform_info_test
14TEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test
15TEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test
16TEST_GEN_PROGS_x86_64 += x86_64/vmx_tsc_adjust_test
17TEST_GEN_PROGS_x86_64 += x86_64/cr4_cpuid_sync_test
18TEST_GEN_PROGS_x86_64 += x86_64/state_test
Vitaly Kuznetsov18178ff2018-10-16 18:50:11 +020019TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test
Vitaly Kuznetsov7edcb732018-12-10 18:21:59 +010020TEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid
Paolo Bonzini65ab26e2019-01-31 23:49:21 +010021TEST_GEN_PROGS_x86_64 += x86_64/vmx_close_while_nested_test
Vitaly Kuznetsov79904c92019-04-10 11:38:33 +020022TEST_GEN_PROGS_x86_64 += x86_64/smm_test
Aaron Lewis4b350ae2019-05-02 11:31:59 -070023TEST_GEN_PROGS_x86_64 += x86_64/kvm_create_max_vcpus
Andrew Jonesfff8dcd2018-09-18 19:54:32 +020024TEST_GEN_PROGS_x86_64 += dirty_log_test
Paolo Bonzini2a31b9d2018-10-23 02:36:47 +020025TEST_GEN_PROGS_x86_64 += clear_dirty_log_test
Andrew Jonesfff8dcd2018-09-18 19:54:32 +020026
27TEST_GEN_PROGS_aarch64 += dirty_log_test
Paolo Bonzini2a31b9d2018-10-23 02:36:47 +020028TEST_GEN_PROGS_aarch64 += clear_dirty_log_test
Paolo Bonzini783e9e52018-03-27 11:49:19 +020029
30TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
31LIBKVM += $(LIBKVM_$(UNAME_M))
32
33INSTALL_HDR_PATH = $(top_srcdir)/usr
34LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
Andrew Jonescc687652018-09-18 19:54:26 +020035LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
Sean Christophersonffac8392019-03-13 12:43:14 -070036CFLAGS += -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(UNAME_M) -I..
Paolo Bonzinic2390f12019-04-11 15:51:19 +020037
38no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
39 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
40
41LDFLAGS += -pthread $(no-pie-option)
Paolo Bonzini783e9e52018-03-27 11:49:19 +020042
43# After inclusion, $(OUTPUT) is defined and
44# $(TEST_GEN_PROGS) starts with $(OUTPUT)/
45include ../lib.mk
46
47STATIC_LIBS := $(OUTPUT)/libkvm.a
48LIBKVM_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM))
Andrew Joneseea192b2018-09-18 19:54:27 +020049EXTRA_CLEAN += $(LIBKVM_OBJ) $(STATIC_LIBS) cscope.*
Paolo Bonzini783e9e52018-03-27 11:49:19 +020050
51x := $(shell mkdir -p $(sort $(dir $(LIBKVM_OBJ))))
52$(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c
53 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
54
55$(OUTPUT)/libkvm.a: $(LIBKVM_OBJ)
56 $(AR) crs $@ $^
57
Anders Roxellb2d35fa2018-09-04 12:47:21 +020058all: $(STATIC_LIBS)
Paolo Bonzini783e9e52018-03-27 11:49:19 +020059$(TEST_GEN_PROGS): $(STATIC_LIBS)
Andrew Joneseea192b2018-09-18 19:54:27 +020060
61cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
62cscope:
63 $(RM) cscope.*
64 (find $(include_paths) -name '*.h' \
65 -exec realpath --relative-base=$(PWD) {} \;; \
66 find . -name '*.c' \
67 -exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files
68 cscope -b