1#This is a make file with common rules for both x86 & x86-64 2 3all: directories test_cases 4 5cflatobjs += lib/acpi.o 6cflatobjs += lib/pci.o 7cflatobjs += lib/pci-edu.o 8cflatobjs += lib/alloc.o 9cflatobjs += lib/auxinfo.o 10cflatobjs += lib/vmalloc.o 11cflatobjs += lib/alloc_page.o 12cflatobjs += lib/alloc_phys.o 13cflatobjs += lib/x86/setup.o 14cflatobjs += lib/x86/io.o 15cflatobjs += lib/x86/smp.o 16cflatobjs += lib/x86/vm.o 17cflatobjs += lib/x86/fwcfg.o 18cflatobjs += lib/x86/apic.o 19cflatobjs += lib/x86/atomic.o 20cflatobjs += lib/x86/desc.o 21cflatobjs += lib/x86/isr.o 22cflatobjs += lib/x86/stack.o 23cflatobjs += lib/x86/fault_test.o 24cflatobjs += lib/x86/delay.o 25cflatobjs += lib/x86/pmu.o 26ifeq ($(CONFIG_EFI),y) 27cflatobjs += lib/x86/amd_sev.o 28cflatobjs += lib/efi.o 29cflatobjs += x86/efi/reloc_x86_64.o 30endif 31 32OBJDIRS += lib/x86 33 34$(libcflat): LDFLAGS += $(arch_LDFLAGS) 35$(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib 36 37COMMON_CFLAGS += -m$(bits) 38ifneq ($(WA_DIVIDE),) 39COMMON_CFLAGS += -Wa,--divide 40endif 41COMMON_CFLAGS += -O1 42 43# stack.o relies on frame pointers. 44KEEP_FRAME_POINTER := y 45 46FLATLIBS = lib/libcflat.a 47 48ifeq ($(CONFIG_EFI),y) 49.PRECIOUS: %.efi %.so 50 51%.so: %.o $(FLATLIBS) $(SRCDIR)/x86/efi/elf_x86_64_efi.lds $(cstart.o) 52 $(LD) -T $(SRCDIR)/x86/efi/elf_x86_64_efi.lds $(EFI_LDFLAGS) -o $@ \ 53 $(filter %.o, $^) $(FLATLIBS) 54 @chmod a-x $@ 55 56%.efi: %.so 57 $(OBJCOPY) --only-keep-debug $^ $@.debug 58 $(OBJCOPY) --strip-debug $^ 59 $(OBJCOPY) --add-gnu-debuglink=$@.debug $^ 60 $(OBJCOPY) \ 61 -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \ 62 -j .rela -j .reloc -S --target=$(FORMAT) $< $@ 63 @chmod a-x $@ 64else 65# We want to keep intermediate file: %.elf and %.o 66.PRECIOUS: %.elf %.o 67 68%.elf: LDFLAGS += $(arch_LDFLAGS) 69%.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o) 70 $(LD) $(LDFLAGS) -T $(SRCDIR)/x86/flat.lds -o $@ \ 71 $(filter %.o, $^) $(FLATLIBS) 72 @chmod a-x $@ 73 74%.flat: %.elf 75 $(OBJCOPY) -O elf32-i386 $^ $@ 76 @chmod a-x $@ 77endif 78 79tests-common = $(TEST_DIR)/vmexit.$(exe) $(TEST_DIR)/tsc.$(exe) \ 80 $(TEST_DIR)/smptest.$(exe) $(TEST_DIR)/dummy.$(exe) \ 81 $(TEST_DIR)/msr.$(exe) \ 82 $(TEST_DIR)/hypercall.$(exe) $(TEST_DIR)/sieve.$(exe) \ 83 $(TEST_DIR)/kvmclock_test.$(exe) \ 84 $(TEST_DIR)/s3.$(exe) $(TEST_DIR)/pmu.$(exe) $(TEST_DIR)/setjmp.$(exe) \ 85 $(TEST_DIR)/tsc_adjust.$(exe) $(TEST_DIR)/asyncpf.$(exe) \ 86 $(TEST_DIR)/init.$(exe) \ 87 $(TEST_DIR)/hyperv_synic.$(exe) $(TEST_DIR)/hyperv_stimer.$(exe) \ 88 $(TEST_DIR)/hyperv_connections.$(exe) \ 89 $(TEST_DIR)/tsx-ctrl.$(exe) \ 90 $(TEST_DIR)/emulator.$(exe) \ 91 $(TEST_DIR)/eventinj.$(exe) \ 92 $(TEST_DIR)/smap.$(exe) \ 93 $(TEST_DIR)/umip.$(exe) 94 95# The following test cases are disabled when building EFI tests because they 96# use absolute addresses in their inline assembly code, which cannot compile 97# with the '-fPIC' flag 98ifneq ($(CONFIG_EFI),y) 99tests-common += $(TEST_DIR)/realmode.$(exe) \ 100 $(TEST_DIR)/la57.$(exe) 101realmode_bits := $(if $(call cc-option,-m16,""),16,32) 102endif 103 104test_cases: $(tests-common) $(tests) 105 106$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib 107 108$(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o $(SRCDIR)/$(TEST_DIR)/realmode.lds 109 $(LD) -m elf_i386 -nostdlib -o $@ \ 110 -T $(SRCDIR)/$(TEST_DIR)/realmode.lds $(filter %.o, $^) 111 112$(TEST_DIR)/realmode.o: bits = $(realmode_bits) 113 114$(TEST_DIR)/access_test.$(bin): $(TEST_DIR)/access.o 115 116$(TEST_DIR)/vmx.$(bin): $(TEST_DIR)/access.o 117 118$(TEST_DIR)/svm_npt.$(bin): $(TEST_DIR)/svm.o 119 120$(TEST_DIR)/kvmclock_test.$(bin): $(TEST_DIR)/kvmclock.o 121 122$(TEST_DIR)/hyperv_synic.$(bin): $(TEST_DIR)/hyperv.o 123 124$(TEST_DIR)/hyperv_stimer.$(bin): $(TEST_DIR)/hyperv.o 125 126$(TEST_DIR)/hyperv_connections.$(bin): $(TEST_DIR)/hyperv.o 127 128arch_clean: 129 $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ 130 $(TEST_DIR)/.*.d lib/x86/.*.d \ 131 $(TEST_DIR)/efi/*.o $(TEST_DIR)/efi/.*.d \ 132 $(TEST_DIR)/*.so $(TEST_DIR)/*.efi $(TEST_DIR)/*.debug 133