143fbd8cdSSean Christopherson# SPDX-License-Identifier: GPL-2.0-only 243fbd8cdSSean Christophersoninclude ../../../build/Build.include 343fbd8cdSSean Christopherson 443fbd8cdSSean Christophersonall: 543fbd8cdSSean Christopherson 643fbd8cdSSean ChristophersonLIBKVM += lib/assert.c 743fbd8cdSSean ChristophersonLIBKVM += lib/elf.c 843fbd8cdSSean ChristophersonLIBKVM += lib/guest_modes.c 943fbd8cdSSean ChristophersonLIBKVM += lib/io.c 1043fbd8cdSSean ChristophersonLIBKVM += lib/kvm_util.c 11d166453eSJames HoughtonLIBKVM += lib/lru_gen_util.c 1243fbd8cdSSean ChristophersonLIBKVM += lib/memstress.c 1343fbd8cdSSean ChristophersonLIBKVM += lib/guest_sprintf.c 1443fbd8cdSSean ChristophersonLIBKVM += lib/rbtree.c 1543fbd8cdSSean ChristophersonLIBKVM += lib/sparsebit.c 1643fbd8cdSSean ChristophersonLIBKVM += lib/test_util.c 1743fbd8cdSSean ChristophersonLIBKVM += lib/ucall_common.c 1843fbd8cdSSean ChristophersonLIBKVM += lib/userfaultfd_util.c 1943fbd8cdSSean Christopherson 2043fbd8cdSSean ChristophersonLIBKVM_STRING += lib/string_override.c 2143fbd8cdSSean Christopherson 2267730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/apic.c 2367730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/handlers.S 2467730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/hyperv.c 2567730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/memstress.c 2667730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/pmu.c 2767730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/processor.c 2867730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/sev.c 2967730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/svm.c 3067730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/ucall.c 3167730e6cSSean ChristophersonLIBKVM_x86 += lib/x86/vmx.c 3243fbd8cdSSean Christopherson 3367730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/gic.c 3467730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/gic_v3.c 3567730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/gic_v3_its.c 3667730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/handlers.S 3767730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/processor.c 3867730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/spinlock.c 3967730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/ucall.c 4067730e6cSSean ChristophersonLIBKVM_arm64 += lib/arm64/vgic.c 4143fbd8cdSSean Christopherson 4267730e6cSSean ChristophersonLIBKVM_s390 += lib/s390/diag318_test_handler.c 4367730e6cSSean ChristophersonLIBKVM_s390 += lib/s390/processor.c 4467730e6cSSean ChristophersonLIBKVM_s390 += lib/s390/ucall.c 4567730e6cSSean ChristophersonLIBKVM_s390 += lib/s390/facility.c 4643fbd8cdSSean Christopherson 4743fbd8cdSSean ChristophersonLIBKVM_riscv += lib/riscv/handlers.S 4843fbd8cdSSean ChristophersonLIBKVM_riscv += lib/riscv/processor.c 4943fbd8cdSSean ChristophersonLIBKVM_riscv += lib/riscv/ucall.c 5043fbd8cdSSean Christopherson 51*a867688cSBibo MaoLIBKVM_loongarch += lib/loongarch/processor.c 52*a867688cSBibo MaoLIBKVM_loongarch += lib/loongarch/ucall.c 53*a867688cSBibo MaoLIBKVM_loongarch += lib/loongarch/exception.S 54*a867688cSBibo Mao 5543fbd8cdSSean Christopherson# Non-compiled test targets 5667730e6cSSean ChristophersonTEST_PROGS_x86 += x86/nx_huge_pages_test.sh 5743fbd8cdSSean Christopherson 58c57047f6SPaolo Bonzini# Compiled test targets valid on all architectures with libkvm support 59c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON = demand_paging_test 60c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += dirty_log_test 61c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += guest_print_test 62c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += irqfd_test 63c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += kvm_binary_stats_test 64c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += kvm_create_max_vcpus 65c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += kvm_page_table_test 66c57047f6SPaolo BonziniTEST_GEN_PROGS_COMMON += set_memory_region_test 6743fbd8cdSSean Christopherson 68c57047f6SPaolo Bonzini# Compiled test targets 69c57047f6SPaolo BonziniTEST_GEN_PROGS_x86 = $(TEST_GEN_PROGS_COMMON) 7067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/cpuid_test 7167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/cr4_cpuid_sync_test 7267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/dirty_log_page_splitting_test 7367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/feature_msrs_test 745e9ac644SSean ChristophersonTEST_GEN_PROGS_x86 += x86/exit_on_emulation_failure_test 7567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/fastops_test 7667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/fix_hypercall_test 7767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hwcr_msr_test 7867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_clock 7967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_cpuid 8067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_evmcs 8167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_extended_hypercalls 8267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_features 8367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_ipi 8467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_svm_test 8567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/hyperv_tlb_flush 8667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/kvm_clock_test 8772df72e1SNikunj A DadhaniaTEST_GEN_PROGS_x86 += x86/kvm_pv_test 8867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/kvm_buslock_test 892428865bSSean ChristophersonTEST_GEN_PROGS_x86 += x86/monitor_mwait_test 9067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/nested_emulation_test 9167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/nested_exceptions_test 9267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/platform_info_test 9367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/pmu_counters_test 9467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/pmu_event_filter_test 9567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/private_mem_conversions_test 9667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/private_mem_kvm_exits_test 9767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/set_boot_cpu_id 9867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/set_sregs_test 9967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/smaller_maxphyaddr_emulation_test 10067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/smm_test 10167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/state_test 10267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_preemption_timer_test 10367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/svm_vmcall_test 10467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/svm_int_ctl_test 10567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/svm_nested_shutdown_test 10667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/svm_nested_soft_inject_test 10767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/tsc_scaling_sync 10867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/sync_regs_test 10967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/ucna_injection_test 11067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/userspace_io_test 11167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/userspace_msr_exit_test 11267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_apic_access_test 11367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_close_while_nested_test 11467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_dirty_log_test 11567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_exception_with_invalid_guest_state 11667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_msrs_test 11767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_invalid_nested_guest_state 11867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_set_nested_state_test 11967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_tsc_adjust_test 12067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_nested_tsc_scaling_test 12167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/apic_bus_clock_test 12267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xapic_ipi_test 12367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xapic_state_test 12467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xcr0_cpuid_test 12567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xss_msr_test 12667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/debug_regs 12767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/tsc_msrs_test 12867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/vmx_pmu_caps_test 12967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xen_shinfo_test 13067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/xen_vmcall_test 13167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/sev_init2_tests 13267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/sev_migrate_tests 13367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/sev_smoke_test 13467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/amx_test 13567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/max_vcpuid_cap_test 13667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/triple_fault_event_test 13767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/recalc_apic_map_test 13867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += x86/aperfmperf_test 13967730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += access_tracking_perf_test 14067730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += coalesced_io_test 14167730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += dirty_log_perf_test 14267730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += guest_memfd_test 14367730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += hardware_disable_test 14467730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += memslot_modification_stress_test 14567730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += memslot_perf_test 14667730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += mmu_stress_test 14767730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += rseq_test 14867730e6cSSean ChristophersonTEST_GEN_PROGS_x86 += steal_time 14943fbd8cdSSean ChristophersonTEST_GEN_PROGS_x86 += system_counter_offset_test 15043fbd8cdSSean ChristophersonTEST_GEN_PROGS_x86 += pre_fault_memory_test 15167730e6cSSean Christopherson 15243fbd8cdSSean Christopherson# Compiled outputs used by test targets 153c57047f6SPaolo BonziniTEST_GEN_PROGS_EXTENDED_x86 += x86/nx_huge_pages_test 15467730e6cSSean Christopherson 15567730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 = $(TEST_GEN_PROGS_COMMON) 15667730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/aarch32_id_regs 157e0ccc45bSMark BrownTEST_GEN_PROGS_arm64 += arm64/arch_timer_edge_cases 15867730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/debug-exceptions 15967730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/host_sve 16067730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/hypercalls 16167730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/external_aborts 16267730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/page_fault_test 16367730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/psci_test 16467730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/set_id_regs 16567730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/smccc_filter 16667730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/vcpu_width_config 16767730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/vgic_init 16867730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/vgic_irq 16967730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/vgic_lpi_stress 17067730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/vpmu_counter_access 17167730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arm64/no-vgic-v3 17267730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += access_tracking_perf_test 17367730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += arch_timer 17467730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += coalesced_io_test 17567730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += dirty_log_perf_test 17667730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += get-reg-list 17767730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += memslot_modification_stress_test 17867730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += memslot_perf_test 17967730e6cSSean ChristophersonTEST_GEN_PROGS_arm64 += mmu_stress_test 18043fbd8cdSSean ChristophersonTEST_GEN_PROGS_arm64 += rseq_test 181c57047f6SPaolo BonziniTEST_GEN_PROGS_arm64 += steal_time 182c57047f6SPaolo Bonzini 18367730e6cSSean ChristophersonTEST_GEN_PROGS_s390 = $(TEST_GEN_PROGS_COMMON) 18467730e6cSSean ChristophersonTEST_GEN_PROGS_s390 += s390/memop 18567730e6cSSean ChristophersonTEST_GEN_PROGS_s390 += s390/resets 18667730e6cSSean ChristophersonTEST_GEN_PROGS_s390 += s390/sync_regs_test 18767730e6cSSean ChristophersonTEST_GEN_PROGS_s390 += s390/tprot 18867730e6cSSean ChristophersonTEST_GEN_PROGS_s390 += s390/cmma_test 18967730e6cSSean ChristophersonTEST_GEN_PROGS_s390 += s390/debug_test 19067730e6cSSean ChristophersonTEST_GEN_PROGS_s390 += s390/cpumodel_subfuncs_test 19167730e6cSSean ChristophersonTEST_GEN_PROGS_s390 += s390/shared_zeropage_test 19243fbd8cdSSean ChristophersonTEST_GEN_PROGS_s390 += s390/ucontrol_test 193c57047f6SPaolo BonziniTEST_GEN_PROGS_s390 += rseq_test 19443fbd8cdSSean Christopherson 19543fbd8cdSSean ChristophersonTEST_GEN_PROGS_riscv = $(TEST_GEN_PROGS_COMMON) 19643fbd8cdSSean ChristophersonTEST_GEN_PROGS_riscv += riscv/sbi_pmu_test 19743fbd8cdSSean ChristophersonTEST_GEN_PROGS_riscv += riscv/ebreak_test 19843fbd8cdSSean ChristophersonTEST_GEN_PROGS_riscv += arch_timer 19943fbd8cdSSean ChristophersonTEST_GEN_PROGS_riscv += coalesced_io_test 20043fbd8cdSSean ChristophersonTEST_GEN_PROGS_riscv += get-reg-list 201*a867688cSBibo MaoTEST_GEN_PROGS_riscv += steal_time 202*a867688cSBibo Mao 203*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += coalesced_io_test 204*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += demand_paging_test 205*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += dirty_log_perf_test 206*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += dirty_log_test 207*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += guest_print_test 208*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += hardware_disable_test 209*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += kvm_binary_stats_test 210*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += kvm_create_max_vcpus 211*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += kvm_page_table_test 212*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += memslot_modification_stress_test 213*a867688cSBibo MaoTEST_GEN_PROGS_loongarch += memslot_perf_test 21443fbd8cdSSean ChristophersonTEST_GEN_PROGS_loongarch += set_memory_region_test 21543fbd8cdSSean Christopherson 21643fbd8cdSSean ChristophersonSPLIT_TESTS += arch_timer 2179af04539SSean ChristophersonSPLIT_TESTS += get-reg-list 2189af04539SSean Christopherson 2199af04539SSean ChristophersonTEST_PROGS += $(TEST_PROGS_$(ARCH)) 2209af04539SSean ChristophersonTEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH)) 22143fbd8cdSSean ChristophersonTEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(ARCH)) 22243fbd8cdSSean ChristophersonLIBKVM += $(LIBKVM_$(ARCH)) 22343fbd8cdSSean Christopherson 22443fbd8cdSSean ChristophersonOVERRIDE_TARGETS = 1 22543fbd8cdSSean Christopherson 22643fbd8cdSSean Christopherson# lib.mak defines $(OUTPUT), prepends $(OUTPUT)/ to $(TEST_GEN_PROGS), and most 22743fbd8cdSSean Christopherson# importantly defines, i.e. overwrites, $(CC) (unless `make -e` or `make CC=`, 228b11fcb51SJames Houghton# which causes the environment variable to override the makefile). 22943fbd8cdSSean Christophersoninclude ../lib.mk 23043fbd8cdSSean Christophersoninclude ../cgroup/lib/libcgroup.mk 23143fbd8cdSSean Christopherson 23243fbd8cdSSean ChristophersonINSTALL_HDR_PATH = $(top_srcdir)/usr 2339af04539SSean ChristophersonLINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/ 23443fbd8cdSSean ChristophersonLINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include 23543fbd8cdSSean ChristophersonLINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include 23643fbd8cdSSean ChristophersonCFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ 23743fbd8cdSSean Christopherson -Wno-gnu-variable-sized-type-not-at-end -MD -MP -DCONFIG_64BIT \ 23843fbd8cdSSean Christopherson -fno-builtin-memcmp -fno-builtin-memcpy \ 23943fbd8cdSSean Christopherson -fno-builtin-memset -fno-builtin-strnlen \ 2409af04539SSean Christopherson -fno-stack-protector -fno-PIE -fno-strict-aliasing \ 24143fbd8cdSSean Christopherson -I$(LINUX_TOOL_INCLUDE) -I$(LINUX_TOOL_ARCH_INCLUDE) \ 24243fbd8cdSSean Christopherson -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(ARCH) \ 24343fbd8cdSSean Christopherson -I ../rseq -I.. $(EXTRA_CFLAGS) $(KHDR_INCLUDES) 24443fbd8cdSSean Christophersonifeq ($(ARCH),s390) 24543fbd8cdSSean Christopherson CFLAGS += -march=z10 24643fbd8cdSSean Christophersonendif 24743fbd8cdSSean Christophersonifeq ($(ARCH),x86) 24843fbd8cdSSean Christophersonifeq ($(shell echo "void foo(void) { }" | $(CC) -march=x86-64-v2 -x c - -c -o /dev/null 2>/dev/null; echo "$$?"),0) 24943fbd8cdSSean Christopherson CFLAGS += -march=x86-64-v2 25043fbd8cdSSean Christophersonendif 25143fbd8cdSSean Christophersonendif 25243fbd8cdSSean Christophersonifeq ($(ARCH),arm64) 25343fbd8cdSSean Christophersontools_dir := $(top_srcdir)/tools 25443fbd8cdSSean Christophersonarm64_tools_dir := $(tools_dir)/arch/arm64/tools/ 25543fbd8cdSSean Christopherson 25643fbd8cdSSean Christophersonifneq ($(abs_objdir),) 25743fbd8cdSSean Christophersonarm64_hdr_outdir := $(abs_objdir)/tools/ 25843fbd8cdSSean Christophersonelse 25943fbd8cdSSean Christophersonarm64_hdr_outdir := $(tools_dir)/ 26043fbd8cdSSean Christophersonendif 26143fbd8cdSSean Christopherson 26243fbd8cdSSean ChristophersonGEN_HDRS := $(arm64_hdr_outdir)arch/arm64/include/generated/ 26343fbd8cdSSean ChristophersonCFLAGS += -I$(GEN_HDRS) 26443fbd8cdSSean Christopherson 26543fbd8cdSSean Christopherson$(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*) 26643fbd8cdSSean Christopherson $(MAKE) -C $(arm64_tools_dir) OUTPUT=$(arm64_hdr_outdir) 26743fbd8cdSSean Christophersonendif 26843fbd8cdSSean Christopherson 26943fbd8cdSSean Christophersonno-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \ 27043fbd8cdSSean Christopherson $(CC) -Werror $(CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) 27143fbd8cdSSean Christopherson 27243fbd8cdSSean Christopherson# On s390, build the testcases KVM-enabled 27343fbd8cdSSean Christophersonpgste-option = $(call try-run, echo 'int main(void) { return 0; }' | \ 27443fbd8cdSSean Christopherson $(CC) -Werror -Wl$(comma)--s390-pgste -x c - -o "$$TMP",-Wl$(comma)--s390-pgste) 27543fbd8cdSSean Christopherson 27643fbd8cdSSean ChristophersonLDLIBS += -ldl 27743fbd8cdSSean ChristophersonLDFLAGS += -pthread $(no-pie-option) $(pgste-option) 27843fbd8cdSSean Christopherson 27943fbd8cdSSean ChristophersonLIBKVM_C := $(filter %.c,$(LIBKVM)) 28043fbd8cdSSean ChristophersonLIBKVM_S := $(filter %.S,$(LIBKVM)) 28143fbd8cdSSean ChristophersonLIBKVM_C_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_C)) 282b11fcb51SJames HoughtonLIBKVM_S_OBJ := $(patsubst %.S, $(OUTPUT)/%.o, $(LIBKVM_S)) 28343fbd8cdSSean ChristophersonLIBKVM_STRING_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_STRING)) 2849af04539SSean ChristophersonLIBKVM_OBJS = $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ) $(LIBKVM_STRING_OBJ) $(LIBCGROUP_O) 28543fbd8cdSSean ChristophersonSPLIT_TEST_GEN_PROGS := $(patsubst %, $(OUTPUT)/%, $(SPLIT_TESTS)) 28643fbd8cdSSean ChristophersonSPLIT_TEST_GEN_OBJ := $(patsubst %, $(OUTPUT)/$(ARCH)/%.o, $(SPLIT_TESTS)) 28743fbd8cdSSean Christopherson 28843fbd8cdSSean ChristophersonTEST_GEN_OBJ = $(patsubst %, %.o, $(TEST_GEN_PROGS)) 28943fbd8cdSSean ChristophersonTEST_GEN_OBJ += $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED)) 29043fbd8cdSSean ChristophersonTEST_DEP_FILES = $(patsubst %.o, %.d, $(TEST_GEN_OBJ)) 29143fbd8cdSSean ChristophersonTEST_DEP_FILES += $(patsubst %.o, %.d, $(LIBKVM_OBJS)) 29243fbd8cdSSean ChristophersonTEST_DEP_FILES += $(patsubst %.o, %.d, $(SPLIT_TEST_GEN_OBJ)) 2939af04539SSean Christopherson-include $(TEST_DEP_FILES) 29443fbd8cdSSean Christopherson 29543fbd8cdSSean Christopherson$(shell mkdir -p $(sort $(OUTPUT)/$(ARCH) $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ)))) 29643fbd8cdSSean Christopherson 29743fbd8cdSSean Christopherson$(filter-out $(SPLIT_TEST_GEN_PROGS), $(TEST_GEN_PROGS)) \ 29843fbd8cdSSean Christopherson$(TEST_GEN_PROGS_EXTENDED): %: %.o 29943fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBKVM_OBJS) $(LDLIBS) -o $@ 30043fbd8cdSSean Christopherson$(TEST_GEN_OBJ): $(OUTPUT)/%.o: %.c 3019af04539SSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ 30243fbd8cdSSean Christopherson 3039af04539SSean Christopherson$(SPLIT_TEST_GEN_PROGS): $(OUTPUT)/%: $(OUTPUT)/%.o $(OUTPUT)/$(ARCH)/%.o 30443fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@ 30543fbd8cdSSean Christopherson$(SPLIT_TEST_GEN_OBJ): $(OUTPUT)/$(ARCH)/%.o: $(ARCH)/%.c 30643fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ 30743fbd8cdSSean Christopherson 30843fbd8cdSSean ChristophersonEXTRA_CLEAN += $(GEN_HDRS) \ 30943fbd8cdSSean Christopherson $(LIBKVM_OBJS) \ 31043fbd8cdSSean Christopherson $(SPLIT_TEST_GEN_OBJ) \ 31143fbd8cdSSean Christopherson $(TEST_DEP_FILES) \ 31243fbd8cdSSean Christopherson $(TEST_GEN_OBJ) \ 31343fbd8cdSSean Christopherson cscope.* 31443fbd8cdSSean Christopherson 31543fbd8cdSSean Christopherson$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c $(GEN_HDRS) 31643fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ 31743fbd8cdSSean Christopherson 31843fbd8cdSSean Christopherson$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S $(GEN_HDRS) 31943fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ 32043fbd8cdSSean Christopherson 32143fbd8cdSSean Christopherson# Compile the string overrides as freestanding to prevent the compiler from 32243fbd8cdSSean Christopherson# generating self-referential code, e.g. without "freestanding" the compiler may 32343fbd8cdSSean Christopherson# "optimize" memcmp() by invoking memcmp(), thus causing infinite recursion. 32443fbd8cdSSean Christopherson$(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c 32543fbd8cdSSean Christopherson $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -ffreestanding $< -o $@ 32643fbd8cdSSean Christopherson 32743fbd8cdSSean Christopherson$(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS)))) 32843fbd8cdSSean Christopherson$(SPLIT_TEST_GEN_OBJ): $(GEN_HDRS) 32943fbd8cdSSean Christopherson$(TEST_GEN_PROGS): $(LIBKVM_OBJS) 33043fbd8cdSSean Christopherson$(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS) 33143fbd8cdSSean Christopherson$(TEST_GEN_OBJ): $(GEN_HDRS) 33243fbd8cdSSean Christopherson 33343fbd8cdSSean Christophersoncscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib .. 33443fbd8cdSSean Christophersoncscope: 33543fbd8cdSSean Christopherson $(RM) cscope.* 33643fbd8cdSSean Christopherson (find $(include_paths) -name '*.h' \ 33743fbd8cdSSean Christopherson -exec realpath --relative-base=$(PWD) {} \;; \ 33843fbd8cdSSean Christopherson find . -name '*.c' \ 339 -exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files 340 cscope -b 341