blob: 365e199f93e4e8087e61abd313803c6a03ea3206 [file] [log] [blame]
#This is a make file with common rules for both x86 & x86-64
all: directories test_cases
cflatobjs += lib/pci.o
cflatobjs += lib/pci-edu.o
cflatobjs += lib/alloc.o
cflatobjs += lib/auxinfo.o
cflatobjs += lib/vmalloc.o
cflatobjs += lib/alloc_page.o
cflatobjs += lib/alloc_phys.o
cflatobjs += lib/x86/setup.o
cflatobjs += lib/x86/io.o
cflatobjs += lib/x86/smp.o
cflatobjs += lib/x86/vm.o
cflatobjs += lib/x86/fwcfg.o
cflatobjs += lib/x86/apic.o
cflatobjs += lib/x86/atomic.o
cflatobjs += lib/x86/desc.o
cflatobjs += lib/x86/isr.o
cflatobjs += lib/x86/acpi.o
cflatobjs += lib/x86/stack.o
cflatobjs += lib/x86/fault_test.o
cflatobjs += lib/x86/delay.o
cflatobjs += lib/x86/pmu.o
ifeq ($(CONFIG_EFI),y)
cflatobjs += lib/x86/amd_sev.o
cflatobjs += lib/efi.o
cflatobjs += x86/efi/reloc_x86_64.o
endif
OBJDIRS += lib/x86
$(libcflat): LDFLAGS += -nostdlib $(arch_LDFLAGS)
$(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
COMMON_CFLAGS += -m$(bits)
ifneq ($(WA_DIVIDE),)
COMMON_CFLAGS += -Wa,--divide
endif
COMMON_CFLAGS += -O1
# stack.o relies on frame pointers.
KEEP_FRAME_POINTER := y
FLATLIBS = lib/libcflat.a
ifeq ($(CONFIG_EFI),y)
.PRECIOUS: %.efi %.so
%.so: %.o $(FLATLIBS) $(SRCDIR)/x86/efi/elf_x86_64_efi.lds $(cstart.o)
$(LD) -T $(SRCDIR)/x86/efi/elf_x86_64_efi.lds $(EFI_LDFLAGS) -o $@ \
$(filter %.o, $^) $(FLATLIBS)
@chmod a-x $@
%.efi: %.so
$(OBJCOPY) \
-j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
-j .rela -j .reloc -S --target=$(FORMAT) $< $@
@chmod a-x $@
else
# We want to keep intermediate file: %.elf and %.o
.PRECIOUS: %.elf %.o
%.elf: LDFLAGS = -nostdlib $(arch_LDFLAGS)
%.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o)
$(LD) $(LDFLAGS) -T $(SRCDIR)/x86/flat.lds -o $@ \
$(filter %.o, $^) $(FLATLIBS)
@chmod a-x $@
%.flat: %.elf
$(OBJCOPY) -O elf32-i386 $^ $@
@chmod a-x $@
endif
tests-common = $(TEST_DIR)/vmexit.$(exe) $(TEST_DIR)/tsc.$(exe) \
$(TEST_DIR)/smptest.$(exe) $(TEST_DIR)/dummy.$(exe) \
$(TEST_DIR)/msr.$(exe) \
$(TEST_DIR)/hypercall.$(exe) $(TEST_DIR)/sieve.$(exe) \
$(TEST_DIR)/kvmclock_test.$(exe) \
$(TEST_DIR)/s3.$(exe) $(TEST_DIR)/pmu.$(exe) $(TEST_DIR)/setjmp.$(exe) \
$(TEST_DIR)/tsc_adjust.$(exe) $(TEST_DIR)/asyncpf.$(exe) \
$(TEST_DIR)/init.$(exe) \
$(TEST_DIR)/hyperv_synic.$(exe) $(TEST_DIR)/hyperv_stimer.$(exe) \
$(TEST_DIR)/hyperv_connections.$(exe) \
$(TEST_DIR)/tsx-ctrl.$(exe) \
$(TEST_DIR)/emulator.$(exe) \
$(TEST_DIR)/eventinj.$(exe) \
$(TEST_DIR)/smap.$(exe) \
$(TEST_DIR)/umip.$(exe)
# The following test cases are disabled when building EFI tests because they
# use absolute addresses in their inline assembly code, which cannot compile
# with the '-fPIC' flag
ifneq ($(CONFIG_EFI),y)
tests-common += $(TEST_DIR)/realmode.$(exe)
endif
test_cases: $(tests-common) $(tests)
$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib
$(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
$(LD) -m elf_i386 -nostdlib -o $@ \
-T $(SRCDIR)/$(TEST_DIR)/realmode.lds $^
$(TEST_DIR)/realmode.o: bits = $(if $(call cc-option,-m16,""),16,32)
$(TEST_DIR)/access_test.$(bin): $(TEST_DIR)/access.o
$(TEST_DIR)/vmx.$(bin): $(TEST_DIR)/access.o
$(TEST_DIR)/svm_npt.$(bin): $(TEST_DIR)/svm.o
$(TEST_DIR)/kvmclock_test.$(bin): $(TEST_DIR)/kvmclock.o
$(TEST_DIR)/hyperv_synic.$(bin): $(TEST_DIR)/hyperv.o
$(TEST_DIR)/hyperv_stimer.$(bin): $(TEST_DIR)/hyperv.o
$(TEST_DIR)/hyperv_connections.$(bin): $(TEST_DIR)/hyperv.o
arch_clean:
$(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \
$(TEST_DIR)/.*.d lib/x86/.*.d \
$(TEST_DIR)/efi/*.o $(TEST_DIR)/efi/.*.d \
$(TEST_DIR)/*.so $(TEST_DIR)/*.efi