blob: 6aade26e9ca2c9334447ed555f423e400b436ef1 [file] [log] [blame]
Paolo Bonzini783e9e52018-03-27 11:49:19 +02001all:
2
3top_srcdir = ../../../../
4UNAME_M := $(shell uname -m)
5
6LIBKVM = lib/assert.c lib/kvm_util.c lib/sparsebit.c
7LIBKVM_x86_64 = lib/x86.c
8
9TEST_GEN_PROGS_x86_64 = set_sregs_test
10
11TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
12LIBKVM += $(LIBKVM_$(UNAME_M))
13
14INSTALL_HDR_PATH = $(top_srcdir)/usr
15LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
16CFLAGS += -O2 -g -I$(LINUX_HDR_PATH) -Iinclude -I$(<D)
17
18# After inclusion, $(OUTPUT) is defined and
19# $(TEST_GEN_PROGS) starts with $(OUTPUT)/
20include ../lib.mk
21
22STATIC_LIBS := $(OUTPUT)/libkvm.a
23LIBKVM_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM))
24EXTRA_CLEAN += $(LIBKVM_OBJ) $(STATIC_LIBS)
25
26x := $(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
36all: $(STATIC_LIBS) $(LINUX_HDR_PATH)
37$(TEST_GEN_PROGS): $(STATIC_LIBS)
38$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH)