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/vmalloc.o 9cflatobjs += lib/alloc_page.o 10cflatobjs += lib/alloc_phys.o 11cflatobjs += lib/x86/setup.o 12cflatobjs += lib/x86/io.o 13cflatobjs += lib/x86/smp.o 14cflatobjs += lib/x86/vm.o 15cflatobjs += lib/x86/fwcfg.o 16cflatobjs += lib/x86/apic.o 17cflatobjs += lib/x86/atomic.o 18cflatobjs += lib/x86/desc.o 19cflatobjs += lib/x86/isr.o 20cflatobjs += lib/x86/acpi.o 21cflatobjs += lib/x86/stack.o 22cflatobjs += lib/x86/fault_test.o 23cflatobjs += lib/x86/delay.o 24 25OBJDIRS += lib/x86 26 27$(libcflat): LDFLAGS += -nostdlib 28$(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib 29 30COMMON_CFLAGS += -m$(bits) 31COMMON_CFLAGS += -O1 32 33# stack.o relies on frame pointers. 34KEEP_FRAME_POINTER := y 35 36libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name) 37 38# We want to keep intermediate file: %.elf and %.o 39.PRECIOUS: %.elf %.o 40 41FLATLIBS = lib/libcflat.a $(libgcc) 42%.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o) 43 $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \ 44 $(filter %.o, $^) $(FLATLIBS) 45 @chmod a-x $@ 46 47%.flat: %.elf 48 $(OBJCOPY) -O elf32-i386 $^ $@ 49 @chmod a-x $@ 50 51tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \ 52 $(TEST_DIR)/smptest.flat $(TEST_DIR)/port80.flat \ 53 $(TEST_DIR)/realmode.flat $(TEST_DIR)/msr.flat \ 54 $(TEST_DIR)/hypercall.flat $(TEST_DIR)/sieve.flat \ 55 $(TEST_DIR)/kvmclock_test.flat $(TEST_DIR)/eventinj.flat \ 56 $(TEST_DIR)/s3.flat $(TEST_DIR)/pmu.flat $(TEST_DIR)/setjmp.flat \ 57 $(TEST_DIR)/tsc_adjust.flat $(TEST_DIR)/asyncpf.flat \ 58 $(TEST_DIR)/init.flat $(TEST_DIR)/smap.flat \ 59 $(TEST_DIR)/hyperv_synic.flat $(TEST_DIR)/hyperv_stimer.flat \ 60 $(TEST_DIR)/hyperv_connections.flat \ 61 $(TEST_DIR)/umip.flat $(TEST_DIR)/tsx-ctrl.flat 62 63ifdef API 64tests-api = api/api-sample api/dirty-log api/dirty-log-perf 65 66OBJDIRS += api 67endif 68 69test_cases: $(tests-common) $(tests) $(tests-api) 70 71$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib 72 73$(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o 74 $(CC) -m32 -nostdlib -o $@ -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^ 75 76$(TEST_DIR)/realmode.o: bits = 32 77 78$(TEST_DIR)/kvmclock_test.elf: $(TEST_DIR)/kvmclock.o 79 80$(TEST_DIR)/hyperv_synic.elf: $(TEST_DIR)/hyperv.o 81 82$(TEST_DIR)/hyperv_stimer.elf: $(TEST_DIR)/hyperv.o 83 84$(TEST_DIR)/hyperv_connections.elf: $(TEST_DIR)/hyperv.o 85 86arch_clean: 87 $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ 88 $(TEST_DIR)/.*.d lib/x86/.*.d \ 89 $(tests-api) api/*.o api/*.a api/.*.d 90 91api/%.o: CXXFLAGS += -m32 -std=gnu++11 92 93api/%: LDLIBS += -lstdc++ -lpthread -lrt 94api/%: LDFLAGS += -m32 95 96api/libapi.a: api/kvmxx.o api/identity.o api/exception.o api/memmap.o 97 $(AR) rcs $@ $^ 98 99$(tests-api) : % : %.o api/libapi.a 100