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