Paolo Bonzini | 783e9e5 | 2018-03-27 11:49:19 +0200 | [diff] [blame^] | 1 | all: |
| 2 | |
| 3 | top_srcdir = ../../../../ |
| 4 | UNAME_M := $(shell uname -m) |
| 5 | |
| 6 | LIBKVM = lib/assert.c lib/kvm_util.c lib/sparsebit.c |
| 7 | LIBKVM_x86_64 = lib/x86.c |
| 8 | |
| 9 | TEST_GEN_PROGS_x86_64 = set_sregs_test |
| 10 | |
| 11 | TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M)) |
| 12 | LIBKVM += $(LIBKVM_$(UNAME_M)) |
| 13 | |
| 14 | INSTALL_HDR_PATH = $(top_srcdir)/usr |
| 15 | LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/ |
| 16 | CFLAGS += -O2 -g -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) |
| 17 | |
| 18 | # After inclusion, $(OUTPUT) is defined and |
| 19 | # $(TEST_GEN_PROGS) starts with $(OUTPUT)/ |
| 20 | include ../lib.mk |
| 21 | |
| 22 | STATIC_LIBS := $(OUTPUT)/libkvm.a |
| 23 | LIBKVM_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM)) |
| 24 | EXTRA_CLEAN += $(LIBKVM_OBJ) $(STATIC_LIBS) |
| 25 | |
| 26 | x := $(shell mkdir -p $(sort $(dir $(LIBKVM_OBJ)))) |
| 27 | $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c |
| 28 | $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ |
| 29 | |
| 30 | $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) |
| 31 | $(AR) crs $@ $^ |
| 32 | |
| 33 | $(LINUX_HDR_PATH): |
| 34 | make -C $(top_srcdir) headers_install |
| 35 | |
| 36 | all: $(STATIC_LIBS) $(LINUX_HDR_PATH) |
| 37 | $(TEST_GEN_PROGS): $(STATIC_LIBS) |
| 38 | $(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) |