source: trunk/packages/xen-3.1/xen-3.1/tools/xenstore/Makefile @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 6.3 KB
Line 
1XEN_ROOT=../..
2include $(XEN_ROOT)/tools/Rules.mk
3XEN_LIBXC          = $(XEN_ROOT)/tools/libxc
4
5MAJOR = 3.0
6MINOR = 0
7
8PROFILE=#-pg
9BASECFLAGS=-Werror
10# Make gcc generate dependencies.
11BASECFLAGS += -Wp,-MD,.$(@F).d
12PROG_DEP = .*.d
13BASECFLAGS+= $(PROFILE)
14#BASECFLAGS+= -I$(XEN_ROOT)/tools
15BASECFLAGS+= -I$(XEN_ROOT)/tools/libxc
16BASECFLAGS+= -I.
17
18CFLAGS  += $(BASECFLAGS)
19LDFLAGS += $(PROFILE) -L$(XEN_LIBXC)
20TESTDIR  = testsuite/tmp
21TESTFLAGS= -DTESTING
22TESTENV  = XENSTORED_ROOTDIR=$(TESTDIR) XENSTORED_RUNDIR=$(TESTDIR)
23
24CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod
25CLIENTS += xenstore-write
26CLIENTS_OBJS := $(patsubst xenstore-%,xenstore_%.o,$(CLIENTS))
27
28XENSTORED_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
30XENSTORED_OBJS_$(CONFIG_Linux) = xenstored_linux.o
31XENSTORED_OBJS_$(CONFIG_SunOS) = xenstored_solaris.o
32
33XENSTORED_OBJS += $(XENSTORED_OBJS_y)
34
35.PHONY: all
36all: libxenstore.so libxenstore.a xenstored $(CLIENTS) xs_tdb_dump xenstore-control xenstore-ls
37
38test_interleaved_transactions: test_interleaved_transactions.o
39        $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@
40
41.PHONY: testcode
42testcode: xs_test xenstored_test xs_random
43
44xenstored: $(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
53xenstore-control: xenstore_control.o libxenstore.so
54        $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@
55
56xenstore-ls: xsls.o libxenstore.so
57        $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@
58
59xenstored_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
62xs_tdb_dump: xs_tdb_dump.o utils.o tdb.o talloc.o
63        $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
64
65xs_test xs_random xs_stress xs_crashme: LDFLAGS+=-lpthread
66xs_test: xs_test.o xs_lib.o utils.o
67xs_random: xs_random.o xs_test_lib.o xs_lib.o talloc.o utils.o
68xs_stress: xs_stress.o xs_test_lib.o xs_lib.o talloc.o utils.o
69xs_crashme: xs_crashme.o xs_lib.o talloc.o utils.o
70
71speedtest: speedtest.o xs.o xs_lib.o utils.o talloc.o
72
73.PHONY: check-speed
74check-speed: speedtest xenstored_test $(TESTDIR)
75        $(TESTENV) time ./speedtest 100
76
77xs_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
79xenstored_%_test.o: xenstored_%.c
80        $(COMPILE.c) -o $@ $<
81
82xs_test_lib.o: xs.c
83        $(COMPILE.c) -o $@ $<
84
85talloc_test.o: talloc.c
86        $(COMPILE.c) -o $@ $<
87
88libxenstore.so: libxenstore.so.$(MAJOR)
89        ln -sf $< $@
90libxenstore.so.$(MAJOR): libxenstore.so.$(MAJOR).$(MINOR)
91        ln -sf $< $@
92
93libxenstore.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
96libxenstore.a: xs.o xs_lib.o
97        $(AR) rcs libxenstore.a $^
98
99.PHONY: clean
100clean: 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
108print-dir:
109        @echo -n tools/xenstore:
110
111.PHONY: print-end
112print-end:
113        @echo
114
115.PHONY: check
116check: print-dir testsuite-fast randomcheck-fast print-end
117
118.PHONY: fullcheck
119fullcheck: testsuite-run randomcheck stresstest
120
121$(TESTDIR):
122        mkdir $@
123
124.PHONY: testsuite-run
125testsuite-run: xenstored_test xs_test $(TESTDIR)
126        $(TESTENV) testsuite/test.sh && echo
127
128.PHONY: testsuite-fast
129testsuite-fast: xenstored_test xs_test $(TESTDIR)
130        @$(TESTENV) testsuite/test.sh --fast
131
132.PHONY: testsuite-clean
133testsuite-clean:
134        rm -rf $(TESTDIR)
135
136# Make this visible so they can see repeat tests without --fast if they
137# fail.
138RANDSEED=$(shell date +%s)
139.PHONY: randomcheck
140randomcheck: 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
146crashme:  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
153randomcheck-fast: xs_random xenstored_test $(TESTDIR)
154        @$(TESTENV) ./xs_random --fast /tmp/xs_random 2000 $(RANDSEED)
155
156.PHONY: stresstest
157stresstest: 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
162TAGS:
163        etags `find . -name '*.[ch]'`
164
165.PHONY: tarball
166tarball: clean
167        cd .. && tar -c -j -v -h -f xenstore.tar.bz2 xenstore/
168
169.PHONY: install
170install: 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:
Note: See TracBrowser for help on using the repository browser.