1#
2# tools/libvchan/Makefile
3#
4
5XEN_ROOT = $(CURDIR)/../..
6include $(XEN_ROOT)/tools/Rules.mk
7
8LIBVCHAN_OBJS = init.o io.o
9NODE_OBJS = node.o
10NODE2_OBJS = node-select.o
11
12LIBVCHAN_PIC_OBJS = $(patsubst %.o,%.opic,$(LIBVCHAN_OBJS))
13LIBVCHAN_LIBS = $(LDLIBS_libxenstore) $(LDLIBS_libxengnttab) $(LDLIBS_libxenevtchn)
14$(LIBVCHAN_OBJS) $(LIBVCHAN_PIC_OBJS): CFLAGS += $(CFLAGS_libxenstore) $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
15$(NODE_OBJS) $(NODE2_OBJS): CFLAGS += $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
16vchan-socket-proxy.o: CFLAGS += $(CFLAGS_libxenstore) $(CFLAGS_libxenctrl) $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
17
18MAJOR = 4.14
19MINOR = 0
20
21CFLAGS += -I../include -I.
22
23io.o io.opic: CFLAGS += $(CFLAGS_libxenctrl) # for xen_mb et al
24
25PKG_CONFIG := xenvchan.pc
26PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
27
28ifneq ($(CONFIG_LIBXC_MINIOS),y)
29PKG_CONFIG_INST := $(PKG_CONFIG)
30$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
31$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
32$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
33endif
34
35PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
36
37$(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
38$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBVCHAN)
39$(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
40$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
41
42.PHONY: all
43all: libxenvchan.so vchan-node1 vchan-node2 vchan-socket-proxy libxenvchan.a $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
44
45libxenvchan.so: libxenvchan.so.$(MAJOR)
46	ln -sf $< $@
47
48libxenvchan.so.$(MAJOR): libxenvchan.so.$(MAJOR).$(MINOR)
49	ln -sf $< $@
50
51libxenvchan.so.$(MAJOR).$(MINOR): $(LIBVCHAN_PIC_OBJS)
52	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenvchan.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LIBVCHAN_LIBS) $(APPEND_LDFLAGS)
53
54libxenvchan.a: $(LIBVCHAN_OBJS)
55	$(AR) rcs libxenvchan.a $^
56
57vchan-node1: $(NODE_OBJS) libxenvchan.so
58	$(CC) $(LDFLAGS) -o $@ $(NODE_OBJS) $(LDLIBS_libxenvchan) $(APPEND_LDFLAGS)
59
60vchan-node2: $(NODE2_OBJS) libxenvchan.so
61	$(CC) $(LDFLAGS) -o $@ $(NODE2_OBJS) $(LDLIBS_libxenvchan) $(APPEND_LDFLAGS)
62
63vchan-socket-proxy: vchan-socket-proxy.o libxenvchan.so
64	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenvchan) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
65
66.PHONY: install
67install: all
68	$(INSTALL_DIR) $(DESTDIR)$(libdir)
69	$(INSTALL_DIR) $(DESTDIR)$(includedir)
70	$(INSTALL_DIR) $(DESTDIR)$(bindir)
71	$(INSTALL_PROG) libxenvchan.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
72	ln -sf libxenvchan.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenvchan.so.$(MAJOR)
73	ln -sf libxenvchan.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenvchan.so
74	$(INSTALL_PROG) vchan-socket-proxy $(DESTDIR)$(bindir)
75	$(INSTALL_DATA) libxenvchan.h $(DESTDIR)$(includedir)
76	$(INSTALL_DATA) libxenvchan.a $(DESTDIR)$(libdir)
77	$(INSTALL_DATA) xenvchan.pc $(DESTDIR)$(PKG_INSTALLDIR)
78
79.PHONY: uninstall
80uninstall:
81	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenvchan.pc
82	rm -f $(DESTDIR)$(libdir)/libxenvchan.a
83	rm -f $(DESTDIR)$(includedir)/libxenvchan.h
84	rm -f $(DESTDIR)$(libdir)/libxenvchan.so
85	rm -f $(DESTDIR)$(libdir)/libxenvchan.so.$(MAJOR)
86	rm -f $(DESTDIR)$(libdir)/libxenvchan.so.$(MAJOR).$(MINOR)
87
88.PHONY: clean
89clean:
90	$(RM) -f *.o *.opic *.so* *.a vchan-node1 vchan-node2 $(DEPS_RM)
91	$(RM) -f xenvchan.pc
92
93distclean: clean
94
95-include $(DEPS_INCLUDE)
96