1XEN_ROOT = $(CURDIR)/../../..
2OCAML_TOPLEVEL = $(CURDIR)/..
3include $(OCAML_TOPLEVEL)/common.make
4
5# Include configure output (config.h)
6CFLAGS += -include $(XEN_ROOT)/tools/config.h
7CFLAGS-$(CONFIG_SYSTEMD)  += $(SYSTEMD_CFLAGS)
8LDFLAGS-$(CONFIG_SYSTEMD) += $(SYSTEMD_LIBS)
9
10CFLAGS  += $(CFLAGS-y)
11CFLAGS  += $(APPEND_CFLAGS)
12LDFLAGS += $(LDFLAGS-y)
13LDFLAGS += $(APPEND_LDFLAGS)
14
15OCAMLINCLUDE += \
16	-I $(OCAML_TOPLEVEL)/libs/xb \
17	-I $(OCAML_TOPLEVEL)/libs/mmap \
18	-I $(OCAML_TOPLEVEL)/libs/xc \
19	-I $(OCAML_TOPLEVEL)/libs/eventchn
20
21LIBS = syslog.cma syslog.cmxa select.cma select.cmxa
22syslog_OBJS = syslog
23syslog_C_OBJS = syslog_stubs
24select_OBJS = select
25select_C_OBJS = select_stubs
26OCAML_LIBRARY = syslog select
27
28LIBS += systemd.cma systemd.cmxa
29systemd_OBJS = systemd
30systemd_C_OBJS = systemd_stubs
31OCAML_LIBRARY += systemd
32
33$(foreach obj,$(systemd_C_OBJS),$(obj).o): _paths.h
34
35LIBS_systemd += $(LDFLAGS-y)
36
37OBJS = paths \
38	define \
39	stdext \
40	trie \
41	config \
42	packet \
43	logging \
44	quota \
45	perms \
46	symbol \
47	utils \
48	store \
49	disk \
50	transaction \
51	event \
52	domain \
53	domains \
54	connection \
55	connections \
56	history \
57	parse_arg \
58	process \
59	xenstored
60
61INTF = symbol.cmi trie.cmi syslog.cmi systemd.cmi select.cmi
62
63XENSTOREDLIBS = \
64	unix.cmxa \
65	-ccopt -L -ccopt . syslog.cmxa \
66	-ccopt -L -ccopt . systemd.cmxa \
67	-ccopt -L -ccopt . select.cmxa \
68	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/mmap $(OCAML_TOPLEVEL)/libs/mmap/xenmmap.cmxa \
69	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \
70	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xenctrl.cmxa \
71	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xenbus.cmxa \
72	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc
73
74PROGRAMS = oxenstored
75
76oxenstored_LIBS = $(XENSTOREDLIBS)
77oxenstored_OBJS = $(OBJS)
78
79OCAML_PROGRAM = oxenstored
80
81all: $(INTF) $(LIBS) $(PROGRAMS)
82
83bins: $(PROGRAMS)
84
85libs: $(LIBS)
86
87install: all
88	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
89	$(INSTALL_PROG) oxenstored $(DESTDIR)$(sbindir)
90	$(INSTALL_DIR) $(DESTDIR)$(XEN_CONFIG_DIR)
91	$(INSTALL_DATA) oxenstored.conf $(DESTDIR)$(XEN_CONFIG_DIR)
92
93uninstall:
94	rm -f $(DESTDIR)$(XEN_CONFIG_DIR)/oxenstored.conf
95	rm -f $(DESTDIR)$(sbindir)/oxenstored
96
97include $(OCAML_TOPLEVEL)/Makefile.rules
98
99genpath-target = $(call buildmakevars2module,paths.ml)
100$(eval $(genpath-target))
101
102GENERATED_FILES += paths.ml
103
104genpath-target = $(call buildmakevars2header,_paths.h)
105$(eval $(genpath-target))
106
107GENERATE_FILES += _paths.h
108