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