1XEN_ROOT = $(CURDIR)/../../..
2include $(XEN_ROOT)/tools/Rules.mk
3
4MAJOR    = 1
5MINOR    = 1
6SHLIB_LDFLAGS += -Wl,--version-script=libxendevicemodel.map
7
8CFLAGS   += -Werror -Wmissing-prototypes
9CFLAGS   += -I./include $(CFLAGS_xeninclude)
10CFLAGS   += $(CFLAGS_libxentoollog)
11CFLAGS   += $(CFLAGS_libxentoolcore)
12CFLAGS   += $(CFLAGS_libxencall)
13
14SRCS-y                 += core.c
15SRCS-$(CONFIG_Linux)   += linux.c
16SRCS-$(CONFIG_FreeBSD) += compat.c
17SRCS-$(CONFIG_SunOS)   += compat.c
18SRCS-$(CONFIG_NetBSD)  += compat.c
19SRCS-$(CONFIG_MiniOS)  += compat.c
20
21LIB_OBJS := $(patsubst %.c,%.o,$(SRCS-y))
22PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS-y))
23
24LIB := libxendevicemodel.a
25ifneq ($(nosharedlibs),y)
26LIB += libxendevicemodel.so
27endif
28
29PKG_CONFIG := xendevicemodel.pc
30PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
31
32ifneq ($(CONFIG_LIBXC_MINIOS),y)
33PKG_CONFIG_INST := $(PKG_CONFIG)
34$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
35$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
36$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
37endif
38
39PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
40
41$(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
42$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENDEVICEMODEL)/include
43$(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
44$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
45
46.PHONY: all
47all: build
48
49.PHONY: build
50build:
51	$(MAKE) libs
52
53.PHONY: libs
54libs: headers.chk $(LIB) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
55
56headers.chk: $(wildcard include/*.h)
57
58libxendevicemodel.a: $(LIB_OBJS)
59	$(AR) rc $@ $^
60
61libxendevicemodel.so: libxendevicemodel.so.$(MAJOR)
62	$(SYMLINK_SHLIB) $< $@
63libxendevicemodel.so.$(MAJOR): libxendevicemodel.so.$(MAJOR).$(MINOR)
64	$(SYMLINK_SHLIB) $< $@
65
66libxendevicemodel.so.$(MAJOR).$(MINOR): $(PIC_OBJS) libxendevicemodel.map
67	$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxendevicemodel.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxencall) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
68
69.PHONY: install
70install: build
71	$(INSTALL_DIR) $(DESTDIR)$(libdir)
72	$(INSTALL_DIR) $(DESTDIR)$(includedir)
73	$(INSTALL_SHLIB) libxendevicemodel.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
74	$(INSTALL_DATA) libxendevicemodel.a $(DESTDIR)$(libdir)
75	$(SYMLINK_SHLIB) libxendevicemodel.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxendevicemodel.so.$(MAJOR)
76	$(SYMLINK_SHLIB) libxendevicemodel.so.$(MAJOR) $(DESTDIR)$(libdir)/libxendevicemodel.so
77	$(INSTALL_DATA) include/xendevicemodel.h $(DESTDIR)$(includedir)
78	$(INSTALL_DATA) xendevicemodel.pc $(DESTDIR)$(PKG_INSTALLDIR)
79
80.PHONY: uninstall
81uninstall:
82	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xendevicemodel.pc
83	rm -f $(DESTDIR)$(includedir)/xendevicemodel.h
84	rm -f $(DESTDIR)$(libdir)/libxendevicemodel.so
85	rm -f $(DESTDIR)$(libdir)/libxendevicemodel.so.$(MAJOR)
86	rm -f $(DESTDIR)$(libdir)/libxendevicemodel.so.$(MAJOR).$(MINOR)
87	rm -f $(DESTDIR)$(libdir)/libxendevicemodel.a
88
89.PHONY: TAGS
90TAGS:
91	etags -t *.c *.h
92
93.PHONY: clean
94clean:
95	rm -rf *.rpm $(LIB) *~ $(DEPS_RM) $(LIB_OBJS) $(PIC_OBJS)
96	rm -f libxendevicemodel.so.$(MAJOR).$(MINOR) libxendevicemodel.so.$(MAJOR)
97	rm -f headers.chk
98	rm -f xendevicemodel.pc
99
100.PHONY: distclean
101distclean: clean
102