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 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 += -nostdlib $(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) \ 58 -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \ 59 -j .rela -j .reloc -S --target=$(FORMAT) $< $@ 60 @chmod a-x $@ 61else 62# We want to keep intermediate file: %.elf and %.o 63.PRECIOUS: %.elf %.o 64 65%.elf: LDFLAGS = -nostdlib $(arch_LDFLAGS) 66%.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o) 67 $(LD) $(LDFLAGS) -T $(SRCDIR)/x86/flat.lds -o $@ \ 68 $(filter %.o, $^) $(FLATLIBS) 69 @chmod a-x $@ 70 71%.flat: %.elf 72 $(OBJCOPY) -O elf32-i386 $^ $@ 73 @chmod a-x $@ 74endif 75 76tests-common = $(TEST_DIR)/vmexit.$(exe) $(TEST_DIR)/tsc.$(exe) \ 77 $(TEST_DIR)/smptest.$(exe) $(TEST_DIR)/dummy.$(exe) \ 78 $(TEST_DIR)/msr.$(exe) \ 79 $(TEST_DIR)/hypercall.$(exe) $(TEST_DIR)/sieve.$(exe) \ 80 $(TEST_DIR)/kvmclock_test.$(exe) \ 81 $(TEST_DIR)/s3.$(exe) $(TEST_DIR)/pmu.$(exe) $(TEST_DIR)/setjmp.$(exe) \ 82 $(TEST_DIR)/tsc_adjust.$(exe) $(TEST_DIR)/asyncpf.$(exe) \ 83 $(TEST_DIR)/init.$(exe) \ 84 $(TEST_DIR)/hyperv_synic.$(exe) $(TEST_DIR)/hyperv_stimer.$(exe) \ 85 $(TEST_DIR)/hyperv_connections.$(exe) \ 86 $(TEST_DIR)/tsx-ctrl.$(exe) \ 87 $(TEST_DIR)/emulator.$(exe) \ 88 $(TEST_DIR)/eventinj.$(exe) \ 89 $(TEST_DIR)/smap.$(exe) \ 90 $(TEST_DIR)/umip.$(exe) 91 92# The following test cases are disabled when building EFI tests because they 93# use absolute addresses in their inline assembly code, which cannot compile 94# with the '-fPIC' flag 95ifneq ($(CONFIG_EFI),y) 96tests-common += $(TEST_DIR)/realmode.$(exe) 97endif 98 99test_cases: $(tests-common) $(tests) 100 101$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib 102 103$(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o 104 $(LD) -m elf_i386 -nostdlib -o $@ \ 105 -T $(SRCDIR)/$(TEST_DIR)/realmode.lds $^ 106 107$(TEST_DIR)/realmode.o: bits = $(if $(call cc-option,-m16,""),16,32) 108 109$(TEST_DIR)/access_test.$(bin): $(TEST_DIR)/access.o 110 111$(TEST_DIR)/vmx.$(bin): $(TEST_DIR)/access.o 112 113$(TEST_DIR)/svm_npt.$(bin): $(TEST_DIR)/svm.o 114 115$(TEST_DIR)/kvmclock_test.$(bin): $(TEST_DIR)/kvmclock.o 116 117$(TEST_DIR)/hyperv_synic.$(bin): $(TEST_DIR)/hyperv.o 118 119$(TEST_DIR)/hyperv_stimer.$(bin): $(TEST_DIR)/hyperv.o 120 121$(TEST_DIR)/hyperv_connections.$(bin): $(TEST_DIR)/hyperv.o 122 123arch_clean: 124 $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ 125 $(TEST_DIR)/.*.d lib/x86/.*.d \ 126 $(TEST_DIR)/efi/*.o $(TEST_DIR)/efi/.*.d \ 127 $(TEST_DIR)/*.so $(TEST_DIR)/*.efi 128