Makefile.common 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #This is a make file with common rules for both x86 & x86-64
  2. all: directories test_cases
  3. cflatobjs += lib/pci.o
  4. cflatobjs += lib/pci-edu.o
  5. cflatobjs += lib/x86/setup.o
  6. cflatobjs += lib/x86/io.o
  7. cflatobjs += lib/x86/smp.o
  8. cflatobjs += lib/x86/vm.o
  9. cflatobjs += lib/x86/fwcfg.o
  10. cflatobjs += lib/x86/apic.o
  11. cflatobjs += lib/x86/atomic.o
  12. cflatobjs += lib/x86/desc.o
  13. cflatobjs += lib/x86/isr.o
  14. cflatobjs += lib/x86/acpi.o
  15. cflatobjs += lib/x86/stack.o
  16. OBJDIRS += lib/x86
  17. $(libcflat): LDFLAGS += -nostdlib
  18. $(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
  19. COMMON_CFLAGS += -m$(bits)
  20. COMMON_CFLAGS += -O1
  21. COMMON_CFLAGS += -fno-stack-protector
  22. # stack.o relies on frame pointers.
  23. KEEP_FRAME_POINTER := y
  24. libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
  25. # We want to keep intermediate file: %.elf and %.o
  26. .PRECIOUS: %.elf %.o
  27. FLATLIBS = lib/libcflat.a $(libgcc)
  28. %.elf: %.o $(FLATLIBS) $(SRCDIR)/x86/flat.lds $(cstart.o)
  29. $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,$(SRCDIR)/x86/flat.lds \
  30. $(filter %.o, $^) $(FLATLIBS)
  31. %.flat: %.elf
  32. $(OBJCOPY) -O elf32-i386 $^ $@
  33. tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \
  34. $(TEST_DIR)/smptest.flat $(TEST_DIR)/port80.flat \
  35. $(TEST_DIR)/realmode.flat $(TEST_DIR)/msr.flat \
  36. $(TEST_DIR)/hypercall.flat $(TEST_DIR)/sieve.flat \
  37. $(TEST_DIR)/kvmclock_test.flat $(TEST_DIR)/eventinj.flat \
  38. $(TEST_DIR)/s3.flat $(TEST_DIR)/pmu.flat $(TEST_DIR)/setjmp.flat \
  39. $(TEST_DIR)/tsc_adjust.flat $(TEST_DIR)/asyncpf.flat \
  40. $(TEST_DIR)/init.flat $(TEST_DIR)/smap.flat \
  41. $(TEST_DIR)/hyperv_synic.flat $(TEST_DIR)/hyperv_stimer.flat \
  42. $(TEST_DIR)/hyperv_connections.flat \
  43. $(TEST_DIR)/pae.flat \
  44. ifdef API
  45. tests-api = api/api-sample api/dirty-log api/dirty-log-perf
  46. OBJDIRS += api
  47. endif
  48. test_cases: $(tests-common) $(tests) $(tests-api)
  49. $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/x86 -I lib
  50. $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
  51. $(CC) -m32 -nostdlib -o $@ -Wl,-T,$(SRCDIR)/$(TEST_DIR)/realmode.lds $^
  52. $(TEST_DIR)/realmode.o: bits = 32
  53. $(TEST_DIR)/kvmclock_test.elf: $(TEST_DIR)/kvmclock.o
  54. $(TEST_DIR)/hyperv_synic.elf: $(TEST_DIR)/hyperv.o
  55. $(TEST_DIR)/hyperv_stimer.elf: $(TEST_DIR)/hyperv.o
  56. $(TEST_DIR)/hyperv_connections.elf: $(TEST_DIR)/hyperv.o
  57. arch_clean:
  58. $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \
  59. $(TEST_DIR)/.*.d lib/x86/.*.d \
  60. $(tests-api) api/*.o api/*.a api/.*.d
  61. api/%.o: CXXFLAGS += -m32 -std=gnu++11
  62. api/%: LDLIBS += -lstdc++ -lpthread -lrt
  63. api/%: LDFLAGS += -m32
  64. api/libapi.a: api/kvmxx.o api/identity.o api/exception.o api/memmap.o
  65. $(AR) rcs $@ $^
  66. $(tests-api) : % : %.o api/libapi.a