1ec8f24b7SThomas Gleixner# SPDX-License-Identifier: GPL-2.0-only
2b61442dfSMasahiro Yamadainclude ../../../build/Build.include
3c2390f16SPaolo Bonzini
4783e9e51SPaolo Bonziniall:
5783e9e51SPaolo Bonzini
6cc68765dSAndrew Jonestop_srcdir = ../../../..
7baea2ce5SPaolo Bonziniinclude $(top_srcdir)/scripts/subarch.include
8baea2ce5SPaolo BonziniARCH            ?= $(SUBARCH)
966d69e08SShuah Khan
106a5db83aSSean Christophersonifeq ($(ARCH),x86)
116a5db83aSSean Christopherson	ARCH_DIR := x86_64
126a5db83aSSean Christophersonelse ifeq ($(ARCH),arm64)
136a5db83aSSean Christopherson	ARCH_DIR := aarch64
146a5db83aSSean Christophersonelse ifeq ($(ARCH),s390)
156a5db83aSSean Christopherson	ARCH_DIR := s390x
166a5db83aSSean Christophersonelse
176a5db83aSSean Christopherson	ARCH_DIR := $(ARCH)
183e06cdf1SAnup Patelendif
1966d69e08SShuah Khan
20cf97d5e9SDavid MatlackLIBKVM += lib/assert.c
21cf97d5e9SDavid MatlackLIBKVM += lib/elf.c
22cf97d5e9SDavid MatlackLIBKVM += lib/guest_modes.c
23cf97d5e9SDavid MatlackLIBKVM += lib/io.c
24cf97d5e9SDavid MatlackLIBKVM += lib/kvm_util.c
259fda6753SDavid MatlackLIBKVM += lib/memstress.c
26e5119382SAaron LewisLIBKVM += lib/guest_sprintf.c
27cf97d5e9SDavid MatlackLIBKVM += lib/rbtree.c
28cf97d5e9SDavid MatlackLIBKVM += lib/sparsebit.c
29cf97d5e9SDavid MatlackLIBKVM += lib/test_util.c
3070466381SSean ChristophersonLIBKVM += lib/ucall_common.c
31a93871d0SRicardo KollerLIBKVM += lib/userfaultfd_util.c
32cf97d5e9SDavid Matlack
336b6f7148SSean ChristophersonLIBKVM_STRING += lib/string_override.c
346b6f7148SSean Christopherson
35cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/apic.c
36cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/handlers.S
37e8f3d23cSVitaly KuznetsovLIBKVM_x86_64 += lib/x86_64/hyperv.c
389fda6753SDavid MatlackLIBKVM_x86_64 += lib/x86_64/memstress.c
39cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/processor.c
40cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/svm.c
41cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/ucall.c
42cf97d5e9SDavid MatlackLIBKVM_x86_64 += lib/x86_64/vmx.c
43cf97d5e9SDavid Matlack
44cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/gic.c
45cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/gic_v3.c
46cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/handlers.S
47cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/processor.c
48cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/spinlock.c
49cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/ucall.c
50cf97d5e9SDavid MatlackLIBKVM_aarch64 += lib/aarch64/vgic.c
51cf97d5e9SDavid Matlack
52cf97d5e9SDavid MatlackLIBKVM_s390x += lib/s390x/diag318_test_handler.c
53cf97d5e9SDavid MatlackLIBKVM_s390x += lib/s390x/processor.c
54cf97d5e9SDavid MatlackLIBKVM_s390x += lib/s390x/ucall.c
55cf97d5e9SDavid Matlack
56cf97d5e9SDavid MatlackLIBKVM_riscv += lib/riscv/processor.c
57cf97d5e9SDavid MatlackLIBKVM_riscv += lib/riscv/ucall.c
58783e9e51SPaolo Bonzini
598448ec59SBen Gardon# Non-compiled test targets
608448ec59SBen GardonTEST_PROGS_x86_64 += x86_64/nx_huge_pages_test.sh
618448ec59SBen Gardon
628448ec59SBen Gardon# Compiled test targets
639e6d484fSVitaly KuznetsovTEST_GEN_PROGS_x86_64 = x86_64/cpuid_test
649e6d484fSVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/cr4_cpuid_sync_test
65dfa78a20SBen GardonTEST_GEN_PROGS_x86_64 += x86_64/dirty_log_page_splitting_test
6677a3aa26SEmanuele Giuseppe EspositoTEST_GEN_PROGS_x86_64 += x86_64/get_msr_index_features
673ae5b759SDavid MatlackTEST_GEN_PROGS_x86_64 += x86_64/exit_on_emulation_failure_test
686c2fa8b2SOliver UptonTEST_GEN_PROGS_x86_64 += x86_64/fix_hypercall_test
692c7f76b4SVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_clock
707edcb734SVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid
710fa32dadSVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_evmcs
7260325261SVipin SharmaTEST_GEN_PROGS_x86_64 += x86_64/hyperv_extended_hypercalls
73e2e1cc1fSVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_features
7499848924SVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_ipi
75e67bd7dfSVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_svm_test
769e7726a8SVitaly KuznetsovTEST_GEN_PROGS_x86_64 += x86_64/hyperv_tlb_flush
7761fb1c54SOliver UptonTEST_GEN_PROGS_x86_64 += x86_64/kvm_clock_test
78ac4a4d6dSOliver UptonTEST_GEN_PROGS_x86_64 += x86_64/kvm_pv_test
799dba988eSAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/mmio_warning_test
802325d4ddSSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/monitor_mwait_test
8128c40b2cSSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/nested_exceptions_test
8261cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/platform_info_test
83bef9a701SJim MattsonTEST_GEN_PROGS_x86_64 += x86_64/pmu_event_filter_test
843df22524SEmanuele Giuseppe EspositoTEST_GEN_PROGS_x86_64 += x86_64/set_boot_cpu_id
8561cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test
8652d3a4fbSDavid MatlackTEST_GEN_PROGS_x86_64 += x86_64/smaller_maxphyaddr_emulation_test
8761cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/smm_test
8861cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/state_test
898d7fbf01SMakarand SonareTEST_GEN_PROGS_x86_64 += x86_64/vmx_preemption_timer_test
9094c4b76bSAndrew JonesTEST_GEN_PROGS_x86_64 += x86_64/svm_vmcall_test
911ad32105SMaxim LevitskyTEST_GEN_PROGS_x86_64 += x86_64/svm_int_ctl_test
920bd2d3f4SMaxim LevitskyTEST_GEN_PROGS_x86_64 += x86_64/svm_nested_shutdown_test
93d8969871SMaciej S. SzmigieroTEST_GEN_PROGS_x86_64 += x86_64/svm_nested_soft_inject_test
94e467b0deSDavid WoodhouseTEST_GEN_PROGS_x86_64 += x86_64/tsc_scaling_sync
9561cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test
96eede2065SJue WangTEST_GEN_PROGS_x86_64 += x86_64/ucna_injection_test
9710e7a099SSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/userspace_io_test
983cea1891SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/userspace_msr_exit_test
9997a71a54SJim MattsonTEST_GEN_PROGS_x86_64 += x86_64/vmx_apic_access_test
10061cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/vmx_close_while_nested_test
10109444420SPaolo BonziniTEST_GEN_PROGS_x86_64 += x86_64/vmx_dirty_log_test
102e337f7e0SSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/vmx_exception_with_invalid_guest_state
103ce30d8b9SSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/vmx_msrs_test
104ab1ef344SSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/vmx_invalid_nested_guest_state
105da1e3071SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/vmx_set_nested_state_test
10661cfcd54SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/vmx_tsc_adjust_test
107efe58549SIlias StamatisTEST_GEN_PROGS_x86_64 += x86_64/vmx_nested_tsc_scaling_test
108678e90a3SPeter ShierTEST_GEN_PROGS_x86_64 += x86_64/xapic_ipi_test
10985c68eb4SSean ChristophersonTEST_GEN_PROGS_x86_64 += x86_64/xapic_state_test
11003a405b7SAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/xcr0_cpuid_test
111c90992bfSAaron LewisTEST_GEN_PROGS_x86_64 += x86_64/xss_msr_test
112449aa906SPeter XuTEST_GEN_PROGS_x86_64 += x86_64/debug_regs
1130c899c25SPaolo BonziniTEST_GEN_PROGS_x86_64 += x86_64/tsc_msrs_test
114825be3b5SYang WeijiangTEST_GEN_PROGS_x86_64 += x86_64/vmx_pmu_caps_test
1158d4e7e80SDavid WoodhouseTEST_GEN_PROGS_x86_64 += x86_64/xen_shinfo_test
11623200b7aSJoao MartinsTEST_GEN_PROGS_x86_64 += x86_64/xen_vmcall_test
1176a581508SPeter GondaTEST_GEN_PROGS_x86_64 += x86_64/sev_migrate_tests
118bf70636dSYang ZhongTEST_GEN_PROGS_x86_64 += x86_64/amx_test
119753dcf7aSZeng GuangTEST_GEN_PROGS_x86_64 += x86_64/max_vcpuid_cap_test
12030267b43SChenyi QiangTEST_GEN_PROGS_x86_64 += x86_64/triple_fault_event_test
12147d2804bSMichal LuczajTEST_GEN_PROGS_x86_64 += x86_64/recalc_apic_map_test
122de1956f4SDavid MatlackTEST_GEN_PROGS_x86_64 += access_tracking_perf_test
123025eed7bSBen GardonTEST_GEN_PROGS_x86_64 += demand_paging_test
12494c4b76bSAndrew JonesTEST_GEN_PROGS_x86_64 += dirty_log_test
1254fd94ec7SBen GardonTEST_GEN_PROGS_x86_64 += dirty_log_perf_test
1265d1d46f9SAaron LewisTEST_GEN_PROGS_x86_64 += guest_print_test
1271838b06bSIgnacio AlvaradoTEST_GEN_PROGS_x86_64 += hardware_disable_test
128fd4198bfSPaolo BonziniTEST_GEN_PROGS_x86_64 += kvm_create_max_vcpus
129b9c2bd50SYanan WangTEST_GEN_PROGS_x86_64 += kvm_page_table_test
130b58c55d5SSean ChristophersonTEST_GEN_PROGS_x86_64 += max_guest_memory_test
131f73a3446SBen GardonTEST_GEN_PROGS_x86_64 += memslot_modification_stress_test
132cad347faSMaciej S. SzmigieroTEST_GEN_PROGS_x86_64 += memslot_perf_test
13361e52f16SSean ChristophersonTEST_GEN_PROGS_x86_64 += rseq_test
1345b4f758fSSean ChristophersonTEST_GEN_PROGS_x86_64 += set_memory_region_test
13594c4b76bSAndrew JonesTEST_GEN_PROGS_x86_64 += steal_time
1360b45d587SJing ZhangTEST_GEN_PROGS_x86_64 += kvm_binary_stats_test
1373f9808caSOliver UptonTEST_GEN_PROGS_x86_64 += system_counter_offset_test
138fff8dcd7SAndrew Jones
1398448ec59SBen Gardon# Compiled outputs used by test targets
1408448ec59SBen GardonTEST_GEN_PROGS_EXTENDED_x86_64 += x86_64/nx_huge_pages_test
1418448ec59SBen Gardon
142797b8451SOliver UptonTEST_GEN_PROGS_aarch64 += aarch64/aarch32_id_regs
1434959d865SRaghavendra Rao AnantaTEST_GEN_PROGS_aarch64 += aarch64/arch_timer
1444f05223aSRicardo KollerTEST_GEN_PROGS_aarch64 += aarch64/debug-exceptions
145fd02029aSAndrew JonesTEST_GEN_PROGS_aarch64 += aarch64/hypercalls
1465ca24697SRaghavendra Rao AnantaTEST_GEN_PROGS_aarch64 += aarch64/page_fault_test
14735c58101SRicardo KollerTEST_GEN_PROGS_aarch64 += aarch64/psci_test
148bf08515dSOliver UptonTEST_GEN_PROGS_aarch64 += aarch64/smccc_filter
14960e7dadeSOliver UptonTEST_GEN_PROGS_aarch64 += aarch64/vcpu_width_config
1502f5d27e6SReiji WatanabeTEST_GEN_PROGS_aarch64 += aarch64/vgic_init
151dc0e058eSEric AugerTEST_GEN_PROGS_aarch64 += aarch64/vgic_irq
15250b020cdSRicardo KollerTEST_GEN_PROGS_aarch64 += access_tracking_perf_test
15345681804SOliver UptonTEST_GEN_PROGS_aarch64 += demand_paging_test
154025eed7bSBen GardonTEST_GEN_PROGS_aarch64 += dirty_log_test
15594c4b76bSAndrew JonesTEST_GEN_PROGS_aarch64 += dirty_log_perf_test
15687c5f35eSAndrew JonesTEST_GEN_PROGS_aarch64 += guest_print_test
1575d1d46f9SAaron LewisTEST_GEN_PROGS_aarch64 += get-reg-list
15849fe9a5dSThomas HuthTEST_GEN_PROGS_aarch64 += kvm_create_max_vcpus
159b9c2bd50SYanan WangTEST_GEN_PROGS_aarch64 += kvm_page_table_test
160358928fdSRicardo KollerTEST_GEN_PROGS_aarch64 += memslot_modification_stress_test
161358928fdSRicardo KollerTEST_GEN_PROGS_aarch64 += memslot_perf_test
16261e52f16SSean ChristophersonTEST_GEN_PROGS_aarch64 += rseq_test
1635b4f758fSSean ChristophersonTEST_GEN_PROGS_aarch64 += set_memory_region_test
16494c4b76bSAndrew JonesTEST_GEN_PROGS_aarch64 += steal_time
1650b45d587SJing ZhangTEST_GEN_PROGS_aarch64 += kvm_binary_stats_test
166783e9e51SPaolo Bonzini
167be6f55a6SThomas HuthTEST_GEN_PROGS_s390x = s390x/memop
168b25d4cb4SJanosch FrankTEST_GEN_PROGS_s390x += s390x/resets
16994c4b76bSAndrew JonesTEST_GEN_PROGS_s390x += s390x/sync_regs_test
170c7ef9ebbSJanis Schoetterl-GlauschTEST_GEN_PROGS_s390x += s390x/tprot
171e325ba22SNico BoehrTEST_GEN_PROGS_s390x += s390x/cmma_test
172*642dbc03SIlya LeoshkevichTEST_GEN_PROGS_s390x += s390x/debug_test
173025eed7bSBen GardonTEST_GEN_PROGS_s390x += demand_paging_test
17494c4b76bSAndrew JonesTEST_GEN_PROGS_s390x += dirty_log_test
1755d1d46f9SAaron LewisTEST_GEN_PROGS_s390x += guest_print_test
17649fe9a5dSThomas HuthTEST_GEN_PROGS_s390x += kvm_create_max_vcpus
177b9c2bd50SYanan WangTEST_GEN_PROGS_s390x += kvm_page_table_test
17861e52f16SSean ChristophersonTEST_GEN_PROGS_s390x += rseq_test
1795b4f758fSSean ChristophersonTEST_GEN_PROGS_s390x += set_memory_region_test
1800b45d587SJing ZhangTEST_GEN_PROGS_s390x += kvm_binary_stats_test
181783e9e51SPaolo Bonzini
1823e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += demand_paging_test
1833e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += dirty_log_test
1845d1d46f9SAaron LewisTEST_GEN_PROGS_riscv += guest_print_test
1853e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += get-reg-list
1863e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += kvm_create_max_vcpus
1873e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += kvm_page_table_test
1883e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += set_memory_region_test
1893e06cdf1SAnup PatelTEST_GEN_PROGS_riscv += kvm_binary_stats_test
1906a5db83aSSean Christopherson
1916a5db83aSSean ChristophersonSPLIT_TESTS += get-reg-list
1926a5db83aSSean Christopherson
1936a5db83aSSean ChristophersonTEST_PROGS += $(TEST_PROGS_$(ARCH_DIR))
194783e9e51SPaolo BonziniTEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH_DIR))
1955ed19528SYu ZhangTEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(ARCH_DIR))
1965ed19528SYu ZhangLIBKVM += $(LIBKVM_$(ARCH_DIR))
1975efb946bSSean Christopherson
1985efb946bSSean ChristophersonOVERRIDE_TARGETS = 1
1995efb946bSSean Christopherson
2005efb946bSSean Christopherson# lib.mak defines $(OUTPUT), prepends $(OUTPUT)/ to $(TEST_GEN_PROGS), and most
2015efb946bSSean Christopherson# importantly defines, i.e. overwrites, $(CC) (unless `make -e` or `make CC=`,
202783e9e51SPaolo Bonzini# which causes the environment variable to override the makefile).
203783e9e51SPaolo Bonziniinclude ../lib.mk
204cc68765dSAndrew Jones
205b80db73dSVitaly KuznetsovINSTALL_HDR_PATH = $(top_srcdir)/usr
206b80db73dSVitaly KuznetsovLINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
207b80db73dSVitaly KuznetsovLINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
20866d69e08SShuah Khanifeq ($(ARCH),x86_64)
209b80db73dSVitaly KuznetsovLINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
210319f6f97SThomas Huthelse
2115ed19528SYu ZhangLINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
2127cf2e737SSean Christophersonendif
213a1c1b55eSAaron LewisCFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
214319f6f97SThomas Huth	-Wno-gnu-variable-sized-type-not-at-end -MD\
215a5543d34SSean Christopherson	-fno-builtin-memcmp -fno-builtin-memcpy -fno-builtin-memset \
2166a5db83aSSean Christopherson	-fno-builtin-strnlen \
21766d42ac7SGavin Shan	-fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
218d7b9dc14SNina Schoetterl-Glausch	-I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
219d7b9dc14SNina Schoetterl-Glausch	-I$(<D) -Iinclude/$(ARCH_DIR) -I ../rseq -I.. $(EXTRA_CFLAGS) \
220d7b9dc14SNina Schoetterl-Glausch	$(KHDR_INCLUDES)
221c2390f16SPaolo Bonziniifeq ($(ARCH),s390)
2225dc38777SSean Christopherson	CFLAGS += -march=z10
2232b2d8afcSSean Christophersonendif
224c2390f16SPaolo Bonzini
2258343ba2dSChristian Borntraegerno-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \
2265dc38777SSean Christopherson        $(CC) -Werror $(CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
2278343ba2dSChristian Borntraeger
2288343ba2dSChristian Borntraeger# On s390, build the testcases KVM-enabled
22966d42ac7SGavin Shanpgste-option = $(call try-run, echo 'int main(void) { return 0; }' | \
2308343ba2dSChristian Borntraeger	$(CC) -Werror -Wl$(comma)--s390-pgste -x c - -o "$$TMP",-Wl$(comma)--s390-pgste)
231783e9e51SPaolo Bonzini
23229faeb96SAaron LewisLDLIBS += -ldl
23329faeb96SAaron LewisLDFLAGS += -pthread $(no-pie-option) $(pgste-option)
23429faeb96SAaron Lewis
23529faeb96SAaron LewisLIBKVM_C := $(filter %.c,$(LIBKVM))
2366b6f7148SSean ChristophersonLIBKVM_S := $(filter %.S,$(LIBKVM))
2376b6f7148SSean ChristophersonLIBKVM_C_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_C))
238cdc979daSDavid MatlackLIBKVM_S_OBJ := $(patsubst %.S, $(OUTPUT)/%.o, $(LIBKVM_S))
2395ed19528SYu ZhangLIBKVM_STRING_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_STRING))
2405ed19528SYu ZhangLIBKVM_OBJS = $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ) $(LIBKVM_STRING_OBJ)
2415ed19528SYu ZhangSPLIT_TESTS_TARGETS := $(patsubst %, $(OUTPUT)/%, $(SPLIT_TESTS))
2425ed19528SYu ZhangSPLIT_TESTS_OBJS := $(patsubst %, $(ARCH_DIR)/%.o, $(SPLIT_TESTS))
2435ed19528SYu Zhang
2445ed19528SYu ZhangTEST_GEN_OBJ = $(patsubst %, %.o, $(TEST_GEN_PROGS))
2455ed19528SYu ZhangTEST_GEN_OBJ += $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED))
2465ed19528SYu ZhangTEST_DEP_FILES = $(patsubst %.o, %.d, $(TEST_GEN_OBJ))
2475ed19528SYu ZhangTEST_DEP_FILES += $(patsubst %.o, %.d, $(LIBKVM_OBJS))
2485ed19528SYu ZhangTEST_DEP_FILES += $(patsubst %.o, %.d, $(SPLIT_TESTS_OBJS))
2495ed19528SYu Zhang-include $(TEST_DEP_FILES)
2505ed19528SYu Zhang
251783e9e51SPaolo Bonzini$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): %: %.o
25229faeb96SAaron Lewis	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBKVM_OBJS) $(LDLIBS) -o $@
25329faeb96SAaron Lewis$(TEST_GEN_OBJ): $(OUTPUT)/%.o: %.c
254783e9e51SPaolo Bonzini	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
255783e9e51SPaolo Bonzini
25629faeb96SAaron Lewis$(SPLIT_TESTS_TARGETS): %: %.o $(SPLIT_TESTS_OBJS)
25729faeb96SAaron Lewis	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
25829faeb96SAaron Lewis
2596b6f7148SSean ChristophersonEXTRA_CLEAN += $(LIBKVM_OBJS) $(TEST_DEP_FILES) $(TEST_GEN_OBJ) $(SPLIT_TESTS_OBJS) cscope.*
2606b6f7148SSean Christopherson
2616b6f7148SSean Christophersonx := $(shell mkdir -p $(sort $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ))))
2626b6f7148SSean Christopherson$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c
2636b6f7148SSean Christopherson	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
2646b6f7148SSean Christopherson
26566d69e08SShuah Khan$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S
266cdc979daSDavid Matlack	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
2678448ec59SBen Gardon
268eea192bfSAndrew Jones# Compile the string overrides as freestanding to prevent the compiler from
269eea192bfSAndrew Jones# generating self-referential code, e.g. without "freestanding" the compiler may
270eea192bfSAndrew Jones# "optimize" memcmp() by invoking memcmp(), thus causing infinite recursion.
271eea192bfSAndrew Jones$(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c
272eea192bfSAndrew Jones	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -ffreestanding $< -o $@
273eea192bfSAndrew Jones
274eea192bfSAndrew Jonesx := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
275eea192bfSAndrew Jones$(TEST_GEN_PROGS): $(LIBKVM_OBJS)
276eea192bfSAndrew Jones$(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
277
278cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
279cscope:
280	$(RM) cscope.*
281	(find $(include_paths) -name '*.h' \
282		-exec realpath --relative-base=$(PWD) {} \;; \
283	find . -name '*.c' \
284		-exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files
285	cscope -b
286