| #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/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 |
| |
| OBJDIRS += lib/x86 |
| |
| $(libcflat): LDFLAGS += -nostdlib |
| $(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib |
| |
| COMMON_CFLAGS += -m$(bits) |
| COMMON_CFLAGS += -O1 |
| |
| # stack.o relies on frame pointers. |
| KEEP_FRAME_POINTER := y |
| |
| libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name) |
| |
| # We want to keep intermediate file: %.elf and %.o |
| .PRECIOUS: %.elf %.o |
| |
| FLATLIBS = lib/libcflat.a $(libgcc) |
| %.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o) |
| $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \ |
| $(filter %.o, $^) $(FLATLIBS) |
| @chmod a-x $@ |
| |
| %.flat: %.elf |
| $(OBJCOPY) -O elf32-i386 $^ $@ |
| @chmod a-x $@ |
| |
| tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \ |
| $(TEST_DIR)/smptest.flat $(TEST_DIR)/port80.flat \ |
| $(TEST_DIR)/realmode.flat $(TEST_DIR)/msr.flat \ |
| $(TEST_DIR)/hypercall.flat $(TEST_DIR)/sieve.flat \ |
| $(TEST_DIR)/kvmclock_test.flat $(TEST_DIR)/eventinj.flat \ |
| $(TEST_DIR)/s3.flat $(TEST_DIR)/pmu.flat $(TEST_DIR)/setjmp.flat \ |
| $(TEST_DIR)/tsc_adjust.flat $(TEST_DIR)/asyncpf.flat \ |
| $(TEST_DIR)/init.flat $(TEST_DIR)/smap.flat \ |
| $(TEST_DIR)/hyperv_synic.flat $(TEST_DIR)/hyperv_stimer.flat \ |
| $(TEST_DIR)/hyperv_connections.flat \ |
| $(TEST_DIR)/umip.flat $(TEST_DIR)/tsx-ctrl.flat |
| |
| 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 |
| $(CC) -m32 -nostdlib -o $@ -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^ |
| |
| $(TEST_DIR)/realmode.o: bits = 32 |
| |
| $(TEST_DIR)/kvmclock_test.elf: $(TEST_DIR)/kvmclock.o |
| |
| $(TEST_DIR)/hyperv_synic.elf: $(TEST_DIR)/hyperv.o |
| |
| $(TEST_DIR)/hyperv_stimer.elf: $(TEST_DIR)/hyperv.o |
| |
| $(TEST_DIR)/hyperv_connections.elf: $(TEST_DIR)/hyperv.o |
| |
| arch_clean: |
| $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ |
| $(TEST_DIR)/.*.d lib/x86/.*.d \ |