1 | XEN_ROOT=../.. |
---|
2 | include $(XEN_ROOT)/tools/Rules.mk |
---|
3 | XEN_LIBXC = $(XEN_ROOT)/tools/libxc |
---|
4 | |
---|
5 | MAJOR = 3.0 |
---|
6 | MINOR = 0 |
---|
7 | |
---|
8 | PROFILE=#-pg |
---|
9 | BASECFLAGS=-Werror |
---|
10 | # Make gcc generate dependencies. |
---|
11 | BASECFLAGS += -Wp,-MD,.$(@F).d |
---|
12 | PROG_DEP = .*.d |
---|
13 | BASECFLAGS+= $(PROFILE) |
---|
14 | #BASECFLAGS+= -I$(XEN_ROOT)/tools |
---|
15 | BASECFLAGS+= -I$(XEN_ROOT)/tools/libxc |
---|
16 | BASECFLAGS+= -I. |
---|
17 | |
---|
18 | CFLAGS += $(BASECFLAGS) |
---|
19 | LDFLAGS += $(PROFILE) -L$(XEN_LIBXC) |
---|
20 | TESTDIR = testsuite/tmp |
---|
21 | TESTFLAGS= -DTESTING |
---|
22 | TESTENV = XENSTORED_ROOTDIR=$(TESTDIR) XENSTORED_RUNDIR=$(TESTDIR) |
---|
23 | |
---|
24 | CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod |
---|
25 | CLIENTS += xenstore-write |
---|
26 | CLIENTS_OBJS := $(patsubst xenstore-%,xenstore_%.o,$(CLIENTS)) |
---|
27 | |
---|
28 | XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o |
---|
29 | |
---|
30 | XENSTORED_OBJS_$(CONFIG_Linux) = xenstored_linux.o |
---|
31 | XENSTORED_OBJS_$(CONFIG_SunOS) = xenstored_solaris.o |
---|
32 | |
---|
33 | XENSTORED_OBJS += $(XENSTORED_OBJS_y) |
---|
34 | |
---|
35 | .PHONY: all |
---|
36 | all: libxenstore.so libxenstore.a xenstored $(CLIENTS) xs_tdb_dump xenstore-control xenstore-ls |
---|
37 | |
---|
38 | test_interleaved_transactions: test_interleaved_transactions.o |
---|
39 | $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@ |
---|
40 | |
---|
41 | .PHONY: testcode |
---|
42 | testcode: xs_test xenstored_test xs_random |
---|
43 | |
---|
44 | xenstored: $(XENSTORED_OBJS) |
---|
45 | $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -lxenctrl $(SOCKET_LIBS) -o $@ |
---|
46 | |
---|
47 | $(CLIENTS): xenstore-%: xenstore_%.o libxenstore.so |
---|
48 | $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@ |
---|
49 | |
---|
50 | $(CLIENTS_OBJS): xenstore_%.o: xenstore_client.c |
---|
51 | $(COMPILE.c) -DCLIENT_$(*F) -o $@ $< |
---|
52 | |
---|
53 | xenstore-control: xenstore_control.o libxenstore.so |
---|
54 | $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@ |
---|
55 | |
---|
56 | xenstore-ls: xsls.o libxenstore.so |
---|
57 | $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@ |
---|
58 | |
---|
59 | xenstored_test: xenstored_core_test.o xenstored_watch_test.o xenstored_domain_test.o xenstored_transaction_test.o xs_lib.o talloc_test.o fake_libxc.o utils.o tdb.o |
---|
60 | $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ |
---|
61 | |
---|
62 | xs_tdb_dump: xs_tdb_dump.o utils.o tdb.o talloc.o |
---|
63 | $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ |
---|
64 | |
---|
65 | xs_test xs_random xs_stress xs_crashme: LDFLAGS+=-lpthread |
---|
66 | xs_test: xs_test.o xs_lib.o utils.o |
---|
67 | xs_random: xs_random.o xs_test_lib.o xs_lib.o talloc.o utils.o |
---|
68 | xs_stress: xs_stress.o xs_test_lib.o xs_lib.o talloc.o utils.o |
---|
69 | xs_crashme: xs_crashme.o xs_lib.o talloc.o utils.o |
---|
70 | |
---|
71 | speedtest: speedtest.o xs.o xs_lib.o utils.o talloc.o |
---|
72 | |
---|
73 | .PHONY: check-speed |
---|
74 | check-speed: speedtest xenstored_test $(TESTDIR) |
---|
75 | $(TESTENV) time ./speedtest 100 |
---|
76 | |
---|
77 | xs_test.o xs_stress.o xenstored_core_test.o xenstored_watch_test.o xenstored_transaction_test.o xenstored_domain_test.o xs_random.o xs_test_lib.o talloc_test.o fake_libxc.o xs_crashme.o: CFLAGS=$(BASECFLAGS) $(TESTFLAGS) |
---|
78 | |
---|
79 | xenstored_%_test.o: xenstored_%.c |
---|
80 | $(COMPILE.c) -o $@ $< |
---|
81 | |
---|
82 | xs_test_lib.o: xs.c |
---|
83 | $(COMPILE.c) -o $@ $< |
---|
84 | |
---|
85 | talloc_test.o: talloc.c |
---|
86 | $(COMPILE.c) -o $@ $< |
---|
87 | |
---|
88 | libxenstore.so: libxenstore.so.$(MAJOR) |
---|
89 | ln -sf $< $@ |
---|
90 | libxenstore.so.$(MAJOR): libxenstore.so.$(MAJOR).$(MINOR) |
---|
91 | ln -sf $< $@ |
---|
92 | |
---|
93 | libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic |
---|
94 | $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^ $(SOCKET_LIBS) -lpthread |
---|
95 | |
---|
96 | libxenstore.a: xs.o xs_lib.o |
---|
97 | $(AR) rcs libxenstore.a $^ |
---|
98 | |
---|
99 | .PHONY: clean |
---|
100 | clean: testsuite-clean |
---|
101 | rm -f *.a *.o *.opic *.so* |
---|
102 | rm -f xenstored xs_random xs_stress xs_crashme |
---|
103 | rm -f xs_test xenstored_test xs_tdb_dump xenstore-control xenstore-ls |
---|
104 | rm -f $(CLIENTS) |
---|
105 | $(RM) $(PROG_DEP) |
---|
106 | |
---|
107 | .PHONY: print-dir |
---|
108 | print-dir: |
---|
109 | @echo -n tools/xenstore: |
---|
110 | |
---|
111 | .PHONY: print-end |
---|
112 | print-end: |
---|
113 | @echo |
---|
114 | |
---|
115 | .PHONY: check |
---|
116 | check: print-dir testsuite-fast randomcheck-fast print-end |
---|
117 | |
---|
118 | .PHONY: fullcheck |
---|
119 | fullcheck: testsuite-run randomcheck stresstest |
---|
120 | |
---|
121 | $(TESTDIR): |
---|
122 | mkdir $@ |
---|
123 | |
---|
124 | .PHONY: testsuite-run |
---|
125 | testsuite-run: xenstored_test xs_test $(TESTDIR) |
---|
126 | $(TESTENV) testsuite/test.sh && echo |
---|
127 | |
---|
128 | .PHONY: testsuite-fast |
---|
129 | testsuite-fast: xenstored_test xs_test $(TESTDIR) |
---|
130 | @$(TESTENV) testsuite/test.sh --fast |
---|
131 | |
---|
132 | .PHONY: testsuite-clean |
---|
133 | testsuite-clean: |
---|
134 | rm -rf $(TESTDIR) |
---|
135 | |
---|
136 | # Make this visible so they can see repeat tests without --fast if they |
---|
137 | # fail. |
---|
138 | RANDSEED=$(shell date +%s) |
---|
139 | .PHONY: randomcheck |
---|
140 | randomcheck: xs_random xenstored_test $(TESTDIR) |
---|
141 | $(TESTENV) ./xs_random --simple --fast /tmp/xs_random 200000 $(RANDSEED) && echo |
---|
142 | $(TESTENV) ./xs_random --fast /tmp/xs_random 100000 $(RANDSEED) && echo |
---|
143 | # $(TESTENV) ./xs_random --fail /tmp/xs_random 10000 $(RANDSEED) |
---|
144 | |
---|
145 | .PHONY: crashme |
---|
146 | crashme: xs_crashme xenstored_test $(TESTDIR) |
---|
147 | rm -rf $(TESTDIR)/store $(TESTDIR)/transactions /tmp/xs_crashme.vglog* /tmp/trace |
---|
148 | export $(TESTENV); ./xs_crashme 5000 $(RANDSEED) 2>/dev/null |
---|
149 | if [ -n "`cat /tmp/xs_crashme.vglog*`" ]; then echo Valgrind complained; cat /tmp/xs_crashme.vglog*; exit 1; fi |
---|
150 | rm -rf $(TESTDIR)/store $(TESTDIR)/transactions /tmp/xs_crashme.vglog* /tmp/trace |
---|
151 | |
---|
152 | .PHONY: randomcheck-fast |
---|
153 | randomcheck-fast: xs_random xenstored_test $(TESTDIR) |
---|
154 | @$(TESTENV) ./xs_random --fast /tmp/xs_random 2000 $(RANDSEED) |
---|
155 | |
---|
156 | .PHONY: stresstest |
---|
157 | stresstest: xs_stress xenstored_test $(TESTDIR) |
---|
158 | rm -rf $(TESTDIR)/store $(TESTDIR)/transactions |
---|
159 | export $(TESTENV); PID=`./xenstored_test --output-pid --trace-file=/tmp/trace`; ./xs_stress 5000; ret=$$?; kill $$PID; exit $$ret |
---|
160 | |
---|
161 | .PHONY: TAGS |
---|
162 | TAGS: |
---|
163 | etags `find . -name '*.[ch]'` |
---|
164 | |
---|
165 | .PHONY: tarball |
---|
166 | tarball: clean |
---|
167 | cd .. && tar -c -j -v -h -f xenstore.tar.bz2 xenstore/ |
---|
168 | |
---|
169 | .PHONY: install |
---|
170 | install: all |
---|
171 | $(INSTALL_DIR) $(DESTDIR)/var/run/xenstored |
---|
172 | $(INSTALL_DIR) $(DESTDIR)/var/lib/xenstored |
---|
173 | $(INSTALL_DIR) $(DESTDIR)/usr/bin |
---|
174 | $(INSTALL_DIR) $(DESTDIR)/usr/sbin |
---|
175 | $(INSTALL_DIR) $(DESTDIR)/usr/include |
---|
176 | $(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin |
---|
177 | $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)/usr/bin |
---|
178 | $(INSTALL_PROG) xenstore-control $(DESTDIR)/usr/bin |
---|
179 | $(INSTALL_PROG) xenstore-ls $(DESTDIR)/usr/bin |
---|
180 | $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR) |
---|
181 | $(INSTALL_PROG) libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR) |
---|
182 | ln -sf libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)/libxenstore.so.$(MAJOR) |
---|
183 | ln -sf libxenstore.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenstore.so |
---|
184 | $(INSTALL_DATA) libxenstore.a $(DESTDIR)/usr/$(LIBDIR) |
---|
185 | $(INSTALL_DATA) xs.h $(DESTDIR)/usr/include |
---|
186 | $(INSTALL_DATA) xs_lib.h $(DESTDIR)/usr/include |
---|
187 | |
---|
188 | -include $(PROG_DEP) |
---|
189 | |
---|
190 | # never delete any intermediate files. |
---|
191 | .SECONDARY: |
---|